Page 1 of 1
Can we label a port in nagios hosts ?
Posted: Fri May 19, 2017 3:24 am
by soamz
Hello, im doing port monitoring of various switches in nagios and it works wonderful.
But I issue I face is, Im not able to know which port is doing what unless I remember.
For example, I get notification s
DEVICE CISCO A = port 21 down.
But I want to label my ports like , port 21 (current sensor)
So, notification should come like
DEVICE CISCO A = port 21 down (current sensor ) is down.
Re: Can we label a port in nagios hosts ?
Posted: Fri May 19, 2017 12:42 pm
by tgriep
If you want to add custom labels / information to your service checks to get betters details / descriptions, you could use the Notes object.
The description of the notes object.
notes: This directive is used to define an optional string of notes pertaining to the service.
https://assets.nagios.com/downloads/nag ... ml#service
Just add the notes object to your service checks and then you would have to edit your notification command and add the $SERVICENOTES$ macro to it so when an email is sent, it will also send the information from the notes field from your service.
https://assets.nagios.com/downloads/nag ... rvicenotes
Let us know if this works for your needs.
Re: Can we label a port in nagios hosts ?
Posted: Sat May 20, 2017 3:27 am
by soamz
So lets say, my host group is - DC001 NOC SWITCHES.
And one host added is - CORE NOC CISCO 001 SWITCH
And Im monitoring the ports ge0/0/1 and ge0/0/11
Can I name ge0/0/11 as "NOC SWITCH CURRENT SENSOR" ?
So, when the port goes off,
will I get email like,
DC001 NOC SWITCHES
NOC SWITCH CURRENT SENSOR is critical ?
Re: Can we label a port in nagios hosts ?
Posted: Mon May 22, 2017 9:34 am
by tgriep
If you add the "NOC SWITCH CURRENT SENSOR" to the notes object for that service and edit the notify-service-by-email command to add the notes field and the Hostgroup macro to it, you could format the email to how you would like it to look.
Try editing the notify-service-by-email command like the example below, and see if this is what you are looking for.
Code: Select all
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n$HOSTGROUPNAME$\n$SERVICENOTES$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
What I did was add the following to the command in the body of the message
That will add the hostgroup name as well as the Notes field to the email notification.
Re: Can we label a port in nagios hosts ?
Posted: Tue May 30, 2017 2:41 am
by soamz
For example i have one host and service definition and port monitoring in configuration file of nagios. Can you tell me where you should i fit the note attributes in below configuration so that i get alert with notes when the monitored port gets down
define host{
use generic-switch ; Inherit default values from a template
host_name LEWIS ; The name we're giving to this switch
alias LEWIS ; A longer name associated with the switch
address 10.10.X.X ; IP address of the switch
hostgroups test21 ; Host groups this switch is associated with
}
define service{
use generic-service ; Inherit values from a template
host_name LEWIS ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
define service{
use generic-service ; Inherit values from a template
host_name LEWIS
service_description Port 4 Link Status
check_command check_snmp!-C test -o ifOperStatus.10604 -r 1 -m RFC1213-MIB
}
Re: Can we label a port in nagios hosts ?
Posted: Tue May 30, 2017 1:17 pm
by tgriep
You would put the notes field in the service check for the port check.
Code: Select all
define service{
use generic-service ; Inherit values from a template
host_name LEWIS
service_description Port 4 Link Status
check_command check_snmp!-C test -o ifOperStatus.10604 -r 1 -m RFC1213-MIB
notes "Put your label/note here"
}