Hi!
This is my script to fix it (Run it on your cloudstack server; You'll
need SSH keys to the Xen servers or you'll have to type the root
password often):
----------------
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use DBI;
use Getopt::Long;
use JSON;
use IO::Socket;
use IO::Socket::INET;
my %dbargs = (dsn => 'DBI:mysql:dbname=cloud;host=localhost',
dbuser => "cloud",
dbpass => "cloud");
sub fetch_server_list {
my $dbh = DBI->connect( $dbargs{dsn}, $dbargs{dbuser},
$dbargs{dbpass} ) || die DBI->errstr;
my $query =
"SELECT vm_instance.name as routername, vm_instance.host_id as
host_id, vm_instance.private_ip_address as routerip,
host.private_ip_address as hostip from vm_instance, host where host.id =
vm_instance.host_id AND vm_instance.name LIKE 'r-%' and
vm_instance.state = 'Running';";
my $result = $dbh->selectall_arrayref( $query, { "Slice" => {} } )
|| die $dbh->errstr;
return $result;
}
sub run_on_router($$)
{
my $target = shift || die;
my $remotecommand = shift || die;
my $command = 'ssh root@'.$target->{hostip}.' \'ssh -i
/root/.ssh/id_rsa.cloud -l root -p 3922 '.$target->{routerip}.'
"'.$remotecommand.'"\'';
print STDERR "executing:\n $command";
system($command);
}
sub fix_router($)
{
my $target = shift || die;
run_on_router($target, 'sed -i -e \"s/rsyslog reload/rsyslog
rotate/\" -e \"s%/nvoke%/invoke%;\" /etc/logrotate.d/rsyslog');
run_on_router($target, '/usr/sbin/invoke-rc.d rsyslog rotate');
}
sub status_router($)
{
my $target = shift || die;
run_on_router($target, 'df -k /var');
}
####################################### main
{
my @targets = @{ fetch_server_list() };
for my $target (@targets)
{
print STDOUT "VR ".$target->{routername}.":\n";
if ($ARGV[0] eq "info")
{
status_router($target);
}
else
{
fix_router($target);
}
}
}
----------------
Ciao
Martin
Am 28.07.2015 um 09:00 schrieb Martin Emrich:
Thanks, that's how I can access the VRs. So the procedure would be:
- get Host IP, VR LL IP from MySQL DB
- Log on to VR via its Host
- Fix logrotate config
I'll try that.
Thanks
Martin