# HG changeset patch # User Peter Gervai # Date 1237811208 -3600 # Node ID efb595e3b0a2be8556892e53a43e0f0b72f2cf35 ovz_statshow v0.0 diff -r 000000000000 -r efb595e3b0a2 ovz_statshow.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ovz_statshow.pl Mon Mar 23 13:26:48 2009 +0100 @@ -0,0 +1,47 @@ +#!/usr/bin/perl +#$Id$ +#(C)Peter Gervai, 2009 +# + +use strict; +use warnings; + +use IO::File; + + +my $f_stat = "/proc/vz/vestat"; +my $stat_ver = "2.2"; + +my $f = new IO::File "< $f_stat" or die $!; +my $l = <$f>; +if( $l !~ /Version: $stat_ver/ ) { + die "Unknown file version $l, required $stat_ver"; +} + +$l = <$f>; # headers + +my @fields = (1,2,3,4,5,7,8); +my %ve, %ve1; + +while(1) { + while( <$f> ) { + chomp; + my @d = split; + # 0veid, 1user, 2nice, 3systm, 4uptime, 5idle, (6strv) + # 7uptime, 8used, (9maxlat, 10totlat, 11numched) + $ve{$d[0]} = [ @d[0..11] ]; + } + + for my $veid ( sort {$a<=>$b} keys %ve ) { + if( defined( $ve1{$veid} ) ) { + print "$veid: "; + for my $field ( @fields ) { + print "$field=", $ve{$veid}->[$field] - $ve1{$veid}->[$field]; + } + print "\n"; + } + $ve1{$veid}->[$field] = $ve{$veid}->[$field]; + } + + sleep(1); +}