Script - SUM SIZE


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script - SUM SIZE
# 1  
Old 11-08-2013
Script - SUM SIZE

Hello,

I need help. I working a a script that will get back directory size.

I am on linux.

I am using
Code:
du -sk

to get the size of directories.

But, as the script is launch under nagios, i need to find a work aound to get rid of time out issue due to the large amount of files in one of the directory.

so, I am using
Code:
df -k

to get the volume of the drive,

Code:
df -k /dir1/dir2/dir3/home
Sys. de fichiers      1K-blocs   Utilisé    Dispo. Uti% Monté sur
servername:/vol/vol_DIR
                    2771596096 2436947392 334648704  88% /dir1/dir2/dir3

then the script is looking with
Code:
du -sk

to get the size from the directories.

I need help to sum the size result from the directories and then substract the result of the command
Code:
df -k

.

here is the first part. I do not know how I could make this work ? Help needed. Thanks in advance for your help, and time.


Code:
#df -k /dir1/dir2/dir3/home > check_dir_size.log
size=`du -sk ${chemin_dir} | awk '{print $1}'`
#echo ${size} >> check_dir_size.log
size_gb=`echo "scale=3; $size/1024/1024" | bc -l`
exitmsg="size=$size ko - size in gb=$size_gb gb|size="$size_gb"gb;$warn;$crit"


Last edited by vbe; 11-08-2013 at 09:49 AM.. Reason: rm little fonts in last code...
# 2  
Old 11-08-2013
I wonder if your issue is not network related... Am I seeing a NFS mount? ... If so not a good idea...
This User Gave Thanks to vbe For This Post:
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 find the sum of argument passed to the script

I want to make a script which takes the number of argument, add those argument and gives output to the user, but I am not getting through... Script that i am using is below : #!/bin/bash sum=0 for i in $@ do sum=$sum+$1 echo $sum shift done I am executing the script as... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

2. UNIX for Dummies Questions & Answers

How to get the set of files size as a sum in a directory.

Hi, Can someone help me to get the complete files size (sum) over a perod time (1 day,2days)in a directory. eg: Directory :ABC I have a1,a2,a3 files are created in last 24 hours so I need to get the some of all these files. I am using the below find command but its giving me the... (1 Reply)
Discussion started by: gaddamja
1 Replies

3. Shell Programming and Scripting

Script to read file size and send email only if size > 0.

Hi Experts, I have a script like $ORACLE_HOME/bin/sqlplus username/password # << ENDSQL set pagesize 0 trim on feedback off verify off echo off newp none timing off set serveroutput on set heading off spool Schemaerrtmp.txt select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies

4. UNIX for Advanced & Expert Users

size for sum variable limitation on awk

Hello first, truth been told, I'm not even close to be advanced user. I'm posting here because maybe my question is complicated enough to need your expert help I need to use awk (or nawk - I don't have gawk) to validate some files by computing the total sum for a large numeric variable. It... (1 Reply)
Discussion started by: cwitarsa
1 Replies

5. Shell Programming and Scripting

Sum of file size in directory / subdirectory

Hi , I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level .. #!/bin/ksh FNAME='.pdf' S_PATH=/abc/def/xyz find $S_PATH -exec ls -lad... (4 Replies)
Discussion started by: Vaddadi
4 Replies

6. Solaris

calculate sum size of files by date (arg list too long)

Hi, I wanted a script to find sum of files for a particular date, below is my script ls -lrt *.req | nawk '$6 == "Aug"' | nawk '$7 == "1"'| awk '{sum = sum + $5} END {print sum}' However, i get the error below /usr/bin/ls: arg list too long How do i fix that. Many thanks before. (2 Replies)
Discussion started by: beginningDBA
2 Replies

7. Shell Programming and Scripting

How to traverse directory structure and sum size of files?

How do I write a bash or ruby or perl or groovy script to print all the files in my directory tree that are one-to-two years old, the size of each file, and the sum of file sizes and then delete them? I was using find . -atime +365 -exec rm '{}' \; but the problem was that I could not... (5 Replies)
Discussion started by: siegfried
5 Replies

8. Shell Programming and Scripting

Sum up files whose size Kbytes and Mbytes

Hello Friends, When i type du -sh *.jar | sort -n under a library directory i get a result similar below output: 1M 1.jar 2.4M 2.jar 4.5M 3.jar . . . . . . 1K (n-2).jar 15K (n-1).jar 77.7K n.jar I want to sum up the size... (1 Reply)
Discussion started by: EAGL€
1 Replies

9. Shell Programming and Scripting

Function SUM SIZE

Dear Friends, I wrote a script that get the size of specific files in a specific space directory. To get the total size I wrote a function in that script. So far I am not convinced that function is working correctly. Do you mind tell if there is anything wrong. I am on SOLARIS (KSH)... (4 Replies)
Discussion started by: Aswex
4 Replies

10. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies
Login or Register to Ask a Question