Easy servers load tip

in #steem4 years ago

Hi everybody,

At this moment, I set up an steem node Linux server, I think I can contribute to it throught applications (It seems not so easy, but I keep going ).

I just want share a little trick, I use for years now, to read instantly a server load, that's useful when you have a lot of opened terminal for instance.

BEFORE

you have to check "top" instruction, you get
load1.png

AFTER

Open a new session with Putty, you get the server load in the bar, refreshing every 2 seconds
load2.png

So cool ! and easy !

To do this :

Put this PERL code to a new file called /home/steem/view_load

#!/usr/bin/perl -w

use strict;
$|++;

my $machine=`/bin/hostname`;
chomp $machine;

while (1) {
open (CHARGE,"/proc/loadavg") ||die "Unable to open /proc/loadavg: $!\n";

my @charge=split(/ /,<CHARGE>);
close (CHARGE);

print "\033]0;";
print "$machine -- load :  $charge[0]   $charge[1]   $charge[2]        at ", scalar(localtime);
print "\007";

sleep 2
}

Don't forget to put good executing right


chmod +x /home/steem/view_load

then add this line in the end of your .bash_profile (or create .bash_profile if it's not existing) /home/steem/.bash_profile (~/. bash_profile)


/home/steem/view_load &

And that's all !

You can customize and put other informations to display, but I prefer keeping simple "load + clock".

As terminal I use Putty, it works as a charm on CentOS and here on Ubuntu 16.04 LTS

See you next time