-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_scalance_fault.sh
150 lines (135 loc) · 5.16 KB
/
check_scalance_fault.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
###########################################################################################
# #
# A plugin that uses SNMP to get error codes from a Siemens Scalance X300 or X400 switch. #
# The plugin outputs the fault in a human readable form, #
# as long as there are not several faults. #
# #
# #
# USAGE: #
# Add as a check in any Nagios compatible product with proper variables #
# The script expects either two variables for SNMPv2c or six variables for SNMPv3. #
# #
# Version history: #
# 1.1 2015-08-04 Cleaned up some minor ambiguities. #
# 1.0 2014-10-27 Initial release. Tested with CentOS, Op5 and Scalance X300. #
# #
# Licensed under the Apache License Version 2.0 #
# Written by [email protected] #
###########################################################################################
if [ $# == 6 ]; then
SNMPOPT="-v 3 -u $2 -a $3 -A $4 -l authPriv -x $5 -X $6 $1 -Ov -t 0.5 -Lo"
fi
if [ $# == 2 ]; then
SNMPOPT="-v 2c -c $2 $1 -Ov -t 0.5 -Lo"
fi
if [ $# != 2 ] && [ $# != 6 ]; then
echo "Wrong amount of arguments!"
echo
echo "Usage:"
echo "SNMPv2c: check_scalance_fault HOSTNAME community"
echo "SNMPv3: check_scalance_fault HOSTNAME username MD5/SHA authpass DES/AES privpass"
exit 3
fi
#Get the fault value and clean it up.
faultvalue=`/usr/bin/snmpget $SNMPOPT 1.3.6.1.4.1.4196.1.1.5.4.100.2.2.3.0 | /bin/sed -e 's/\STRING: //g' | /bin/sed -e 's/\"//g' | /bin/sed -e 's/\Hex-//g' | /bin/sed -e 's/\s*$//'`
# eveluate the fault value.
if [ "$faultvalue" == "00 00 00 00" ]; then
echo "OK - No errors on this device."
exit 0
fi
if [ "$faultvalue" == "00 00 00 01" ]; then
echo "Power error!"
exit 1
fi
if [ "$faultvalue" == "00 00 00 02" ]; then
echo "Linkdown error!"
exit 2
fi
if [ "$faultvalue" == "00 00 00 03" ]; then
echo "Power error and Linkdown error!"
exit 2
fi
if [ "$faultvalue" == "00 00 00 04" ]; then
echo "Internal error!"
exit 2
fi
if [ "$faultvalue" == "00 00 00 08" ]; then
echo "Standby error!"
exit 2
fi
if [ "$faultvalue" == "00 00 00 0f" ]; then
echo "rm error!"
exit 2
fi
if [ "$faultvalue" == "00 00 01 00" ]; then
echo "observer error!"
exit 2
fi
if [ "$faultvalue" == "00 00 02 00" ]; then
echo "non-recoverable ring error!"
exit 2
fi
if [ "$faultvalue" == "00 00 04 00" ]; then
echo "c-plug error!"
exit 2
fi
if [ "$faultvalue" == "00 00 08 00" ]; then
echo "pnio error!"
exit 2
fi
if [ "$faultvalue" == "00 00 0f 00" ]; then
echo "module error!"
exit 2
fi
if [ "$faultvalue" == "00 00 10 00" ]; then
echo "loopd error!"
exit 2
fi
if [ "$faultvalue" == "00 00 11 00" ]; then
echo "Standby observer error!"
exit 2
fi
echo "More than one error on device!"
echo ""Error code: $faultvalue""
exit 2
# Excerpt from the MIB-file:
#
#snX300X400FaultValue OBJECT-TYPE
# SYNTAX BITS
# ACCESS read-only
# STATUS mandatory
# DESCRIPTION "Fault value: 0 = no fault,
# 0. Octet LSB bit 0 = power,
# 0. Octet bit 1 = linkdown,
# 0. Octet bit 2 = internal error,
# 0. Octet bit 3 = standby,
# 0. Octet bit 4 = rm,
# 0. Octet bit 5 = reserved,
# 0. Octet bit 6 = reserved,
# 0. Octet MSB bit 7 = reserved,
# 1. Octet LSB bit 8 = reserved,
# 1. Octet bit 9 = reserved,
# 1. Octet bit 10 = reserved,
# 1. Octet bit 11 = reserved,
# 1. Octet bit 12 = reserved,
# 1. Octet bit 13 = reserved,
# 1. Octet bit 14 = reserved,
# 1. Octet MSB bit 15 = reserved,
# 2. Octet LSB bit 16 = observer error,
# 2. Octet bit 17 = non-recoverable ring error,
# 2. Octet bit 18 = c-plug error,
# 2. Octet bit 19 = pnio error,
# 2. Octet bit 20 = module error,
# 2. Octet bit 21 = loopd error,
# 2. Octet bit 22 = standby observer error,
# 2. Octet MSB bit 23 = reserved,
# 3. Octet LSB bit 24 = reserved,
# 3. Octet bit 25 = reserved,
# 3. Octet bit 26 = reserved,
# 3. Octet bit 27 = reserved,
# 3. Octet bit 28 = reserved,
# 3. Octet bit 29 = reserved,
# 3. Octet bit 30 = reserved,
# 3. Octet MSB bit 31 = reserved"
# ::= { snX300X400Report 3 }