Health check report

Hi Team,

I am writing a small script in that I want collect all servers of /opt and /stage.

Below is my small script


#!/bin/ksh

#checking Media server opt_Disk_Space_logs

myclient=`cat media_server.txt`
> opt_logs.txt

printf " Server Name\tsize\tused\tavail\tcapacity\tMounted on\n"

for i in $myclient

do

j=`sudo xxxxxx $i df -h |egrep -i "/opt|/stage" | awk '{print $2, "\t", $3, "\t", $4, "\t", $5,"\t", $6}'`

printf "\n $j"
done
echo""
echo""

the output as below.

 Server Name    size    used    avail   capacity        Mounted on

 13G     7.8G    4.9G    62      /opt
300G     268G    32G     90      /stage

but I want, some more in depth means.
If column 62 is more than 90 I need warming message

a=90

echo "out of opt_out"
echo $opt_out
if [ "$opt_out" -ge "$a" ]

then
printf "%s\t WARNING NEED TO CHECK NOW /opt \n",$opt
else
printf "%s\tGood Required space\n",$opt
echo "$opt_out   Good Required space"
fi

I know the above script as some problem, it is not give any correct output

Please provide the exact script.. The out put should be as below..

AND also I am checking many server as

server 1

 13G     7.8G    4.9G    62      /opt     Good, Required space avilable
300G     268G    32G     90      /stage  WARNING NEED TO CHECK NOW


server 2 

 13G     7.8G    4.9G    62      /opt     Good, Required space avilable
300G     268G    32G     90      /stage  WARNING NEED TO CHECK NOW


.....

etc

Did you do an intensive search in these forums? This question has been asked (and answered) n times...

You will be able to do it yourself!

Hi Rudic,

Thanks for encouragement, At last I have did the script.

If you don't mind can you please help the small graphics here.

13G      7.8G    4.9G    62%     /opt           Good Required space
300G     268G    32G     90%     /stage                 WARNING NEED TO CHECK NOW

" Good Required space".... should be Yellow or blue
and

"WARNING NEED TO CHECK NOW" ... Should be Red color

Thanks for your help

Something as described in the below link :

http://unix.stackexchange.com/questions/43408/printing-colored-text-using-echo

Hi Mate,

is it possible the same color in awk program

print $j |awk '{print $1, "\t", $2 "\t", $3, "\t", $4,"\t", $5,"\t\t "\e[1;34m Good Required space\e[0m"}'

The out put like below.

awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1

---------- Post updated at 03:47 PM ---------- Previous update was at 03:38 PM ----------

It works by below link

http://www.bashguru.com/2010/01/shell-colors-colorizing-shell-scripts.html

Thanks all

Using escape sequence in awk gives me this:

awk: warning: escape sequence `\e' treated as plain `e'

Yes, try this:

"\033[1;34m Good Required space\033[0m"

On Solaris use nawk or /usr/xpg4/bin/awk.

You've got one double quote too many : "\e , eliminate that one!

EDIT: And, yes, radoulov is right: awk - unlike e.g. shell printf - does not recognize \e , so use \033 instead.

Thanks radoulov
\033 did work in awk

Hi All,

if [ "$opt_out" -eq 0 ]
then
printf "\t\t\tNo opt Disk space"

elif [ "$opt_out" -ge "$a" ]

then
print $j |awk '{print $1, "\t", $2 "\t", $3, "\t", $4,"\t", $5,"\t\t"}'
printf "\033[1;4;33;44m WARNING NEED TO CHECK NOW \033[0m"

else
print $j |awk '{print $1, "\t", $2 "\t", $3, "\t", $4,"\t", $5,"\t\t"}'
printf  "\033[1;31;64m Good Required space \033[0m"

fi

the output as below

server Name: adcsdf0001
13G      7.8G    4.9G    62%     /opt
 Good Required space 300G    5.8G    294G    2%      /stage
 Good Required space

is it possible, the messages on same lines with colors

like below

server Name: ssbkup0037
13G      7.8G    4.9G    62%     /opt  Good Required space 
300G    5.8G    294G    2%      /stage  Good Required space

Understand the difference (mayhap reading man pages?) between print and printf and you should be able to find out yourself.
Colour, however, is working fine!

Hey Rudic,

You are not giving any suggestion , I was upset your comments.

But Now I did myself Because of you

Your Encouragement is Awesome mate. I am sooooooo Happy now. I doing my self. 

FIRST I SHOULD LEARN THE BASICS, WITHOUT GOOGLE FOR EACH ISSUES.
Thanks lot mate

---------- Post updated at 08:05 PM ---------- Previous update was at 08:05 PM ----------

cheers

I'm glad you got the right mind set. And - as you can see - it is selfrewarding (may not be a proper English word but fits exactly) getting your own script to do what you want it to do.
Of course we could write the scripts for you, now, and the times to come. Would it help? I doubt it. Now you can write all your scripts if need be. And, of course, we are happy to help should specific problems arise in the future.