diff --git a/ansible/ansible_nagios_em2.sh b/ansible/ansible_nagios_em2.sh new file mode 100644 index 0000000..88f1721 --- /dev/null +++ b/ansible/ansible_nagios_em2.sh @@ -0,0 +1,19 @@ +#!/bin/bash +## ansible_nagios_em2 2017-01-13 +## http://www.aqzt.com +## email: ppabc@qq.com +## robert yu +## centos 6 + +ps -ef | grep 'nagios' | grep 'nrpe' | grep -v 'grep' | awk '{print $2}' | xargs kill +num1=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep em2 | grep public123 | awk -F ' ' '{print $11}' | awk -F ',' '{print $2}'` +num2=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep em2 | grep public123 | awk -F ' ' '{print $11}'` +num5=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep em2 | grep public123 | awk -F ' ' '{print $13}' | awk -F ',' '{print $2}'` +num6=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep em2 | grep public123 | awk -F ' ' '{print $13}'` +var1=`expr $num1 + 10000` +var2=`expr $num5 + 10000` +echo "w=$num1 c=$num5" +echo "w=$var1 c=$var2" +sed -i "s/-w $num2/-w $var1,$var1/g" /usr/local/nagios/etc/nrpe.cfg +sed -i "s/-c $num6/-c $var2,$var2/g" /usr/local/nagios/etc/nrpe.cfg +/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d \ No newline at end of file diff --git a/ansible/ansible_nagios_ss.sh b/ansible/ansible_nagios_ss.sh new file mode 100644 index 0000000..ebf9840 --- /dev/null +++ b/ansible/ansible_nagios_ss.sh @@ -0,0 +1,18 @@ +#!/bin/bash +## ansible_nagios_ss 2017-01-13 +## http://www.aqzt.com +## email: ppabc@qq.com +## robert yu +## centos 6 + +ps -ef | grep 'nagios' | grep 'nrpe' | grep -v 'grep' | awk '{print $2}' | xargs kill +num1=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep check_ss | grep nagios | awk -F ' ' '{print $2}'` +num2=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep check_ss | grep nagios | awk -F ' ' '{print $2}'` +num5=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep check_ss | grep nagios | awk -F ' ' '{print $3}'` +num6=`cat /usr/local/nagios/etc/nrpe.cfg |grep -v "#" |grep check_ss | grep nagios | awk -F ' ' '{print $3}'` +var1=`expr $num1 + 2000` +var2=`expr $num5 + 2000` +echo "w=$num1 c=$num5" +echo "w=$var1 c=$var2" +sed -i "s/check_ss.sh $num1 $num5/check_ss.sh $var1 $var2/g" /usr/local/nagios/etc/nrpe.cfg +/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d \ No newline at end of file