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

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

df -k

to get the volume of the drive,

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

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

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.

#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"

I wonder if your issue is not network related... Am I seeing a NFS mount? ... If so not a good idea...

1 Like