monitoring script

Hi,

I ned to monitor the memory for the red-hat machine,when its reaches a threshold value like 2GB then a mail should be sent as soon as it finds the the value is met

can you suggest me which is the best way to do this?

limit=2000000 #KB 
used=$(free -k|sed -n '2p'|awk {'print $3'} ) ; cached=$(free -k|sed -n '2p'|awk {'print $7'})
  if [ $used -ge $limit ]; then
   echo -e "Used Memory space reached amount to \"$used KB used \" with '$cached KB cached' \nhost '$(hostname)' \
---> $(date +%F__%H:%M:%S) "|mail -s "Used Memory Space Control $hostname" yourmail@domain ; fi
1 Like

hi ygemici ... it sounds gud , thanQ for valuable post:)