Hi, my company uses prtg "ssh disk free" to monitor Ubuntu snap partitions. Snap partitions are (by default) very small, so fill up quickly and alarm during out of hours. I am trying to find a way to prevent snap partitions being monitored.

I have tried modifying the 'df' that runs on he server with an alias:

  • The "ssh disk free" check performs the periodic command: df -TP -x tmpfs -x devtmpfs -x debugfs

I created a new user and a bash alias on the client server for df: alias df="df -x squashfs"

I was attempting to modify df so it wouldn't display squashfs. the df would be running the command df -TP -x tmpfs -x devtmpfs -x debugfs -x squashfs

However, the logs generated have not changed.

Can anyone advise me? Thanks


Article Comments

Hi Daniel,

Thank you for your message.

To avoid the SSH Disk Free sensor to create channel for new snap partitions, I invite you to create the sensor anew. When doing that, please make sure to keep the snap partitions not selected/enabled.

The sensor should not create snap channel anymore afterwards.

Regards.


Sep, 2022 - Permalink

Thanks for your reply. I appreciate it. Does PRTG off the possibility to modify checks/commands such as 'df'?

Thanks


Sep, 2022 - Permalink

Hi Dianel,

I'm afraid that it is not possible to modify the command executed by the sensor. However, you have the possibility to use yours via a custom script, executed by the SSH Script or SSH Script Advanced sensor.

In that case, the script must return a response in the corresponding format: https://www.paessler.com/manuals/prtg/custom_sensors

If you have further questions, do not hesitate.

Regards.


Sep, 2022 - Permalink

In the end the solution was to write a script, which can be seen here:

#!/bin/bash
# filename: check_prtg_free_bytes.sh
# author: D P Loizos daniel.loizos@gmail.com
# create date: 20/9/2022
# description: a PRTG check that displays free bytes, for various filesystems, ignoring tmpfs, devtmpfs, squashfs. PRTG prefers XML as its output machanism.

# get mount name
MOUNT=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Filesystem' | awk '{print $7}')
MOUNT_ARRAY=( $MOUNT )

# get free bytes
FREEB=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Available' | awk '{ print $5}')
MOUNT_FREEB=( $FREEB )

# build the XML file, iterating through two arrays
echo "<prtg>"
n=0
for i in "${MOUNT_ARRAY[@]}"
do
        echo "  <result>"
        echo "    <channel>Mount: $i</channel>"
        echo -e "      <value> ${MOUNT_FREEB[n]} </value>"
        n=$(($n+1))
        echo "  </result>"
done

echo "</prtg>"

Sep, 2022 - Permalink

Hi Daniel,

Thank you for your feedback and for sharing a script.

Do not hesitate to contact the support again if needed.

Have a great day.

Regards.


Sep, 2022 - Permalink

I have updated the script. In my output, it will give the percent free space left on the disk, and will give warning when its below 10%, and error when its below 5%.

  1. !/bin/bash
  2. filename: check_prtg_free_bytes.sh
  3. author: D P Loizos daniel.loizos@gmail.com
  4. create date: 20/9/2022
  5. description: a PRTG check that displays free bytes, for various filesystems, ignoring tmpfs, devtmpfs, squashfs. PRTG prefers XML as its output machanism.
  • get mount name
MOUNT=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Filesystem' | awk '{print $7}')
MOUNT_ARRAY=( $MOUNT )
  • get free bytes
FREEB=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Available' | awk '{ print $5}')
MOUNT_FREEB=( $FREEB )
  • get total bytes
PERCENT=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Available' | awk '{ print $6}')
MOUNT_PERCENT=( $PERCENT )
  • build the XML file, iterating through two arrays
echo "<prtg>"
n=0
for i in "${MOUNT_ARRAY[@]}"
do
        percent=${MOUNT_PERCENT[n]}
        percent=${percent%\%}
        percent=$((100-percent))
        echo "  <result>"
        echo "    <channel>Freespace on Mount: $i</channel>"
        echo -e "      <value> $percent </value>"
        n=$(($n+1))
        echo "         <unit>percent</unit>"
        echo "         <LimitMode>1</LimitMode>"
        echo "         <LimitMinWarning>10</LimitMinWarning>"
        echo "         <LimitMinError>5</LimitMinError>"
        echo "  </result>"
done

echo "</prtg>"

Dec, 2022 - Permalink

My update of the script, looks funny, so try again with a new post :)

#!/bin/bash
# filename: check_prtg_free_bytes.sh
# author: D P Loizos daniel.loizos@gmail.com
# create date: 20/9/2022
# description: a PRTG check that displays free bytes, for various filesystems, ignoring tmpfs, devtmpfs, squashfs. PRTG prefers XML as its output machanism.

# get mount name
MOUNT=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Filesystem' | awk '{print $7}')
MOUNT_ARRAY=( $MOUNT )

# get free bytes
FREEB=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Available' | awk '{ print $5}')
MOUNT_FREEB=( $FREEB )

# get total bytes
PERCENT=$(df -T -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Available' | awk '{ print $6}')
MOUNT_PERCENT=( $PERCENT )

# build the XML file, iterating through two arrays
echo "<prtg>"
n=0
for i in "${MOUNT_ARRAY[@]}"
do
        percent=${MOUNT_PERCENT[n]}
        percent=${percent%\%}
        percent=$((100-percent))
        echo "  <result>"
        echo "    <channel>Freespace on Mount: $i</channel>"
        echo -e "      <value> $percent </value>"
        n=$(($n+1))
        echo "         <unit>percent</unit>"
        echo "         <LimitMode>1</LimitMode>"
        echo "         <LimitMinWarning>10</LimitMinWarning>"
        echo "         <LimitMinError>5</LimitMinError>"
        echo "  </result>"
done

echo "</prtg>"

Dec, 2022 - Permalink

Hi there, thanks so much for sharing this script, and for detailing your progress with it - it's great to see your process, and your results. Please do keep us updated - it's much appreciated!


Dec, 2022 - Permalink