MonitoringExchange
NagiosForge
NagiosWiki
Nagios Community Platform powered by NETWAYS

HowTos:BestPractice:NagiosGrapher

Search  
From MonEx Wiki
Jump to: navigation, search

This page will outline how to install and configure NagiosGrapher.

Contents







Requirements

What you need?

apt-get install autoconf rrdtool perl perl-base perl-modules libcalendar-simple-perl \
libgd-gd2-perl perlmagick librrds-perl liburi-perl


Installation

wget "http://LINK-URL" -O NagiosGrapher-x.x.x.tar.gz

Save the source code on your Nagios-Server in the /usr/local/src directory.

  • Extract the NagiosGrapher source code tarball
tar xzvf NagiosGrapher-x.x.x.tar.gz
  • change into the sourcefolder
cd NagiosGrapher-x.x.x
  • Create the configure script with the program autoconf
autoconf
  • Run the NagiosGrapher configure script.
    With the --help command you can see the configuration options.
./configure
  • Check the output
# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... no
checking for mawk... mawk
checking for perl... /usr/bin/perl
checking distribution... found debian
checking for layout... debian
checking layout: directory prefix... set to '/usr/local/nagios'
checking for init_scripts/nagios_grapher.debian... yes
checking if user www-data exists... found
checking if group www-data exists... found
configure: creating ./config.status
config.status: creating Makefile
config.status: creating bin/collect2.pl
config.status: creating bin/fifo_write.pl
config.status: creating lib/NagiosGrapher.pm
config.status: creating lib/NagiosGrapher/HTML.pm
config.status: creating lib/NagiosGrapher/Hooks/Generic.pm
config.status: creating lib/NagiosGrapher/Hooks/SrvExtWriteHostextInfo.pm
config.status: creating sbin/graphs.cgi
config.status: creating sbin/rrd2-graph.cgi
config.status: creating sbin/rrd2-system.cgi
config.status: creating nagios_grapher
config.status: creating cfg/ngraph.ncfg
config.status: creating cfg/logrotate/nagios_grapher
  • The important options are distribution, layout, directory prefix and init_scripts
checking distribution... found debian
checking for layout... debian
checking layout: directory prefix... set to '/usr/local/nagios'
checking for init_scripts/nagios_grapher.debian... yes

Image:Tip.gif Do you have another distribution? you can take a look in the file config.layout in the source folder
If you don't find your distribution there or you have another nagios configuration, please edit the config.layout file.
and send the developers your layout

  • Checking the required perl-libs
make testdeps
/usr/bin/perl ./tools/testdeps.pl
Checking Data::Dumper ... found
Checking File::Copy ... found
Checking File::Basename ... found
Checking Carp ... found
Checking POSIX ... found
Checking Time::HiRes ... found
Checking Time::Local ... found
Checking Storable ... found
Checking GD ... found
Checking Image::Magick ... found
Checking RRDs ... found
Checking CGI ... found
Checking CGI::Carp ... found
Checking IO::Handle ... found
Checking URI::Escape ... found
Checking Calendar::Simple ... found
  • If you have a not found you can install the required perl modules with CPAN, or your distributions software management system.
  • Installing the NagiosGrapher
make install

Image:Tip.gif to upgrade an existing installation you need make update

Configuration

ngraph.ncfg

  • Edit the config file /usr/local/nagios/etc/ngraph.ncfg
interface          file
perffile_path      /usr/local/nagios/var

nagios.cfg

  • Edit the config file /usr/local/nagios/etc/naigos.cfg
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

commands.cfg

  • Insert the follow command in /usr/local/nagios/etc/objects/commands.cfg
define command{
          command_name process-service-perfdata-file
          command_line mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/service-perfdata.$TIMET$
}


NagiosGrapher Templates

Regular Templates

This is an example:

  • Copy the template file to the ngraph.d directory
cp ./ngraph.d/templates/standard/check_ping.ncfg_disabled ./ngraph.d/check_ping.ncfg
  • Change the graph_log_regex to match values in the Nagios Status Output (the value to be graphed is inside the brackets). The output of the Ping plugin is like this:
PING OK - Packet loss = 0%, RTA = 25.91 ms
#---
#NagiosGrapherTemplateforcheck_ping
#Author:MariusHein
#---
  
define ngraph{
       service_name		PING
       graph_log_regex		loss = (\d+)
       graph_value		Loss
       graph_units		%
       graph_legend		Loss
       graph_legend_eol	none
       page			2 Loss
       rrd_plottype		LINE2
       rrd_color		ff0000
}

#PingDEFRTA
define ngraph{
       service_name		PING
       graph_log_regex		rta = (\d+[,\.]\d+)
       graph_value		RTA
       graph_units		ms
       graph_legend		RTA
       page			1 RTA
       rrd_plottype		AREA
       rrd_color		00a000
}

#PingVDEF,AverageRTA
define ngraph{
       service_name		PING
       type			VDEF
       graph_value		vdef_ping_average
       graph_units
       graph_legend		RTA Average
       graph_calc		RTA,AVERAGE
       graph_legend_eol	LEFT
       page			1 RTA
       rrd_plottype		LINE1
       rrd_color		0000ff
       hide			no
}


  • Restart the NagiosGrapher
/etc/init.d/nagiosgrapher stop
/etc/init.d/nagiosgrapher start
  • Reload Nagios
/etc/init.d/nagios reload

Image:Tip.gif The Grapher icon will not be displayed in the Nagios interface until a check for the service has been processed, FOLLOWED BY a reload of the Nagios process itself.

Multigraph Templates

If you want to compare graphs of several services, Multigraphs are the way to go. Using the ping example above, we have the round-trip value (RTA) and packet-loss for each host we are pinging.

If you want to compare the RTA of several hosts. Here is a template from nmgraph.ncfg

define nmgraph{
       host_name		* Multigraphen
       service_name		All Ping RTA
       # RegEX
       hosts			.*?
       # RegEX
       services       		PING
       # This matches 'graph_value' from the ngraph definition
       graph_values		RTA
       # line or stack or area
       graph_type		LINE1
       # normal or reverse or leave blank
       order			reverse
       colors			ff8000, 00ff00, 0000ff,000000,ff0000
}

Image:Ping-RTA-Multigraph.png

See also

External Links