App-Slaughter
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Slaughter/Info/linux.pm view on Meta::CPAN
if ( open( my $mdstat, "<", "/proc/mdstat" ) )
{
foreach my $line (<$mdstat>)
{
if ( ( $line =~ /^md([0-9]+)/ ) &&
( $line =~ /active/i ) )
{
$ref->{ 'softwareraid' } = 1;
$ref->{ 'raid' } = "software";
}
}
close($mdstat);
}
}
#
# Memory total and memory free.
#
if ( open( my $mem, "<", "/proc/meminfo" ) )
{
foreach my $line (<$mem>)
{
chomp($line);
if ( $line =~ /MemTotal:\s+(\d+) kB/ )
{
$ref->{ 'memtotal' } = $1;
}
if ( $line =~ /MemFree:\s+(\d+) kB/ )
{
$ref->{ 'memfree' } = $1;
}
}
close($mem);
}
#
# Kernel version.
#
$ref->{ 'kernel' } = `uname -r`;
chomp( $ref->{ 'kernel' } );
#
# IP address(es).
#
my $ip = undef;
$ip = "/sbin/ip" if ( -x "/sbin/ip" );
$ip = "/bin/ip" if ( -x "/bin/ip" );
if ( defined($ip) )
{
#
# Two commands to find the IP addresses we have
#
my @cmd = ( " -o -f inet addr show scope global",
" -o -f inet6 addr show scope global"
);
#
# Run each
#
foreach my $cmd (@cmd)
{
my $count = 1;
my $family = "ip";
$family = "ip6" if ( $cmd =~ /inet6/i );
foreach my $line ( split( /[\r\n]/, `$ip $cmd` ) )
{
next if ( !defined($line) || !length($line) );
chomp($line);
#
# This matches something like:
#
# eth0 inet 192.168.1.9/24 brd 192.168.1.255 scope global eth0
#
# or
# eth0 inet6 2001:41c8:1:5abb::62/64 scope global valid_lft forever preferred_lft forever
#
#
if ( $line =~ /(inet|inet6)[ \t]+([^ \t+]+)[ \t]+/ )
{
my $proto = $1;
my $ip = $2;
#
# Strip off /24, /128, etc.
#
$ip =~ s/\/.*//g;
#
# Save away the IP address in "ip0", "ip1", "ip2" .. etc.
#
$ref->{ $family . "_" . $count } = $ip;
$count += 1;
}
}
if ( $count > 0 )
{
$ref->{ $family . '_count' } = ( $count - 1 );
}
}
}
#
# Find the name of our release
#
my $version = "unknown";
my $distrib = "unknown";
my $release = "unknown";
if ( -x "/usr/bin/lsb_release" )
{
foreach
my $line ( split( /[\r\n]/, `/usr/bin/lsb_release -a 2>/dev/null` ) )
{
chomp $line;
if ( $line =~ /Distributor ID:\s*(.*)/ )
{
$distrib = $1;
}
if ( $line =~ /Release:\s*(.*)/ )
{
$version = $1;
}
if ( $line =~ /Codename:\s*(.*)/ )
{
$release = $1;
}
}
}
$ref->{ 'version' } = $version;
$ref->{ 'distribution' } = $distrib;
$ref->{ 'release' } = $release;
#
# TODO: 3Ware RAID?
#
#
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.587 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )