#!/bin/bash
OUTPUTFILE="/usr/local/nagios/libexec/tools/linux/nrpe-agent-installation.txt"
for server in `cat /usr/local/nagios/libexec/tools/serverlist.txt`
do
FLAG=0
for password in `cat /usr/local/nagios/libexec/tools/linux/password.txt`
do
/usr/local/nagios/libexec/tools/sftp_put.pl -h $server -u root -p $password -s "file" -f "/usr/local/nagios/libexec/tools/linux/test.txt" -t "/tmp/test.txt"
TEST=`echo $?`
if [ "$TEST" -eq "0" ];then
echo -e "$server \t $password" >> $OUTPUTFILE
#create nagios user
/usr/local/nagios/libexec/check_openssh.pl -H $server -u root -p $password -s command -C "useradd -m -d /var/spool/nagios -p "naZaxHcLCJwT2" nagios"
#Install NRPE Agent#
/usr/local/nagios/libexec/check_openssh.pl -H $server -u root -p $password -s command -C "yum -y install nagios-common-3.5.1-1.el6.x86_64 nagios-plugins-all-2.0.3-3.el6.x86_64 nagios-plugins-nrpe-2.15-7.el6.x86_64 nagios-nrpe-2.14-1.el6.rf.x86_64"
#Upload nrpe.cfg golden copy#
/usr/local/nagios/libexec/tools/sftp_put.pl -h $server -u root -p $password -s "file" -f "/usr/local/nagios/libexec/tools/linux/nrpe_cfg/nrpe.cfg" -t "/etc/nagios/nrpe.cfg"
#Upload nagios sudoers file#
/usr/local/nagios/libexec/tools/sftp_put.pl -h $server -u root -p $password -s "file" -f "/usr/local/nagios/libexec/tools/linux/nagios-sudo/nagios" -t "/etc/sudoers.d/nagios"
#Change the permissions of the nagios directories#
/usr/local/nagios/libexec/check_openssh.pl -H $server -u root -p $password -s command -C "chown -R nagios:nagios /etc/nagios/;chown -R nagios:nagios /usr/lib64/nagios/"
FLAG=1
break
fi
done
if [ "$FLAG" -eq "0" ];then
echo -e "$server \t No Password" >> $OUTPUTFILE
fi
done
OUTPUTFILE="/usr/local/nagios/libexec/tools/linux/nrpe-agent-installation.txt"
for server in `cat /usr/local/nagios/libexec/tools/serverlist.txt`
do
FLAG=0
for password in `cat /usr/local/nagios/libexec/tools/linux/password.txt`
do
/usr/local/nagios/libexec/tools/sftp_put.pl -h $server -u root -p $password -s "file" -f "/usr/local/nagios/libexec/tools/linux/test.txt" -t "/tmp/test.txt"
TEST=`echo $?`
if [ "$TEST" -eq "0" ];then
echo -e "$server \t $password" >> $OUTPUTFILE
#create nagios user
/usr/local/nagios/libexec/check_openssh.pl -H $server -u root -p $password -s command -C "useradd -m -d /var/spool/nagios -p "naZaxHcLCJwT2" nagios"
#Install NRPE Agent#
/usr/local/nagios/libexec/check_openssh.pl -H $server -u root -p $password -s command -C "yum -y install nagios-common-3.5.1-1.el6.x86_64 nagios-plugins-all-2.0.3-3.el6.x86_64 nagios-plugins-nrpe-2.15-7.el6.x86_64 nagios-nrpe-2.14-1.el6.rf.x86_64"
#Upload nrpe.cfg golden copy#
/usr/local/nagios/libexec/tools/sftp_put.pl -h $server -u root -p $password -s "file" -f "/usr/local/nagios/libexec/tools/linux/nrpe_cfg/nrpe.cfg" -t "/etc/nagios/nrpe.cfg"
#Upload nagios sudoers file#
/usr/local/nagios/libexec/tools/sftp_put.pl -h $server -u root -p $password -s "file" -f "/usr/local/nagios/libexec/tools/linux/nagios-sudo/nagios" -t "/etc/sudoers.d/nagios"
#Change the permissions of the nagios directories#
/usr/local/nagios/libexec/check_openssh.pl -H $server -u root -p $password -s command -C "chown -R nagios:nagios /etc/nagios/;chown -R nagios:nagios /usr/lib64/nagios/"
FLAG=1
break
fi
done
if [ "$FLAG" -eq "0" ];then
echo -e "$server \t No Password" >> $OUTPUTFILE
fi
done
#######################################
#Dependencies :
check_openssh.pl Plugin for Nagios, Net::SFTP::Foreign - FTP protocol to put files from folder or file to remote server.
#######################################
No comments:
Post a Comment