New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


SSH Script Advanced - Invalid JSON

Votes:

0

Your Vote:

Up

Down

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 [[email protected] scriptsxml]# bash dirsize.sh 0:133G:OK [[email protected] 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?

centos json ssh

Created on Sep 15, 2017 2:19:42 PM by  wbolten (60) 1 1



2 Replies

Votes:

0

Your Vote:

Up

Down

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.

Created on Sep 18, 2017 9:10:20 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Sep 18, 2017 10:07:09 AM by  wbolten (60) 1 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.