-
Notifications
You must be signed in to change notification settings - Fork 0
/
drive_temp_proxmox.sh
80 lines (73 loc) · 2.27 KB
/
drive_temp_proxmox.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
#!/bin/bash
## Drive Temp Alert script for use on Proxmox servers
# Specify your email address here:
email="[email protected]"
logfile="/tmp/hd_temp_report.tmp"
smartctl=/usr/sbin/smartctl
critTemp=45
subject="CRITIAL HD TEMP - PROXMOX SERVER"
#Set your drives here. DO NOT set SAS or SSD Drives here as they do not report temperature properly
#and the script will fail.
drives="sdf sde"
# Used with the Pushbullet (send.sh) script. You much sign up for free pushbullet account
send_pb_alert()
{
/root/scripts/push.sh "PROXMOX HD TEMP ALERT" "Your Proxmox Server Hard Drives are HOT!"
touch /root/scripts/hd_temp_alert_sent
}
# Your susyem must be configured to send mail already
send_email_alert()
{
### Set email headers
(
echo "To: ${email}"
echo "Subject: ${subject}"
echo "Content-Type: text/html"
echo "MIME-Version: 1.0"
printf "\r\n"
) > ${logfile}
### Set email body ###
echo "<pre style=\"font-size:14px\">" >> ${logfile}
(
echo "There is a problem with the temperature on one or more hard drives on the Proxmox Server."
echo ""
echo "It is HIGHLY advisable that you relocate the servers to a cooler location before "
echo "any of your hard drives are damaged!"
echo ""
echo ""
echo "This is an automated email, please do not reply!"
echo ""
echo ""
echo "You will only receive this email once per day. To immediately re-enable this alert, please ssh into the Proxmox "
echo "server and remove this file: "
echo ""
echo ""
echo " /root/scripts/hd_temp_alert_sent"
echo ""
echo ""
echo " WARNING WARNING WARNING "
echo " Failure to resolve this hard drive temperature issue can lead to failure of the server and all Virtual Machines!"
echo ""
) >> ${logfile}
echo "</pre>" >> ${logfile}
sendmail ${email} < ${logfile}
rm ${logfile}
touch /root/scripts/hd_temp_alert_sent
}
for drive in $drives
do
(
drive_temp=`smartctl -a /dev/${drive} | awk '/Temperature_Celsius/{print $0}' | awk '{print $10}'`
if (( $drive_temp > $critTemp )); then
echo $drive_temp
if [ ! -e "/root/scripts/hd_temp_alert_sent" ]; then
send_email_alert
send_pb_alert
else
exit 1
fi
else
echo $drive_temp
fi
)
done