Filesystem Checker

A “quick&dirty” script to check FS usage on a Linux machine. If above a certain threshold it is possibile to define any action (e.g. send an email)

#!/bin/bash

FS=$1
THRESHOLD=$2

echo “Checking Filesystem ” $FS “with threshold “$THRESHOLD

SIZE=$(df -h $FS | grep $FS | awk ‘{print $1}’)
USED=$(df -h $FS | grep $FS | awk ‘{print $2}’)
AVAIL=$(df -h $FS | grep $FS | awk ‘{print $3}’)
PERC_USAGE=$(df -h $FS | grep $FS | awk ‘{print $4}’)

echo “Size: ” $SIZE
echo “Used: ” $USED
echo “Avail: ” $AVAIL
echo “Perc Usage: ” $PERC_USAGE

PERC=$(echo $PERC_USAGE | awk -F’%’ ‘{print $1}’)

if [[ $PERC -gt $THRESHOLD ]]
then
echo “Filesystem Usage above threshold!!!”
fi

Display Archive Log Generation


— Display Archive Log Generation by Day

SET PAUSE ON
SET PAUSE ‘Press Return to Continue’
SET PAGESIZE 60
SET LINESIZE 300
SET VERIFY OFF

COL “Generation Date” FORMAT a20

SELECT TRUNC(completion_time) “Generation Date” ,
round(SUM(blocks*block_size)/1048576,0) “Total for the Day in MB”
FROM gv$archived_log
GROUP BY TRUNC(completion_time)
ORDER BY TRUNC(completion_time)
/