-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_nrpe.sh
67 lines (58 loc) · 1.34 KB
/
update_nrpe.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# v1.0 [email protected]
# + Pushes NRPE to the defined host.
# v1.1 [email protected]
# + NRPE restart method changed depending upon client OS. This is only temporary until "/etc/init.d/nrpe stop" is fixed
usage()
{
cat << EOF
Usage: $0 options
This script adds a host into Nagios.
OPTIONS:
-h Show this message
-H FQDN of the host to be added
EOF
}
while getopts "hH:" OPTION
do
case $OPTION in
h)
usage
exit 0
;;
H)
FQDN=$OPTARG
;;
?)
usage
exit 1
;;
esac
done
if [ -z $FQDN ]; then
usage
exit 1
else
#
# FIXME! - The below command runs 3 ssh commands, when one will do. Time to learn proper string parsing ...
#
HOST_OS=`ssh -l root $FQDN uname`
HOST_PLATFORM=`ssh -l root $FQDN uname -i`
ZONENAME='ssh -l root $FQDN zonename'
scp /usr/local/nagios/scripts/nrpe.$HOST_OS.$HOST_PLATFORM.tar.gz root@$FQDN:/opt
ssh root@$FQDN "rm /etc/init.d/nrpe"
ssh root@$FQDN "cd /opt ; gunzip nrpe.$HOST_OS.$HOST_PLATFORM.tar.gz; tar xf nrpe.$HOST_OS.$HOST_PLATFORM.tar ; cd nrpe ; ./nrpe.install ; cd .. ; rm nrpe.$HOST_OS.$HOST_PLATFORM.tar"
case $HOST_OS in
SunOS)
ssh root@$FQDN "pkill -z $ZONENAME nrpe"
;;
Linux)
ssh root@$FQDN "killall nrpe"
;;
*)
echo -e "Unknown OS, unable to safely stop NRPE. Carrying on anyway ...
;;
esac
/etc/init.d/nagios reload
fi
# EOF