From 92d8e0d43788333afc3afcc72670482a5ac656ff Mon Sep 17 00:00:00 2001
From: robert <ppabc@qq.com>
Date: Fri, 13 Jan 2017 13:45:04 +0800
Subject: [PATCH] nrpe

---
 ansible/ansible_nagios_em2.sh | 19 +++++++++++++++++++
 ansible/ansible_nagios_ss.sh  | 18 ++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 ansible/ansible_nagios_em2.sh
 create mode 100644 ansible/ansible_nagios_ss.sh

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