CPU monitoring script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users CPU monitoring script
# 1  
Old 08-24-2005
CPU monitoring script

I looking for a very basic, script that monitors the load on the cpu and writes it to a text file.


Can anyone help please?
# 2  
Old 08-24-2005
Java

Quote:
Originally Posted by alpha_manic
I looking for a very basic, script that monitors the load on the cpu and writes it to a text file.
Can anyone help please?
Code:
$ top -d2 | awk '/CPU states/'
CPU states:  7.8% user,  0.0% nice,  1.2% system,  1.2% interrupt, 89.8% idle
$

This shows you the load of the CPU. If you want to redirect the output to some file and use it in some shell script you can do it like this:

Code:
# !/bin/sh
top -d2 | awk '/CPU states/' >> file.log

After you changed the file permissions to have "execute" rights, add it to /etc/crontab to run it every minute/hour/day...
# 3  
Old 08-24-2005
top -d2 | awk '/CPU states/'

This code, put the xterm into halt mode. I can't see the output????
# 4  
Old 08-24-2005
Try using this:

Code:
#!/usr/bin/ksh
uptime >> some_log_file

The rest of the things are just as posted by Sergiu. You can schedule it in cron or whatever..
# 5  
Old 08-25-2005
use something tried and proven.
Do a search in google "System Activity reporter".
All unix has this... You gota turn it on.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Understanding & Monitoring CPU performance (Load vs SAR)

Hi all, Been reading a lot of the cpu load and its "analogy of it to car traffic path of expressway" From wiki Most UNIX systems count only processes in the running (on CPU) or runnable (waiting for CPU) states. However, Linux also includes processes in uninterruptible sleep states... (13 Replies)
Discussion started by: javanoob
13 Replies

2. AIX

CPU monitoring query

Hi all, I am a DBA , I want to take the output of topas command result in every 1minute to write on the output file. If I redirected the file it attached with some control M characters. Nmon and sar commands are not working. only topas working in my AIX environment. Please suggest me on this.... (2 Replies)
Discussion started by: kumaravelu2006
2 Replies

3. Infrastructure Monitoring

freeBSD CPU monitoring using nagios

Hi all, I am not being able to monitor CPU of freeBSD machine from my CentOS server. I have used check_aix_cpu but always gives garbage value, seems wrong in scripting. i want to monitor CPU usage of my freeBSD machine from my centOS server. I am able to monitor many services of that machine... (0 Replies)
Discussion started by: gsuwal
0 Replies

4. Infrastructure Monitoring

Monitoring CPU Usage with SNMP

Can someone please tell me how to calculate the CPU usage from what one gets back from snmpwalk? I have searched and dug through the internet and apparently, no one has the answer to this? i can use snmpwalk to pull out relevant information about cpu. but i have no clue what values are to be... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. UNIX for Advanced & Expert Users

Monitoring cpu usage of mysql processes/threads/queries without any tool

hi all, i want to monitor mysql processes/threads/queries with respect to cpu usage.how can i do it? show processlist is of no use as no information abt cpu usage is given. plz help (7 Replies)
Discussion started by: rohitmahambre
7 Replies

6. Programming

Solaris CPU/memory status monitoring (Shell script or c++)

i'm trying to find a way to monitor the CPU/Memory status of a solaris station using vmstat. I like to write a small script to periodically run vmstat and store the output. Can anyone show me how (preferrably in C++ if possible)? Thanks in advance. (6 Replies)
Discussion started by: shingpui
6 Replies

7. HP-UX

HPUX monitoring and alerting script per CPU

Hi Guys, Hopefully someone would be able to help me out. Basically I have an HPUX 11.11i system which is backed up by Data Protector 4.5. Every so often the vdba process hangs and chews up 100% of one of the systems CPU resources. As our monitoring tool can only monitor on a per system basis... (3 Replies)
Discussion started by: fulhamfcboy
3 Replies

8. UNIX for Dummies Questions & Answers

monitoring cpu and memory of the unix box

Hi all, Unix has the TOP and SAR command to monitor machine's performance. Can it be used in a script to alert if the cpu utilization is more than 80 or memory used is more than 90. Is SAR preferable than TOP? Please advise. (3 Replies)
Discussion started by: er_ashu
3 Replies

9. Solaris

monitoring cpu

I have a windows snmp server running prtg. I have a solaris 8 v440R server and only see the network statistics for the server. When I try to add a new service to watch for the CPU, I am not offered the results. There is the default sun.mib installed. SNMPDX is not running but mibiisa is. I... (1 Reply)
Discussion started by: csross
1 Replies

10. UNIX for Advanced & Expert Users

Monitoring CPU usage on AIX 5.3 with SNMP

Hi I would like to monitor CPU usage ( %) , memory utilization and such on an AIX 5.3 with snmp. How would I do that ? :confused: If I do "snmpwalk -c public -v1 hosttomonitor" I get nothing about the CPU. I've done this on Linux ( not much trouble doing it on linux ) but I'm having a hard... (2 Replies)
Discussion started by: art
2 Replies
Login or Register to Ask a Question