initial commit

This commit is contained in:
Fabio Scotto di Santolo
2020-07-28 19:28:25 +02:00
commit 4cc88d2f6e
245 changed files with 22820 additions and 0 deletions

52
chapter17/fs_mon_LINUX.ksh Executable file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/ksh
#
# SCRIPT: fs_mon_LINUX.ksh
# AUTHOR: Randy Michael
# DATE: 08-22-2007
# REV: 1.1.P
# PURPOSE: This script is used to monitor for full filesystems,
# which is defined as "exceeding" the FSMAX value.
# A message is displayed for all "full" filesystems.
#
# PLATFORM: Linux
#
# REV LIST:
#
# set -n # Uncomment to check syntax without any execution
# set -x # Uncomment to debug this script
#
##### DEFINE FILES AND VARIABLES HERE ####
WORKFILE="/tmp/df.work" # Holds filesystem data
>$WORKFILE # Initialize to empty
OUTFILE="/tmp/df.outfile" # Output display file
>$OUTFILE # Initialize to empty
THISHOST=`hostname` # Hostname of this machine
FSMAX="85" # Max. FS percentage value
######## START OF MAIN #############
# Get the data of interest by stripping out the rows that
# are not monitored and keeping columns 1, 5 and 6
df -k | tail +2 | egrep -v '/cdrom' \
| awk '{print $1, $5, $6}' > $WORKFILE
# Loop through each line of the file and compare column 2
while read FSDEVICE FSVALUE FSMOUNT
do
FSVALUE=$(echo $FSVALUE | sed s/\%//g) # Remove the % sign
if [ $FSVALUE -gt $FSMAX ]
then
echo "$FSDEVICE mounted on $FSMOUNT is ${FSVALUE}%" \
>> $OUTFILE
fi
done < $WORKFILE
if [[ -s $OUTFILE ]]
then
echo "\nFull Filesystem(s) on $THISHOST\n"
cat $OUTFILE
print
fi