Made this one a while ago, for the terrific IRC client Irssi. Many people asked me to create a command-line version (which actually is removing "use Irssi" and having print instead of Irssi::print), so I created a hybrid one.
Copied/pasted from an xterm, so might be incorrect...
# By Juerd <juerd@juerd.nl> # This is a second version BEGIN{ use vars '$console'; eval q{ use Irssi; Irssi::version(); }; $console = !!$@; } use strict; sub sysinfo{ # This should really need indenting, but I'm kinda lazy. my (@uname, $ret, @pci, $usr, $avg, $up); @uname = (split ' ', `uname -a`)[0..2]; $ret = "@uname[0..2] - "; open FOO, '/proc/cpuinfo'; while (<FOO>){ /^processor\s*:\s*(\d+)/ ? $ret .= "Cpu$1: " : /^model name\s*:\s*(\w+[ A-Za-z]*)/ ? do { my $t = $1; $t =~ s/\s+ +$//; $ret .= "$t " } : /^cpu MHz\s*:\s*([\.\d]+)/ ? $ret .= int(.5+$1) . 'MHz ' : undef; } close FOO; $ret =~ s/( ?)$/;$1/; open FOO, '/proc/meminfo'; while (<FOO>){ /^(Mem|Swap):\s*(\d+)/ and $ret .= "$1: " . int(.5 + ($2/2**20)) . + 'M; '; } close FOO; for (`df -h`){ /^\/\S*\s*(\S*)\s*\S*\s*(\S*)\s*\S*\s*(\S*)/ and $ret .= "$3: $1(f +=$2); "; } open FOO, '/proc/pci'; while (<FOO>){ /^\s*(?:multimedia )?(.*?)( storage| compatible)? controller/i and + push @pci, $1; } close FOO; $ret .= 'PCI: ' . join(',', map ucfirst, @pci) . '; ' if @pci; if (`uptime` =~ /^.*?up\s*(.*?),\s*(\d+) users?,.*: ([\d\.]+)/){ ($usr, $avg) = ($2, $3); ($up = $1) =~ s/\s*days?,\s*|\+/d+/; $ret .= "Up: $up; Users: $usr; Load: $avg; "; } if ($console){ print "$ret\n"; }else{ Irssi::active_win->command("/say $ret"); } } #end of sub if ($console){ sysinfo(); }else{ Irssi::command_bind('sysinfo', 'sysinfo') }

In reply to Basic Linux system information by Juerd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.