As so often, I wanted a script, that’ll crawl my filers and regenerate the configuration if there are any new volumes/snapvaults/snapmirrors or if one of them has been removed.
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
| #!/bin/bash
FAS_HOSTS="$( ls /etc/nagios/objects/hosts/san/fas*{a,b}.cfg | cut -d/ -f7 | cut -d. -f1 )"
for host in $FAS_HOSTS; do
OUTPUT_FILE=/etc/nagios/objects/hosts/san/$host-vol.cfg
# Clear the output file
echo "" > $OUTPUT_FILE
# Get the volume list
for volume in `ssh $host vol status | awk '{ print $1 }' | grep ^vol | sort -u | grep -v vol0$`; do
user="$( grep "USER=" /etc/netapp-sdk/$host | cut -d= -f2 )"
pass="$( grep "PASS=" /etc/netapp-sdk/$host | cut -d= -f2 )"
# echo "define service {"
# echo " use generic-service"
# echo ""
# echo " check_command check_netapp-volfree!$user!$pass!${volume}!92!98"
# echo " check_interval 5"
# echo " host_name ${host}"
# echo " notifications_enabled 0"
# echo " notification_interval 720"
# echo " service_description VOLSPACE ${volume}"
# echo "}"
echo
echo "define service {"
echo " use generic-service-san-perfdata"
echo ""
echo " check_command check_netapp-lunspace!$user!$pass!${volume}"
echo " check_interval 5"
echo " host_name ${host}"
echo " notifications_enabled 0"
echo " notification_interval 720"
echo " service_description LUNSPACE ${volume}"
echo "}"
echo
SR="$( ssh $host snap reserve $volume | cut -d -f7 )"
if [ "$SR" != "0%" ] ; then
echo "define service {"
echo " use generic-service-san-perfdata"
echo ""
echo " check_command check_netapp-snapreserve!$user!$pass!${volume}"
echo " check_interval 10"
echo " host_name ${host}"
echo " notifications_enabled 0"
echo " notification_interval 720"
echo " # SR: $SR"
echo " service_description SNAPRESERVE ${volume}"
echo "}"
echo
fi
done | tee -a $OUTPUT_FILE
# Check snapvault foo
for sv in `ssh $host snapvault status -l 2>/dev/null | awk '{ print $2 }' | grep vol`; do
# only do the checks on sv_secondary
if [ "$( echo $sv | grep $host | cut -d: -f1 )" == "${host}" ]; then
vol="$( echo $sv | cut -d/ -f3 )"
user="$( grep "USER=" /etc/netapp-sdk/$host | cut -d= -f2 )"
pass="$( grep "PASS=" /etc/netapp-sdk/$host | cut -d= -f2 )"
echo "define service {"
echo " use generic-service-san-perfdata"
echo ""
echo " check_command check_netapp-snapvault!$user!$pass!$vol!38!42!"
echo " check_interval 60"
echo " host_name ${host}"
echo " notifications_enabled 0"
echo " notification_interval 720"
echo " service_description SNAPVAULT ${vol}"
echo "}"
echo
fi
done | tee -a $OUTPUT_FILE
# Check snapmirror foo
for sm in `ssh $host snapmirror status 2>/dev/null | awk '{ print $2 }' | grep vol | grep $host`; do
# only do the checks on sm_secondary
if [ "$( echo $sm | grep $host | cut -d: -f1 )" == "${host}" ]; then
vol="$( echo $sm | cut -d/ -f3 | cut -d: -f2 )"
user="$( grep "USER=" /etc/netapp-sdk/$host | cut -d= -f2 )"
pass="$( grep "PASS=" /etc/netapp-sdk/$host | cut -d= -f2 )"
echo "define service {"
echo " use generic-service-san-perfdata"
echo ""
echo " check_command check_netapp-snapmirror!$user!$pass!$vol!38!42!"
echo " check_interval 60"
echo " host_name ${host}"
echo " notifications_enabled 0"
echo " notification_interval 720"
echo " service_description SNAPMIRROR ${vol}"
echo "}"
echo
fi
done | tee -a $OUTPUT_FILE
done
|