Hi,

When it comes to this sensor and Linux/JSON I am fairly new so lease bare with me on this.

Goal: Is to get the size of a directory on a volume that is used by a CentOS server. I only have SSH access to the server from PRTG.

Script code dirSize=$(du -sh /home/data/sites/portal-acceptation/www/media/orders/ | awk '{print $1}') echo 0:$dirSize:OK

Running the script manually on the server gives me, what I think is the correct format [root@pvh scriptsxml]# bash dirsize.sh 0:133G:OK [root@pvh scriptsxml]#

The 133G is the size of the folder as I am writing this.

The sensor keeps returning XML: The returned XML does not match the expected schema. (code: PE233) -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)

Where did I took a wrong exit?


Article Comments

Hi there,

It seems that you are using the Advanced Sensor which expects a XML/JSON result. Please use the normal "SSH Script" sensor instead or change the result to JSON/XML according to PRTG documentation under "Setup > PRTG API > Custom Sensors".

Best regards.


Sep, 2017 - Permalink

Actually, I was working on that this morning... ;-)

Got it working with the SSH Script sensor

{{{dirSize=$(du -sh /location_on_disk/ | awk '{print $1}' | sed 's/[G]$')

echo "0:$dirSize:OK"}}}

This code is now working for me and it is reporting the size of the folder. Return code and message is not important for now.

The | sed 's/[G]$' behind it was to trim the G from the response. The sensor did not like that.

Thanks for helping out


Sep, 2017 - Permalink