blob: 725e800704016af06474e6f2a226f81e3c021c58 (
plain)
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
|
#!/bin/sh
#
# Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Monitor number of vm running on a xen dom0.
#
# $Log$
# Revision 1.0 2006/09/08 19:20:19 rodo
# Created by Rodolphe Quiedeville
#
# Need to be run as root, add the following lines ...
#
# [xen*]
# user root
#
# to /etc/munin/plugin-conf.d/munin-node
#
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#
#
# Magic markers (optional - used by munin-config and installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf
XM="/usr/sbin/xm"
# we cache xm list for 5 min for perfomance reasons
((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \
[ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \
/usr/sbin/xm list | grep -v "^Name .* ID" > /var/lib/munin/plugin-state/xm_list.state
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Xen Virtual Machines'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel vm'
echo 'graph_category xen'
echo 'graph_info This graph shows how many virtual machines runs on dom0.'
echo 'domains.label vm'
exit 0
fi
domains=`cat /var/lib/munin/plugin-state/xm_list.state | wc -l`
echo -n "domains.value "
echo $(($domains-1))
|