Run Script to get DCI Data

Started by alike767, January 29, 2018, 11:10:56 PM

Previous topic - Next topic

alike767

I'm trying to use NetXMS to monitor license usage on RLM and FlexLM License servers.  There are commands you can run that give the output.  I'd like to run them throughout the day and have NetXMS capture the output.

I have created a shell script on one license server, and when I type sh license_usage.sh it outputs the correct number of licenses in use.

How can I get NetXMS to capture the output of that script and make it a DCI for my node?

tomaskir

Hi,

There are a few ways in which you can accomplish this:
1) ExternalParameter
2) ExternalParameterProvider
3) Use native SSH-based DCI
(assuming you take this as an output of some command from a SSH CLI of the device)

You can find a bunch of any on any of this on the Wiki, the Admin Guide, and here on the forums.

Feel free to ask if you have any questions.

alike767

I found information on ExternalParameter and ExternalParameterProvider.  On my systems, I currently don't have the NetXMS agent, I have only SNMP agent. 

Can the SSH-based DCI be used with SNMP only or does it need the NetXMS agent?

I did a search on the forum and web for SSH-based DCI and didn't see a good explanation.  When I go into the DCI and choose "Origin - SSH", I don't see where to enter any kind of script.  Is this the right place for SSH-based DCI or is the process different?

alike767

I hope on the right path for using native SSH-based DCI. 

On my license server, the server where I want the command to run, I don't have NetXMS Agent installed.  I right click on it and go to Properties and under 'Communications - SSH', I put in the username and password for a user that can SSH into the license server.  Under Proxy, I put in my NetXMS server because that server has the NetXMS Agent installed.  It is the only Linux node I have with NetXMS Agent installed.  All other nodes just have SNMP.

On my NetXMS Server (with the agent installed) I right click on that node and when to Trusted Nodes.  Here I entered the License Server, the server I want to run code on.

Lastly I created a Test DCI.  Origin SSH.  Data Type String.  Parameter uname -a.

This is not working.  Am I even going about this the right way?

Thanks





tomaskir

For Trusted Nodes, by default, you should have "CheckTrustedNodes" set to "0" (false) in Server Configuration.
Trusted Nodes functionality is usually only needed in very secure environments.

More info here:
https://wiki.netxms.org/wiki/SG:Security_Issues

On the node used as the SSH proxy, do you have the SSH SubAgent declared properly?

alike767

I don't remember the reason why, but I have "CheckTrustedNodes" set to "1".  Is this possible with it set to "1"?

I found one article on SSH SubAgent and I am not sure I am understanding the right information.  I think it said to setup an "Action".  So under "Configuration - Actions Configuration", I created an action to "Execute command on management server".  For "Command", I put uname -a just for a test.

If this is the right way to go, how do I trigger that "Action"?  If this is the wrong approach, then can I get a more detailed explanation on setting up the SSH SubAgent?

Thanks

Victor Kirhenshtein

Hi,

trusted nodes settings are used only when you set "source node" in DCI. It is irrelevant for SSH proxy settings. You don't need to create action for data collection - you correctly configured your DCI with SSH as data source.
Make sure that SSH subagent is loaded and can connect to target (you can set debug level to 6 and check agent log for messages with prefix SSH).
When you say your test DCI is not working - do you get data collection error, unsupported, or just empty value?

Best regards,
Victor

alike767

What is the SSH subagent and how do I load it or configure it.  What machine does that go on?  The Proxy, or the machine I want to SSH into?  Maybe that is the last step to getting this to work.  My DCI came back unsupported. 

I only setup the Trusted Node because another thread had it.  I'll remove that setting. 

Victor Kirhenshtein

In agent configuration file (nxagentd.conf) on your NetXMS server make sure you have line

SubAgent = ssh.nsm

This will load SSH subagent. For SSH DCIs connection chain is following:

server --- NXCP protocol ---> agent with SSH subagent --- SSH protocol ---> target system

where agent can be on same machine as server or any different machine. This is why server do not connect directly over SSH but use agent instead.

Best regards,
Victor

alike767

#9
I don't have the ssh.nsm file on my system. 

I believe I am running 2.2.2 on Ubuntu as that is the console version I am connecting with.

How do I get the ssh.nsm on my server?  I want the NetXMS server running the agent to be the proxy. 

Victor Kirhenshtein

Seems to be packaging error. We will check.

Best regards,
Victor

alike767

Thanks for checking. 

Is it possible to make that file available via FTP or another method?  Would it be as simple as downloading a single file and putting it in the right place?

Victor Kirhenshtein

Hi,

we just published release 2.2.3 which should include ssh.nsm.

Best regards,
Victor

alike767

I'm running Ubuntu 14.04.5 and did an apt-get update/upgrade.

dpkg -s netxms-agent is 2.2.2-1.

Do I need to update OS or source list to get 2.3? 

Victor Kirhenshtein

Hi,

packages for Ubuntu 14.04 (trusty) are published. Please check that you have correct source - should be:


deb https://packages.netxms.org/ubutu trusty main


Best regards,
Victor