#$Id: sysinfo.pl,v 1.3 2001/05/23 13:16:52 where Exp $ #!/usr/bin/perl -w # ----------------------------------------------------------------- # whoo's hacked up sysinfo for x-chat v.0.2.8 # Avaliable at http://www.owenmeany.com/linux.html # Author: # # If you use pico to edit use the -w switch ( pico -w ) # Check the variables, if your not using lm_sensors, remove ALL the refernces to it # All of the variables are explained... ...read the perl Luke.. # PS: I could NOT have done any of this without the help of a few people, # Xwild, for making me fix the dual processor bugs # sys_rage, for being my conscious, and a most tolerant teacher, # considering how damn bitchy I can be # and elfing, for throwing perl books at my feet # Come visit us all on irc server us.undernet.org in #/dev/null :) # Bargraph for memory via mIRC style is courtesy of # Sebastian Wenzler # Fix for traffic/in traffic/out not just showing in Gbytes is # courtesy of caetin # usage : /sys /temp or /net # ----------------------------------------------------------------- # YOU MUST ASSIGN THE VARIABLE BELOW SINCE IM TOO LAZY # TO FIGURE OUT WHAT YOU WANT FOR YOUR NETDEVICE $DEV = eth0; ## <-------------------------------CHANGE THAT IRC::register("Sysinfo", "0.2.4", "", ""); IRC::print "Loading whoo's hacked sysinfo script"; IRC::add_command_handler("sys", "display_sys_info"); sub display_sys_info { #--SYSNAME--# $SYSNAME = `uname -n`; chop($SYSNAME); #--UNAME--# $UNAME = `uname -sr`; chop ($UNAME); #--MODEL--# $MODEL = `cat /proc/cpuinfo | grep '^model name' | head -1 | sed -e 's/^.*: //'`; #--HOW MANY CPUS--# $NUM=`cat /proc/cpuinfo | grep "model name" | wc -l | sed 's/ *//'`; chop ($NUM); #--PROCESSOR SPEED--# $CPU = `cat /proc/cpuinfo | grep 'cpu MHz' | head -1 | sed -e 's/^.*: //'`; chop ($CPU); #--PROCS RUNNING--# $PROCS = `ps ax | wc -l | awk '{print \$1 - 5}'`; chop ($PROCS); #--UPTIME--# # $UPTIME = `up | awk '{ print }'`; @UPTIME = split " ", `up -n`; $UPTIME = $UPTIME[1] ? "$UPTIME[1]y " : ""; $UPTIME .= $UPTIME[2] ? "$UPTIME[2]w " : ""; $UPTIME .= $UPTIME[3] ? "$UPTIME[3]d " : ""; $UPTIME .= $UPTIME[4] ? "$UPTIME[4]h " : ""; $UPTIME .= $UPTIME[5] ? "$UPTIME[5]m " : ""; chop ($UPTIME); #--TOTAL MEMORY--# $MEMTOTAL = `free | grep Mem | awk '{printf (\"%dMiB \", \$2/1024 )}'`; chop ($MEMTOTAL); #--PERCENTAGE OF MEMORY FREE--# # $MEMPERCENT = `free | grep Mem | awk '{print (( \$3 -(\$6 + \$7) )/\$2)*100}'`; # chop ($MEMPERCENT); #--MEMORY FREE--# $MEMFREE = `free | grep Mem | awk '{printf (\"%.0fg\", ( \$3 -(\$6 + \$7) )/1024)}'`; chop ($MEMFREE); #--BARGRAPH OF MEMORY FREE--# # $FREEBAR = int($MEMPERCENT/10); # $MEMBAR = "%C14[%C4"; # for ( $x = 0; $x < 10; $x++ ) # { # if ( $x eq $FREEBAR ) # { # $MEMBAR = "$MEMBAR%C3"; # } # $MEMBAR = "$MEMBAR\|"; # } # $MEMBAR = "$MEMBAR%C14]%C"; #--SCREEN RESOLUTION--# $RES = `xdpyinfo | grep dimensions | awk '{print \$2}'`; chop ($RES); $SCREENDPI = `xdpyinfo | grep -i resolution | awk '{print \$2}'`; chop ($SCREENDPI); #--DISKSPACE--# # 20030627, ASB, avoid dupes # $HDD = `df -P | awk '{ sum+=\$2/1024^2 }; END { printf (\"%dGiB \", sum )}'`; $HDD = `df -P | awk '{print \$2\" \"\$3\" \"\$4\" \"\$5}' | sort | uniq | awk '{ sum+=\$1/1024^2 }; END { printf (\"%0.2fGiB \", sum )}'`; chop ($HDD); #--DISKSPACE FREE--# # 20030627, ASB, avoid dupes # $HDDFREE = `df -P | awk '{ sum+=\$4/1024^2 }; END { printf (\"%dGiB \", sum )}'`; $HDDFREE = `df -P | awk '{print \$2\" \"\$3\" \"\$4\" \"\$5}' | sort | uniq | awk '{ sum+=\$3/1024^2 }; END { printf (\"%0.2fGiB \", sum )}'`; chop ($HDDFREE); #--BOGOMIPS--# $MIPS = `cat /proc/cpuinfo | grep '^bogomips' | awk '{ sum+=\$3 }; END { print sum }'`; chop ($MIPS); #--LM_SENSORS #1--# $SENSOR1 = `sensors | grep 'temp2' | awk '{print \$2, \$3}'`; chop ($SENSOR1); #--LM_SENSORS #2--# $SENSOR2 = `sensors | grep 'temp1' | awk '{print \$2, \$3}'`; chop ($SENSOR2); $COREV1 = `sensors | grep 'VCore 1' | awk '{print \$3, \$4}'`; chop ($COREV1); $COREV2 = `sensors | grep 'VCore 2' | awk '{print \$3, \$4}'`; chop ($COREV2); #--PACKETS IN--# $PACKIN = `cat /proc/net/dev | grep $DEV | awk -F: '/:/ {print \$2}' | awk '{printf \$1}'`; if($PACKIN < 1024**3) { $PACKIN = sprintf("%.02f",$PACKIN / 1024**2)."M"; } else { $PACKIN = sprintf("%.02f", $PACKIN / 1024**3)."G"; } #--PACKETS OUT--# $PACKOUT = `cat /proc/net/dev | grep $DEV | awk -F: '/:/ {print \$2}' | awk '{print \$9}'`; if($PACKOUT < 1024**3) { $PACKOUT = sprintf("%.02f",$PACKOUT / 1024**2)."M"; } else { $PACKOUT = sprintf("%.02f", $PACKOUT / 1024**3)."G"; } #--SUPPORT FOR DUAL PROCS--# unless($NUM eq 1 ) { $MODEL="Dual $MODEL"; } chop ($MODEL); #--SPEW IT INTO THE CHANNEL SHALL WE--# IRC::command("Host: $SYSNAME | Kernel: $UNAME | $MODEL @ ${CPU} MHz @ $COREV1 | Mem: $MEMFREE/$MEMTOTAL @ $COREV2 | Diskspace: $HDD Free: $HDDFREE | Bogomips: $MIPS | Screen Res: $RES @ $SCREENDPI dpi | Procs: $PROCS | Temps: CPU: $SENSOR1 Mobo: $SENSOR2 | Up: $UPTIME | $DEV: In: $PACKIN Out: $PACKOUT"); return 1; }