Last active
December 12, 2015 10:38
-
-
Save hdonnay/4760233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use List::MoreUtils qw(zip); | |
my @a = ( 'Kernel Name', 'Hostname', 'Kernel', 'Platform', 'OS' ); | |
my @b = split(/ /, `uname -snrio`); | |
chomp($b[-1]); | |
my @c = ( 'used', 'total' ); | |
my %uname = zip(@a, @b); | |
print "<html><head></head>"; | |
print "<ul id=\"info\">"; | |
foreach (sort keys %uname) { | |
print "<li>$_: $uname{$_}</li>\n"; | |
} | |
print "</ul>"; | |
print "<ul id=\"\">"; | |
my @uptime = split(/,/, `uptime`); | |
chomp($uptime[-1]); | |
print "<li>@uptime[0,1]</li>"; | |
print "<li>@uptime[3 .. $#uptime]</li>"; | |
foreach my $line (`free -h`) { | |
if ($line =~ m/^Mem:/) { | |
my @mem = split(/\s+/, $line); | |
@mem = ($mem[2], $mem[1]); | |
print "<li>Memory<ul>"; | |
my %hash = zip(@c, @mem); | |
foreach (keys %hash) { | |
print "<li>$_: $hash{$_}</li>"; | |
} | |
print "</ul></li>"; | |
} | |
} | |
print "</ul>"; | |
print "</html>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment