Page 1 of 1

command to trigger a test alert for notification development

Posted: Thu Feb 25, 2021 2:15 pm
by jkimbrough
I'm making adjustments to our slack service/host notify script and was wondering if there was a command line way to trigger an alert event with all the macro variables populated - rather than have to trigger an alert by reconfiguring an existing check.

Re: command to trigger a test alert for notification develop

Posted: Fri Feb 26, 2021 1:27 pm
by dchurch
The macro variables are specific to the host/service. You'll want to sub them out with dummy values if generating a notification email.

The commands that generate host and service emails are viewable under Core Config Manager -> Commands, and they're called xi_host_notification_handler and xi_service_notification_handler respectively.

Here's an example script that'll generate and send a service notification email:

Code: Select all

#!/bin/sh
[email protected] # Replace with your email address
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php \
	--notification-type=service \
	--contact="Test Contact" \
	--contactemail="$EMAIL_TO" \
	--type=ACKNOWLEDGEMENT \
	--escalated="Test Escalated" \
	--author="Test Author" \
	--comments="Test Comments" \
	--host="test-host.example.com" \
	--hostaddress="test-host.example.com" \
	--hostalias="test-host.example.com" \
	--hostdisplayname="Test Host" \
	--service="Test Service" \
	--hoststate=OK \
	--hoststateid=1 \
	--servicestate=CRITICAL \
	--servicestateid=3 \
	--lastservicestate=OK \
	--lastservicestateid=1 \
	--servicestatetype=HARD \
	--currentattempt=4 \
	--maxattempts=5 \
	--serviceeventid=1 \
	--serviceproblemid=1 \
	--serviceoutput="DISK CRITICAL - free space: / 1124 MiB (3.19% inode=96%):" \
	--longserviceoutput="DISK CRITICAL - free space: / 1124 MiB (3.19% inode=96%):" \
	--datetime="2021-02-25T06:00:00-6"