← Back to list

Nagiosgraph & html based Notification Integration with Nagios

Nagios, by default, sends plain text-based notifications, which often lack sufficient context and make it difficult to quickly identify the…

Zakir Hossain · 2026-03-17 08:58 · 1 claps · 2.8 min read
#nagios #nagiosgraph #notifications #graph
Open on Medium ↗
Wiki topics: 🌐 · Web Development

Nagiosgraph & html based Notification Integration with Nagios

Nagios, by default, sends plain text-based notifications, which often lack sufficient context and make it difficult to quickly identify the root cause of an issue. In most cases, administrators need to log in to the Nagios web UI to analyze the problem in detail.

To address this limitation, I integrated NagiosGraph with HTML-based notifications. This enhancement enables recipients to view performance graphs and critical insights directly within the notification itself — eliminating the need to access the Nagios web interface for initial analysis and significantly improving response efficiency.

Scenario:

nagiosgraph-and-html-alert

nagiosgraph-and-html-alert

Pre-requisite:

  1. nagios -> Consider it already installed
  2. nagiosgraph -> Consider it already installed
  3. nagios_send_host_mail.pl plugin
  4. nagios_send_service_mail.pl plugin

Install required packages.

You required epel-release and crb repository

[#] dnf install -y perl-Getopt-Long perl-Mail-Sendmail perl-Digest-MD5 perl-MIME-Base64 perl-File-Temp

Add below section at the end of the command.cfg file. [#] vim /usr/local/nagios/et/object/command.cfg

define command{
 command_name host-email-graph
 command_line /usr/local/nagios/libexec/nagios_send_host_mail.pl \
 -p "Company Name, Address" \
 -H "10.0.14.40:25" \
 -r "$CONTACTEMAIL$" \
 -f graph \
 -u
}
define command{
 command_name service-email-graph
 command_line /usr/local/nagios/libexec/nagios_send_service_mail.pl \
 -p "Company Name, Address" \
 -H "10.0.14.40:25" \
 -r "$CONTACTEMAIL$" \
 -f graph \
 -u
}

Modify contacts.cfg file as like below file [#] vim /usr/local/nagios/et/object/contacts.cfg

define contact{
 contact_name **sysadmin**
 use generic-contact
 alias System Admin
 email sysadmin@example.com
 service_notification_commands service-email-graph
 host_notification_commands host-email-graph
 }
define contact{
 contact_name zakir
 use generic-contact
 alias Md. Zakir Hossain
 email zhossain@example.com
 service_notification_commands service-email-graph
 host_notification_commands host-email-graph
 }
define contactgroup {
 contactgroup_name sysadmin
 alias System Administrators
 members **sysadmin**, zakir
}

Modify templates.cfg file as like below file [#] vim /usr/local/nagios/et/object/templates.cfg

define service{
 name important-service 
 use generic-service 
 max_check_attempts 3 
 check_interval 1 
 retry_interval 1 
 notifications_enabled 1
 check_period 24x7
 contact_groups **sysadmin** 
 notification_options w,u,c,r 
 notification_interval 60 
 notification_period 24x7 
 register 0
 }

Modify linux-services.cfg file as like below file [#] vim /usr/local/nagios/et/object/linux-services.cfg

#Below service must by available otherwise nagios_send_host_mail.pl will not work.
#check-host-alive service must be active if you want to send host graph with email notification
define service {
 use important-service,nagiosgraph
 host_name ns01,ns02
 service_description check-host-alive
 check_command check-host-alive
 contact_groups sysadmin
}
# Current Load
define service {
 use important-service,nagiosgraph
 host_name ns01,ns02
 service_description Current Load
 check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
 contact_groups sysadmin
}

Note: Add all the services that you want to monitor and get the rich-text based alert along with nagiosgraph.

Enable Environment Macros [#] vim /usr/local/nagios/etc/nagios.cfg

enable_environment_macros=1

Download required plugins

https://github.com/zakirpcs/nagios-plugins/blob/29bc546ebaec9452f5a4da4a31c1eb03ec67b93a/nagios_send_host_mail.pl

https://github.com/zakirpcs/nagios-plugins/blob/29bc546ebaec9452f5a4da4a31c1eb03ec67b93a/nagios_send_service_mail.pl

Modify nagios_send_host_mail.pl & nagios_send_service_mail.pl as like below [#] vim /usr/local/nagios/libexec/nagios_send_host_mail.pl

my $mail_sender = "Nagios Monitoring <nagios\@example.com>";
my $nagios_cgiurl = "http://nagios.example.com/nagios/cgi-bin";
my $test_host = "localhost"; 
my $test_service = "Current Load"; 
my $ngraph_cgiurl = "http://nagios.example.com/nagios/cgi-bin/show.cgi";
my $rrd_basedir = "/usr/local/nagiosgraph/var/rrd/";
my $o_smtphost = "10.0.14.40";
my $domain = "\@example.com"; 
my $logofile = "/var/www/html/fm4dd/images/logo.png";

Note: For this kind of SMTP configuration You required SMTP realy without authentication

Create logo directory for Rich-Text based notification [#] mkdir -p /var/www/html/fm4dd/images/ [#] copy logo.png into /var/www/html/fm4dd/images/ this directory

Finally reload the nagios service and test the alert

[#] systemctl reload nagios

[#] perl /usr/local/nagios/libexec/nagios_send_service_mail.pl -t -H “10.0.14.40:25” -p “Company Name, Address” -r “youremail@gmail.com” -f graph -u [#] perl /usr/local/nagios/libexec/nagios_send_host_mail.pl -t -H “10.0.14.40:25” -p “Company Name, Address” -r “youremail@gmail.com” -f graph -u

Usage: /usr/local/nagios/libexec/nagios_send_service_mail.pl [-v] [-V] [-h] [-t] [-H <SMTP host>] [-p <customername>] [-r <to_recipients> or -g <to_group>] [-c <cc_recipients>] [-b <bcc_recipients>] [-f <text|html|multi|graph>] [-u] [-l <en|jp|fr|de|es|(or other languages if added)>]

Nagios alert before use this plugin:

generic-nagios-alert

generic-nagios-alert

Nagios alert after use this plugin:

nagios-alert-with-graph

nagios-alert-with-graph


메타데이터
post_id
4e9dd4bcf8b9
slug
nagiosgraph-html-based-integration-with-nagios-4e9dd4bcf8b9
url
https://medium.com/@zakirpcs/nagiosgraph-html-based-integration-with-nagios-4e9dd4bcf8b9
canonical_url
https://medium.com/@zakirpcs/nagiosgraph-html-based-integration-with-nagios-4e9dd4bcf8b9
author_url
https://medium.com/@zakirpcs
status
ok
fetched_at
2026-07-13 06:23:13