Quantcast

My Linux cpuload monitoring script.

canadmos

Cake Tease
May 29, 2011
20,437
19,448
Canaderp
If anyone here uses Linux and wants to check out a script I wrote over the weekend, here it is.

This is my last assignment for a bash scripting class that I am taking at my college.

All this script does is basically translates the command "uptime" into a bar graph in the terminal window.

Link to the actual assignment;
https://scs.senecac.on.ca/~john.selmys/subjects/ops435-123/ass02.html

View attachment cload.doc

Download this file and remove the .doc extention. I only added it on there so that I could upload the script to here. Apparently there is a maximum of 11000 characters per forum post.

If you don't know how to run a script on Linux, feel free to ask and I will try to answer :headbang:

And if you do run it and you find an error or it breaks, let me know pleasssssssssse.
 
Last edited:

$tinkle

Expert on blowing
Feb 12, 2003
14,591
6
the only recommendation i could make is to tighten this up:
Code:
tput cup $a $barfield1
green=`echo "$onemin <= 0.5" | bc`
red=`echo "$onemin >= 1.0" | bc`
if [ $green = 1 ] ; then
	printf '\e[0;32m\xe2\x96\x88\e[0m'
elif [ $red = 1 ] ; then
	printf '\e[0;31m\xe2\x96\x88\e[0m'
else 
	printf '\e[1;33m\xe2\x96\x88\e[0m'
fi
perhaps turn this into a parameterised function, passing in barfield, etc.

other than that, well done!
 

canadmos

Cake Tease
May 29, 2011
20,437
19,448
Canaderp
thanks!

Yeah I think most of that script could have been made into several functions to shorten the length of it. That class is over now though, honestly one of the hardest classes I have taken yet. Our professor pushed us so hard.

View attachment cload2.doc
 
Last edited: