annotate openvz_checker.pl @ 5:464dea07deb8 default tip

Add vzps replacements.
author Peter Gervai <grin@grin.hu>
date Wed, 07 May 2014 16:23:45 +0200
parents c2cff30df6dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
1 #!/usr/bin/perl
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
2 #$Id: openvz_checker.pl,v 1c29ac915688 2009/12/09 21:17:13 grin $
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
3 #(c)Peter Gervai, 2009
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
4 # GPLv2 / CC-BY-SA 3.0
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
5 #
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
6 # check openvz resource settings
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
7 # based on wiki pages
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
8 #
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
9
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
10 use strict;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
11 use warnings;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
12
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
13 use IO::File;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
14 use Data::Dumper;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
15
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
16 my $dir_bc = "/proc/bc";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
17
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
18 my $CUR=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
19 my $MAX=1;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
20 my $BAR=2;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
21 my $LIM=3;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
22
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
23 # ia32...
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
24 my $PAGESIZE=4096;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
25
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
26 my @allsocketbuf = qw( tcprcvbuf tcpsndbuf dgramrcvbuf othersockbuf );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
27
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
28 opendir( DIR, $dir_bc );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
29 my @veids = grep { /^\d+/ && -d "$dir_bc/$_" } readdir(DIR);
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
30 closedir( DIR );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
31
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
32 my %res;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
33 for my $veid ( @veids ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
34 next if $veid == 0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
35 my $f = new IO::File "< $dir_bc/$veid/resources" or next;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
36 while( <$f> ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
37 chomp;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
38 # trim spaces
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
39 s/^\s*(.*?)\s*$/$1/;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
40 my @data = split /\s+/;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
41 # held, maxheld, barrier, limit, failcnt
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
42 $res{$veid}{$data[0]} = [ @data[1..5] ];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
43 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
44 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
45
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
46 ## total ram
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
47 my $ram = qx( free | grep Mem: ); chomp $ram;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
48 $ram = (split /\s+/, $ram)[1];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
49 print "RAM=$ram\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
50 $ram *= 1024;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
51
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
52 ## swap
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
53 my $swap = qx( free | grep Swap: ); chomp $swap;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
54 $swap = (split /\s+/, $swap)[1];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
55 print "SWAP=$swap\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
56 $swap *= 1024;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
57
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
58
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
59 my $sum;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
60 ### low mem x86_32
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
61 # max lowram 832MB
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
62 my $lowram = $ram > 832000000 ? 832000000 : $ram;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
63
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
64
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
65 ###############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
66 ####### system wide config
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
67 ###############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
68
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
69
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
70 ###############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
71 ## utiliation
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
72 $sum=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
73 foreach my $veid (keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
74 my $b = $res{$veid}{'kmemsize'}->[$CUR];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
75 foreach my $sb (@allsocketbuf) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
76 $b += $res{$veid}{$sb}->[$CUR];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
77 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
78 $sum += $b;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
79 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
80
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
81 print "Low memory (x86_32) Utilisation: ", &pretty($sum / (0.4 * $lowram));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
82 print " ( <1 OK; <2 unsafe; >2 dangerous)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
83
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
84
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
85 ###############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
86 ## commitment level
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
87 $sum=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
88 foreach my $veid (keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
89 my $b = $res{$veid}{'kmemsize'}->[$LIM];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
90 foreach my $sb (@allsocketbuf) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
91 $b += $res{$veid}{$sb}->[$LIM];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
92 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
93 $sum += $b;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
94 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
95
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
96 print "Low memory (x86_32) Commitment: ", &pretty($sum / (0.4 * $lowram));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
97 print " ( <1 OK; <1.5 acceptable; >2 not recommended)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
98
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
99
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
100 ############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
101 #### total ram
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
102 ## utilisation
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
103 $sum=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
104 foreach my $veid (keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
105 my $b = $res{$veid}{'physpages'}->[$CUR] * $PAGESIZE;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
106 $b += $res{$veid}{'kmemsize'}->[$CUR];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
107 foreach my $sb (@allsocketbuf) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
108 $b += $res{$veid}{$sb}->[$CUR];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
109 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
110 $sum += $b;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
111 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
112 print "Total RAM utilisation: ", &pretty($sum / $ram);
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
113 print " ( <0.8 low; <1 ok; >1 impossible)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
114
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
115
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
116 ############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
117 #### total ram+swap
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
118 ## utilisation
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
119 $sum=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
120 foreach my $veid (keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
121 my $b = $res{$veid}{'oomguarpages'}->[$CUR] * $PAGESIZE;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
122 $b += $res{$veid}{'kmemsize'}->[$CUR];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
123 foreach my $sb (@allsocketbuf) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
124 $b += $res{$veid}{$sb}->[$CUR];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
125 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
126 $sum += $b;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
127 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
128 print "RAM+swap utilisation: ", &pretty($sum / ($ram+$swap));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
129 my $low_bound = &pretty($ram / ($ram+$swap));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
130 my $hi_bound = &pretty(($ram + 0.5*$swap) / ($ram+$swap));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
131 print " ( <$low_bound low; between ok; >$hi_bound bad)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
132
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
133
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
134 ## commitment
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
135 $sum=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
136 foreach my $veid (keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
137 my $b = $res{$veid}{'oomguarpages'}->[$BAR] * $PAGESIZE;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
138 $b += $res{$veid}{'kmemsize'}->[$LIM];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
139 foreach my $sb (@allsocketbuf) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
140 $b += $res{$veid}{$sb}->[$LIM];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
141 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
142 $sum += $b;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
143 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
144 print "RAM+swap commitment: ", &pretty($sum / ($ram+$swap));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
145 print " ( <0.8 low; <1 ok; >1 not recommended)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
146
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
147
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
148 ## allocations
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
149 $sum=0;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
150 foreach my $veid (keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
151 my $b = $res{$veid}{'privvmpages'}->[$LIM] * $PAGESIZE;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
152 $b += $res{$veid}{'kmemsize'}->[$LIM];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
153 foreach my $sb (@allsocketbuf) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
154 $b += $res{$veid}{$sb}->[$LIM];
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
155 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
156 $sum += $b;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
157 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
158 print "RAM+swap allocations: ", &pretty($sum / ($ram+$swap));
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
159 print " ( <1.5 low; <4 ok; >4 not recommended [oom])\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
160
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
161
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
162 ###############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
163 ####### per VE configs
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
164 ###############################
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
165 foreach my $veid (sort { $a <=> $b } keys %res) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
166 # <numproc> should be average process num
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
167 &compare( $veid, $res{$veid}{'kmemsize'}->[$BAR],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
168 40*1024*$res{$veid}{'numproc'}->[$CUR] + $res{$veid}{'dcachesize'}->[$LIM],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
169 "kmemsize(bar)", "numproc~dcachesize", "kmemsize low for # of processes" );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
170
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
171 &compare( $veid, $res{$veid}{'privvmpages'}->[$BAR], $res{$veid}{'vmguarpages'}->[$BAR],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
172 "privvmpages","vmguarpages", "mem alloc less than guarantee" );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
173
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
174
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
175 &compare( $veid, $res{$veid}{'tcpsndbuf'}->[$LIM] - $res{$veid}{'tcpsndbuf'}->[$BAR],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
176 2.5*1024*$res{$veid}{'numtcpsock'}->[$LIM],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
177 "tcpsndbuf(lim-bar)", "numtcpsock(lim{bytes})", "tcp may hang");
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
178
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
179
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
180 &compare( $veid, $res{$veid}{'othersockbuf'}->[$LIM] - $res{$veid}{'othersockbuf'}->[$BAR],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
181 2.5*1024*$res{$veid}{'numothersock'}->[$LIM],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
182 "othersockbuf(lim-bar)", "numothersock{bytes}", "othersock may hang");
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
183
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
184
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
185 &compare( $veid, $res{$veid}{'tcprcvbuf'}->[$LIM] - $res{$veid}{'tcprcvbuf'}->[$BAR],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
186 2.5*1024*$res{$veid}{'numothersock'}->[$LIM],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
187 "tcprcvbuf(lim-bar)","numothersock{bytes}","may slow tcp" );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
188
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
189
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
190 if( $res{$veid}{'tcprcvbuf'}->[$BAR] < 65535 ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
191 print "$veid: tcprcvbuf too low (<64k)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
192 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
193
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
194
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
195 if( $res{$veid}{'tcpsndbuf'}->[$BAR] < 65535 ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
196 print "$veid: tcpsndbuf too low (<64k)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
197 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
198
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
199
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
200 if( $res{$veid}{'dgramrcvbuf'}->[$BAR] < 131200 ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
201 print "$veid: dgramrcvbuf too low (<129k)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
202 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
203
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
204
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
205 if( $res{$veid}{'othersockbuf'}->[$BAR] < 131200 ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
206 print "$veid: othersockbuf too low (<129k)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
207 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
208
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
209
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
210 # numfile < avgnumproc*32
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
211 # ...
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
212
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
213 if( $res{$veid}{'dcachesize'}->[$BAR] <
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
214 $res{$veid}{'numfile'}->[$MAX] * 384 ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
215 print "$veid: dcachesize likely low for dentry and inode allocs\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
216 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
217
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
218
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
219 foreach my $param (keys %{$res{$veid}}) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
220 &compare( $veid, $res{$veid}{$param}->[$LIM], $res{$veid}{$param}->[$BAR],
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
221 "limit", "barrier", "problem with $param" );
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
222 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
223 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
224
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
225
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
226
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
227 sub compare {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
228 my ($veid, $large, $small, $ltext, $stext, $text) = @_;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
229
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
230 if( $large < $small ) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
231 # bad...
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
232 print "VE $veid: $text ($ltext=$large < $stext=$small)\n";
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
233 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
234 return;
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
235 }
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
236
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
237
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
238
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
239 sub pretty($) {
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
240 return sprintf("%6.4f", shift);
c2cff30df6dc Add openvz_checker.pl (24:1c29ac915688) form local repo
Peter Gervai <grin@grin.hu>
parents:
diff changeset
241 }