-
Notifications
You must be signed in to change notification settings - Fork 8
/
check_snmp_synology.sh
executable file
·460 lines (410 loc) · 21.5 KB
/
check_snmp_synology.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
#!/bin/bash
#
#
# check_website_by_selenium.sh
# Description : Checks a website using the Selenium Grid
#
# The MIT License (MIT)
#
# Copyright (c) 2016, Roland Rickborn ([email protected])
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# check_snmp_synology for nagios version 2.4
# See https://exchange.nagios.org/directory/Plugins/Network-and-Systems-Management/Others/Synology-status/details
#
# 16.04.2015 Nicolas Ordonez, Switzerland
# 05.10.2015 Roland Rickborn <[email protected]>, Germany
# 29.02.2016 j-ed, https://github.com/j-ed
# 10.05.2016 Luiz Henrique De Andrade, luizhandrade
#---------------------------------------------------
# this plugin checks the health of your Synology NAS
# - System status (Power, Fans)
# - Disks status
# - RAID status
# - DSM update status
# - Temperature Warning and Critical
# - UPS information
# - Storage percentage of use
#
# Tested with DSM 5.0, 5.1 & 5.2
#---------------------------------------------------
# Based on http://ukdl.synology.com/download/Document/MIBGuide/Synology_DiskStation_MIB_Guide.pdf
#---------------------------------------------------
# actual number disk limit = 52 disks per Synology
#---------------------------------------------------
SNMPWALK=$(which snmpwalk)
SNMPGET=$(which snmpget)
SNMPVersion="3"
SNMPV2Community="public"
SNMPTimeout="10"
warningTemperature="50"
criticalTemperature="60"
warningStorage="80"
criticalStorage="95"
hostname=""
healthWarningStatus=0
healthCriticalStatus=0
healthString=""
verbose="no"
ups="no"
perfDataTempString=""
perfDataStorageString=""
perfData="no"
dsmcheck="no"
#OID declarations
OID_syno="1.3.6.1.4.1.6574"
OID_model="1.3.6.1.4.1.6574.1.5.1.0"
OID_serialNumber="1.3.6.1.4.1.6574.1.5.2.0"
OID_DSMVersion="1.3.6.1.4.1.6574.1.5.3.0"
OID_DSMUpgradeAvailable="1.3.6.1.4.1.6574.1.5.4.0"
OID_systemStatus="1.3.6.1.4.1.6574.1.1.0"
OID_temperature="1.3.6.1.4.1.6574.1.2.0"
OID_powerStatus="1.3.6.1.4.1.6574.1.3.0"
OID_systemFanStatus="1.3.6.1.4.1.6574.1.4.1.0"
OID_CPUFanStatus="1.3.6.1.4.1.6574.1.4.2.0"
OID_disk=""
OID_disk2=""
OID_diskID="1.3.6.1.4.1.6574.2.1.1.2"
OID_diskModel="1.3.6.1.4.1.6574.2.1.1.3"
OID_diskStatus="1.3.6.1.4.1.6574.2.1.1.5"
OID_diskTemp="1.3.6.1.4.1.6574.2.1.1.6"
OID_RAID=""
OID_RAIDName="1.3.6.1.4.1.6574.3.1.1.2"
OID_RAIDStatus="1.3.6.1.4.1.6574.3.1.1.3"
OID_Storage="1.3.6.1.2.1.25.2.3.1"
OID_StorageDesc="1.3.6.1.2.1.25.2.3.1.3"
OID_StorageAllocationUnits="1.3.6.1.2.1.25.2.3.1.4"
OID_StorageSize="1.3.6.1.2.1.25.2.3.1.5"
OID_StorageSizeUsed="1.3.6.1.2.1.25.2.3.1.6"
OID_UpsModel="1.3.6.1.4.1.6574.4.1.1.0"
OID_UpsSN="1.3.6.1.4.1.6574.4.1.3.0"
OID_UpsStatus="1.3.6.1.4.1.6574.4.2.1.0"
OID_UpsLoad="1.3.6.1.4.1.6574.4.2.12.1.0"
OID_UpsBatteryCharge="1.3.6.1.4.1.6574.4.3.1.1.0"
OID_UpsBatteryChargeWarning="1.3.6.1.4.1.6574.4.3.1.4.0"
usage()
{
echo "usage: ./check_snmp_synology [OPTION] -u [user] -p [pass] -h [hostname]"
echo "options:"
echo " -u [snmp username] Username for SNMPv3"
echo " -p [snmp password] Password for SNMPv3"
echo ""
echo " -2 [community name] Use SNMPv2 (no need user/password) & define community name (default $SNMPV2Community)"
echo ""
echo " -W [warning temp] Warning temperature (for disks & synology) (default $warningTemperature)"
echo " -C [critical temp] Critical temperature (for disks & synology) (default $criticalTemperature)"
echo ""
echo " -w [warning %] Warning storage usage percentage (default $warningStorage)"
echo " -c [critical %] Critical storage usage percentage (default $criticalStorage)"
echo ""
echo " -U Show informations about the connected UPS (default no)"
echo " -v Verbose - print all informations about your Synology (default $verbose)"
echo " -f PerfData - print performance data for temperature and storage usage percentage (default $perfData)"
echo " -d Check DSM Version - check if an update for DiskStation Manager is available (default $dsmcheck)"
echo ""
echo ""
echo "examples: ./check_snmp_synology -u admin -p 1234 -h nas.intranet"
echo " ./check_snmp_synology -u admin -p 1234 -h nas.intranet -v"
echo " ./check_snmp_synology -2 public -h nas.intranet"
exit 3
}
if [ "$1" == "--help" ]; then
usage
exit 0
fi
while getopts 2:W:C:w:c:u:p:h:Uvfd OPTNAME;
do
case "$OPTNAME" in
u) SNMPUser="$OPTARG";;
p) SNMPPassword="$OPTARG";;
h) hostname="$OPTARG";;
v) verbose="yes";;
2) SNMPVersion="2"
SNMPV2Community="$OPTARG";;
w) warningStorage="$OPTARG";;
c) criticalStorage="$OPTARG";;
W) warningTemperature="$OPTARG";;
C) criticalTemperature="$OPTARG";;
U) ups="yes";;
f) perfData="yes";;
d) dsmcheck="yes";;
*) usage;;
esac
done
if [ "$warningTemperature" -gt "$criticalTemperature" ] ; then
echo "Critical temperature must be higher than warning temperature"
echo "Warning temperature: $warningTemperature"
echo "Critical temperature: $criticalTemperature"
echo ""
echo "For more information: ./${0##*/} --help"
exit 1
fi
if [ "$warningStorage" -gt "$criticalStorage" ] ; then
echo "The Critical storage usage percentage must be higher than the warning storage usage percentage"
echo "Warning: $warningStorage"
echo "Critical: $criticalStorage"
echo ""
echo "For more information: ./${0##*/} --help"
exit 1
fi
if [ "$hostname" = "" ] || ([ "$SNMPVersion" = "3" ] && [ "$SNMPUser" = "" ]) || ([ "$SNMPVersion" = "3" ] && [ "$SNMPPassword" = "" ]) ; then
usage
else
if [ "$SNMPVersion" = "2" ] ; then
SNMPArgs=" -OQne -v 2c -c $SNMPV2Community -t $SNMPTimeout"
else
SNMPArgs=" -OQne -v 3 -u $SNMPUser -A $SNMPPassword -l authNoPriv -a MD5 -t $SNMPTimeout"
if [ ${#SNMPPassword} -lt "8" ] ; then
echo "snmpwalk: (The supplied password length is too short.)"
exit 1
fi
fi
tmpRequest=`$SNMPWALK $SNMPArgs $hostname $OID_model 2> /dev/null`
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request, check user/password/host"
exit 2
fi
nbDisk=`$SNMPWALK $SNMPArgs $hostname $OID_diskID | wc -l`
nbRAID=`$SNMPWALK $SNMPArgs $hostname $OID_RAIDName | wc -l`
for i in `seq 1 $nbDisk`;
do
if [ $i -lt 25 ] ; then
OID_disk="$OID_disk $OID_diskID.$(($i-1)) $OID_diskModel.$(($i-1)) $OID_diskStatus.$(($i-1)) $OID_diskTemp.$(($i-1)) "
else
OID_disk2="$OID_disk2 $OID_diskID.$(($i-1)) $OID_diskModel.$(($i-1)) $OID_diskStatus.$(($i-1)) $OID_diskTemp.$(($i-1)) "
fi
done
for i in `seq 1 $nbRAID`;
do
OID_RAID="$OID_RAID $OID_RAIDName.$(($i-1)) $OID_RAIDStatus.$(($i-1))"
done
if [ "$ups" = "yes" ] && [ "$dsmcheck" = "yes" ]; then
syno=`$SNMPGET $SNMPArgs $hostname $OID_model $OID_serialNumber $OID_DSMVersion $OID_systemStatus $OID_temperature $OID_powerStatus $OID_systemFanStatus $OID_CPUFanStatus $OID_disk $OID_RAID $OID_DSMUpgradeAvailable $OID_UpsModel $OID_UpsSN $OID_UpsStatus $OID_UpsLoad $OID_UpsBatteryCharge $OID_UpsBatteryChargeWarning 2> /dev/null`
elif [ "$ups" = "no" ] && [ "$dsmcheck" = "yes" ] ; then
syno=`$SNMPGET $SNMPArgs $hostname $OID_model $OID_serialNumber $OID_DSMVersion $OID_systemStatus $OID_temperature $OID_powerStatus $OID_systemFanStatus $OID_CPUFanStatus $OID_disk $OID_RAID $OID_DSMUpgradeAvailable 2> /dev/null`
elif [ "$ups" = "yes" ] && [ "$dsmcheck" = "no" ] ; then
syno=`$SNMPGET $SNMPArgs $hostname $OID_model $OID_serialNumber $OID_DSMVersion $OID_systemStatus $OID_temperature $OID_powerStatus $OID_systemFanStatus $OID_CPUFanStatus $OID_disk $OID_RAID $OID_UpsModel $OID_UpsSN $OID_UpsStatus $OID_UpsLoad $OID_UpsBatteryCharge $OID_UpsBatteryChargeWarning 2> /dev/null`
elif [ "$ups" = "no" ] && [ "$dsmcheck" = "no" ] ; then
syno=`$SNMPGET $SNMPArgs $hostname $OID_model $OID_serialNumber $OID_DSMVersion $OID_systemStatus $OID_temperature $OID_powerStatus $OID_systemFanStatus $OID_CPUFanStatus $OID_disk $OID_RAID 2> /dev/null`
fi
if [ "$OID_disk2" != "" ]; then
syno2=`$SNMPGET $SNMPArgs $hostname $OID_disk2 2> /dev/null`
syno=$(echo "$syno";echo "$syno2";)
fi
model=$(echo "$syno" | grep $OID_model | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
serialNumber=$(echo "$syno" | grep $OID_serialNumber | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
DSMVersion=$(echo "$syno" | grep $OID_DSMVersion | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
healthString="Synology $model (s/n:$serialNumber, $DSMVersion)"
DSMUpgradeAvailable=$(echo "$syno" | grep $OID_DSMUpgradeAvailable | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
case $DSMUpgradeAvailable in
"1") DSMUpgradeAvailable="Available"; healthWarningStatus=1; healthString="$healthString, DSM update available";;
"2") DSMUpgradeAvailable="Unavailable";;
"3") DSMUpgradeAvailable="Connecting";;
"4") DSMUpgradeAvailable="Disconnected"; healthWarningStatus=1; healthString="$healthString, DSM Update Disconnected";;
"5") DSMUpgradeAvailable="Others"; healthWarningStatus=1; healthString="$healthString, Check DSM Update";;
esac
RAIDName=$(echo "$syno" | grep $OID_RAIDName | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
RAIDStatus=$(echo "$syno" | grep $OID_RAIDStatus | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
systemStatus=$(echo "$syno" | grep $OID_systemStatus | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
temperature=$(echo "$syno" | grep $OID_temperature | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
powerStatus=$(echo "$syno" | grep $OID_powerStatus | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
systemFanStatus=$(echo "$syno" | grep $OID_systemFanStatus | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
CPUFanStatus=$(echo "$syno" | grep $OID_CPUFanStatus | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
#Check system status
if [ "$systemStatus" = "1" ] ; then
systemStatus="Normal"
else
systemStatus="Failed"
healthCriticalStatus=1
healthString="$healthString, System status: $systemStatus "
fi
#Check system temperature
if [ "$temperature" -gt "$warningTemperature" ] ; then
if [ "$temperature" -gt "$criticalTemperature" ] ; then
temperature="$temperature (CRITICAL)"
healthCriticalStatus=1
healthString="$healthString, temperature: $temperature "
else
temperature="$temperature (WARNING)"
healthWarningStatus=1
healthString="$healthString, temperature: $temperature "
fi
else
temperature="$temperature (Normal)"
fi
#Check power status
if [ "$powerStatus" = "1" ] ; then
powerStatus="Normal"
else
powerStatus="Failed";
healthCriticalStatus=1
healthString="$healthString, Power status: $powerStatus "
fi
#Check system fan status
if [ "$systemFanStatus" = "1" ] ; then
systemFanStatus="Normal"
else
systemFanStatus="Failed";
healthCriticalStatus=1
healthString="$healthString, System fan status: $systemFanStatus "
fi
#Check CPU fan status
if [ "$CPUFanStatus" = "1" ] ; then
CPUFanStatus="Normal"
else
CPUFanStatus="Failed";
healthCriticalStatus=1
healthString="$healthString, CPU fan status: $CPUFanStatus "
fi
#Check all disk status
for i in `seq 1 $nbDisk`;
do
diskID[$i]=$(echo "$syno" | grep "$OID_diskID.$(($i-1)) " | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
diskModel[$i]=$(echo "$syno" | grep "$OID_diskModel.$(($i-1)) " | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
diskStatus[$i]=$(echo "$syno" | grep "$OID_diskStatus.$(($i-1)) " | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
diskTemp[$i]=$(echo "$syno" | grep "$OID_diskTemp.$(($i-1)) " | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
#Store perfData
perfDataTempString="$perfDataTempString 'Temp Disk $i'=${diskTemp[$i]};$warningTemperature;$criticalTemperature;0" ;
case ${diskStatus[$i]} in
"1") diskStatus[$i]="Normal"; ;;
"2") diskStatus[$i]="Initialized"; ;;
"3") diskStatus[$i]="NotInitialized"; ;;
"4") diskStatus[$i]="SystemPartitionFailed"; healthCriticalStatus=1; healthString="$healthString, problem with ${diskID[$i]} (model:${diskModel[$i]}) status:${diskStatus[$i]} temperature:${diskTemp[$i]}";;
"5") diskStatus[$i]="Crashed"; healthCriticalStatus=1; healthString="$healthString, problem with ${diskID[$i]} (model:${diskModel[$i]}) status:${diskStatus[$i]} temperature:${diskTemp[$i]}";;
esac
if [ "${diskTemp[$i]}" -gt "$warningTemperature" ] ; then
if [ "${diskTemp[$i]}" -gt "$criticalTemperature" ] ; then
diskTemp[$i]="${diskTemp[$i]} (CRITICAL)"
healthCriticalStatus=1;
healthString="$healthString, ${diskID[$i]} temperature: ${diskTemp[$i]}"
else
diskTemp[$i]="${diskTemp[$i]} (WARNING)"
healthWarningStatus=1;
healthString="$healthString, ${diskID[$i]} temperature: ${diskTemp[$i]}"
fi
fi
done
#Check all RAID volume status
for i in `seq 1 $nbRAID`;
do
RAIDName[$i]=$(echo "$syno" | grep $OID_RAIDName.$(($i-1)) | cut -d "=" -f2)
RAIDStatus[$i]=$(echo "$syno" | grep $OID_RAIDStatus.$(($i-1)) | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
storageName[$i]=$(echo "${RAIDName[$i]}" | sed -e 's/[[:blank:]]//g' | sed -e 's/\"//g' | sed 's/.*/\L&/')
syno_diskDescr=`$SNMPWALK $SNMPArgs $hostname $OID_Storage.3 2> /dev/null`
storageID[$i]=$(echo "$syno_diskDescr" | grep -Eo ".[0-9]* = \"\/${storageName[$i]}\" *" | cut -d "." -f2 | cut -d " " -f1)
if [ "${storageID[$i]}" != "" ] ; then
storageSize[$i]=`$SNMPGET $SNMPArgs $hostname $OID_StorageSize.${storageID[$i]} | cut -d "=" -f2`
storageSizeUsed[$i]=`$SNMPGET $SNMPArgs $hostname $OID_StorageSizeUsed.${storageID[$i]} | cut -d "=" -f2`
storageAllocationUnits[$i]=`$SNMPGET $SNMPArgs $hostname $OID_StorageAllocationUnits.${storageID[$i]} | cut -d "=" -f2`
storagePercentUsed[$i]=$((${storageSizeUsed[$i]} * 100 / ${storageSize[$i]}))
storagePercentUsedString[$i]="${storagePercentUsed[$i]}% used"
#Store perfData
perfDataStorageString="$perfDataStorageString 'Raid $i Usage'=${storagePercentUsed[$i]};$warningStorage;$criticalStorage;0" ;
if [ "${storagePercentUsed[$i]}" -gt "$warningStorage" ] ; then
if [ "${storagePercentUsed[$i]}" -gt "$criticalStorage" ] ; then
healthCriticalStatus=1;
storagePercentUsedString[$i]="${storagePercentUsedString[$i]} CRITICAL"
healthString="$healthString,${RAIDName[$i]}: ${storagePercentUsedString[$i]}"
else
healthWarningStatus=1;
storagePercentUsedString[$i]="${storagePercentUsedString[$i]} WARNING"
healthString="$healthString,${RAIDName[$i]}: ${storagePercentUsedString[$i]}"
fi
fi
fi
case ${RAIDStatus[$i]} in
"1") RAIDStatus[$i]="Normal"; ;;
"2") RAIDStatus[$i]="Repairing"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"3") RAIDStatus[$i]="Migrating"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"4") RAIDStatus[$i]="Expanding"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"5") RAIDStatus[$i]="Deleting"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"6") RAIDStatus[$i]="Creating"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"7") RAIDStatus[$i]="RaidSyncing"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"8") RAIDStatus[$i]="RaidParityChecking"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"9") RAIDStatus[$i]="RaidAssembling"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"10") RAIDStatus[$i]="Canceling"; healthWarningStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"11") RAIDStatus[$i]="Degrade"; healthCriticalStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
"12") RAIDStatus[$i]="Crashed"; healthCriticalStatus=1; healthString="$healthString, RAID status (${RAIDName[$i]}): ${RAIDStatus[$i]} ";;
esac
done
if [ "$verbose" = "yes" ] ; then
echo "Synology model: $model" ;
echo "Synology s/n: $serialNumber" ;
echo "DSM Version: $DSMVersion" ;
echo "DSM update: $DSMUpgradeAvailable" ;
echo "System Status: $systemStatus" ;
echo "Temperature: $temperature" ;
echo "Power Status: $powerStatus" ;
echo "System Fan Status: $systemFanStatus" ;
echo "CPU Fan Status: $CPUFanStatus" ;
echo "Number of disks: $nbDisk" ;
for i in `seq 1 $nbDisk`;
do
echo " ${diskID[$i]} (model:${diskModel[$i]}) status:${diskStatus[$i]} temperature:${diskTemp[$i]}" ;
done
echo "Number of RAID volume: $nbRAID" ;
for i in `seq 1 $nbRAID`;
do
echo " ${RAIDName[$i]} status:${RAIDStatus[$i]} ${storagePercentUsedString[$i]}" ;
done
# Display UPS information
if [ "$ups" = "yes" ] ; then
upsModel=$(echo "$syno" | grep $OID_UpsModel | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
upsSN=$(echo "$syno" | grep $OID_UpsSN | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
upsStatus=$(echo "$syno" | grep $OID_UpsStatus | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
upsLoad=$(echo "$syno" | grep $OID_UpsLoad | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
upsBatteryCharge=$(echo "$syno" | grep $OID_UpsBatteryCharge | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
upsBatteryChargeWarning=$(echo "$syno" | grep $OID_UpsBatteryChargeWarning | cut -d "=" -f2 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
echo "UPS:"
echo " Model: $upsModel"
echo " s/n: $upsSN"
echo " Status: $upsStatus"
echo " Load: $upsLoad"
echo " Battery charge: $upsBatteryCharge"
echo " Battery charge warning:$upsBatteryChargeWarning"
fi
echo "";
fi
if [ "$healthCriticalStatus" = "1" ] && [ "$perfData" == "no" ] ; then
echo "CRITICAL - $healthString"
exit 2
fi
if [ "$healthWarningStatus" = "1" ] && [ "$perfData" == "no" ] ; then
echo "WARNING - $healthString"
exit 1
fi
if [ "$healthCriticalStatus" = "0" ] && [ "$healthWarningStatus" = "0" ] && [ "$perfData" == "no" ] ; then
echo "OK - $healthString is in good health"
exit 0
fi
if [ "$healthCriticalStatus" = "1" ] && [ "$perfData" == "yes" ] ; then
echo "CRITICAL - $healthString | $perfDataTempString $perfDataStorageString"
exit 2
fi
if [ "$healthWarningStatus" = "1" ] && [ "$perfData" == "yes" ] ; then
echo "WARNING - $healthString | $perfDataTempString $perfDataStorageString"
exit 1
fi
if [ "$healthCriticalStatus" = "0" ] && [ "$healthWarningStatus" = "0" ] && [ "$perfData" == "yes" ] ; then
echo "OK - $healthString is in good health | $perfDataTempString $perfDataStorageString"
exit 0
fi
fi
exit 3