I have a Linux system, and I am continuously running a backup of my files to a external hard drive. One time, I encountered an error where my system can no longer copy files to my External HDD because it has lost its writing permission.

I know that there is no built-in sensor that could help me with this issue, and this is quite tricky.

I am thinking of a workaround where I will use SSH Disk free sensor to monitor the external HDD, and I want it to notify me if the disk space is not changing anymore. However, I can't find a way that PRTG will trigger a notification if this happens.

Any inputs will be appreciated.

Thanks


Article Comments

Hi,

you can use our SSH Script-Sensor for this.

You have to create a script with the following content in the path /var/prtg/scripts/ on your Linux-Machine:

#!/bin/bash
TOUCH="/usr/bin/touch"
RM="/bin/rm"
GREP="/bin/grep"

PATH="$1"
if [ `echo $PATH | $GREP '/$'; echo "$?"` -eq 1 ]; then
  PATH+="/"
fi
PATH+="testfile_prtg"

# check if the path exists
if [ -d "$1" ]; then
  # check if the path is writable
  if [ `$TOUCH "$PATH" 2> /dev/null; echo "$?"` -eq 0 ]; then
    # if it is writable return "1"
    echo "0:1:OK"
    # and then remove the file:
    $RM "$PATH"
  else
    # if not return "0"
    echo "2:0:Path '$1' is not writable!"
  fi
else
  # notify the user to check the path-parameter
  echo "1:0:Path '$1' does not exist!"
fi

After making it executable you can add the ssh-script-sensor in PRTG and provide the path to check as parameter in the sensor settings. If the path is not writable you will be alerted with a down-state, if the path does not exist you will see a warning-state.

Kind regards


Dec, 2012 - Permalink

Wow, thank you a lot! That's exactly what I am looking for. Anyway, I'm sorry but I'm really not familiar with these scripts, may I know where exactly should I insert the path that I want to monitor in this script?

Thanks!


Dec, 2012 - Permalink

The path needs to be applied as a parameter in the sensor settings: Screenshot sensor settings

For testing purposes you can also add it as a commandline-parameter during execution, e. g. '/var/prtg/scripts/is_writable.sh /home/testuser'.


Dec, 2012 - Permalink

Thank you for your quick response. I have successfully created a script on my Linux and use it on my SSH Script sensor. It worked, however, it always says that the path is not writable even though I can write files in that path. I am using root as its SSH credentials. Are there any adjustments that needed to be done?


Dec, 2012 - Permalink

Maybe the paths for the 3 commands at the start of the script need to be adjusted to your system. Try to figure out which paths are correct on your system using 'which <command (touch|rm|grep)>' and modify the variables to the results.

Kind regards


Dec, 2012 - Permalink