LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-15-2012, 01:38 PM   #1
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Rep: Reputation: Disabled
df vs du and Alert messges


Hi to all;

Every time i am getting superb reply from here ..
Thanks once again in advance !!
I need main difference between du vs df command. I worked very well both commands.

PHP Code:
du -> shows  each file system uasge in kb's
df -> shows disc  partions used and avail. 
1. Except above mentioned what's the main difference ?
2. df -ah -> shows dummy file systems (i could n't understand)
Showing none -> what's here ?
o/p is here ..

PHP Code:
root@localhost ~]# df -ah
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              26G   19G  6.1G  76% /
none                     0     0     0   -  /proc
none                     0     0     0   
-  /sys
none                     0     0     0   
-  /dev/pts
/dev/sda1              99M   12M   83M  12% /boot
none                  506M     0  506M   0
% /dev/shm
/dev/sda3             2.0G   36M  1.8G   2% /tmp
none                     0     0     0   
-  /proc/sys/fs/binfmt_misc
.host:/               245G  127G  118G  52% /mnt/hgfs
none                  0.0K  0.0K  0.0K   
-  /proc/fs/vmblock/mountPoint
sunrpc                   0     0     0   
-  /var/lib/nfs/rpc_pipefs 
PHP Code:
root@localhost ~]# cd /home/rose
root@localhost rose]# du  -c
4       ./oo
8       
./roselin
4       
./abc
4       
./bbbbb
4       
./rose
4       
./rosalin
4       
./xxx
4       
./xxxx
4       
./level1/kevel2/kevel3
12      
./level1/kevel2
16      
./level1
4       
./size
112     
.
112     total 
3. $ du -sh * -> showed only level 1 size.
here how can i check sub_dir space with out level-1 dir ?
i mean separately i need kevel2 size and kevel3 size.

PHP Code:
/dev/sda5              26G   19G  6.1G  76% / 
It's going to reach 90% very soon. I am planning to enable mobile alert or e-mail alert.

4. how can i configure alerts when reaching 90% ?


Thanks and Regards
Thiyagusham
 
Old 11-15-2012, 01:46 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,754
Blog Entries: 14

Rep: Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052
df deals ONLY with filesystems.

du deals with files of any sort including directories. Since filesystems are mounted on special directories called "mount points" it can some times seem to be the same thing but it it is NOT.

If for example you had a filesystem called /usr and another one called /usr/share when you ran "df /usr" it will show you only the space assigned to the filesystem /usr and NOT what is in /usr/share filesystem. "du /usr" on the other hand would show you the space in /usr INCLUDING what is in /usr/share because /usr/share is a subdirectory of /usr even though it is separate filesystem.

Also it is incorrect to say that one or the other reports in KB on Linux. They report in whatever you tell them to report in or if you use "-h" whatever makes sense for the size they see.

Last edited by MensaWater; 11-15-2012 at 02:31 PM.
 
1 members found this post helpful.
Old 11-16-2012, 07:31 AM   #3
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Original Poster
Rep: Reputation: Disabled
@ hello to all ;

I did n't get reply for some more questions from this thread.
Can anyone post your answers .. I am Expecting still ,...
 
Old 11-16-2012, 10:16 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,286

Rep: Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423Reputation: 1423
It's not clear what additional information you seek. The df command simply reads the counters that the kernel constantly maintains for the number of allocated blocks and inodes on a file system. That is a very quick operation. The du command descends through the directory tree from whatever starting point you specify and reads out the sizes of everything it finds. The output from df always shows the true state of the file system (assuming a non-corrupted file system, of course). There are several ways that files can be invisible to du and still occupy space in the file system.
 
1 members found this post helpful.
Old 11-16-2012, 10:29 AM   #5
mandyapenguin
Member
 
Registered: Nov 2011
Location: India
Distribution: RedHat, Cent OS, Fedora, Debian, Ubuntu
Posts: 106

Rep: Reputation: Disabled
Quote:
Every time i am getting superb reply from here
I didn't understand! What does it mean?

Quote:
I did n't get reply for some more questions from this thread.
Can anyone post your answers .. I am Expecting still
1) Did you read 1st reply, in which it is clearly answered for difference between du and df?

2) Why can you not try once?
Code:
man du
man df
df --help
du --help
I think this may also help you a bit?

3) you can use find command to check 1/2/3 subdirectories size. For example
Code:
find /home/username/ -maxdepth 2 -type d -exec du -sh {} \;
This will shows 2 more directories size starting from/inside /home/username.

4)
Quote:
It's going to reach 90% very soon. I am planning to enable mobile alert or e-mail alert.
This below small script may help you for the above,
Code:
cat check_disk_usage 

#!/bin/bash
admin="you@yourdomain.com"
max="90"   # To get mail immediately reduce this to 5 or 10 and watch.
df -H | grep -vE '^Filesystem' | awk '{ print $5 " " $1 " " $6 }' | while read output;
do
  usage=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  mountpoint=$(echo $output | awk '{ print $3 }' )
  if [ $usage -ge $max ]; then
    echo "The \"$partition\" partition which is mounted as \"$mountpoint\" has reached \"$usage%\" in $(hostname) PC."| mail -s "Alert on disk usage" $admin
  fi
done
Add this to crontab using "crontab -e" command as a root user. For example add the entry as below in the end of the file.
Code:
01 10 * * * /path/of/check_disk_usage >/dev/null 2>&1
This will run at every morning 10:01 am.
Code:
chmod +x /path/of/check_disk_usage
Hope the above will help you.

Last edited by mandyapenguin; 11-16-2012 at 10:53 AM.
 
1 members found this post helpful.
Old 11-16-2012, 10:35 AM   #6
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Original Poster
Rep: Reputation: Disabled
@ mandyapenguin

I am very clear with du & df commnads. No problem!
Really i was expecting answers for 3rd and 4th question.
Thank you very much!
 
Old 11-16-2012, 10:48 AM   #7
mandyapenguin
Member
 
Registered: Nov 2011
Location: India
Distribution: RedHat, Cent OS, Fedora, Debian, Ubuntu
Posts: 106

Rep: Reputation: Disabled
Quote:
Originally Posted by thiyagusham View Post
@ mandyapenguin

I am very clear with du & df commnads. No problem!
Really i was expecting answers for 3rd and 4th question.
Thank you very much!
You are welcome.
And also can you make this thread as solved from thread tools if it could helped you?

Last edited by mandyapenguin; 11-16-2012 at 10:51 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
OPENNMS -how can i get disk space alert & memory alert BY MAIL saravanakumar Linux - Server 11 05-30-2014 08:45 AM
opennms --memory alert & disk alert issue saravanakumar Linux - Server 4 07-19-2011 10:54 AM
strange messges when closing X adds2one Slackware 4 11-24-2005 06:23 AM
message in /var/log/messges hereshashi Linux - Security 2 08-03-2005 08:00 PM


All times are GMT -5. The time now is 07:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration