-
Notifications
You must be signed in to change notification settings - Fork 6
/
proxmox
59 lines (50 loc) · 1.79 KB
/
proxmox
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
#!/bin/bash
#/usr/lib/check_mk_agent/local
export LANG=de_DE.UTF-8
# Get data
px_version=$(pveversion);
px_vms_sum=$(($(qm list|wc -l)-1));
px_vms_stopped=$(qm list|grep -c stopped);
px_vms_started=$(qm list|grep -c running);
reboot=0
if [ -x /var/run/reboot-required.pkgs ] ; then
reboot=$(cat /var/run/reboot-required.pkgs|wc -l)
fi
supdates=0
supdates=$(apt-get upgrade -s 2>/dev/null| grep ^Security |wc -l)
nupdates=0
nupdates=$(apt-get upgrade -s 2>/dev/null| grep ^Inst |wc -l)
# Temperature sensors
TFILE="/tmp/$(basename $0).$$.tmp"
/usr/bin/sensors > $TFILE
temper="P LMsensors "
while read line; do
if [[ $line == *-*-* ]] ; then
prefix=$(echo $line)
fi
if ( [[ $line == *:*C\ * ]] || [[ $line == *:*W\ * ]] ) ; then
key=$(echo $line|cut -d":" -f1|sed s/\ //|sed s/\ //)
values=$(echo $line|cut -d":" -f2)
value=$(echo $values|cut -d" " -f1|tr -d "°C():;+,=-")
high=$(echo $values|cut -d"h" -f2-10|cut -d" " -f3|tr -d "°C():;+,=-")
crit=$(echo $values|cut -d"r" -f2-10|cut -d" " -f3|tr -d "°C():;+,=-")
if ( [[ $key == *power* ]] || [[ $key == *pwr* ]] ) ; then #TDP values are tight!
high=$( bc <<< "$high + 10")
crit=$( bc <<< "$crit + 10")
fi
# fallback values
if [[ $high != *"."* ]] ; then
high=100
fi
if [[ $crit != *"."* ]] ; then
crit=120
fi
temper="$temper$prefix-$key=$value;0.1:$high;0.1:$crit|"
fi
done <$TFILE
rm $TFILE
# Output
echo "0 Proxmox_Version Version=$px_version;"
echo "0 Proxmox_VMs Started=$px_vms_started|Stopped=$px_vms_stopped|Gesamt=$px_vms_sum; $px_vms_started von $px_vms_sum VMs laufen"
echo $(echo $temper|sed 's/|$//')
echo "P Debian-Patchstatus SecurityUpdates-waiting=$supdates.0;0:0.5;0:1|RegularUpdates-waiting=$nupdates.0;0:10;0:15|Reboot-waiting=$reboot.0;0:0.5;0:1"