command to trigger a test alert for notification development

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jkimbrough
Posts: 2
Joined: Tue Jun 16, 2020 7:13 am

command to trigger a test alert for notification development

Post 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.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: command to trigger a test alert for notification develop

Post 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"
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Locked