I have a perl script on a linux system that measures the sizes of various directories. The script is in /var/prtg/scriptsxml and is correctly found when adding a sensor.

PRTG runs the script without error, but the values returned are not what the script outputs and I'm confused why.

Script output:

{
 "prtg": {
  "result": [
             {
              "channel": "ThingOne",
              "value": "372005484",
              "VolumeSize": "GigaByte",
              "unit": "BytesFile"
             },
             {
              "channel": "Tester",
              "value": "85",
              "VolumeSize": "GigaByte",
              "unit": "BytesFile"
             }
           ]
          }
         }

In PRTG I've created a new "SSH Script Adanced" sensor on running, it reports ThingOne as 4096 and Tester as 20 bytes, rather than the value in json.

Eg:

Date Time 	Execution Time 	ThingOne   Tester 	Downtime 	Coverage 
  
07/01/2020 15:30:39 544 msec	4,096 Byte	20 Byte	0 %	100 %
07/01/2020 15:29:39 426 msec	4,096 Byte	20 Byte	0 %	100 %
07/01/2020 15:28:39 466 msec	4,096 Byte	20 Byte	0 %	100 %
07/01/2020 15:27:39 469 msec	4,096 Byte	20 Byte	0 %	100 %
07/01/2020 15:26:39 492 msec	4,096 Byte	20 Byte	0 %	100 %

Article Comments

Hi digdilem,

Thank you for the post!

Please let me know if you already used the option "Write Results To Disk" in the Sensor settings. If not, please enable this option. This will create additional log files in the "Logs (Sensors)" folder in the PRTG Data Directory (https://helpdesk.paessler.com/en/support/solutions/articles/7600006351163).
In "Logs (Sensors)" there should be a file called "Result of Sensor XXXXX". Please post the content of this file. The output should be very similar to the json output you already posted.


Jan, 2020 - Permalink

Thanks for your response, Moritz.

I have tried this, and just re-tried this - creating the sensor again with write to file enabled, but no files are created in "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)" on the prtg server after several minutes of running.

I've searched the entire C: drive for "Result of*" and nothing's coming up, so now I'm wondering if there is a secondary issue with our PRTG installation where it's not creating these log files.

Additional to my original query: I've changed the output from my perl script to XML and it behaves the same as the json output.

Bizarrely, if I hardcode the values and just print that output (as opposed to programmatically generating the script), PRTG then graphs the correct results. I can't see anything wrong with the generated output (no strange characters) - the only thing that differs is that the perl program is calling a sub-shell using `du -s /path/to/dirs`

My current suspicion is that making this sub-shell is somehow breaking how PRTG's ssh monitor reads the perl's output....

Does this ring any bells?


Jan, 2020 - Permalink

Thanks for your help - I have now resolved my problem and have the sensor working as expected.

For the benefit of you and others;

  • Issue 1: Script returning different values through prtg: Turned out to be a permissions issue. The directories that the script was checking were accessible to me running the script manually as root, but the prtg ssh user didn't have access. It's odd that it returned different values for the two directories rather than a failure, but that's definitely what the cause was. I rewrote the plugin to generate an xml file when supplied with a cron parameter, and scheduled that - and the same plugin just outputs that xml dropfile from an accessible location when prtg calls it.
  • Issue 2 Lack of logging: It seems that since prtg was installed, a previous admin had changed the ProgramData path it uses to the D: drive, so the location offered in your documentation only showed stuff from 2017.

    Glad to have resolved this now

Jan, 2020 - Permalink

Hi digdilem,

Thank you for the update.

I'm glad the issue is solved and thank you to share the answer to our community.

Have a nice day!


Jan, 2020 - Permalink