-
Notifications
You must be signed in to change notification settings - Fork 0
/
hp-raid-status.sh
70 lines (58 loc) · 2.84 KB
/
hp-raid-status.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
#!/bin/bash
NTFY_TOPIC=$(hostname | sed 's/\./-/g')-$(/sbin/dmidecode -t system | grep "Serial Number" | cut -d\ -f3)
diskstatus=$(/sbin/hpssacli ctrl slot=0 show config detail | grep -ci "Status: Failed physical drive")
ctrlstatus=$(/sbin/hpssacli ctrl slot=0 show config detail | grep -ci "Controller Status: OK")
cachestatus=$(/sbin/hpssacli ctrl slot=0 show config detail | grep -ci "Cache Status: OK")
batstatus=$(/sbin/hpssacli ctrl slot=0 show config detail | grep -ci "Battery/Capacitor Status: OK")
diskfile="/var/cache/$(basename $0 .sh)-present"
ctrlfile="/var/cache/$(basename $0 .sh)-redundant"
cachefile="/var/cache/$(basename $0 .sh)-condition"
batfile="/var/cache/$(basename $0 .sh)-battery"
if [ ! -f $diskfile ] || [ $(( $(date +%s) - $(date +%s -r $diskfile))) -gt 86400 ]; then
if [ $diskstatus -eq 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,skull" -d "One or more physical disks have failed." ntfy.sh/$NTFY_TOPIC &&
touch $diskfile
fi
fi
if [ ! -f $ctrlfile ] || [ $(( $(date +%s) - $(date +%s -r $ctrlfile))) -gt 86400 ]; then
if [ $ctrlstatus -ne 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,skull" -d "Controller Status NOT OK." ntfy.sh/$NTFY_TOPIC &&
touch $ctrlfile
fi
fi
if [ ! -f $cachefile ] || [ $(( $(date +%s) - $(date +%s -r $cachefile))) -gt 86400 ]; then
if [ $cachestatus -ne 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,skull" -d "Cache Status NOT OK" ntfy.sh/$NTFY_TOPIC &&
touch $cachefile
fi
fi
if [ ! -f $batfile ] || [ $(( $(date +%s) - $(date +%s -r $batfile))) -gt 86400 ]; then
if [ $batstatus -ne 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,skull" -d "Battery/Capacitor Status NOT OK." ntfy.sh/$NTFY_TOPIC &&
touch $batfile
fi
fi
if [ -f $diskfile ]; then
if [ $diskstatus -eq 0 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,white_check_mark" -d "Physical disks OK." ntfy.sh/$NTFY_TOPIC &&
rm $diskfile
fi
fi
if [ -f $ctrlfile ]; then
if [ $ctrlstatus -eq 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,white_check_mark" -d "Controller Status OK." ntfy.sh/$NTFY_TOPIC &&
rm $ctrlfile
fi
fi
if [ -f $cachefile ]; then
if [ $cachestatus -eq 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,white_check_mark" -d "Cache Status OK" ntfy.sh/$NTFY_TOPIC &&
rm $cachefile
fi
fi
if [ -f $batfile ]; then
if [ $batstatus -eq 1 ]; then
curl -H "Title: HP RAID Status" -H "Priority: high" -H "tags: computer,white_check_mark" -d "Battery/Capacitor Status OK." ntfy.sh/$NTFY_TOPIC &&
rm $batfile
fi
fi