DOH! god how could I miss something that stupid???? do you know how long I stared at that and didn't see that????
---------- Post updated at 10:09 AM ---------- Previous update was at 08:39 AM ----------
Ok so my final command looks like this and I'm really liking it. Lets me set how much load I want to watch for and then changes the output color to red anytime it is a heavier load than what I set it for.
echo "How many Megs" ; read gload ; gload2=`echo $gload | awk '{print $1*1024*1024/8}'` ; netstat -i 1 1 | awk '{ if($3 < '$gload2' ) {print "\033[1;0m" $3/1024/1024*8, $6/1024/1024*8} else {print "\033[1;31m" $3/1024/1024*8, $6/1024/1024*8}}'
The last minor thing that I can't seem to get rid of is the stupid 0's that show up. Since its doing math and every 20 or so lines it prints the column heads again.... errs errs coll etc.. I can't seem to get those to not show up. So i'll get these kind of results.
45.4351 45.513
47.8142 47.8741
50.3284 50.3137
51.098 51.1384
0 0
0 0
50.4882 50.5795
43.9978 43.9685
43.9704 44.1034
44.715 45.1511
Only slightly annoying but ideally i'd like to get those zero's to not show up.
---------- Post updated at 10:26 AM ---------- Previous update was at 10:09 AM ----------
I've tried doing a simple grep -v errs yet for some reason that breaks the whole command and i'm not certain why.
---------- Post updated at 01:44 PM ---------- Previous update was at 10:26 AM ----------
HA! got rid of the stupid zero's by adding
/[1-9]/
to my awk statement. That way if the line only has zero's it wont print.
---------- Post updated at 01:53 PM ---------- Previous update was at 01:44 PM ----------
Is there any way to get awk to append a timestamp to an output line?
My command is coming along smashingly however if I leave this running for long periods of time unattended its going to spew out tons of data and with no time stamp if the box goes over the load I'll have no idea when that actually occurred and therefor no time frame to investigate.
---------- Post updated at 02:18 PM ---------- Previous update was at 01:53 PM ----------
added
; x="'"`date +%T`"'"; print x
---------- Post updated at 03:28 PM ---------- Previous update was at 02:18 PM ----------
Well I jumped the gun on my timestamp. It puts the timestamp in there but its not current. Its only the time when I started the command, it doesn't refresh.