

#Monit disk space how to#
See blog post “ Shell script to watch the disk space and send an email” about how to use this script. Mail -s "Alert: Almost out of disk space $usep" " $ADMIN" fi done # - # Linux shell script to watch disk space (should work on other UNIX oses ) # SEE URL: # set admin email so that you can get email ADMIN= dot com" # set alert level 90% is default ALERT= 90 df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '' ) if then echo "Running out of space \" $partition ( $usep%) \" on $(hostname) as on $(date)" | With the addition of our suggested arguments, these commands are ready to to be part of your sysadmin toolkit.#!/bin/sh # Shell script to monitor or watch the disk space # It will send an email to $ADMIN, if the (free avilable) percentage # of space is >= 90% # - # Copyright (c) 2005 nixCraft project # This script is licensed under GNU GPL version 2.0 or above # - # This script is part of nixCraft shell script collection (NSSC) # Visit for more information. At the basic level, each command gives you the information that you need. No matter if you are a relative newcomer or a seasoned sysadmin, both commands are absolutely essential for the smooth running of your Linux machines. The df and du commands are deceptively simple but immensely powerful. This can be a relative path, from our current location, or an absolute path. Similar to other linux commands we don’t always need to run the du command from within the target directory, rather we can specify a path to a target directory. If we just want to know the total size of the directory and its subdirectories, adding -s as an argument will return just the total. Simplify the output to just show the total directory size. Add the -h argument to make du return results in megabytes and gigabytes.

The output of this command is quite straightforward: it lists the size of each sub directory and then the name and then finally on the last line returns the sum of all the subdirectory sizes to give the directory disk usage.Ģ. Note that similar to the df command, in its standard form the du command returns values in kilobytes. Move to a directory, list its contents and then check disk usage.
#Monit disk space free#
This free disk space monitoring tool keeps you abreast of which servers are getting close to low disk space conditions so you can prevent server downtime and unexpected failures.

You can use any directory with contents on your system to try these commands.ġ. Netwrix Disk Space Monitor automatically monitors low disk space on multiple servers for you. In the following examples we have used our Music directory which contains 3 subdirectories containing mp3’s. The du command is useful for this and works in a similar way to the df command we looked at earlier. Often we might simply want to check how much room a file or directory is using.
