--- /dev/null
+#!/bin/sh
+
+if [ $# -lt 2 ]
+then
+ echo "Usage: $0 <fs> <percentage> [email]"
+ echo "Where"
+ echo " fs - file system to check"
+ echo " percentage - acceptable file system usage treshold"
+ echo " email - send warning to specified e-mail address (print to stdout, if omitted)"
+ echo "Example: $0 / 95 admin@cutekittens.tld"
+ exit
+fi
+
+if [ $(df -m $1 | sed 1d | awk '{print $5}' | sed "s/%//") -ge $2 ]
+then
+ subject="WARNING! File system usage ($1) on $(hostname) is higher than $2 percent!"
+ if [ -z "$3" ]
+ then
+ echo ${subject}
+ df -m
+ else
+ df -m | mail -s "${subject}" $3
+ fi
+fi
--- /dev/null
+#!/bin/sh
+
+if [ $# -lt 1 ]
+then
+ echo "Usage: $0 <fs> [email]"
+ echo "Where"
+ echo " fs - file system to check"
+ echo " email - send warning to specified e-mail address (print to stdout, if omitted)"
+ echo "Example: $0 /srv/remoteshare admin@cutekittens.tld"
+ exit 1
+fi
+
+make_command()
+{
+ if [ -z "$1" ]
+ then
+ echo "cat"
+ else
+ echo "mail -s \"$subject\" $1"
+ fi
+}
+
+if ! mount | grep "on $1 type nfs" > /dev/null
+then
+ subject="WARNING! Network file system ($1) on $(hostname) is not mounted!"
+
+ [ -z "$2" ] && echo "${subject}"
+ CMD=$(make_command "$2")
+ eval ${CMD} << EOT
+This is to inform you that no NFS is mounted at $1.
+Please investigate immediately!
+EOT
+exit 2
+
+elif ! timeout 15 stat "$1" > /dev/null
+then
+ subject="WARNING! Network file system ($1) on $(hostname) is hanging/unreachable!"
+
+ [ -z "$2" ] && echo "${subject}"
+ CMD=$(make_command "$2")
+ eval ${CMD} << EOT
+This is to inform you that network share $1 is hanging/unreachable.
+
+Mount details:
+
+$(mount | grep "$1")
+
+Please investigate immediately!
+EOT
+exit 3
+
+fi
+++ /dev/null
-#!/bin/sh
-
-if [ $# -lt 2 ]
-then
- echo "Usage: $0 <fs> <percentage> [email]"
- echo "Where"
- echo " fs - file system to check"
- echo " percentage - acceptable file system usage treshold"
- echo " email - send warning to specified e-mail address (print to stdout, if omitted)"
- echo "Example: $0 / 95 admin@cutekittens.tld"
- exit
-fi
-
-if [ $(df -m $1 | sed 1d | awk '{print $5}' | sed "s/%//") -ge $2 ]
-then
- subject="WARNING! File system usage ($1) on $(hostname) is higher than $2 percent!"
- if [ -z "$3" ]
- then
- echo ${subject}
- df -m
- else
- df -m | mail -s "${subject}" $3
- fi
-fi