Leon: thank you very much for your reply...lots of interesting things
there. I like the top command rather than free as top would give me the %
of memory used by weewxd. I took the command ps -C weewxd -o
comm,size,rss,vsize,%mem (which I never saw before, thank you!) and
shortened it to ps -C weewxd -o %mem as that is the parameter I am
interested in tracking. I then made the following script, which has a
problem: It does not send the email when the first "threshold" is exceeded;
it sends an email that the second threshold is exceeded and simultaneously
restarts weewx. Do I have something in the wrong order in the script?
-------------------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
threshold=3
threshold2=4
usage=$(($(ps -C weewxd -o %mem |awk 'NR==2 {printf ("%.0f", $1}')))
if [ "$usage" -gt "$threshold2" ]
then
sudo /etc/init.d/service_name restart
if [ "$usage" -gt "$threshold" ]
then
echo "The memory usage has reached $usage% on $HOSTNAME." | mail -s
"High Memory Usage Alert" userssemailaddress
fi
fi
-------------------------------------------------------------------------------------------
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/722fbf07-c6b1-467b-b5a3-7ef1c9f80d81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.