New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Convert message string to numbered value or how to monitor string messages of a sensor in a PRTG map

Votes:

0

Your Vote:

Up

Down

Hello there,

We are monitoring our Infoblox Appliance and using a Sensor created by using the Infoblox mib.

Sensor is "Ib Ha Status". This sensor returns a message with Passive or Active. But it does not create a channel, so that we can not monitor changes over a time span as you can do with channels. The sensor does have the channels response time and down time.

So my question is: How can I use the message to create a channel, so that i can use the sensor in a map to see when which Infoblox member was active or passive?

I do not have any experience with regex and I have absolutely no clue how to use it. PCRE looks like program code while Regex is a confusing set of characters.... PCRE does have the function "pcre2_substring_length_byname" or "pcre2convert", can this be used to convert the returned message to a numbered value which can used for a channel?

Active = 6 characters Passive = 7 characters

bit length of string should be different to..

Reading the the sensor options and PRTG manual i guess it should be possible using "Extended Processing" and "Extract Number Using Regular Expressions" and "PRTG supports Perl Compatible Regular Expression (PCRE) regex".

I do not know to explain it easier, so please excuse my bad english explanation.

Thanks and Regards

Robert

channel convert map message prtg regex string

Created on May 14, 2020 11:00:31 AM by  robert_grossmann (70) 2 1



Best Answer

Accepted Answer

Votes:

1

Your Vote:

Up

Down

If anyone has interest, here is my updated bat Script, changed to a "switch-cased" writing.
I using the same script now for checkpoint HA state (OK, NOT OK) and HA status (active, standby) and Infoblox HA Status (Active, Passive)

you have to add 4 Parameters in the Script-Sensor
%host %snmpcommunity OID-VALUE %sensorid
the corresponding script variables are %1 %2 %3 und %4

In my Sensor settings i am using the following alarm limits:
upper limit warning:3
upper limit error:4
lowe limit error: 0

Of Course you can adjust any of the values and paths to your requirements.

snmpget.exe is from SNMPsoft / EZ5 Systems. Of course you can use an other snmpget tool, but be aware to change the code parameter syntax!

@echo off

"C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\SnmpGet.exe" -r:%1 -v:2c -c:%2 -o:%3 |find "Value" >C:\PRTG-scripts-results\%1-%4.txt

Set /p VAR2= < C:\PRTG-scripts-results\%1-%4.txt
Set VAR=%VAR2:~6%

:: Call and mask out invalid call targets
call :"switch-case-N-%VAR%" 2>nul || (
    :: Default case
    SET RESULT=5
)
goto :switch-case-end

:"switch-case-N-Active"
    SET RESULT=1
    goto :eof

:"switch-case-N-Passive"
    SET RESULT=2
    goto :eof

:"switch-case-N-active"
    SET RESULT=1
    goto :eof

:"switch-case-N-standby"
    SET RESULT=2
    goto :eof

:"switch-case-N-Active Attention"
    SET RESULT=3
    goto :eof

:"switch-case-N-down"
    SET RESULT=4
    goto :eof

:"switch-case-N-OK"
    SET RESULT=1
    goto :eof

:"switch-case-N-Attention"
    SET RESULT=3
    goto :eof

:"switch-case-N-Problem"
    SET RESULT=4
    goto :eof

:switch-case-end
echo After Switch/case

SET /A RESULT=%RESULT%

echo %RESULT%:%VAR%

goto :eof

edited for better readability

Created on May 20, 2020 10:00:51 AM by  robert_grossmann (70) 2 1

Last change on May 21, 2020 6:28:19 AM by  Marijan Horsky [Paessler Support]



10 Replies

Votes:

0

Your Vote:

Up

Down

Hi Robert,
If the target device provides a value like 1 = active, 2 = passive for the status. Then you need to create a lookup file which helps PRTG to interpret the provided values.
You can find more information here.

