Skip to content

Commit

Permalink
Merge pull request #161 from aacole/check-fs-writable
Browse files Browse the repository at this point in the history
adding check-fs-writable.sh
  • Loading branch information
scoop206 authored Apr 27, 2018
2 parents 78d6bb3 + 7b94888 commit 45c22bd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sensu/plugins/check-fs-writable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# checks that all mounts listed in fstab are writeable

mount_status=0

for mount in $( findmnt -sno target | grep -v none ); do
file="${mount}/.tmp-writable-check"
trap '[[ -f "${file}" ]] && rm "${file}"' TERM EXIT

if ! touch "$file" 2>/dev/null; then
echo "FAIL - Could not create a file into '${mount}' !"
((mount_status++))
fi
done

if [[ $mount_status == 0 ]]; then
echo "OK - all fstab mounts are writable"
exit 0
else
echo "CRITICAL - '${mount_status}' mount(s) failing to write data"
exit 2
fi

0 comments on commit 45c22bd

Please sign in to comment.