forked from vhostmd/vhostmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvhostmd.xml
158 lines (143 loc) · 4.93 KB
/
vhostmd.xml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?xml version="1.0" ?>
<!DOCTYPE vhostmd SYSTEM "vhostmd.dtd">
<!--
Copyright (C) 2008 Novell, Inc.
Configuration file for virtual host metrics daemon (vhostmd).
A metrics disk between 1024 bytes and 256Mbytes is supported.
Supported metric types are: int32, uint32, int64, uint64, real32,
real64, and string
A metric's value is set to the output produced by executing its action.
'action' can include the special token NAME, in which case the name of
the vm currently under inspection is substituted for NAME. Only useful
within the vm element.
NOTE - 'action' must be a valid shell builtin, script or external
command found in the path specified by the global <path> element.
When chaining commands, '&', '<' and '>' are reserved characters,
therefore '&', '<' and '>' must be used instead. For example,
the logical && operator must be replaced with "&&".
-->
<vhostmd>
<globals>
<disk>
<name>host-metrics-disk</name>
<path>/dev/shm/vhostmd0</path>
<size unit="k">256</size>
</disk>
<virtio>
<max_channels>1024</max_channels>
<expiration_time>15</expiration_time>
</virtio>
<update_period>5</update_period>
<path>/usr/sbin:/sbin:/usr/bin:/bin:/usr/share/vhostmd/scripts</path>
<transport>vbd</transport>
<transport>virtio</transport>
<!-- <transport>xenstore</transport> -->
</globals>
<metrics>
<metric type="string" context="host">
<name>HostName</name>
<action>
virsh CONNECT hostname | tr -d '[:space:]'
</action>
</metric>
<metric type="string" context="host">
<name>VirtualizationVendor</name>
<action>
rpm -q --qf '%{VENDOR}\n' -qf /etc/os-release
</action>
</metric>
<metric type="string" context="host">
<name>VirtualizationProductInfo</name>
<action>
virsh version | awk '/Running hypervisor/ {print $(NF-1),$NF}'
</action>
</metric>
<metric type="uint32" context="host">
<name>TotalPhyCPUs</name>
<action>
virsh nodeinfo | awk '/^CPU\(s\)/ {print $2}'
</action>
</metric>
<metric type="uint32" context="host">
<name>NumCPUs</name>
<action>
virsh nodeinfo | awk '/^CPU\(s\)/ {print $2}'
</action>
</metric>
<metric type="uint64" context="host">
<name>TotalPhyMem</name>
<action>
echo $((`virsh nodeinfo | awk '/^Memory/ {print $3}'` / 1024))
</action>
</metric>
<metric type="uint64" context="host">
<name>UsedMem</name>
<action>
[ -f /proc/xen/privcmd ] && echo "$((`xentop -b -i 1 | awk '/Domain-0/ {print $5}'` / 1024))" || \
free | egrep -i '^[[:space:]]*(.*buffers/cache:)' | awk '{ printf "%d\n", $3/1024; }'
</action>
</metric>
<metric type="uint64" context="host">
<name>FreeMem</name>
<action>
[ -f /proc/xen/privcmd ] && xl info | awk '/^free_memory/ {print $3}' || \
free | egrep -i '^[[:space:]]*(.*buffers/cache:)' | awk '{ printf "%d\n", $4/1024; }'
</action>
</metric>
<metric type="uint64" context="host">
<name>PagedInMemory</name>
<action>
vmstat -s | awk '/pages paged in/ {printf "%d\n", $1 / 1024 * $(getconf PAGESIZE) / 1024;}'
</action>
</metric>
<metric type="uint64" context="host">
<name>PagedOutMemory</name>
<action>
vmstat -s | awk '/pages paged out/ {printf "%d\n", $1 / 1024 * $(getconf PAGESIZE) / 1024;}'
</action>
</metric>
<metric type="group" context="host">
<name>PageRates</name>
<action>pagerate.pl</action>
<variable name="PageInRate" type="uint64"/>
<variable name="PageFaultRate" type="uint64"/>
</metric>
<metric type="real64" context="host">
<name>TotalCPUTime</name>
<action>
[ -f /proc/xen/privcmd ] && xl list | awk '/^Domain-0/ {print $6}' || \
awk '
function user_hz( hz)
{
cmd = "getconf CLK_TCK";
cmd | getline;
hz = $1;
close(cmd);
return hz;
}
BEGIN {
USER_HZ = user_hz();
TotalCPUTime = 0;
while ( 0 < ( getline < "/proc/stat" ) )
{
if ( "cpu" == $1 )
{
TotalCPUTime = $2 + $3 + $4;
break;
}
}
close("/proc/stat");
TotalCPUTime /= USER_HZ;
printf "%f\n", TotalCPUTime;
}'
</action>
</metric>
<metric type="real64" context="vm">
<name>TotalCPUTime</name>
<action>
virsh CONNECT dominfo NAME | sed 's/: */:/' | \
awk -F: '/CPU time/ {print $2;}' | sed 's/s//'
</action>
</metric>
</metrics>
</vhostmd>