This is a small script which we used to setup on our large cluster of webservers to see loadavg on terminal or putty title. This was very useful as you dont have to run top or w command to see what’s the current loadavg. It automatically updated the loadavg value every 2 seconds (it can be increased or decreased) on title of terminal or putty screen. Additionally it shows hostname and current time & date with loadavg.
We need to create small script with following code.
open (LOAD,”/proc/loadavg”) || die “could not open load avg: $! \n”;
my @load =split(/ /,);
print “$host: $load $load $load at “, scalar(localtime);
save the script and give execute permission. Then put it in your .bashrc of your user that it can run on every login you do or open any new terminal.
chmod +x /scripts/top.pl
at end put following line.
Whenever you login into your linux server using putty or terminal you can see the following screen how it shows the information in title of terminal or putty.