This article explain how to forward Nagios event log to Apsolab-Server. Nagios allows you to setup event handler for host and service events. To forward events to Apsolab-Server you need to:
- Copy event scripts to Nagios location
- Configure Nagios commands
- Configure Nagios event handlers
Copy event scripts to Nagios location
Apsolab provides bash script to handle Nagios events (host and service). Those script files are located in /opt/apsolab/latest/script/nagios
. Copy those files in Nagios event handlers directory /usr/local/nagios/libexec/eventhandlers
. Change file owner and permissions (nagios:nagios 0750).
Configure Nagios commands
To configure Nagios commands you need to edit the commands.cfg
file located in /usr/local/nagios/etc/objects
. At the end of the commands file, add the following lines:
define command{ command_name apsolab_host_event command_line /usr/local/nagios/libexec/eventhandlers/apsolab_host_event.sh --host-name $HOSTNAME$ --host-address $HOSTADDRESS$ --state $HOSTSTATE$ --state-type $HOSTSTATETYPE$ --attempt $HOSTATTEMPT$ --text "$HOSTOUTPUT$ $LONGHOSTOUTPUT$ $HOSTPERFDATA$" --host 127.0.0.1 --ssl --port 5473 } define command{ command_name apsolab_service_event command_line /usr/local/nagios/libexec/eventhandlers/apsolab_service_event.sh --name $SERVICEDESC$ --host-name $HOSTNAME$ --host-address $HOSTADDRESS$ --state $SERVICESTATE$ --state-type $SERVICESTATETYPE$ --attempt $SERVICEATTEMPT$ --text "$SERVICEOUTPUT$ $LONGSERVICEOUTPUT$ $SERVICEPERFDATA$" --host 127.0.0.1 --ssl --port 5473 }
This configuration assume that Apsolab-Server is located in localhost. If you install Apsolab product in a different host than use an appropriate value for --host
parameter. If you don’t want to use SSL, remove --ssl
parameter and set --port
to 5472 or any other port you may have configure for TAG service.
WARNING: If Apsolab is in a different host than Nagios, copy /opt/apsolab/latest/bin/xlogagent.pl
and /opt/apsolab/latest/bin/XLogAgent.pm
to Nagios host and update apsolab_host_event.sh
and apsolab_service_event.sh
with the new file location. Update file owner and permissions (nagios:nagios 0750).
Configure Nagios event handlers
To configure Nagios event handlers you need to edit the nagios.cfg
file located in /usr/local/nagios/etc
. Add or replace the following parameters:
global_host_event_handler=apsolab_host_event global_service_event_handler=apsolab_service_event
To make you change effective, restart Nagios service.
Note: You won’t see Nagios Service logger in Apsolab-Console until an event happen.