while (1) {
print scalar localtime() . "\n";
- print "------------------------\n" ;
+ print "------------------------\n";
system("/usr/bin/vmstat -z --libxo xml >$filename");
my $doc = XML::LibXML->load_xml(location => $filename);
+ my $c = 0;
foreach my $id ($doc->findnodes('//zone')) {
my $name=$id->findvalue('name');
my $used=$id->findvalue('used');
my $val = int($used);
if ($name eq "vm pgcache") {
- next;
+ $name = $name . "_$c";
+ $c++;
}
if (exists $dict{$name}) {
# requires textproc/p5-XML-LibXML
#
use warnings;
+use strict;
use XML::LibXML;
my $filename = 'vmstatm.xml';
-
my %dict;
-my $offset = 10;
+
+my ($offset) = @ARGV;
+
+if (not defined $offset) {
+ $offset = 10;
+}
while (1) {
print scalar localtime() . "\n";
system("/usr/bin/vmstat -m --libxo xml >$filename");
- $doc = XML::LibXML->load_xml(location => $filename);
+ my $doc = XML::LibXML->load_xml(location => $filename);
foreach my $id ( $doc->findnodes('//memory')) {
my $name=$id->findvalue('type');
my $used=$id->findvalue('memory-use');
my $v0=$dict{$name} + $offset;
if ($v0 < $used) {
- print "$name: $v0 => $used \n";
+format DIFF_V0V1 =
+ @<<<<<<<<<<<<<<<<<<<<<< @######## => @########
+ $name,$v0,$used
+.
+ $~ = "DIFF_V0V1";
+ write;
$dict{$name}=$used;
}
} else {