# 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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |