%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /scripts2/attic/
Upload File :
Create Path :
Current File : //scripts2/attic/install-nagios-nrpe.sh

#! /bin/bash

groupadd  -g 200 nagios
adduser  -d /usr/local/nrpe -g 200 -u 200 -m nagios
passwd -l nagios
cd /root
wget http://ufpr.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --prefix=/usr/local/nrpe
make all
make install
cd /usr/local/nrpe
mkdir etc
> etc/nrpe.cfg
chown nagios.nagios etc
chown nagios.nagios etc/nrpe.cfg


cat > etc/nrpe.cfg <<NRPE


pid_file=/var/run/nrpe.pid
server_port=5666
nrpe_user=nagios
nrpe_group=nagios
dont_blame_nrpe=0
debug=1

command_timeout=60

command[check_load]=/usr/local/nrpe/libexec/check_load 5 8
command[check_queue]=/usr/local/nrpe/libexec/check_queue 5000 10000
command[check_tmp]=/usr/local/nrpe/libexec/check_tmp 80 90
NRPE

cat > libexec/check_load <<LOAD

load=\$(uptime | awk '{print \$10}' | sed 's/\...,//g')

if [ \$load -gt \$2 ]
then
	echo "CRITICAL \$load"
	exit 2
fi

if [ \$load -gt \$1 ]
then
	echo "WARNING \$load"
	exit 1
fi

echo \$load

exit 0

LOAD

cat > libexec/check_queue <<QUEUE

queue=\$(sudo -u root /usr/sbin/exim -bpc)

if [ \$queue -gt \$2 ]
then
        echo "CRITICAL \$queue"
        exit 2
fi

if [ \$queue -gt \$1 ]
then
        echo "WARNING \$queue"
        exit 1
fi

echo "INFO \$queue"

exit 0

QUEUE

cat > libexec/check_tmp <<TMP

usage=\$(df -h | grep '/tmp' | awk ' { print $5 } ' | sed 's/%//g')

if [ \$usage -gt $2 ]
then
        echo "CRITICAL \$usage %"
        exit 2
fi

if [ \$usage -gt $1 ]
then
        echo "WARNING \$usage % "
        exit 1
fi

echo \$usage

exit 0

TMP


chown nagios.nagios libexec/*
chmod 775 libexec/*

cat > /etc/init.d/nrpe <<INIT
#! /bin/sh
#
# nrpe            This shell script takes care of starting and stopping
#
# chkconfig: - 99 45
# description: nrpe daemon

# Source function library.
. /etc/rc.d/init.d/functions


# See how we were called.
case "\$1" in
  start)
        # Start daemons.
        echo -n "Starting nrpe: "
        su - nagios -c "/usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg -d"
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down nrpe: "
        killproc nrpe
        ;;
  *)
        echo "Usage: nrpe {start|stop}"
        exit 1
esac

exit 0

INIT

chmod 755 /etc/init.d/nrpe
chkconfig --level 2345 nrpe on

/etc/init.d/nrpe stop

sleep 2

/etc/init.d/nrpe start

if grep "nagios" /etc/sudoers > /dev/null 2> /dev/null ; then

exit 0

else

echo "nagios  ALL=NOPASSWD:/usr/sbin/exim" >> /etc/sudoers

fi

if grep "#Defaults    requiretty" > /dev/null 2> /dev/null ; then

exit 0

else

find /etc -name "sudoers" -exec replace "Defaults    requiretty" "#Defaults    requiretty" -- {} \;

fi


Zerion Mini Shell 1.0