-
Notifications
You must be signed in to change notification settings - Fork 3
/
checkro.sh
45 lines (39 loc) · 1.47 KB
/
checkro.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Author: Joshua Cagle
# Organization: The University of Oregon
# This script checks for filesystems that are read only. This will
# be used in conjuction with the Zabbix monitoring and alerting system.
# If the script returns 0 then the filesystem in read only mode.
# This script uses a non-exhaustive case statment of potential mount paths,
# yet they are common in our environment.
# In order to use this a Zabbix configuration fragment will have to be made.
# It should look like this:
# UserParameter=checkro[*],/etc/zabbix/scripts/checkro.sh $1
mountPoint=$1
# Ensures that one parameter is used while using script.
[ "$#" -eq 1 ] || { echo "usage: checkro.sh <mountPoint> "; exit 1; }
case "$1" in
/)
regex="^rootfs\s/\s"
;;
/dev/mapper/VolGroup00-LogVol00)
regex="^/dev/mapper/VolGroup00-LogVol00\s/\s"
;;
/boot)
regex="^/dev/sda1\s/boot\s"
;;
*)
echo "Please enter a supported path."
exit 128
;;
esac
# Checks /proc/mounts for regular expressions that match mounted filesystems.
# Then checks to see if found string has read/write (rw) enabled. If read/write
# is enabled then the script returns a 1, if not it returns a 0. I will create
# an item and trigger in Zabbix to trigger on a 0.
if cat /proc/mounts | grep ${regex} | grep "\srw" > /dev/null
then
echo 1
else
echo 0
fi