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

PRTG EXE/Script Advanced Sensor return 0

Votes:

0

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

bat cmd prtg

Created on Oct 6, 2022 6:36:28 PM

Last change on Oct 7, 2022 6:47:34 AM by  Felix Wiesneth [Paessler Support]



2 Replies

Votes:

0

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

Created on Oct 12, 2022 2:21:55 PM by  Ricardo Sanchez [Paessler Technical Support]



Votes:

0

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

Created on Oct 13, 2022 6:24:03 AM

Last change on Oct 13, 2022 1:58:41 PM by  Felix Wiesneth [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.