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?
Add comment