The following information is provided with no representation
or warranty of any kind either express or implied. You may use it
freely at your own risk, and no one else will be liable for any damages
arising out of such usage.
OS: CentOS 5.6 i386, CentOS 5.7 i386, CentOS 5.7 x86_64
Nagios Version: 3.3.1
NagiosGraph Version: 1.4.4
Hardware: Virtual Machine (VMware Server 2.0.0.2712)
/trends.cgi" target="">Trends
OS: CentOS 5.6 i386, CentOS 5.7 i386, CentOS 5.7 x86_64
Nagios Version: 3.3.1
NagiosGraph Version: 1.4.4
Hardware: Virtual Machine (VMware Server 2.0.0.2712)
About
NagiosGraph is an addon for Nagios that take the performace data from Nagios services and create graphs that you can use to see your network health.Prerequisite
- Install Nagios server http://nagios.sourceforge.net/docs/3_0/quickstart.html
- we need to install the folllowing prerequisites packages: rrdtool perl-GD
yum install rrdtool perl-GD perl-CGI rrdtool-perl perl-Time-HiRes -y
Install NagiosGraph
- Download NagiosGraph
cd /usr/local/src/nagios/ wget http://sourceforge.net/projects/nagiosgraph/files/nagiosgraph/1.4.4/nagiosgraph-1.4.4.tar.gz -O nagiosgraph.tar.gz
- Extract NagiosGraph
tar zxf nagiosgraph.tar.gz cd nagiosgraph-1.4.4
- Make directory for NagiosGraph in Nagios directory
mkdir /usr/local/nagios/nagiosgraph
- Copy etc NagiosGraph directory
cp -r etc /usr/local/nagios/nagiosgraph/
- Change NagiosGraph path in cgi and perl scripts
sed -i "s#/opt/nagiosgraph/etc#/usr/local/nagios/nagiosgraph/etc#g" cgi/*cgi sed -i "s#/opt/nagiosgraph/etc#/usr/local/nagios/nagiosgraph/etc#g" lib/insert.pl
- Copy cgi and perl scripts
cp lib/insert.pl /usr/local/nagios/libexec cp cgi/*.cgi /usr/local/nagios/sbin
- Copy CSS and JavaScript files
cp share/nagiosgraph.css /usr/local/nagios/share cp share/nagiosgraph.js /usr/local/nagios/share
- Edit nagiosgraph.conf and set the following:
vi /usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf
... # Location of output from nagiosgraph data processing logfile = /usr/local/nagios/nagiosgraph/var/nagiosgraph.log # Location of output from nagiosgraph CGI scripts cgilogfile = /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log # Location of nagios performance data log file. perflog = /usr/local/nagios/var/perfdata.log # Directory in which to store RRD files rrddir = /usr/local/nagios/nagiosgraph/var/rrd # File containing regular expressions to identify service and perf data mapfile = /usr/local/nagios/nagiosgraph/etc/map # Nagiosgraph CGI URL. nagiosgraphcgiurl = /nagios/cgi-bin # Nagios CGI URL. If the Nagiosgraph CGI scripts are in a directory other # than the Nagios CGI directory, then specify the Nagios CGI URL here. #nagioscgiurl = /nagios/cgi-bin # JavaScript: URL to the nagiosgraph javascript file. javascript = /nagios/nagiosgraph.js # Stylesheet: URL to the nagiosgraph stylesheet. stylesheet = /nagios/nagiosgraph.css # File containing labels for services and data (optional) #labelfile = /etc/nagiosgraph/labels.conf # Location of showhost control file (optional) #hostdb = /etc/nagiosgraph/hostdb.conf # Location of showservice control file (optional) #servdb = /etc/nagiosgraph/servdb.conf # Location of showgroup control file (required for showgroup.cgi) groupdb = /usr/local/nagios/nagiosgraph/etc/groupdb.conf # File containing data sets that should be selected in queries (optional) #datasetdb = /etc/nagiosgraph/datasetdb.conf ...
- Create directories for NagiosGraph
mkdir /usr/local/nagios/nagiosgraph/var mkdir /usr/local/nagios/nagiosgraph/var/rrd
- In NagiosGraph SSI file, set the URL for nagiosgraph.js
vi share/nagiosgraph.ssi
...
- Copy NagiosGraph ssi file
cp share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi chown nagios:nagios /usr/local/nagios/share/ssi/common-header.ssi
- Set NagiosGraph files permissions
chown -R nagios:nagios /usr/local/nagios/nagiosgraph chmod 755 /usr/local/nagios/nagiosgraph/var/rrd touch /usr/local/nagios/nagiosgraph/var/nagiosgraph.log chmod 664 /usr/local/nagios/nagiosgraph/var/nagiosgraph.log touch /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log chown apache /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log chmod 664 /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log
Nagios Configuration
- In Nagios configuration file edit the following (you can mark out all these items and add this block to the end of the file):
vi /usr/local/nagios/etc/nagios.cfg
... process_performance_data=1 service_perfdata_file=/usr/local/nagios/var/perfdata.log service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$ service_perfdata_file_mode=a service_perfdata_file_processing_interval=30 service_perfdata_file_processing_command=process-service-perfdata
- Copy NagiosGraph icon
cp -f share/graph.gif /usr/local/nagios/share/images/action.gif
- Edit Nagios sidebar by adding bullets under “Trends”:
vi /usr/local/nagios/share/side.php
...
Nagios without Nconf (use this section if you are not using Nconf)
- In Nagios command file add the following command:
vi /usr/local/nagios/etc/objects/commands.cfg ... define command { command_name process-service-perfdata command_line /usr/local/nagios/libexec/insert.pl }
- In Nagios configuration add a template for graphed services
vi /usr/local/nagios/etc/objects/templates.cfg ... define service { name graphed-service action_url /nagios/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagios/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j }
- Add the created graph template to all services that you can (has performance data) and want to create graphs
vi /usr/local/nagios/etc/objects/localhost.cfg ... define service { use local-service,graphed-service ... }
- Restart Nagios
/etc/init.d/nagios restart
Nagios with Nconf (use this section if you use Nconf to configure your Nagios system)
- In Nconf edit the Misccommand for processing performance data
Misccomands-> show
process-service-perfdata-> edit
"misc command line" = /usr/local/nagios/libexec/insert.pl
-> submit
- InNconf edit the “action_url” attribute to NagiosGraph URL
Attributes-> show
Select class-> service
action_url-> edit
"list of possible values" = \
/nagios/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagios/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j
-> submit
Attributes-> show
Select Class-> service-template
action_url-> edit
"list of possible values" = \
/nagios/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagios/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j
-> submit
- Set action_url path on all service templates that you want to have graph for
Services templates-> show
-> + Advanced
select requested services
Advanced-> "multi modify"
"select the attribute which you want to modify" = "action URL"
"New value to write" = /nagios/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagios/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j
-> submit
-> "Generate Nagios Config" -> Deploy
NagiosGraph installation completed.