NetXMS Support Forum

English Support => General Support => Topic started by: rainerh on June 21, 2018, 08:28:01 PM

Title: Process - Instance discovery
Post by: rainerh on June 21, 2018, 08:28:01 PM
Hello,

I have 8 prcesses to discover.
phonalisa-ctrld
phonalisa-dbsrv
phonalisa-ldapd
phonalisa-logd
phonalisa-random
...
and so on

I want to use Process.Count(*) and will check if =1

How can I creat an Instance Discovery to get all processes called phonalisa-*

Thank you

Title: Re: Process - Instance discovery
Post by: Tursiops on June 27, 2018, 07:28:36 AM
Create an ExternalList in your agent configuration:
ExternalList = Phonalisa.Processes:ps axco command | grep phonalisa- | sort -u

That should give you a list called "Phonalisa.Processes" on your agent, which you can then use in your Instance Discovery DCI.
Title: Re: Process - Instance discovery
Post by: rainerh on July 10, 2018, 01:31:49 PM
Thanks

i am not able to handle these new list.
I added these to netxmsd.config:

# Log File
LogFile=/var/log/nxagentd

# IP white list, can contain multiple records separated by comma.
# CIDR notation supported for subnets.
MasterServers=10.10.__.__/32

#ExternalList
ExternalList=Phonalisa.Processes:ps axco command | grep phonalisa- | sort -u


Then I restartet the Agent.
I think that these will work fine, because a test of show agent suportet lists in info will result like this:

Agent.ActionList
Agent.SubAgentList
...
Phonalisa.Processes
...
System.IO.Devices
System.ProcessList


How can I use this?

In "General" I set   Process.Count({instance})   at Parameter

In Instance Discovery I select Agent List at discovery method
and   Phonalisa.Processes  in List name

What Have I to do in discovery filter script?

When I do nothin only   75  will be returned  -I thin the total number of precesses


Thank you very much
Rainer
Title: Re: Process - Instance discovery
Post by: Tursiops on July 12, 2018, 03:46:44 AM
There should be no need to use the instance discovery filter.
I'm assuming Instance Discovery did run against the Agent?

Setup under General should look something like the attached screenshot.

Please confirm if the list contains the data you expect.
Right-click on your agent, select "Execute server script" and run the following:
processes = AgentReadList($node,"Phonelisa.Processes");
if ( processes == null ) return "The list is empty!";
foreach ( process : processes ) {
  println(process);
}

This should list all the processes it knows about. If it does, then that's not your problem.

But if the above returns "The list is empty!", check that running the command that generates the list produces the expected output.
It worked on my system when I tested it against other processes (I don't have any phonalisa ones), so there is a possibility the command doesn't work as expected on your system.
As the user running the Agent, run the command that generates the list:
ps axco command | grep phonalisa- | sort -u
See if that actually produces the list of process names you expect.

Title: Re: Process - Instance discovery
Post by: rainerh on July 13, 2018, 10:35:31 AM
the script works fine - here the result:

phonalisa-callr
phonalisa-ctid
phonalisa-ctrld
phonalisa-dbsrv
phonalisa-ldapd
phonalisa-logd
phonalisa-msgd
phonalisa-voipd


*** FINISHED ***

Result: (null)

configuration like this:
(http://general.png)

(http://instancediscovery.png)



this results in:

(http://result.png)
Title: Re: Process - Instance discovery
Post by: rainerh on July 13, 2018, 10:41:51 AM
I have found a little mistake.
I forget the dot.
But the same result.
Title: Re: Process - Instance discovery
Post by: Tursiops on July 23, 2018, 02:23:47 PM
The description should include the process names as per your list and you should end up with one DCI per list entry.
Instead it appears the list returns "1" to your Instance Discovery DCI, hence your DCI returns 0, as there is no process called "1".
Not sure what exactly is happening, I'll have to set the whole thing up at my end (not just the script) for comparison/testing.
I'm assuming you're running the latest version of NetXMS?
Title: Re: Process - Instance discovery
Post by: Victor Kirhenshtein on July 23, 2018, 02:26:35 PM
Hi,

you have wrong discovery method - it should be "Script", not "Agent List" if you are using script from script library for discovery.

Best regards,
Victor
Title: Re: Process - Instance discovery
Post by: Tursiops on July 23, 2018, 02:59:35 PM
The script was only to check if the server gets the correct results back from the ExternalList command on the agent.
I'm guessing the ExternalList command is actually incorrect (I haven't used those on Linux yet, only Windows).
Title: Re: Process - Instance discovery
Post by: Victor Kirhenshtein on July 23, 2018, 03:22:09 PM
Yes, my mistake - method is correct. Still seems to be a typo in list name: it is "Phonelisa.Processes" in script and "Phonalisa.Processes" in DCI configuration.

Best regards,
Victor
Title: Re: Process - Instance discovery
Post by: Tursiops on July 23, 2018, 03:52:39 PM
Yep, the script had a typo. Oops. Was only for testing though, so should not affect the actual DCI.

I just set something similar up on a Ubuntu system here and I think the ExternalList needs an update:
ExternalList=Phonalisa.Processes:/bin/bash -c "ps axco command | grep phonalisa- | sort -u"

Using that (i.e. with /bin/bash), it worked for me when I grepped for "imap" processes (returned imap and imap-login). Created two DCIs, one for each and returned the correct values.

Let me know if that works for you.