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.
Hey Gurus,
I need a small help to figure it out that how can i setup a nagios individual service URL in the email notification. Right now i am getting email alert with XXXX information but i need the email notification with the URL that take you straight to nagios service information page.
Thanks
http://<nagios server ip>/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$SERVICEDESC$
Obviously change <nagios server ip> to your server's ip.
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.
Thanks abrist for your reply, but i am pretty new in nagios world so quite slow to understand. The suggestion you gave me, where i need to add that. my configuration is something like that... and do i also need to add anything in the (notification of email) too ?..
define service {
hostgroup_name api,EPP,generic-api,generic-svc,PCE,sam
service_description Disk Space
check_command check_nrpe_disk_windows
use generic-service
notification_interval 0
}
$$(echo "http://<nagios server ip>/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$SERVICEDESC$" | sed 's/ /%20/g')
Two $$ because we need to escape the $ used for nagios macros.
The reason to echo the url through sed is so that we can replace any spaces in the url (spaces in the service or hostname) with the url encoded %20. This code should add a link to the bottom of your email. Make sure to replace <nagios server ip> with your server's actual ip and to change http to https if needed (like if you force https through rewrite rules).
EDIT: The sed above only url encodes spaces. If your object names have any other characters that need to be url encoded, you will need to extend the sed logic to compensate for them.
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.
Try running it from the cli. It will have a bunch of $ in the fields, but we should see the url in the email. Replace <your email> with your address and try running this monster one liner from the cli::
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nRapid Response:\n$$(echo "http://10.5.56.62/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$SERVICEDESC$" | sed 's/ /%20/g')" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" <your email>
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.