forked from eulenfunk/check_mk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
proxmox
executable file
·76 lines (66 loc) · 2.32 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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)
kernel=$(uname -r);
latestbootkernel=$(ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | sort -Vr | head -n1)
if [ -f /var/run/reboot-required ]; then
reboot=$(cat /var/run/reboot-required|grep \*\*\**\*\*\*|wc -l)
fi
if [ "$kernel" != "$latestbootkernel" ]; then
reboot=1
fi
# 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! SYSTIN:
high=$( bc <<< "$high + 10")
crit=$( bc <<< "$crit + 10")
fi
# fallback values
# if [[ $high != *"."* ]] ; then
# high=100
# fi
# if [[ $crit != *"."* ]] ; then
# crit=120
# fi
if [[ $high != *"."* ]] || [[ $high = "0.0" ]] ; then
high=100
fi
if [[ $crit != *"."* ]] || [[ $crit != "0.0" ]] ; then
crit=120
fi
if ( [[ $key != "PECIAgent1" ]] && [[ $key != "AUXTIN" ]] ) ; then
temper="$temper$prefix-$key=$value;0.1:$high;0.1:$crit|"
fi
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:1;0:2|RegularUpdates-waiting=$nupdates.0;0:25;0:41|Reboot-waiting=$reboot.0;0:0.5;0:2"