From cfd3b3afbc73d0600f702be7adb8834341fdbbad Mon Sep 17 00:00:00 2001 From: David Marec Date: Sun, 7 May 2023 10:18:50 +0200 Subject: [PATCH] Add Perl script to check vmstat diff --- vmstat.pl | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 vmstat.pl diff --git a/vmstat.pl b/vmstat.pl new file mode 100755 index 0000000..6b92c25 --- /dev/null +++ b/vmstat.pl @@ -0,0 +1,42 @@ +#!/usr/local/bin/perl +# +# requires textproc/p5-XML-LibXML +# +use warnings; + +use XML::LibXML; + +my $filename = 'vmstat.xml'; + + +my %dict; +my $offset = 10; + +while (1) { + print scalar localtime() . "\n"; + system("/usr/bin/vmstat -z --libxo xml >$filename"); + $doc = XML::LibXML->load_xml(location => $filename); + foreach my $id ( $doc->findnodes('//zone')) { + my $name=$id->findvalue('name'); + my $used=$id->findvalue('used'); + + if ($name eq "vm pgcache") { + next; + } + + if (exists $dict{$name}) { + my $v0=$dict{$name} + $offset; + + if ($v0 < int($used)) { + print "$name: $v0 => $used \n"; + $dict{$name}=int(${used}); + } + } else { + $dict{$name}=int(${used}); + } + } + print "------------------------\n" ; + + sleep(5); +} + -- 2.47.0