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