Updated vhostmd.conf from Dr. Joachim Schneider at SAP.

This commit is contained in:
Richard W.M. Jones 2010-07-06 16:39:42 +00:00
parent 685be0dbbd
commit 12791203b7
2 changed files with 273 additions and 54 deletions

View File

@ -19,6 +19,59 @@ within the vm element.
-->
<!-- 1 2 3 4 5 6 -->
<!-- 678901234567890123456789012345678901234567890123456789012345678 -->
<!--
We sometimes use the following awk form to filter the output of the
virsh command (mostly `virsh -r CONNECT dominfo NAME' - use
`virsh -r dominfo <dom id>' to test on the commandline) into a standard
format like
ID:6
NAME:ls3055v0
UUID:955c3b65-d013-547f-321b-9fea65439c40
OS_TYPE:hvm
STATE:running
CPU(S):4
CPU_TIME:433016.4:S
MAX_MEMORY:20000000:KB
USED_MEMORY:16384000:KB
AUTOSTART:disable
We do this to extract numbers out of physical quantities in a reliable
way.
-->
<!--
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
-->
<vhostmd>
<globals>
<disk>
@ -45,15 +98,40 @@ within the vm element.
<name>VirtualizationVendor</name>
<action>
rpm -qi libvirt| grep Vendor: \
| gawk '{print substr($0, index($0,$5)) }'
| awk '{ print substr($0, index($0, $5)); }' | sort -u
</action>
</metric>
<!-- SAP "CIM" -->
<metric type="string" context="host">
<name>VirtProductInfo</name>
<action>
virsh -r CONNECT version | grep API \
| gawk -F': ' '{print $2}'
virsh -r CONNECT version \
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
| awk -F: '$1 == "USING_API" { print $2; }'
</action>
</metric>
<!-- SAP "CIM" -->
@ -61,20 +139,56 @@ within the vm element.
<name>HostSystemInfo</name>
<action>hostname -s</action>
</metric>
<!-- SAP "CIM" -->
<!-- SAP "XCIM" -->
<metric type="uint32" context="host">
<name>NumberOfPhysicalCPUsUtilized</name>
<name>NumberOfPhysicalCPUs</name>
<!-- physical CPUs usable by the virtual machines -->
<!-- SAP "CIM" uses "NumberOfPhysicalCPUsUtilized" -->
<!-- which means something different, i.e. -->
<!-- "physical CPUs used by the virtual machines" -->
<!-- but may be calculated (on client side) by -->
<!-- Delta TotalCPUTime / Delta ElapsedTime -->
<action>
virsh -r CONNECT nodeinfo | grep 'CPU(s):' \
| gawk -F': +' '{print $2}'
virsh -r CONNECT nodeinfo \
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
| awk -F: '$1 == "CPU(S)" { print $2; }'
</action>
</metric>
<!-- SAP "CIM" -->
<metric type="uint64" context="host">
<name>MemoryAllocatedToVirtualServers</name>
<!-- physical memory used by the virtual machines, -->
<!-- (_not_ physical memory usable by the virtual -->
<!-- machines) -->
<action>
virsh -r CONNECT nodeinfo | grep 'Memory size:' \
| gawk -F' +' '{ printf "%d\n", $3/1024 }'
free|egrep -i '^[[:space:]]*(Mem:)' \
| awk 'BEGIN { sum = 0; }
{ sum += $3; }
END { printf "%d\n", sum/1024; }'
</action>
</metric>
<!-- SAP "CIM" -->
@ -82,26 +196,17 @@ within the vm element.
<name>FreePhysicalMemory</name>
<action>
free|egrep -i '^[[:space:]]*(Mem:)' \
| gawk 'BEGIN { sum = 0; }
| awk 'BEGIN { sum = 0; }
{ sum += $4; }
END { printf "%d\n", sum/1024; }'
</action>
</metric>
<metric type="uint64" context="host">
<name>UsedPhysicalMemory</name>
<action>
free|egrep -i '^[[:space:]]*(Mem:)' \
| gawk 'BEGIN { sum = 0; }
{ sum += $3; }
END { printf "%d\n", sum/1024; }'
</action>
</metric>
<!-- SAP "CIM" -->
<metric type="uint64" context="host">
<name>FreeVirtualMemory</name>
<action>
free|egrep -i '^[[:space:]]*(Mem:|Swap:)' \
| gawk 'BEGIN { sum = 0; }
| awk 'BEGIN { sum = 0; }
{ sum += $4; }
END { printf "%d\n", sum/1024; }'
</action>
@ -111,15 +216,16 @@ within the vm element.
<name>UsedVirtualMemory</name>
<action>
free|egrep -i '^[[:space:]]*(Mem:|Swap:)' \
| gawk 'BEGIN { sum = 0; }
| awk 'BEGIN { sum = 0; }
{ sum += $3; }
END { printf "%d\n", sum/1024; }'
</action>
</metric>
<!-- SAP "XCIM" -->
<metric type="uint64" context="host">
<name>PagedInMemory</name>
<action>
vmstat -s | gawk 'BEGIN {
vmstat -s | awk 'BEGIN {
cmd = "getconf PAGESIZE";
cmd | getline pagesize;
close(cmd);
@ -133,7 +239,7 @@ within the vm element.
<metric type="uint64" context="host">
<name>PagedOutMemory</name>
<action>
vmstat -s | gawk 'BEGIN {
vmstat -s | awk 'BEGIN {
cmd = "getconf PAGESIZE";
cmd | getline pagesize;
close(cmd);
@ -143,31 +249,40 @@ within the vm element.
}'
</action>
</metric>
<metric type="group" context="host">
<name>PageRates</name>
<action>pagerate.pl</action>
<!-- SAP "CIM" -->
<variable name="PageInRate" type="uint64"/>
<variable name="PageFaultRate" type="uint64"/>
</metric>
<!-- SAP "CIM" -->
<metric type="real64" context="host">
<name>TotalCPUTime</name>
<action>
gawk 'BEGIN {
getline &lt; "/proc/uptime";
idle_sec = $2;
while ( 0 &lt;= (getline &lt; "/proc/stat") )
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 &lt; ( getline &lt; "/proc/stat" ) )
{
if ( "cpu" == $1 )
{
USER_HZ = $5/idle_sec;
#printf "USER_HZ = %f\n", USER_HZ | "cat 1&gt;&amp;2"
TotalCPUTime = ($2 + $3 + $4)/USER_HZ;
printf "%f\n", TotalCPUTime;
TotalCPUTime = $2 + $3 + $4;
break;
}
}
close("/proc/stat");
#printf "USER_HZ = %d\n", USER_HZ | "cat 1&gt;&amp;2";
TotalCPUTime /= USER_HZ;
printf "%f\n", TotalCPUTime;
#close("cat 1&gt;&amp;2");
}'
</action>
@ -176,33 +291,134 @@ within the vm element.
<metric type="real64" context="vm">
<name>TotalCPUTime</name>
<action>
virsh -r CONNECT dominfo NAME | sed 's/: */:/' \
| gawk -F: '/CPU time/ {print $2;}'
virsh -r CONNECT dominfo NAME \
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
| awk -F: '$1 == "CPU_TIME" { print $2; }'
</action>
</metric>
<!-- SAP "CIM" -->
<metric type="uint32" context="vm">
<name>NumberOfAssignedPhysicalCPUs</name>
<name>ResourceProcessorLimit</name>
<action>
virsh -r CONNECT dominfo NAME | grep 'CPU(s):' \
| gawk -F': +' '{print $2}'
virsh -r CONNECT dominfo NAME \
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
| awk -F: '$1 == "CPU(S)" { print $2; }'
</action>
</metric>
<!-- SAP "CIM" -->
<metric type="uint64" context="vm">
<name>ResourceMemoryLimit</name>
<action>
virsh -r CONNECT dominfo NAME \
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
| awk -F: '$1 == "MAX_MEMORY" { print int($2/1024); }'
</action>
</metric>
<!-- SAP "CIM" -->
<metric type="uint64" context="vm">
<name>PhysicalMemoryAllocatedToVirtualSystem</name>
<action>
virsh -r CONNECT dominfo NAME | grep 'Max memory:' \
| gawk -F' +' '{printf "%d\n", $3/1024}'
virsh -r CONNECT dominfo NAME \
|awk -F ':' '
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
gsub("[[:space:]]+", "_", s); s = toupper(s);
return s;
}
function filt_phys(s, sep, num, unit) { # 42.0 KM
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
{
num = s; unit = s;
sub("[[:space:]]*[[:alpha:]]+$", "", num);
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
return num sep toupper(unit);
}
else
{
return s;
}
}
/:/ {
d1 = substr($0, 1, index($0, ":") - 1);
rest = substr($0, index($0, ":") + 1);
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
}' \
| awk -F: '$1 == "USED_MEMORY" { print int($2/1024); }'
</action>
</metric>
<!-- will only be supported by Fedora -->
<!-- <metric type="uint64" context="vm">
<name>UsedMem</name>
<action>
virsh -r CONNECT dominfo NAME | grep 'Used memory:' \
| gawk -F' +' '{printf "%d\n", $3/1024}'
</action>
</metric> -->
</metrics>
</vhostmd>
<!--

View File

@ -8,7 +8,7 @@
Summary: Virtualization host metrics daemon
Name: vhostmd
Version: 0.4
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv2+
Group: System Environment/Daemons
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@ -192,6 +192,9 @@ exit 0
%changelog
* Tue Jul 6 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-7
- Updated vhostmd.conf from Dr. Joachim Schneider at SAP.
* Tue Apr 27 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-6
- Updated vhostmd.conf file which enables TotalCPUTime metric.