#!/bin/bash
#Author Karthikeyan.S
#Any Failing Command Will Cause The Script To Stop
set -e
#Treat Unset Variables As Errors
set -u
test $(id -u) -eq 0 || { echo "You are not a root user to run this script " ; exit 1; }
rpm -qa | grep rpmforge
status=$?
if [ $status = 0 ]
then
echo "rpmforge repo is already installed"
else
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm
fi
yum update
yum -y install autoconf rrdtool perl-GD* ImageMagick-perl perl-URI.noarch perl-Calendar*
if [ -d /opt/downloads ]
then
echo "/opt/downloads folder already exists"
else
mkdir /opt/downloads
fi
cd /opt/downloads
wget http://sourceforge.net/projects/nagiosgrapher/files/nagiosgrapher/NagiosGrapher-1.7.1/NagiosGrapher-1.7.1.tar.gz/download
tar -xvf NagiosGrapher-1.7.1.tar.gz
cd NagiosGrapher-1.7.1
autoconf
./configure --with-layout=default
make install
cat >> /usr/local/nagios/etc/nagios.cfg << EOF
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$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-file
EOF
cat >> /usr/local/nagios/etc/objects.commands.cfg << EOF
#NagiosGrapher commands
define command{
command_name process-service-perfdata-file
command_line mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/service-perfdata.$TIMET$
}
EOF
/etc/init.d/nagios restart
/usr/local/nagios/contrib/collect2.pl restart
echo "Nagios Grapher installation finished successfully..."
No comments:
Post a Comment