/[vz-tools]/trunk/vz-from-config.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-from-config.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (hide annotations)
Thu Mar 26 17:52:06 2009 UTC (13 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 1051 byte(s)
call vzconf with correct barriers and limit

1 dpavlin 75 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use lib 'lib';
7     use VZ;
8    
9     use Data::Dump qw/dump/;
10    
11     my $file = shift @ARGV || die "usage: $0 /etc/vz/conf/veid.conf\n";
12    
13     my $veid = $1 if $file =~ m{(\d+).conf};
14    
15     open(my $fh, '<', $file) || die "can't open $file: $!";
16    
17     my $config;
18    
19     while (<$fh>) {
20     chomp;
21     if ( m{(\w+)\s*=\s*"?([^"]+)"?} ) {
22     my ($name,$value) = ($1,$2);
23     $config->{ lc($name) } = $value;
24     } else {
25     warn "SKIP: $_\n";
26     }
27     }
28    
29     warn "# config ",dump( $config );
30    
31     my $path = "/proc/bc/$veid/resources";
32     open(my $res, '<', $path) || die "can't open $path: $!";
33     while (<$res>) {
34     chomp;
35     s{^\s+}{};
36     my ( $name,$held,$maxheld,$barrier,$limit,$failcnt ) = split(/\s+/, $_, 6);
37    
38     my ( $conf_barrier, $conf_limit ) = split(/:/, $config->{ $name });
39    
40 dpavlin 76 my $update;
41    
42 dpavlin 75 if ( $barrier != $conf_barrier ) {
43 dpavlin 76 warn "# $name barrier $barrier != $conf_barrier\n";
44     $update++;
45 dpavlin 75 }
46    
47     if ( $limit != $conf_limit ) {
48 dpavlin 76 warn "# $name limit $limit != $conf_limit\n";
49     $update++;
50 dpavlin 75 }
51    
52 dpavlin 76 vzctl( 'set', $veid, "--$name", "$conf_barrier:$conf_limit" ) if $update;
53    
54 dpavlin 75 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26