/[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

Contents of /trunk/vz-optimize.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Mon Nov 27 14:16:52 2006 UTC (17 years, 4 months ago) by dpavlin
Original Path: trunk/vzoptimize.pl
File MIME type: text/plain
File size: 965 byte(s)
few more touches

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.00095 ) {
43 my $new_limit = int($r->{limit} * 1.1);
44 # warn "# $vmid $res $r->{limit} -> $new_limit\n";
45 print "vzctl set $vmid --${res} $new_limit\n";
46 } else {
47 warn "$vmid/$res failed, but not used 95% [",$r->{held},"/",$r->{limit},"]\n";
48 }
49
50 }
51 }
52 close($bc);
53
54 #print dump($d);

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26