Hi Folks!
I’ve got a script that will send me jabber messages, and I’d like to add it as a notification command. So, in my misccommands.cfg file, i’ve got an entry like so…
‘service-notify-via-jabber’ command definition
define command{
command_name service-notify-via-jabber
command_line /apps/nagios/libexec/send_jabber $CONTACTPAGER$ “** $NOTIFICATIONTYPE$ $OUTPUT$” “** $NOTIFICATIONTYPE$ alert - $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ : $OUTPUT$”
}
And I added the command name to my contacts.cfg, like so…
service_notification_commands service-email-via-script,service-page-via-script,service-notify-via-jabber
So my basic question is, how do I define my jabber ID for my contact entry, and pass it to the notification command I’ve created? In other words, how can I change $CONTACTPAGER$ to $CONTACTJABBER$ and have that resolve to an entry in my contacts.cfg definition.
Thanks very much for any insight.
-Adam vonNieda
I don’t know what jabber id is, but there is no macro named $CONTACTJABBER$. There is a macro called $CONTACTEMAIL$ and $CONTACTPAGER$ so if for example a jabber id is this: john123@jabber or whatever this id is.
In the contacts.cfg file I would have:
service_notification_commands service-notify-via-jabber and pager john123@jabber.
and in the service-notify-via-jabber command definition I would have used the macro $CONTACTPAGER$.
So, now that a service has failed, it will look at the who to contact, and then look at the contacts definitions. In that contact definition you have stated you want to be notified by running a script called service-notify-via-jabber. Also, that contact has stated his pager is john123@jabber. That will define the macro named $CONTACTPAGER$. Of course, in your script you will have used the $CONTACTPAGER$ macro in the correct place. I suppose this would be a problem if you wanted the same contact to be notified via pager and jabber and email all at the same time, but not a big problem. You could then define one of the 32 #USERx$ macros or you could define 2 contact definitions for the same person. Example contact named joe1 and joe2. Joe1 gets notified via email and pager and joe2 gets notified via jabber.
Thanks for the reply. What I was trying to do was set up 3 different ways to contact the same person, as you saw. Using multiple contacts for the same person is a good idea, I hadn’t thought of that.
What I ended up doing was making a hash in my notification script that mapped the value of $CONTACTNAME$ to their jabber ID, and that’s working fine. I was basically looking to see if there was a clean way to add a third notification option (like creating a custon macro variable like $CONTACTJABBER$ that maps to a keyword in the contact definition).
Thanks again!
-Adam vonNieda
Well, either way you want to do it, but if it’s easier, just use the already existing macro’s of $USERx$. They are defined in the resource.cfg file and can be anything you want, usernames, email addys, passwords, and jabber id’s I bet.