Community discussions

MikroTik App
 
Kaos
just joined
Topic Author
Posts: 12
Joined: Wed Jul 21, 2010 9:58 pm

Regex in a probe/function

Thu Jan 20, 2011 10:10 pm

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?
 
User avatar
gsandul
Member Candidate
Member Candidate
Posts: 154
Joined: Mon Oct 19, 2009 1:42 pm

Re: Regex in a probe/function

Fri Jan 21, 2011 9:21 am

Hello.
My question is: Is there any way to use regular expressions in that setup so that i can monitor similar process names?
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 :(. So you should change your application name on file system.
:)
 
Kaos
just joined
Topic Author
Posts: 12
Joined: Wed Jul 21, 2010 9:58 pm

Re: Regex in a probe/function

Fri Jan 21, 2011 3:10 pm

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
 
User avatar
gsandul
Member Candidate
Member Candidate
Posts: 154
Joined: Mon Oct 19, 2009 1:42 pm

Re: Regex in a probe/function

Fri Jan 21, 2011 6:27 pm

The problem is, it's returning an OK status all of the time, even when the processes don't exist.
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
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: theotang and 13 guests