Can we label a port in nagios hosts ?

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Can we label a port in nagios hosts ?

Postby soamz » Fri May 19, 2017 3:24 am

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.
soamz
 
Posts: 42
Joined: Sat May 07, 2016 8:29 am

Re: Can we label a port in nagios hosts ?

Postby tgriep » Fri May 19, 2017 12:42 pm

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/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#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/nagioscore/docs/nagioscore/3/en/macrolist.html#servicenotes
Let us know if this works for your needs.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

Re: Can we label a port in nagios hosts ?

Postby soamz » Sat May 20, 2017 3:27 am

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 ?
soamz
 
Posts: 42
Joined: Sat May 07, 2016 8:29 am

Re: Can we label a port in nagios hosts ?

Postby tgriep » Mon May 22, 2017 9:34 am

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
Code: Select all
\n$HOSTGROUPNAME$\n$SERVICENOTES$

That will add the hostgroup name as well as the Notes field to the email notification.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

Re: Can we label a port in nagios hosts ?

Postby soamz » Tue May 30, 2017 2:41 am

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
}
soamz
 
Posts: 42
Joined: Sat May 07, 2016 8:29 am

Re: Can we label a port in nagios hosts ?

Postby tgriep » Tue May 30, 2017 1:17 pm

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"
}
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 9 guests