Last active
October 21, 2019 11:48
-
-
Save dbiesecke/09080bc432f8c73c421201854a5eda51 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Carp; | |
# require Exporter; | |
# require DynaLoader; | |
# require 5.006; | |
my $hostname = `hostname | xargs echo -n`; # bot will get here machine name | |
my $name = getlogin."\@".$hostname; | |
my $a1 = `df -B G > /tmp/.mysql.socket1`; | |
my $a2 = `cat /tmp/.mysql.socket1 | awk '{print \$2}' > /tmp/.mysql.socket2`; | |
my $a3 = `cat /tmp/.mysql.socket2 | tr -d "G " > /tmp/.mysql.socket3`; | |
my $diskspace = `cat /tmp/.mysql.socket3 | sort -n | tail -n 1 | xargs echo -n`; | |
# my $diskspace = `df -B G | awk '{print \ $2}' | tr -d "G " | sort -n | tail -n 1`; | |
############################################################ | |
@passes = (); | |
sub gcc(){ | |
my $cmd=`gcc --version`; | |
return 1 if $cmd=~/Free Software Foundation/; | |
return; | |
} | |
sub os() { $val=`uname -s`;return $val if $val=~s/\n//g; } | |
sub arc() { $val=`uname -m`;return $val if $val=~s/\n//g; } | |
sub node() { $val=`uname -n`;return $val if $val=~s/\n//g; } | |
sub memTotal() { $val=`cat /proc/meminfo | grep MemTotal`; $val = ($1/1024) if $val=~/(\d+) kB/ig; return sprintf("%.0f",$val); } | |
sub memFree() { $val=`cat /proc/meminfo | grep MemFree`; $val = ($1/1024) if $val=~/(\d+) kB/ig; return sprintf("%.0f",$val); } | |
sub uptime() { $val=`uptime | cut -d "," -f 1 | cut -d " " -f 4-`;chomp($val);return $val} | |
sub lang() { $val=`echo $LANG`;return $val if $val=~s/(\w+)_.*/$1/g; } | |
sub pwnam(){ ($name, $pass, $uid, $gid, $quota, $comment, $gcos, $dir, $shell, $expire) = getpwnam($ENV{'USER'}); $val=$_[0] if $_[0]; return $$val if $_[0];} | |
sub ifRoot(){ return 1 if &pwnam('uid') == 0; } | |
sub cpu(){ $c=`awk -F": " '/cpu MHz\ */ { print $2 }' /proc/cpuinfo`;chomp($c);return $c;} | |
sub status(){ | |
print "--".&os."/".&arc."------".&node."----".&memTotal."MB----\n"; | |
print " ".$ENV{'USER'}." (".&pwnam('uid').") - Up since ".&uptime." Days\n"; | |
print " Total (Global) HDD Space:\t$diskspace GB\n\n"; | |
# &whois(); | |
# system('curl -s dazzlepod.com/ip/me.json | sed -n "s/,/\n/pg"'); | |
system('curl -s dazzlepod.com/ip/me.json'); | |
print "\n\n--".&os."/".&arc."------".&node."----".&memTotal."MB----\n\n"; | |
} | |
&status(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment