2007-07-05 15:03:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Script to monitor memory status of the xen host
|
|
|
|
#
|
|
|
|
# Written by immerda project (admin(_at_)immerda.ch)
|
|
|
|
# 2007
|
|
|
|
# License: GPL
|
|
|
|
#
|
|
|
|
# Parameters understood:
|
|
|
|
#
|
|
|
|
# config (required)
|
|
|
|
# autoconf (optional - used by munin-config)
|
|
|
|
#
|
|
|
|
|
|
|
|
XM='/usr/sbin/xm'
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2018-08-01 23:51:50 +02:00
|
|
|
if [ -x "$XM" ]; then
|
2007-07-05 15:03:22 +02:00
|
|
|
echo yes
|
2018-08-01 23:51:50 +02:00
|
|
|
else
|
|
|
|
echo "no (xm not found)"
|
2007-07-05 15:03:22 +02:00
|
|
|
fi
|
2018-08-01 23:51:50 +02:00
|
|
|
exit 0
|
2007-07-05 15:03:22 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
|
|
|
echo 'graph_title Xen Memory'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
echo 'graph_scale no'
|
|
|
|
echo 'graph_vlabel MB'
|
2014-09-06 22:28:53 +02:00
|
|
|
echo 'graph_category Virtualization'
|
2007-07-05 15:03:22 +02:00
|
|
|
echo 'graph_info This graph shows of many mS wall time where used by a domain'
|
2018-08-01 23:51:11 +02:00
|
|
|
"$XM" info | while read -r name bla value; do
|
|
|
|
# total_memory 2047
|
|
|
|
# free_memory 1476
|
|
|
|
name=$(echo "$name" | sed -e"s/-/_/")
|
2007-07-05 15:03:22 +02:00
|
|
|
|
2018-08-01 23:53:04 +02:00
|
|
|
if [ "$name" = "total_memory" ] || [ "$name" = "free_memory" ]; then
|
2007-07-05 15:03:22 +02:00
|
|
|
echo "$name.label $name"
|
|
|
|
echo "$name.type GAUGE"
|
2018-08-01 23:53:04 +02:00
|
|
|
echo "$name.draw AREASTACK"
|
2007-07-05 15:03:22 +02:00
|
|
|
echo "$name.min 0"
|
2018-08-01 23:53:04 +02:00
|
|
|
if [ "$name" = "total_memory" ]; then
|
|
|
|
echo "$name.info total memory"
|
|
|
|
elif [ "$name" = "free_memory" ]; then
|
|
|
|
echo "$name.info free memory"
|
|
|
|
fi
|
|
|
|
fi
|
2007-07-05 15:03:22 +02:00
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-08-01 23:51:11 +02:00
|
|
|
# shellcheck disable=SC2034
|
|
|
|
"$XM" info | while read -r name bla value; do
|
|
|
|
name=$(echo "$name" | sed -e"s/-/_/")
|
|
|
|
if [ "$name" = "total_memory" ] || [ "$name" = "free_memory" ]; then
|
2007-07-05 15:03:22 +02:00
|
|
|
echo "$name.value $value"
|
|
|
|
fi
|
|
|
|
done
|