B
Benoit Lefebvre
I made a little script that ssh to many servers (IBM HMCs) to get a
list of all logical partitions on some pSeries servers managed by the
HMCs
Here is the complete script: (It's called getlpars.pl)
-----------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
chomp(@hmclist = `cat ~/scripts/conf/hmc.list`);
foreach (@hmclist) {
my($hmc,$hmctype) = split(":",$_);
if ($hmctype eq "p4") {
chomp(@list = `ssh -q hscroot\@$hmc 'lssyscfg -r sys --all'`);
@managedsystems = ();
for ($i = 1; $i <= scalar @list -1; $i++) {
$system = substr($list[$i],0,16);
$system =~ s/\s*$//g;
push(@managedsystems, $system);
}
foreach (@managedsystems) {
$system = $_;
$system = "\"".$system."\"";
chomp(@list = `ssh -q hscroot\@$hmc 'lssyscfg -m $system -r lpar
--all'`);
for ($i = 2; $i <= scalar @list -1; $i++) {
$lpar = substr($list[$i],0,20);
$lpar =~ s/\s*$//g;
print $hmc .":". $system .":". $lpar . "\n";
}
}
} elsif ($hmctype eq "p5") {
@list = `ssh -q hscroot\@$hmc 'lssyscfg -r sys'`;
@managedsystems = ();
foreach (@list) {
@ln = split(",", $_);
push(@managedsystems, substr($ln[0],5,length($ln[0])));
}
foreach (@managedsystems) {
$system = $_;
$system =~ s/\s/\\ /g;
@list2 = `ssh -q hscroot\@$hmc 'lssyscfg -r lpar -m $system -F --
header`;
foreach (@list2) {
@ln2 = split(",", $_);
print $hmc .":". $system .":". $ln2[0] . "\n";
}
}
}
}
-----------------------------------------------------------------------------------------------------------
~/scripts/conf/hmc.list contains a list of all HMCs with they type (p4
or p5) delemited with ":"
Content of hmc.list
-----------------------------------------------------------------------------------------------------------
name_of_hmc4
name_of_hmc25
-----------------------------------------------------------------------------------------------------------
Here is the "problem"
When I execute the script manually from the shell I get the outputs I
want.
When I run it from the crontab or in background "&" it fails.
[user@server (~/scripts/scripts)]: ./getlpars.pl &
[2] 467196
[2] + Stopped (SIGTTIN) ./getlpars.pl &
Is there any way to get more details on the error.. why it's
stopping ?
Thanks,
--Benoit Lefebvre
(e-mail address removed)
list of all logical partitions on some pSeries servers managed by the
HMCs
Here is the complete script: (It's called getlpars.pl)
-----------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
chomp(@hmclist = `cat ~/scripts/conf/hmc.list`);
foreach (@hmclist) {
my($hmc,$hmctype) = split(":",$_);
if ($hmctype eq "p4") {
chomp(@list = `ssh -q hscroot\@$hmc 'lssyscfg -r sys --all'`);
@managedsystems = ();
for ($i = 1; $i <= scalar @list -1; $i++) {
$system = substr($list[$i],0,16);
$system =~ s/\s*$//g;
push(@managedsystems, $system);
}
foreach (@managedsystems) {
$system = $_;
$system = "\"".$system."\"";
chomp(@list = `ssh -q hscroot\@$hmc 'lssyscfg -m $system -r lpar
--all'`);
for ($i = 2; $i <= scalar @list -1; $i++) {
$lpar = substr($list[$i],0,20);
$lpar =~ s/\s*$//g;
print $hmc .":". $system .":". $lpar . "\n";
}
}
} elsif ($hmctype eq "p5") {
@list = `ssh -q hscroot\@$hmc 'lssyscfg -r sys'`;
@managedsystems = ();
foreach (@list) {
@ln = split(",", $_);
push(@managedsystems, substr($ln[0],5,length($ln[0])));
}
foreach (@managedsystems) {
$system = $_;
$system =~ s/\s/\\ /g;
@list2 = `ssh -q hscroot\@$hmc 'lssyscfg -r lpar -m $system -F --
header`;
foreach (@list2) {
@ln2 = split(",", $_);
print $hmc .":". $system .":". $ln2[0] . "\n";
}
}
}
}
-----------------------------------------------------------------------------------------------------------
~/scripts/conf/hmc.list contains a list of all HMCs with they type (p4
or p5) delemited with ":"
Content of hmc.list
-----------------------------------------------------------------------------------------------------------
name_of_hmc4
name_of_hmc25
-----------------------------------------------------------------------------------------------------------
Here is the "problem"
When I execute the script manually from the shell I get the outputs I
want.
When I run it from the crontab or in background "&" it fails.
[user@server (~/scripts/scripts)]: ./getlpars.pl &
[2] 467196
[2] + Stopped (SIGTTIN) ./getlpars.pl &
Is there any way to get more details on the error.. why it's
stopping ?
Thanks,
--Benoit Lefebvre
(e-mail address removed)