Hi,

I have simple CMD script to read some OIDs form printer: total capacity, print pages left and drum unit. If I run cmd script from command line everything is fine: correct echo values and correct XML value. When I add EXE/Script Advanced to PRTG it returns "0" values. What is wrong? Where I made mistake?

Script:

@echo off

::READ Total toner capacity
for /f "tokens=2,2 delims==" %%a in ('SnmpGet.exe -r:XX.XX.X.XX -t:10 -c:public -o:1.3.6.1.2.1.43.11.1.1.8.1.1 ^| find /i "Value="') do (set totaltonercapacity=%%a)
echo %totaltonercapacity%

:: READ Print pages left
for /f "tokens=2,2 delims==" %%b in ('SnmpGet.exe -r:XX.XX.X.XX -t:10 -c:public -o:1.3.6.1.2.1.43.11.1.1.9.1.1 ^| find /i "Value="') do (set printpragesleft=%%b)
echo %printpragesleft%

::READ Drum unit
for /f "tokens=2,2 delims==" %%c in ('SnmpGet.exe -r:XX.XX.X.XX -t:10 -c:public -o:1.3.6.1.2.1.43.11.1.1.9.1.14 ^| find /i "Value="') do (set drumunit=%%c)
echo %drumunit%

set /A percent = %printpragesleft%*100/%totaltonercapacity%
echo %percent%


echo ^<?xml version="1.0" encoding="Windows-1252" ?^>
echo ^<prtg^>
echo    ^<result^>
echo        ^<channel^>Black^</channel^>
echo        ^<value^>%percent%^</value^>
echo        ^<unit^>%^</unit^>
echo        ^<float^>1^</float^>
echo		^<limitmode^>1</limitmode^>
echo        ^<LimitMinError^>15^</LimitMinError^>
echo        ^<LimitMinWarning^>5^</LimitMinWarning^>
echo        ^<LimitWarningMsg^>To low^</LimitWarningMsg^>
echo        ^<LimitErrorMsg^>End of toner^</LimitErrorMsg^>
echo        ^<LimitMode^>1^</LimitMode^>
echo    ^</result^>
echo    ^<text^>%percent%^</text^>
echo ^</prtg^>

Below output result from command line. Four values (1200, 1020, 100, 85) - results from CMD script:

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>B235-1_toner_drum.cmd
1200
1020
100
85
<?xml version="1.0" encoding="Windows-1252" ?>
<prtg>
   <result>
       <channel>Black</channel>
       <value>85</value>
       <unit></unit>
       <float>1</float>
The filename, directory name, or volume label syntax is incorrect.
       <LimitMinError>15</LimitMinError>
       <LimitMinWarning>5</LimitMinWarning>
       <LimitWarningMsg>Malo tonera</LimitWarningMsg>
       <LimitErrorMsg>Toner na wykonczeniu</LimitErrorMsg>
       <LimitMode>1</LimitMode>
   </result>
   <text>85</text>
</prtg>
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>

http://promanski.info/public/prtg_cmd.PNG |CMD Output
http://promanski.info/public/prtg_error.PNG |PRTG Output


Article Comments

Hello Dear customer,

Thank you for contacting Paessler support.

We as the support do not support scripts as part of our scope, however, as the best effort, I can see some errors in the script.

You need to remove the values you displayed right before returning the XML response and within the XML response, there is the error "The filename, directory name, or volume label syntax is incorrect." which must be fixed.

The unit also does not appear in the response.

The limitmode tag is used twice in the script. The first one is at the same place as the error

Please review these details and let us know if the issue persists.

Regards


Oct, 2022 - Permalink

Ricardo thank You for Your help, I'll check my script.


Oct, 2022 - Permalink