What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom Sensor - bash script

Votes:

0

I installd cygwin to use bash scripts on the Windows machine, where i testing PRTG.

For a custom sensor i made a batch file called bash.bat

@echo off
FOR /F "tokens=*" %%a in ('c:\cygwin64\bin\bash.exe -c "/usr/local/bin/%1 %2') do SET OUTPUT=%%a
echo %OUTPUT%

The first argument is the name of the bash script located in c:\cygwin64\usr\local\bin\ The second argument can be a IP address

My first script "brother-toner.sh" use snmpwalk to collect information from a brother printer and calculate the toner level

#!/bin/bash
FULL=`snmpwalk -v1 -c public $1 ..some oid path...`
LEFT=`snmpwalk -v1 -c public $1 ..some oid path...`
LEVEL=$((${FULL: -1}*100/${LEFT: -1}))
OUTPUT="${LEVEL}:Black"
echo $OUTPUT

if i run "bash.bat 192.168.0.1" from terminal i get something like
66:Black

But PRTG don't get the value (66)

If i set the value e.g in bash script (OUTPUT="66:Black") or in bat file (echo 66:Black) it works.

Strange but also works: "echo 10%OUTPUT%" -> value in PRTG is 10

Encoding missmatch?

bash cygwin script

Created on Mar 7, 2014 4:35:27 PM

Last change on Mar 7, 2014 4:47:44 PM by  Torsten Lindner [Paessler Support]



1 Reply

Votes:

0

Hello,

thank you very much for your KB-Post. Did you already try to implement a bit of logging into the scripts, so that you can see what exactly is passed on to the batch file (when executed via PRTG)?

best regards

Created on Mar 10, 2014 9:24:10 AM by  Torsten Lindner [Paessler Support]




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.