 | 
January 12th, 2007, 11:12 AM
| | Newbie | | Join Date: Jan 2007
Posts: 2
| | unix performance monitoring script
hey,
i am in bit prob..can u help me to write a script in unix (can use perl also) to monitor
1.disk usage
2.cpu usage
3.memory usage
in every 10 seconds(for example)..
it should display the three usage result in screen in every 10 seconds.
it will be better if there is an option for user to set the monitoring time also..
pls help guys...
| 
January 12th, 2007, 12:30 PM
|  | Newbie | | Join Date: Jan 2007
Posts: 16
| |
Hi, I am also facing similar problem. I need to monitor the memory usage, idle %CPU percentage while my application is running. right now I am using "top" utility. But it is difficult to extact required information from "top". "top" is generating the O/P continuously. I want one shot answer as "vmstat","iostat" utilities give.
Could you suggest the solution??
regards,
ramudu.
| 
January 12th, 2007, 03:57 PM
|  | Expert | | Join Date: Oct 2006
Posts: 307
| | Quote: |
Originally Posted by ramudukamudu Hi, I am also facing similar problem. I need to monitor the memory usage, idle %CPU percentage while my application is running. right now I am using "top" utility. But it is difficult to extact required information from "top". "top" is generating the O/P continuously. I want one shot answer as "vmstat","iostat" utilities give.
Could you suggest the solution??
regards,
ramudu. | For Linux, consider using the information provided under /proc:
/proc/diskstat
/proc/cpustat
/proc/meminfo
This is where many monitoring tools under Linux get their info from.
For specific processes look under /proc/<PID>/
Can't say anything about UNIX, though ...
Hope that helps.
| 
January 12th, 2007, 04:24 PM
|  | Expert | | Join Date: Sep 2006
Posts: 4,631
| |
In Unix it's du and df for disk usage.
I found this. | 
January 13th, 2007, 11:27 AM
|  | Newbie | | Join Date: Jan 2007
Posts: 16
| |
Thanks flocks,
That's really helpful.
| 
January 16th, 2007, 03:03 PM
| | Member | | Join Date: Jan 2007
Posts: 36
| |
You could always make a crontab job to dump the values, but you'd probably get less of a performance hit by writing a short perl or shell script to do it, and then "daemonize" it.
I use Python the most, so that's what I'll use to prototype:
import time
cpuidle = 0 # adjust to the word index of the stat you want, counting from 0
# when you do "cat /proc/cpustat"
diskfree = 0 # adjust as per cpuidle
memfree = 9 # adjust as per cpuidle (this one is probably right)
logfile = open("/var/log/perflog","w")
while True:
logfile.write("CPU: %s DISK: %s MEM: %s\n" % (
file("/proc/cpustat").read().split(" ")[cpuidle],
file("/proc/diskstat").read().split(" ")[diskfree],
file("/proc/meminfo").read().split(" ")[memfree]))
logfile.flush()
time.sleep(10)
You could probably convert this to perl quite easily...
reagards,
-cybervegan
| 
June 22nd, 2007, 03:48 PM
| | Member | | Join Date: Jan 2007
Posts: 41
| | Quote: |
Originally Posted by cybervegan You could always make a crontab job to dump the values, but you'd probably get less of a performance hit by writing a short perl or shell script to do it, and then "daemonize" it.
I use Python the most, so that's what I'll use to prototype:
import time
cpuidle = 0 # adjust to the word index of the stat you want, counting from 0
# when you do "cat /proc/cpustat"
diskfree = 0 # adjust as per cpuidle
memfree = 9 # adjust as per cpuidle (this one is probably right)
logfile = open("/var/log/perflog","w")
while True:
logfile.write("CPU: %s DISK: %s MEM: %s\n" % (
file("/proc/cpustat").read().split(" ")[cpuidle],
file("/proc/diskstat").read().split(" ")[diskfree],
file("/proc/meminfo").read().split(" ")[memfree]))
logfile.flush()
time.sleep(10)
You could probably convert this to perl quite easily...
reagards,
-cybervegan | Will this work for hp and solaris ???
| 
June 22nd, 2007, 04:22 PM
| | Expert | | Join Date: Apr 2006
Posts: 503
| | Quote: |
Originally Posted by avik1983 hey,
i am in bit prob..can u help me to write a script in unix (can use perl also) to monitor
1.disk usage
2.cpu usage
3.memory usage
in every 10 seconds(for example)..
it should display the three usage result in screen in every 10 seconds.
it will be better if there is an option for user to set the monitoring time also..
pls help guys... | have you tried to code anything yet? read up anything on shell scripting before this?
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|