Hey there, I am writing a script to simply check the cpu usage of two processes. The script works fine except that it doesn't seem to be evaluating the variable like it should:
max=0.10
top -d1 -f cpu.dat #get the cpu usage of processes
grep lca < cpu.dat > lca.dat #search for the process
awk '{ print $11}' lca.dat > used.dat #print that to file
while read cpusage #read the file line by line to evaluate
do
echo $cpusage
if [ $cpusage -gt 0.10 ]
then
echo "gt .1"
else
echo "NOT gt .1"
fi
done < used.dat
This is what used.dat looks like:
0.29
0.27
I did a WC on it and it says there are 10 chars in the file so that means there are two trailing spaces after the last digit... I don't think that should matter but who knows... I used the tr -d command to take out the spaces but that didn't work either.
I'm fresh out of ideas, could it be the decimals?
max=0.10
top -d1 -f cpu.dat #get the cpu usage of processes
grep lca < cpu.dat > lca.dat #search for the process
awk '{ print $11}' lca.dat > used.dat #print that to file
while read cpusage #read the file line by line to evaluate
do
echo $cpusage
if [ $cpusage -gt 0.10 ]
then
echo "gt .1"
else
echo "NOT gt .1"
fi
done < used.dat
This is what used.dat looks like:
0.29
0.27
I did a WC on it and it says there are 10 chars in the file so that means there are two trailing spaces after the last digit... I don't think that should matter but who knows... I used the tr -d command to take out the spaces but that didn't work either.
I'm fresh out of ideas, could it be the decimals?