Community discussions

 
todd
just joined
Topic Author
Posts: 1
Joined: Sat Aug 29, 2009 8:55 pm

Filter Array

Sat Aug 29, 2009 9:04 pm

Is there any way to filter an array in a function? I am looking to get a count of the number of instances of a running executable on a server. So basically make an SNMP call to get a list of running processes. Filter the list by the name of a single process, then get a count using array_count.

Or alternatively loop through an array and get a count using variables and an if statement.

Todd
 
lebowski
Forum Guru
Forum Guru
Posts: 1616
Joined: Wed Aug 27, 2008 5:17 pm

Re: Filter Array

Thu Sep 10, 2009 7:41 pm

Give this a try...

[array_element(oid_column("1.3.6.1.2.1.25.4.2.1.2"), array_find(oid_column("1.3.6.1.2.1.25.4.2.1.2"),"svchost.exe"))]
[concatenate ( "Instances: ", array_find(oid_column("1.3.6.1.2.1.25.4.2.1.2"),"svchost.exe"))]
 
mjroberts
just joined
Posts: 1
Joined: Mon Oct 04, 2010 5:37 pm

Re: Filter Array

Wed Nov 03, 2010 8:27 pm

This worked great for me, thank you very much.

Anyone have any idea how to do something similar to this in probe form?

I've taken a stab at it, having it graph the value of 'array_find(oid_column("1.3.6.1.2.1.25.4.2.1.2"),"_progres.exe")', but I keep getting numbers that don't match up. For example: Dude reports 41 instances of _progres.exe, but task manager on the system only reports 15. I've been unable to account for this variance.
 
lebowski
Forum Guru
Forum Guru
Posts: 1616
Joined: Wed Aug 27, 2008 5:17 pm

Re: Filter Array

Thu Nov 04, 2010 10:36 pm

IT WORKS :)

Function
name: findsvch
code: if(array_size(oid_column("1.3.6.1.2.1.25.4.2.1.2",10,29)), array_find(oid_column("1.3.6.1.2.1.25.4.2.1.2",10,29),"svchost.exe"),"False")

Probe
name: svccount
type: function
available: findsvch()<>"False"
error: if(findsvch()<>"False", if(findsvch(),"", "No Svchost.exe running"), "Cant read device")
value: findsvch()
unit: total
 
PhilipLykov
newbie
Posts: 48
Joined: Fri Dec 10, 2010 12:24 am

Re: Filter Array

Fri Dec 10, 2010 12:34 am

Hello!
This function works for the whole word in the value only. We need to find the strings which contain some word (but the whole string is longer) and count the quontity of such strings. Can we use any wildcards or maybe you know another functions which can do it?
 
kubaver
just joined
Posts: 10
Joined: Tue Sep 20, 2016 3:03 pm

Re: Filter Array

Fri Jul 26, 2019 5:38 pm

Hi,
this is a historical post, but the return value of the findsvch() function is not the count of running instances? I think it will return the index of the first value "svchost.exe" found in the array oid_column("1.3.6.1.2.1.25.4.2.1.2").
Or am I wrong?
Function
name: findsvch
code: if(array_size(oid_column("1.3.6.1.2.1.25.4.2.1.2",10,29)), array_find(oid_column("1.3.6.1.2.1.25.4.2.1.2",10,29),"svchost.exe"),"False")

Probe
name: svccount
type: function
available: findsvch()<>"False"
error: if(findsvch()<>"False", if(findsvch(),"", "No Svchost.exe running"), "Cant read device")
value: findsvch()
unit: total

Who is online

Users browsing this forum: No registered users and 7 guests