NagiosExchange
NagiosForge
NagiosWiki
Nagios Community Platform powered by NETWAYS

HowTos:BestPractice:NagiosGrapher

Search  
From NagiosWiki
Jump to: navigation, search

Best Practice for NagiosGrapher

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

This is a 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 a value in the Nagios Status Output (the value to be graphed is inside the brackets)
define ngraph{
       service_name            PING
       graph_log_regex         loss = ([0-9]*)
       graph_value             Loss
       graph_units             %
       graph_legend            Loss
       graph_legend_eol        none
       page                    2 Loss
       rrd_plottype            LINE2
       rrd_color               ff0000
}
  • 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.

See also

External Links

Here find you a tutorial for Regular Expressions.