Sponsored Content
Operating Systems HP-UX Formatted TOP command output in file Post 302761019 by Peasant on Friday 25th of January 2013 03:08:22 AM
Old 01-25-2013
Here is what i'm using on my HPUX boxes for basic CPU and DISK monitoring from cron in this manner :
Code:
00,5,10,15,20,25,30,35,40,45,50,55      *    *    *    *    /bin/awk -f /root/monitork /root/mon.data > /dev/null 2>&1

It's not perfect, but suits my needs Smilie

Code:
BEGIN {
cpu=95
stat="1 100"
sms="mailx -s \"`hostname`\" smsaddress@domain.com"
ml="mailx -s \"`hostname` Overload\" mail.address@domain.com"
system("bdf > mon.data")
system("sar -u "stat" >> mon.data")
close("bdf >> mon.data")
close("sar -u "stat" >> mon.data")
}
match($0,/Average/) {
        if ( $2 > cpu ) {
        loadmon="SAR: CPU is above "cpu"% on "$2"% for "substr(stat,3,5) " seconds"
        }
}
match($0,/9[4-9]% \//) {
        diskmon="Mountpoints ALARM "$NF " is on "$(NF -1)
}
match($0,/100% \//) {
        print $NF $(NF -1)
        full="Mountpoints ALARM "$NF " is full"
}
END {
        if ( loadmon != "" ) {
                print loadmon | ml
                }
        if ( diskmon != "" || full != "" ) {
                print diskmon "\n" full | sms
                }
}

Hope that helps.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

mailing customized and formatted ls -lt command output

I'm trying to write a script to email the output of 'ls -lt' command that are 30 days old along with headers for eg. like owner, date, timestamp and a portion of some special character files like 'slfpay$/#:032508AA' in /home/test directory, I just want the numbers from the last field ($9), also... (3 Replies)
Discussion started by: mbak
3 Replies

2. Shell Programming and Scripting

Extract header from top command output

hi, I want to extract and save the cpu(s) information from top command output, but individual cpu statistics separately on a multi-processor machine. In command line, top will show this statistics when we press the switch "1". any ideas? thanks, meharo (3 Replies)
Discussion started by: meharo
3 Replies

3. Shell Programming and Scripting

Need help with shell script - output of top command

I have written shell script to send file as an attachemt of email and output of "top -o res" command as email body. it works fine if i execute manually from prompt but it does not send "top -o res" command output in email body when it is executed via crontab. Any suggestions. My script is below:... (5 Replies)
Discussion started by: needyourhelp10
5 Replies

4. Shell Programming and Scripting

String searching and output to a file in a formatted text

Hi, I'm very new to UNIX scripting and find quite difficult to understand simple UNIX syntax. Really appreciat if somebody could help me to give simple codes for my below problems:- 1) I need to search for a string "TTOH 8031950001" in a files which filename will be "*host*'. For example, the... (3 Replies)
Discussion started by: cuji
3 Replies

5. HP-UX

Sorting top command output in HP_UX 11.11

Hello all, I've been woking on Solaris and Linux (Red Hat) so far but now I've inherited an HP-UX system and having minor issues with syntax...Appreciate if you could help me out here.. 1) I'm trying to sort the output of the top command in HP-UX 11.11 by pressing O (capital O) after typing... (2 Replies)
Discussion started by: luft
2 Replies

6. Shell Programming and Scripting

Capturing first output from 'top'-likes command

Is this a stupid code?? top > top.out & sleep 2 kill %1 cat top.out Thanks, (6 Replies)
Discussion started by: Shawn, Lee
6 Replies

7. UNIX for Advanced & Expert Users

Conflicts in the output of TOP command

Hi All, In the output of TOP command in my unix system, i monitored that some process has utilization more than 100% even some process has 4000% utilisation. Please help me understand how it is possible to show more than 100% utilization. Please see the screenshot below:... (2 Replies)
Discussion started by: anand2308
2 Replies

8. Shell Programming and Scripting

Format Top and prstat command output

need help with formatting output of command top and prstat. My requirment is to remove few columns and display remaining . But when i used awk to do that the output seems to be have gone vague, mixing the column values. After using awk to print particular column the output seems to have lost... (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

9. UNIX for Dummies Questions & Answers

Unable to scroll to the top of the output of a command

Hello, I am a beginner, I have currently Solaris 11 on a vmware machine. Whenever I type a command like 'ls' the screen scrolls to the end of the screen. I am unable to see the entire list of directories and files. I have tried ls |page command, but looking out for a better option. (3 Replies)
Discussion started by: farheenprasad
3 Replies

10. UNIX for Dummies Questions & Answers

Top Command Output is not coming via Cronjob

Dear All, I created a small script to get the CPU, GIS usage etc automatically. However when i run this script manually its working , but when i run through cronjob i am not getting any output. Can anyone please help me on this. I am using SuseLinux. Thank you in advance. #!/bin/sh {... (2 Replies)
Discussion started by: Nitin Kapoor
2 Replies
SA2(8)								Linux User's Manual							    SA2(8)

NAME
sa2 - Write a daily report in the /var/log/sa directory. SYNOPSIS
/usr/lib/sa/sa2 DESCRIPTION
The sa2 command is a shell procedure variant of the sar command which writes a daily report in the /var/log/sa/sardd file, where the dd parameter indicates the current day. The sa2 command handles all of the flags and parameters of the sar command. The sa2 command is designed to be started automatically by the cron command. EXAMPLES
To run the sa2 command daily, place the following entry in your root or adm crontab file: 5 19 * * 1-5 /usr/lib/sa/sa2 -A & This will generate a daily report called /var/log/sa/sardd It will also remove reports more than one week old. FILES
/var/log/sa/sardd Indicate the daily report file, where the dd parameter is a number representing the day of the month. AUTHOR
Sebastien Godard <sebastien.godard@wanadoo.fr> SEE ALSO
sar(1), sadc(8), sa1(8), mpstat(1), iostat(1), vmstat(8) http://perso.wanadoo.fr/sebastien.godard/ Linux DECEMBER 1999 SA2(8)
All times are GMT -4. The time now is 02:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy