Agent Config (Action / ExternalParam)

Started by jdl, June 12, 2009, 05:18:46 PM

Previous topic - Next topic

jdl

Dear all,

Could some one, please, elaborate a bit on how to configure AND use "Action", "ExternalParameter" and "ExternalParameterShellExec"?
The available documentation presents a "dead loop" in section "Agent configuration" pointers are pointing to this same section for more details...
Unfortunately, I did not find any complete explanation on this forum though there are some very interseting topics.

Many Thanks in advance for your help/support. ;D

Expected info:
- Syntax for action definition in nxagentd.conf (not in doc)
- How to use returned / collected info in NetXMS console for both action and external parameter

A nice way would be to explain how to - for example - execute a script or system command (ping, ps or netstat), extract some info after treatment of the output (grep, wc, cut, sed and the like), define event and threshold related to returned info.

Suggestion: copy/past your contribution to the user manual  ;)


jdl

#1
Well as I managed to get through some of this by myself, I'm summarizing a small "HowTo" so you can as well enjoy...

Actions
Actions can be defined on the server using the panel "Actions". Very easy, one shall only follow the kind of wizard.
So far I only used the sending of email for which one shall not forget to define both SMTP server (SMTPserver parameter) and server email address (SMTPFromAddr parameter)

Using the macros provided on the last page of the user manual, one can easily format both email content and subject.

Note, if you want to put several email addresses for destination, use the ";" to separate them. Funny is that as recipient you don't see who else has received the email from NetXMS.

ExternalParameter and ExternalParameterShellExec
The difference is explained somewhere in the forum or user manual. The ShellExec is to be used for those processes or parameters that are interpreted by some additional process: bash, perl or the like.

Then in your agent configuration file (pay attention to respect the declaration order see Log Parser issue in this forum) you define the script you want to run and that is providing the data which will be collected to get graphed or monitored in order to generate alarms.

Syntax is:
ExternalParameterShellExec=<data_collection_name>{(*)}: <script_path> {$1} {$2} .. {$i}
where <data_collection_name> will be your reference to be used in the data collection definition in NetXMS console, you will have to append (*) to the name if you have parameters to provide. Those parameters are represented by the optional $1, $2... $i. As many as you have parameters.

So example:
ExternalParameterShellExec=my_data_coll(*): /home/netxms/my_mon_script.pl $1 $2
This states that you will provide 2 parameters to the script my_mon_script.pl in the data collection definition

Pay attention that in bash the value is returned using echo which in perl, this value is returned by printing out to the standard output. Do not use exit or return.

Pay attention... starting your script by /usr/bin/perl my_mon_script.pl will not call a bash... while ./my_mon_script.pl does! Taouw... as Homer says :o

Data collection
Now in NetXMS console you want to define the data collection based on this script.

You will have to select the NetXMS Agent as origin and insert your <data_collection_name> which by the way you will not find in the available list. I did not try but I would suggest not to use any existing data collection name... Possible conflict or simply possible problem easy to avoid - play it safe and simple ;-)
There enter as well your parameter(s) if any required.
Up to you to tweak / transform the data or define your threshold.

Hope this helps
Regards,

Jdamien

----

Update, Alex: see also http://wiki.netxms.org/wiki/ExternalParametersProvider

Victor Kirhenshtein

Thank you for excellent howto! I'll probably never manage to write so long text :)

Some comments and corrections:

Quote from: jdl on June 19, 2009, 05:17:54 PM
which by the way you will not find in the available list

You will, but only after next configuration poll for that node. To prevent sending request for supported parameters to agent each time you press "Select" button in console, server reads list of supported parameters during configuration poll (each hour by default) and caches it. You should either wait for next configuration poll or force immediate configuration poll from console using Poll -> Configuration menu.


Quote from: jdl on June 19, 2009, 05:17:54 PM
I did not try but I would suggest not to use any existing data collection name... Possible conflict or simply possible problem easy to avoid - play it safe and simple ;-)

In fact, you can use names of existing parameters - if you do, built-in parameter's handler will be replaced by your script. Normally, this should be avoided, but sometimes it may help - for example, if built-in implementation of certain parameter is buggy, and you are able to provide replacement script as workaround.

Best regards,
Victor