/[vz-tools]/trunk/vz-optimize.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/vz-optimize.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Mon Nov 27 14:08:47 2006 UTC (16 years, 2 months ago) by dpavlin
Original Path: trunk/vzoptimize.pl
File MIME type: text/plain
File size: 883 byte(s)
initial import of optimizer

1 dpavlin 1 #!/usr/bin/perl -w
2    
3     use strict;
4    
5     use Data::Dump qw/dump/;
6    
7     my $proc='/proc/user_beancounters';
8     $proc='./user_beancounters' if (! -e $proc);
9    
10     open(my $bc, '<', $proc) || die "can't open $proc: $!";
11    
12     my @cols;
13     my $vmid;
14    
15     my $d;
16    
17     while(<$bc>) {
18     chomp;
19     next if (/^Version/);
20    
21     $vmid = $1 if (s/^\s+(\d+):\s+//);
22     s/^\s+//;
23    
24     my @d = split(/\s+/,$_);
25    
26     if ($#d == 6 && $d[0] =~ m/^\w+$/) {
27     @cols = splice(@d,1);
28     # warn "## found cols: ", dump(@cols), "\n";
29     next;
30     }
31    
32     my $res = $d[0];
33    
34     foreach my $i ( 1 .. $#cols ) {
35     $d->{ $vmid }->{ $res }->{ $cols[$i] } = $d[$i];
36     }
37    
38     my $r = $d->{ $vmid }->{ $res };
39    
40    
41     if ($r->{failcnt} > 0) {
42     if ( ($r->{held} / $r->{limit}) > 0.95 ) {
43     print "vzctl set $vmid --${res} ", int($r->{held} * 1.1), "\n";
44     } else {
45     warn "$vmid/$res failed, but not used 95% [",$r->{held},"/",$r->{limit},"]\n";
46     }
47    
48     }
49     }
50     close($bc);
51    
52     #print dump($d);

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26