I have requirement to developed script which will check values in column two and if the value exceeds the threshold value , it should send alert with following message echo "$column1 has crossed the threshold value of cpu"
Thanks for the response. I replaced the value variable with value 6 and i am getting following error.
I need one more update in script if cpu is below threhold value the output should get written in the file.
bash-3.00$ ps -eo pid,pcpu,args | sort +1n | grep -i java | awk -v threshold=6 '$2 > threshold {print $1,"has crossed the threshold value of cpu";}'
awk: syntax error near line 1
awk: bailing out near line 1
bash-3.00$
This is perfectly working fine. I need one more help,Is it possible to email alert if it cpu has crossed the threshold value.and also when cpu is under threshold it should write the same in file. It would be great if you can explain me the execution of command.