Nagios XMPP Notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Nagios XMPP Notifications

Post by gshergill »

Hi Nagios Community,

Was wondering if anyone has a recommendation of software to send XMPP notifications via Nagios?

I set up a Nagibot instance but I hit a few snags along the way, wondering if there's anything else out there? Wasn't really able to find much online, just Molniya XMPP Gateway and will be trying that out soon.

This will most likely be set up on a Nagios XI box, but it's not really XI specific. Testing on Ubuntu machines first.

Thanks.

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XMPP Notifications

Post by abrist »

Have taken a look at the exchange? There are two plugins there that may be what you are looking for:
http://exchange.nagios.org/index.php?op ... hword=xmpp
Nagibot or nagios jabber seem to be the best supported of the xmpp solutions though.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Nagios XMPP Notifications

Post by gshergill »

Hi abrist,

I've checked the exchange, and I recently tried installing Molniya XMPP Gateway but I had some trouble, plus it is no longer maintained/has a project leader, so I went back to trying to get Nagibot working.

Unfortunately the Gtalk XMPP notifications wouldn't help as we are using Openfire as our XMPP server and wish for notifications to be sent from an account there.

Nagibot does seem to fulfil what we're looking for but my install isn't working as hoped, and there doesn't seem to be a whole lot online to do with configuration/troubleshooting.

I've been using the links below:
I don't actually know German so the last link has been kind of hit and miss in understanding it (luckily my friend is German and has been helping me translate).

Is Nagibot supported on these forums?

Thank you.

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XMPP Notifications

Post by abrist »

gshergill wrote: Is Nagibot supported on these forums?
Not really? But if it works with Nagios (and with enough hacking, just about everything does) we will attempt to give you hand with the setup. The biggest issue with Nagibot, as you no doubt have figured out, is almost all support is in German and even that community is quite small. What specific issues are you having with Nagibot?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Nagios XMPP Notifications

Post by gshergill »

Hi abrist,

Yeah I noticed that the majority of it's support is in German which is unfortunate (google translate can only get you so far).

So the issue I'm having is with the nagibot.conf file. Running the nagibot.pl script comes up with the following error:

Code: Select all

root@nagios:/usr/local/nagios/etc# ~/Nagibot-v0.8.3/nagibot.pl -vvv [email protected] -p nagibot
nagibot 0.8.3 starting ...
trying to find configuration file
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 7
   Document: 4
 at /usr/share/perl5/YAML/Loader.pm line 81
So checking my config file it is as follows:

Code: Select all

---
# Rooms to join
---
#[email protected]
---
# JIDs to inform
[email protected]
---
# Configuration
nagios_status_log_file: /usr/local/nagios/var/status.dat
nagios_msg_fifo: /usr/local/nagios/var/rw/nagibot.fifo
bot_status: available
bot_status_text: I am a bot
bot_status_priority: 10
password: nagibot
---
Line 7 is the text [email protected].

It seems as though it doesn't like the "---" being used as a parser on a different line to the text? Changing things to the same line doesn't help either, it comes up with a new set of errors.

Tried checking online and I was unable to find anything useful (or which I could see as being useful).

Any tips please?
Or does anyone have this working?

I'll try this on a test XI machine some time this week if I can't get it working on core to see if it is a problem on that side.

Thank you.

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XMPP Notifications

Post by abrist »

Looking at the usage for the plugin, and considering YAML's expected format:

Code: Select all

The second part is a list of XMPP IDs (Jabber IDs) the bot should send the notifications to.

    - [email protected]
    - [email protected]
Try adding a " - " before the JID?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XMPP Notifications

Post by abrist »

Just to add a few more things - From the YAML wiki article:

Code: Select all

Basic components of YAML

YAML offers both an indented and an "in-line" style for denoting associative arrays and lists. Here is a sampler of the components.
Lists

Conventional block format uses a hyphen+space to begin a new item in list.

 --- # Favorite movies
 - Casablanca
 - North by Northwest
 - The Man Who Wasn't There

Optional inline format is delimited by comma+space and enclosed in brackets (similar to JSON).[6]

 --- # Shopping list
 [milk, pumpkin pie, eggs, juice]
You could also try:

Code: Select all

--- # JIDs to inform
- [email protected]
---
Or:

Code: Select all

--- # JIDs to inform
[[email protected]]
---
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Nagios XMPP Notifications

Post by gshergill »

Hi abrist,

Thanks for that! Didn't realise it meant I had to use a "- " before!

So adding that in stops that error from popping up now (YAML one) and using a non local server (i.e. a live production xmpp server) I can get it working. Using a local ([email protected]) doesn't actually work though, it stops before it logs in the user (shown below):

Code: Select all

root@nagios:/usr/local/nagios/etc# ~/Nagibot-v0.8.3/nagibot.pl -vvv -c /usr/local/nagios/etc/nagibot.conf [email protected]
nagibot 0.8.3 starting ...
using config file from commandline
Trying to connect ...
Opening fifo for reading ...
connected to 192.168.3.127:5222
For now, it's fine to use the live server though, so I'll continue on that side.

So I set up host and notification commands:

Code: Select all

    # 'service-notify-by-pipe' command definition
define command {
        command_name   notify-service-by-pipe
        command_line   /usr/bin/printf "%b" "*$NOTIFICATIONTYPE$* $SERVICEDESC$ on $HOSTALIAS$ $SERVICESTATE$\n" >> /usr/local/nagios/var/rw/nagibot.fifo 2>&1
    }

    # 'host-notify-by-pipe' command definition
define command {
        command_name   notify-host-by-pipe
        command_line   /usr/bin/printf "%b" "*$NOTIFICATIONTYPE$* $HOSTNAME$ is $HOSTSTATE$\n" >> /usr/local/nagios/var/rw/nagibot.fifo 2>&1
    }
Template:

Code: Select all

define contact{
        name                            xmpp-contact         ; The name of this contact template
        service_notification_period     24x7                    ; service notifications can be sent anytime
        host_notification_period        24x7                    ; host notifications can be sent anytime
        service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-pipe
        host_notification_commands      notify-host-by-pipe
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
        }
Contact:

Code: Select all

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        contactgroups                   admins
        use                             xmpp-contact            ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user
        email                           [email protected]             ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }
So I set a service which sends an email to the group admins to CRITICAL and I received the email on the normal accounts, but no XMPP message for the jabber account.

Maybe I need to configure address1 in the contact? Or I'm not sure... I'll be trying it now with a chatroom, maybe that will work.

Thank you.

Kind Regards,

Gary Shergill
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Nagios XMPP Notifications

Post by gshergill »

Hi abrist,

This is all working now, no problems =)

I just went through a fresh install of the Nagibot to get it to work with hosts and/or group chat rooms (I had been moving things around to get the YAML working, probably broke something xD).

I was wondering something though... If the group chat has a password required to access it, is it possible to reflect that in the config file somewhere?
Also, is there a reason why it isn't working on the local domain?

Thanks for the help.

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XMPP Notifications

Post by abrist »

Looks like nagibot has support for a password: http://nagibot.sourceforge.net/nagibot.html
You can either specify it from the cli or in the configuration file.

No idea why it is not working on the local domain, have you tried localhost?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked