Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"qm list" nur einmal aufrufen statt 4 mal. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions proxmox
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@

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);

# updates
reboot=0
if [ -x /var/run/reboot-required.pkgs ] ; then
reboot=$(cat /var/run/reboot-required.pkgs|wc -l)
Expand All @@ -17,8 +12,7 @@ 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)


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"


# Temperature sensors
Expand All @@ -40,20 +34,37 @@ while read line; do
crit=$( bc <<< "$crit + 10")
fi
# fallback values
if [[ $high != *"."* ]] ; then
if [[ $high != *"."* ]] || [[ $high == "0.0" ]]; then
high=100
fi
if [[ $crit != *"."* ]] ; then
if [[ $crit != *"."* ]] || [[ $crit == "0.0" ]]; 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"

# QEMU-VMs
if which qm >/dev/null ; then
px_version=$(pveversion);
pvetfile="/tmp/$(basename $0).$$.tmp"
qm list > $pvetfile
px_vms_sum=$(($(cat $pvetfile|wc -l)-1));
px_vms_stopped=$(cat $pvetfile|grep -c stopped);
px_vms_started=$(cat $pvetfile|grep -c running);
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"
cat $pvetfile | grep -v VMID | while read L
do
PID=$(echo $L | awk -- '{print $6}')
if [ $PID -gt 0 ]; then
DATA=$(top -p $PID -n 1 -b | tail -n 1 |awk -- '{print $5" "$6" "$7" "$9" "$10}')
else
DATA=""
fi
# echo $L" "$DATA
done
rm $pvetfile;
fi