Regex in a probe/function

I am currently using a probe in function mode to monitor applications running on Windows Servers via SNMP as shown in the “Outlook.exe” example on the Probe Thread. Everything is working correctly and as expected with that.

My question is: Is there any way to use regular expressions in that setup so that i can monitor similar process names? For instance, we have applications that are XY123.exe and XY234.exe that may be running on the servers. It’s going to be a pain logging into each server to figure out which version of the XY application is running and to add each respective service probe to each server when I could attach a “generic” probe that would just monitor and tell is if the XY process is running if either version 123 or 234 is running. Also, I have some instances where the processes are the same name, but the case may be different depending on the version. XYSvr.exe and XYsvr.exe may be running on 2 different servers, same issue as above.

Anyone have any ideas on how I could accomplish this?

Hello.

This is not a case to use regular expressions, but different functions.
In probe thread example array_find function is used. You should use string_find function instead of it.
The result function code will change from

if(array_find(oid_column("1.3.6.1.2.1.25.4.2.1.2"),"OUTLOOK.EXE")>0, 1, -1)

to

if(string_find(oid_column("1.3.6.1.2.1.25.4.2.1.2"),"outlook") > 4294967294, -1, 1)

in such a case it will match “outlook.exe”, “outlook1.exe”, “1otulook.exe”, “1otulook93.com”, etc…
But must say string_find is case sensitive :frowning:. So you should change your application name on file system.
:slight_smile:

Thank you, that did exactly what I needed.

Update.

I thought it was doing what I needed to do. The problem is, it’s returning an OK status all of the time, even when the processes don’t exist.

My probe is setup like this:

Type:function
Available: if(string_find(oid_column(“1.3.6.1.2.1.25.4.2.1.2”),“TCPsvr”)>0,-1,1)
Error: if(string_find(oid_column(“1.3.6.1.2.1.25.4.2.1.2”),“TCPsvr”)>0,“”,“TCPsvr process not running”)
Value: 1
Unit: running

Find the difference
my function
if(string_find(oid_column(“1.3.6.1.2.1.25.4.2.1.2”),“outlook”) > 4294967294, -1, 1)
your function
if(string_find(oid_column(“1.3.6.1.2.1.25.4.2.1.2”),“TCPsvr”)>0,“”,“TCPsvr process not running”)

string_find(oid_column(“1.3.6.1.2.1.25.4.2.1.2”),“outlook”) will return positon of “outlook”, if not found it returns 4294967295
While making new probes you shoud first put function on device label to know exactly what it returns.
device_label.png