NagiosGrapher - useful charts in nagios
1.Preparations
First of all we need to install necessary packages
apt-get install perl perl-base perl-modules libcalendar-simple-perl libgd-gd2-perl perlmagick librrds-perl liburi-perl autoconf rrdtool
2.Nagiosgrapher installation
Currently latest stable version of nagiosgrapher is 1.7.1. The sources can be stored in /tmp directory:
cd /tmp wget http://downloads.sourceforge.net/project/nagiosgrapher/nagiosgrapher/NagiosGrapher-1.7.1/NagiosGrapher-1.7.1.tar.gz?use_mirror=mesh
Unpack with command:
tar -zxvf NagiosGrapher-1.7.1.tar.gz cd NagiosGrapher-1.7.1
With --prefix mark we should point where the nagios is installed:
autoconf && ./configure --prefix=/usr/local/nagios
Make test for perl package dependencies:
make testdeps
After installing all necessary packages we can install nagiosgrapher running below command:
make install
Add or change in your nagios.conf file following lines (make sure that sericeext directory exists):
cfg_dir=/usr/local/nagios/etc/serviceext process_performance_data=1 service_perfdata_file=/usr/local/nagios/var/service-perfdata service_perfdata_file_template=$HOSTNAME$\t$SERVICEDESC$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\t$TIMET$\n service_perfdata_file_mode=a service_perfdata_file_processing_interval=30 service_perfdata_file_processing_command=process-service-perfdata-file
Define in your nagios new command as shown below:
define command {
command_name process-service-perfdata-file
command_line mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/service-perfdata.$TIMET$
}
3.Usage
In /usr/local/nagios/etc/ngraph.d/templates directory there are - ready to use examples nagiosgrapher templates
Example file check_dns.ncfg (if file name is with *_disabled remove it to enable plugin)
# ---
# NagiosGrapher Template for check_dns
# ---
# DNS
define ngraph{
service_name DNS # service name in nagios
graph_log_regex (\d+) second
#DNS service should return regex value ex: 0,15 second
graph_value sec # y axis description
graph_units seconds
graph_legend response time
rrd_plottype LINE2 # could be LINE1 or AREA
rrd_color 00a000
}
# [EOF]
After creating some new templates the nagiosgrapher daemon needs to be restarted
/etc/init.d/nagios_grapher restart
You can monitor the nagiosgrapher log file for regex matches:
tail -f /usr/local/nagios/var/ngraph.log
PIPE: Server DNS DNS OK: 0,086 seconds response time. www.google.pl returns 11.22.33.44,55.66.77.88 time=0,085865s;;;0,000000 1273179557 REGEX: 1 blocks for 'DNS' found. REGEX: graph_value=sec REGEX: output=plugin. REGEX: regex=m/(\d+) second/i REGEX: perfdata=dns ok: 0,086 seconds response time. www.google.pl returns 11.22.33.44,55.66.77.88 REGEX: match=086 VALUES: [Server][DNS]: sec=086 RRD: rrdtool update /usr/local/nagios/var/rrd/Server/19ac25babd382d4bb58325eb417d4ba5.rrd --template=sec 1273179557:086
New rrd file has been created, so check your /usr/local/nagios/etc/serviceext for new nagios serviceextinfo files. If there are any new ones, restart nagios to see graph icon near service description in service detail table:
/etc/init.d/nagios restart
Do not forget to change log level in /usr/local/nagios/etc/ngraph.ncfg after you finish working with configuring templates:
# log_level 1023 log_level 0001
Example DNS nagiosgrapher charts: