calculate usage from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting calculate usage from file
# 1  
Old 07-27-2010
calculate usage from file

Hello folks,

i have a file courierimapuiddb that have contents like

Code:
1 1280206508 4  
1 1280206466.V805I169cM853838.xxx
2 1280207962.V805I16d5M343672.xxx
3 1280208055.V805I16d6M20816.xxx

1280206508 above means total size and its decreasing when file added in directory. when total size utilization >= 90% then i got notification that you have how many percent left space. It will read from first line to last line to get how much percent left.

I want to check above things under below all directories where that file "courierimapuiddb" exist.

Code:
/directory/name/

thanks.
# 2  
Old 07-27-2010
if u already have the script that does for you and you only want to run it on every file.

then you can you below :-

Code:
for file in `find . -name "courierimapuiddb"`
do 
(UR_SCRIPT) $file #pass the file as a parameter...
done

# 3  
Old 07-27-2010
No i dont have script for that. Can you please suggest.
# 4  
Old 07-27-2010
what i understand is that in whichever directory you have "courierimapuiddb" file.. search for this file and find the size of that directory and see if its full or not..
if this is what you looking for ,.. then you can try something like this.

Code:
find . -name "courierimapuiddb" exec 
 find . -name "courierimapuiddb" -exec bdf {} \;

i this will help you
# 5  
Old 07-27-2010
From input, what's the total size , what's the used size?

Do you mean 1280206508 is the total size, how about the rest numbers?
# 6  
Old 07-27-2010
Below is the output of a bdf command.. it will help you in what you are asking me..

Code:
Filesystem - the directory path
kbytes - total size of the directory
used - how much of the size is used
avail  -  available free size in (kb)
%used  - %used tells you that much % of your directory is used.
Mounted on - tell you how on which drive its mounted.

i hope this helps you....
# 7  
Old 07-27-2010
Ok, that's similar output as df command.

Code:
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 20174761 3680421 16292593 19% /
/dev/dsk/c1t3d0s0 19628617 9 19432322 1% /dumps
/dev/dsk/c1t2d0s3 20655529 2352836 18096138 12% /usr

So if I got above O/P, how to use with your file courierimapuiddb ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to calculate the max cpu usage from the main script

Hi All, I have a script which does report the cpu usuage, there are few output parameter/fields displayed from the script. My problem is I have monitor the output and decide which cpu number (column 2) has maximum value (column 6). Since the output is displayed/updated every seconds, it's very... (1 Reply)
Discussion started by: Optimus81
1 Replies

2. Linux

How to calculate total CPU usage from SAR report?

Hi, I want to calculate the total cpu usage from the sar report. Say for example, Linux 2.6.24-21-generic (blade10) 09/10/2012 04:54:36 PM CPU %user %nice %system %iowait %steal %idle 04:54:37 PM all 0.00 0.00 0.00 0.00 ... (1 Reply)
Discussion started by: rohitmd
1 Replies

3. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

4. Shell Programming and Scripting

calculate swap space usage in Solaris and converts it in Percentage

Hi Folks, I am looking for a way to write a script to calculate swap usage in Solaris so that the current usage will be shown in Percentage value. Thanks!! Based on 'swap -s' command # swap -s total: 1378936k bytes allocated + 1236880k reserved = 2615816k used, 2725104k available (2 Replies)
Discussion started by: jaapar
2 Replies

5. Shell Programming and Scripting

Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For... (6 Replies)
Discussion started by: poweroflinux
6 Replies

6. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

7. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

8. Shell Programming and Scripting

Calculate the time difference between a local file and a remote file.

I m stuck with a issue. I need to calculate the time difference between two files.. one on the local machine and one on the remote machine using a script. Can any one suggest the way this can be achevied Thanks, manohar (1 Reply)
Discussion started by: meetmano143
1 Replies

9. Shell Programming and Scripting

Calculate disk usage in different servers

Hello, I'm writing a script to monitor different filesystems in multiple servers. And depending on the % free, my script will send an Alert email if % free is less than threshold. I want to keep a input_feed_file which would have "server,filesystem". If I run a script a host 'a', then I can... (3 Replies)
Discussion started by: bperl
3 Replies

10. Shell Programming and Scripting

How to calculate Memory and CPU Usage on AIX

I have written a script that will calculate CPU usage and Memory usage of a particular process on AIX Unix. I know the PID and I am using the command -- # for CPU Usage MSG_CPU_USG=`ps uax | grep ${PID} | awk {'print $3'}` #for Memory Usage MSG_MEM_USG=`ps uax | grep ${PID} | awk {'print... (0 Replies)
Discussion started by: asutoshch
0 Replies
Login or Register to Ask a Question