Script to clean nmon logs on AIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to clean nmon logs on AIX
# 1  
Old 09-02-2008
Script to clean nmon logs on AIX

I use NMON (Nigels Monitoring) in AIX. It creates a daily nmon log with the naming conventions of:
hostname_YYMMDD_0000.nmon
or
myserver_080902_0000.nmon

What I am interested in doing is creating a script that is executed on the first of each month to clean up last months *nmon files. . .what I mean by clean up is that it would create a directory in the format of yyyymm and move all of last months files in that newly created directory.

The problem is that each hostname is of different lengths (since I would be using this on different hosts). . .so it's difficult to use the "cut" command because the length of characters will differ from box to box.

I would appreciate any assistance you can lend.

outta.
# 2  
Old 09-02-2008
How about using find?

find dirname -mtime +30 -exec rm -f {} \;

Adjust to suit. This clearly won't delete things from the previous month, but those older than 30 days.
# 3  
Old 09-02-2008
I don't want to delete though. . .just move to the newly created directory. I could use the find though and just move them in. . .good idea.
# 4  
Old 09-03-2008
BTW, you can have cut seperate field based on a particular character, in your case, you could get the date section out by running:
Code:
echo $filename | cut -d '_' -f 2

# 5  
Old 09-04-2008
Quote:
Originally Posted by outtacontrol
I use NMON (Nigels Monitoring) in AIX. It creates a daily nmon log with the naming conventions of:
hostname_YYMMDD_0000.nmon
or
myserver_080902_0000.nmon

What I am interested in doing is creating a script that is executed on the first of each month to clean up last months *nmon files. . .what I mean by clean up is that it would create a directory in the format of yyyymm and move all of last months files in that newly created directory.

The problem is that each hostname is of different lengths (since I would be using this on different hosts). . .so it's difficult to use the "cut" command because the length of characters will differ from box to box.

I would appreciate any assistance you can lend.

outta.


Give a try on this:

Code:
find dir -name "*$(date +%m%y -d "1 month ago")_0000.nmon" -mtime+1 -exec mv {} new_dir/  \;

And add it in the cron table to run on 1st of everymonth.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. AIX

Run nmon on other server through script

Hai All, Iam new to AIX unix. Im just tryin to automate my monitoring work and hence i have writen a basic script in which i am running nmon on multiple nodes from a main node. say for ex: From server a : ssh server b nmon -MB -s1 -c1 > nmon_now.txt gave the password and... (7 Replies)
Discussion started by: jayadeava
7 Replies

3. AIX

ORACLE Database running slow on AIX ( nmon / topas )

Hello, How can I know if ORACLE Database is running slow due to Memory or due to processing power ? I have only Oracle Database running on a P4 with 4GB RAM. Could anyone suggest any tools which can help me determine exactly if it is memory issue or processor issue. (43 Replies)
Discussion started by: filosophizer
43 Replies

4. AIX

aix and nmon

Hi All, First of all, I am a DBA and not an AIX admin. I am new at using this NMON tool. In interactive mode, I can start nmon, push 't' to have the list of process with their statistic (ie cpu% etc.). I would like to know if there is a way to redirect that screen output into a log... (1 Reply)
Discussion started by: Nayas
1 Replies

5. Shell Programming and Scripting

How to clean this script?

Hello guys, this script partially works but it's still pretty ugly and, moreover, if the month is jan/feb/mar... it doesn't work at all. Could anyone say me how to correct, cut and clean a little bit? #!/usr/bin/ksh egrep -v -e "^\s*#" /file/permission | awk '{ print $1 }' | sort | uniq... (3 Replies)
Discussion started by: gogol_bordello
3 Replies

6. AIX

need help on NMON in AIX

HI, I have downloaded nmon 3.3c nmon analyzer, and run the command on aix ./nmon -f After that I have terminated the process and found .nmon file. when i have tried to open that file in nmon analyzer i.e in excel I am getting the error "no valid input data nmon run may have failed" ... (8 Replies)
Discussion started by: manoj.solaris
8 Replies

7. AIX

Top command in AIX 4.2 (no topas, no nmon, no top)?

Is there a 'top' command equivalent in AIX 4.2 ? I already checked and I do not see the following ones anywhere: top nmon topas (1 Reply)
Discussion started by: Browser_ice
1 Replies

8. AIX

nmon in aix

Hi, I want to know how to use nmon in aix? I have donwloaded nmon (2 Replies)
Discussion started by: manoj.solaris
2 Replies

9. AIX

location of logs on AIX 4.3 and 5.3

Hi All, I would like to know where's the location of ALL system error logs on AIX43 and AIX53. Thanks, itik (1 Reply)
Discussion started by: itik
1 Replies

10. Shell Programming and Scripting

clean up script

I have a script which would monitor a given directory and delete any files which are older than 10 days. I was going to set the 10 crob jobs to perform this operation for 10 different directories (some are actually sub-directories), but my boss doesn't like that idea, so I need to do that in one... (1 Reply)
Discussion started by: mpang_
1 Replies
Login or Register to Ask a Question