NAME

nagibot.pl - A XMPP robot for Nagios(tm) notifications and interaction.


SYNOPSIS

nagibot.pl [options] JID


DESCRIPTION

This program acts as a XMPP bot and forwards Nagios(tm) notifications to XMPP destinations. XMPP destinations may be one or more JIDs or one or more XMPP chatrooms.

The Nagios(tm) process writes the notifications to a pipe where the bot reads and processes them. The requirements are shown in PREREQUISITES.

You can also send messages to the bot (either directly or in a multi user chatroom). The bot accepts a few commands as shown in ACCEPTED COMMANDS.


OPTIONS

-?, -h, --help

Print a brief help message and exit.

--man

Print the manual page and exit.

-V, --version

Print version number and exit.

-v, --verbose

Be verbose. You can specify this more than once to increase verbosity.

-q, --quiet

Set verbosity to zero. Error messages are printed but no warnings or informational messages will be shown.

-d, --daemon

Fork and run in background.

-c FILE, --config FILE

Configuration file to use. See CONFIGUATION FILE for details.

-p JID password, --password JID password

The logon password for the JID. You can also set the password via the configuration file.


CONFIGURATION FILE

The configutation file is a three document YAML file. The first part contains a list of multi user chatrooms the bot should join and send messages to. The syntax is:

    roomname: Nick in this room

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

    - myself@example.com
    - anotherone@example.com

The last part contains a list of configuration variables (in YAML notation):

ack_notify

If this option is set to one (1), a notification will be sent out to contacts indicating that the current service problem has been acknowledged. The default is 1.

ack_persistent

If this option is set to one (1), the comment associated with the acknowledgement will survive across restarts of the Nagios process. If not, the comment will be deleted the next time Nagios restarts. The default is 0.

ack_sticky

If this option is set to one (1), the acknowledgement will remain until the host/service return to UP/OK state. Otherwise the acknowledgement will automatically be removed when the service changes state. The default is 1.

bot_resource

XMPP resource of the bot. Defaults to nagibot.pl

bot_show_idle_after

Number of minutes before the bot sends an idle presence. The counter is resetted each time a nagios or user message arrives. The default is 5.

bot_status

XMPP status of the bot. This should be one of 'available', 'away', 'chat', 'dnd' and 'xa'.

bot_status_priority

XMPP status priority of the bot

bot_status_text

XMPP status text of the bot.

nagios_cmd_file

Nagios(tm) command file. This file accepts the external Nagios(tm) commands (defaults to /usr/local/nagios/var/rw/nagios.cmd).

nagios_msg_fifo

The pipe for the communication with the Nagios(tm) process.

nagios_status_log_file

Nagios(tm) status file. This file contains the current state of all Nagios(tm) objects (defaults to /usr/local/nagios/var/status.dat).

password

Logon password of the bot's JID.

pid_file

Name of the pid file if the bot forks into background. (defaults to /var/run/nagibot/<local-part-of-jid>.pid)


SAMPLE CONFIGURATION

Here is my configuration file:

    ---
    # Rooms to join
    noc@conference.ruhr-uni-bochum.de: NagiBot
    ---
    # JIDs to inform (none in my case)
    ---
    # Configuration
    nagios_status_log_file: /opt/nagios/ver/status.log
    nagios_cmd_file: /opt/nagios/var/rw/nagios.cmd
    nagios_msg_fifo: /opt/nagios/var/rw/nagibot.fifo
    bot_status: available
    bot_status_text: Ich bin ein bot, holt mich hier raus ...
    bot_status_priority: 0
    password: geHa!m
    ---

That's all.


ACCEPTED COMMANDS

The bot also reacts to some simple commands sent to it. In a MUC (Multi User Chat) the command has to be preceded by @nagibot.

Here is a list of commands:

help

The bot reports a list of available commands and a short description of each command.

status

The bot reports the current Nagios(tm) status. It reports how many services are OK and how many services are in WARNING, CRITICAL or UNKNOWN state.

details [<host> [all]]

The bot reports details about the services that are in a state other than OK. It reports the hostname, the name of the service and its last state followed by a new line and the last plugin output.

If <host> is given only the problems for the given host are displayed. You can add an 'all' the the command to display the status of all services of <host>.

info

The bot reports some information about the system. Currently, only the CPU load of the Nagios(tm) host system is reported.

ack [<service>@]<host> <comment>

The bot will acknowledge the given host or service problem.

recheck [<service>@]<host>

The bot will schedule a check of the given host or service.


PREREQUISITES

For the bot to work you have to establish a communication channel with the Nagios(tm) process. Since the bot reads from a pipe you have to create one. You can do this with the following command:

    mkfifo -m 0660 /path/to/the/pipe

Now you have to instruct the Nagios(tm) process to write to this pipe. An easy way to do this is to define a "notification command". In my installation I've done this with the following definition (the file nagios-misccommands contains a complete example):

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

If you then configure this command to be one of the contacts' notification command, the bot will be able to get the notifications if Nagios(tm) notifies that contact. Be sure to add this command only to one contact or you will get multiple notification messages. And remember: the command_line MUST be on ONE line!