I wrote a script, however when it runs in prtg-desktop, the values display as zero.

The script is shown below:

# description: a PRTG check that displays free space, for various filesystems, ignoring tmpfs, devtmpfs, squashfs. PRTG prefers XML as its output machanism.

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

# get free space
FREES=$(df -Th -x tmpfs -x devtmpfs -x squashfs | egrep -v 'Used' | awk '{ print $4}')
MOUNT_FREES=( $FREES )

# 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_FREES[n]} </value>"
        n=$(($n+1))
        echo "  </result>"
done

echo "</prtg>"

XML is generated in logs on the backend server:

<prtg>
  <result>
  <channel>Mount: /</channel>
  <value>16G</value>
  </result>
  <result>
  <channel>Mount: /boot</channel>
  <value>404M</value>
  </result>
  <result>
  <channel>Mount: /data</channel>
  <value>33G</value>
  </result>
</prtg>

The PRTG-Desktop output is as follows:

ChannelIDLast ValueMinimumMaximum
Downtime-4
Execution Time1612msec529msec698msec
mount: /0 #0 #0 #
mount: /boot0 #0 #0 #
mount: /data0 #0 #0 #

As you can see XML <values> don't match the values in the prtg-desktop output. Please could you suggest why that is?

Thanks


Article Comments

I solved this problem

df -h does not work because the output is letters and numbers.


Oct, 2022 - Permalink