scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

perley (1740B)


      1 #!/usr/bin/perl
      2 
      3 use strict;
      4 
      5 # grep user
      6 chomp (my $username = qx(whoami));
      7 
      8 # grep OS
      9 chomp (my $os = qx(uname));
     10 chomp (my $arch = qx(uname -m));
     11 
     12 # grep kernel version
     13 chomp (my $kernel = qx(sysctl | grep kern.version));
     14 my @kernel_split = split(/=/, $kernel);
     15 $kernel_split[1] =~ s/OpenBSD //g;
     16 my $kernel_out = substr($kernel_split[1], 0, -18);
     17 
     18 # grep hostname
     19 chomp (my $hostname = qx(hostname));
     20 
     21 # grep uptime and split the result
     22 chomp (my $up = qx(uptime));
     23 my @uptime = split(/,/, $up);
     24 # my $uptime_cut = substr($uptime[0], 12);
     25 my $uptime_cut = $uptime[0];
     26 $uptime_cut =~ s/^ //g;
     27 
     28 # grep ram and split
     29 # top -n | grep Memory and split that
     30 
     31 # grep shell
     32 chomp (my $shell = qx(echo \$SHELL));
     33 
     34 # grep RAM
     35 chomp (my $memory = qx(top -n | grep Memory));
     36 my @mem = split(/ /, $memory);
     37 
     38 # grep / space
     39 chomp (my $space = qx(df -h | grep \/\$));
     40 $space =~ s/\h+/ /g;
     41 my @space_stripped = split(/ /, $space);
     42 
     43 ###### Result #######
     44 print '
     45               _____                 ____   _____ _____
     46              / ___ \               |  _ \ / ____|  __ \
     47             / /  / /___  ___  ____ | |_) | (___ | |  | |
     48            / /  / / __ \/ _ \/ __ \|  _ < \___ \| |  | |
     49           / /__/ / /_/ /  __/ / / /| |_) |____) | |__| |
     50           \_____/ .___/\___/_/ /_/ |____/|_____/|_____/
     51                /_/
     52        ';
     53 
     54 print "\n";
     55 print "\t  Username: \t    $username\n";
     56 print "\t        OS: \t    $os \($arch\)\n";
     57 print "\t    Kernel: \t    $kernel_out\n";
     58 print "\t  Hostname: \t    $hostname\n";
     59 print "\t    Uptime: \t    $uptime_cut $uptime[1]\n";
     60 print "\t     Shell: \t    $shell\n";
     61 print "\t    Memory: \t    Real: $mem[2] \/ Free: $mem[5]\n";
     62 print "\t   Root FS: \t    Used: $space_stripped[2] \/ Free: $space_stripped[3]\n\n";