PDA

View Full Version : Script to mail me resources usage?


bigb89
07-18-2008, 05:41 PM
Hi guys,

How can I make a script that will pretty much run "top" (or any other commands that show resource usage) and then get the output from that command and email me the output every four hours?

I know that this may seem like a simple script, but I just don't know yet how to get the output from "top" and then mail that.

Thanks in advance!

TerryP
07-18-2008, 05:57 PM
http://en.wikipedia.org/wiki/Cron


I would also suggest setting the PATH and MAILTO (if needed) variables accordingly within the cronjob.

ocicat
07-18-2008, 05:59 PM
How can I make a script that will pretty much run "top" (or any other commands that show resource usage) and then get the output from that command and email me the output every four hours?
Factors you will want to consider:

Look at the -b switch to top(1) if you are using FreeBSD (-n on OpenBSD or NetBSD...). This will allow you to dump top output to a file.
Study the cron(8) manpage for information on how to configure a script which will run at periodic times.
Look at the manpage for whatever mail transport you are using. This may be sendmail(8).

Carpetsmoker
07-18-2008, 06:55 PM
This may also be of interest:
http://www.freebsdforums.org/forums/showthread.php?t=31072

corey_james
07-19-2008, 02:12 PM
Maybe it would be more beneficial using

rp.statd - host status monitoring daemon
rup - remote status display

bigb89
07-20-2008, 07:58 AM
Thanks for all the replies guys!

I'll definitely try those options to see which one will work best for me.