#!/bin/bash
#Date : 1st April 2012
#Purpose : Nagios service dependency configuration generator script
#Authors : Babu Dhinakaran S and Ranjith Kumar R
`grep host_name /usr/local/nagios/var/status.dat | cut -d=
-f2 | sort | uniq > /tmp/servers`
while read line
do
`grep -A1 -B0 $line /usr/local/nagios/var/status.dat | grep
service_description | cut -d= -f2 | sort | uniq > /tmp/tempvariable`
count=`wc -l < /tmp/tempvariable`
if [ $count -le 1 ]
then
check=`cat /tmp/tempvariable`
if [ "$check" == "PingCheck" ] || [
"$check" == "" ]
then
echo $line
fi
else
temp=""
while read line2
do
if [ "$line2" != "PingCheck" ]
then
temp=`echo $temp,$line2`
fi
done < /tmp/tempvariable
# remove the comma
temp=$(echo $temp | cut -c 2-)
`echo "define servicedependency{
host_name
$line
service_description
PingCheck
dependent_host_name
$line
dependent_service_description
$temp
execution_failure_criteria n
notification_failure_criteria u,c
}" >>
/tmp/ibsserdepdefinition.txt`
fi
done < /tmp/servers
No comments:
Post a Comment