Skip to content

Instantly share code, notes, and snippets.

@zxjinn
Created December 23, 2012 06:33
Show Gist options
  • Save zxjinn/4362311 to your computer and use it in GitHub Desktop.
Save zxjinn/4362311 to your computer and use it in GitHub Desktop.
Simple read/write to ensure the file system is writeable. File to read/write is currently fixed, but contents are dynamic (uses $RANDOM). Designed to be used with Nagios.
#!/bin/bash
RANDOMFILE="/tmp/${RANDOM}-${RANDOM}-${RANDOM}.txt"
RANDOMCONTENTS="${RANDOM}${RANDOM}${RANDOM}"
export $SUVVESS="3"
function writeit()
{
touch $RANDOMFILE
echo -n $RANDOMCONTENTS > $RANDOMFILE
RETVAL=$?
return ${RETVAL}
}
function readit()
{
VALUEREAD=$(cat $RANDOMFILE)
if [ $VALUEREAD -eq $RANDOMCONTENTS ]; then
export SUVVESS="0"
else
export SUVVESS="1"
fi
return $SUVVESS
}
function deleteit()
{
rm $RANDOMFILE
}
writeit
readit
deleteit
exit $SUVVESS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment