/[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 75 - (hide annotations)
Thu Mar 26 17:41:41 2009 UTC (13 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 1022 byte(s)
set parametars from /etc/vz/conf to running VE

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     if ( $barrier != $conf_barrier ) {
41     warn "# $name $barrier != $conf_barrier\n";
42    
43     vzctl( 'set', $veid, "--$name", $conf_barrier );
44     }
45    
46     if ( $limit != $conf_limit ) {
47     warn "# $name $limit != $conf_limit\n";
48     vzctl( 'set', $veid, "--$name", $conf_limit );
49     }
50    
51     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26