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: 40
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: 5002
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: 40
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: 5002
Joined: Thu Oct 30, 2014 9:02 am


Return to Nagios Core

Who is online

Users browsing this forum: luizgomes and 22 guests