Created on May 15, 2020 5:37:59 AM by  Marijan Horsky [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Marijan,

thanks for response. The response value is not numerical, it is a string value.

I tried the custom value lookup and at first it looks good. But only for live View. For the more interesting long time map monitoring it does not work, because the numerical value is not used, instead the unit changes from # to %. I found a matching topic: https://kb.paessler.com/en/topic/73062-can-i-graph-text-values

My custom Lookup is:

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="ewr.activepassive.hastatus" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="OK" value="1">
        Active
      </SingleInt>
      <SingleInt state="OK" value="2">
        Passive
      </SingleInt>
    </Lookups>
  </ValueLookup>

Any further idea how to solve the Problem? Active should be interpreted an displayed as 1 and Passive as 2.

Created on May 15, 2020 9:04:06 AM by  robert_grossmann (70) 2 1

Last change on May 18, 2020 12:12:51 PM by  Marijan Horsky [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Robert,

You need to change the values for the different states to active and passive, as your target device provides a string instead of numeric values. Kind regards Marijan

Created on May 15, 2020 7:01:29 PM by  Marijan Horsky [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Marijan,

What do you mean? I already have changed the original activeinactive lookup and values to Active and Passive. And in the live Graph the Active state is recognized as 1 and the Passive state as 2. But it does not work for other graphs.

PRTG Infoblox HA States

Kind regards

Robert

Created on May 18, 2020 6:16:40 AM by  robert_grossmann (70) 2 1



Votes:

0

Your Vote:

Up

Down

Hi Robert,

The lookup should look like this when the target device doesn't provide a numeric value.

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="ewr.activepassive.hastatus" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="OK" value="Active">
        Active
      </SingleInt>
      <SingleInt state="Error" value="Passive">
        Passive
      </SingleInt>
    </Lookups>
  </ValueLookup>

As you mentioned that the device is reporting a string.

Created on May 18, 2020 12:14:54 PM by  Marijan Horsky [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Marijan,

But that is not what I want, the string should be converted to a numerical value that PRTG is able to monitor over time. To Monitor the actual State of the Cluster I do not need a custom value lookup. Even I think that the values Active and Passive are not Type Integer (SingleInt), so it is not being accepted from PRTG.

So if there is no way to use the regex function (for example to determine string-length), or other easy PRTG integrated way to convert string to numerical value, than I have to ask if anyone in my company is capaple to script. I guess with the exe/script sensor it should be possible, but I by myself does not have any clue about scripting and as mentioned earlier regex and Pearl / PCRE.

Thanks so far

Kind Regards

Robert

Created on May 19, 2020 6:38:19 AM by  robert_grossmann (70) 2 1



Votes:

0

Your Vote:

Up

Down

Hi Robert,

Then I would ask you contact one of your colleagues if they can create a script for. You can monitor this script with PRTG with the EXE/Script Advanced Sensor.

Created on May 19, 2020 6:42:03 AM by  Marijan Horsky [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Marijan,

I tried for myself the Script-Solution (simple exesensor) and I guess I found my solution.

My script.bat (IP, community and OID are command-line parameters from PRTG sensor): I'm sure there is a much better (coding) way to do it^^ But it works for me with Infoblox and Checkpoint HA Status.

@echo off

"C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\SnmpGet.exe" -r:%1 -v:2c -c:%2 -o:%3 |find "Value" >C:\PRTG-scripts-results\%1.txt

Set /p VAR2= < C:\PRTG-scripts-results\%1.txt
Set VAR=%VAR2:~6%

if "%VAR%"=="Active" (
 SET RESULT=1
 ) else (
 if "%VAR%"=="active" (
  SET RESULT=1
  ) else (
  if "%VAR%"=="Passive" (
   SET RESULT=2
   ) else (
   if "%VAR%"=="standby" (
    SET RESULT=2
    ) else (
    if "%VAR%"=="Active Attention" (
     SET RESULT=3
     ) else (
     if "%VAR%"=="down" (
      SET RESULT=4
      ) else (
      SET RESULT=5
      )
     )
    )
   )
  )
 )

SET /A RESULT=%RESULT%

echo %RESULT%:%VAR%

with Scriptsensor

Created on May 19, 2020 10:46:42 AM by  robert_grossmann (70) 2 1



Votes:

0

Your Vote:

Up

Down

Hi Robert, Great to hear that it is working now.

Created on May 19, 2020 12:29:49 PM by  Marijan Horsky [Paessler Support]



Accepted Answer

Votes:

1

Your Vote:

Up

Down

If anyone has interest, here is my updated bat Script, changed to a "switch-cased" writing.
I using the same script now for checkpoint HA state (OK, NOT OK) and HA status (active, standby) and Infoblox HA Status (Active, Passive)

you have to add 4 Parameters in the Script-Sensor
%host %snmpcommunity OID-VALUE %sensorid
the corresponding script variables are %1 %2 %3 und %4

In my Sensor settings i am using the following alarm limits:
upper limit warning:3
upper limit error:4
lowe limit error: 0

Of Course you can adjust any of the values and paths to your requirements.

snmpget.exe is from SNMPsoft / EZ5 Systems. Of course you can use an other snmpget tool, but be aware to change the code parameter syntax!

@echo off

"C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\SnmpGet.exe" -r:%1 -v:2c -c:%2 -o:%3 |find "Value" >C:\PRTG-scripts-results\%1-%4.txt

Set /p VAR2= < C:\PRTG-scripts-results\%1-%4.txt
Set VAR=%VAR2:~6%

:: Call and mask out invalid call targets
call :"switch-case-N-%VAR%" 2>nul || (
    :: Default case
    SET RESULT=5
)
goto :switch-case-end

:"switch-case-N-Active"
    SET RESULT=1
    goto :eof

:"switch-case-N-Passive"
    SET RESULT=2
    goto :eof

:"switch-case-N-active"
    SET RESULT=1
    goto :eof

:"switch-case-N-standby"
    SET RESULT=2
    goto :eof

:"switch-case-N-Active Attention"
    SET RESULT=3
    goto :eof

:"switch-case-N-down"
    SET RESULT=4
    goto :eof

:"switch-case-N-OK"
    SET RESULT=1
    goto :eof

:"switch-case-N-Attention"
    SET RESULT=3
    goto :eof

:"switch-case-N-Problem"
    SET RESULT=4
    goto :eof

:switch-case-end
echo After Switch/case

SET /A RESULT=%RESULT%

echo %RESULT%:%VAR%

goto :eof

edited for better readability

Created on May 20, 2020 10:00:51 AM by  robert_grossmann (70) 2 1

Last change on May 21, 2020 6:28:19 AM by  Marijan Horsky [Paessler Support]



Please log in or register to enter your reply.


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.