You are here:

ActiveXperts.com > Support > ActiveXperts Network Monitor > Online > Linux > Directory Size check

ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Monitor a directory on Linux using an SSH Secure Shell Script

The following script can be used in ActiveXperts Network Monitor to check a directory on a remote LINUX machine:

#################################################################################
# ActiveXperts Network Monitor  - shell script checks
# © 1999-2008, ActiveXperts Software B.V.
#
# For more information about ActiveXperts Network Monitor and SSH, please
# visit the online ActiveXperts Network Monitor Shell Script Guidelines at:
#   http://www.activexperts.com/support/network-monitor/online/linux/
#################################################################################

#!/bin/sh

# Validate number of arguments
if [ $# -ne 2 ] ; then
  echo "UNCERTAIN: Invalidi number of arguments - Usage: directory_size  "
  exit 1
fi

# Check the size of the directory specified
if [ -d "$1" ]; then
  SIZE=`du -s "$1" | awk '{ print $1; }'`
  if [ $SIZE -le $2 ] ; then
	  echo "SUCCESS: Size of directory=[$SIZE KB], maximum allowed=[$2 KB] DATA:$SIZE"
  else
	  echo "ERROR: Size of directory=[$SIZE KB], maximum allowed=[$2 KB] DATA:$SIZE"
  fi
else
  echo "UNCERTAIN: $1 is not a directory"
fi