DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th July 2008
bigb89 bigb89 is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 69
Default Script to mail me resources usage?

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!
Reply With Quote
  #2   (View Single Post)  
Old 18th July 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

http://en.wikipedia.org/wiki/Cron


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

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #3   (View Single Post)  
Old 18th July 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by bigb89 View Post
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).
Reply With Quote
  #4   (View Single Post)  
Old 18th July 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

This may also be of interest:
http://www.freebsdforums.org/forums/...ad.php?t=31072
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #5   (View Single Post)  
Old 19th July 2008
corey_james corey_james is offline
Uber Geek
 
Join Date: Apr 2008
Location: Brisbane, Australia
Posts: 238
Default

Maybe it would be more beneficial using

rp.statd - host status monitoring daemon
rup - remote status display
__________________
"No, that's wrong, Cartman. But don't worry, there are no stupid answers, just stupid people." -- Mr. Garrison

Forum Netiquette
Reply With Quote
  #6   (View Single Post)  
Old 20th July 2008
bigb89 bigb89 is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 69
Default

Thanks for all the replies guys!

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
matts: a shell script to mail attachments from the command line J65nko Guides 7 3rd August 2022 03:13 AM
Forum usage: How to thank? Greg_Morgan Off-Topic 2 9th October 2009 12:49 AM
dd and split usage problem paul-lkw FreeBSD General 4 31st January 2009 08:13 PM
memory usage monitoring using net-snmp ducu_00 FreeBSD Ports and Packages 2 11th October 2008 03:12 PM
pagedaemon 100% cpu usage fenrisW0lf NetBSD General 14 5th June 2008 12:31 PM


All times are GMT. The time now is 02:36 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick