NetXMS Support Forum

English Support => General Support => Topic started by: alike767 on January 29, 2018, 11:10:56 PM

Title: Run Script to get DCI Data
Post by: alike767 on January 29, 2018, 11:10:56 PM
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?
Title: Re: Run Script to get DCI Data
Post by: tomaskir on January 30, 2018, 12:29:20 AM
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.
Title: Re: Run Script to get DCI Data
Post by: alike767 on January 30, 2018, 12:47:30 AM
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?
Title: Re: Run Script to get DCI Data
Post by: alike767 on January 30, 2018, 11:40:01 PM
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




Title: Re: Run Script to get DCI Data
Post by: tomaskir on January 31, 2018, 02:40:13 AM
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?
Title: Re: Run Script to get DCI Data
Post by: alike767 on January 31, 2018, 07:36:31 PM
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
Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on January 31, 2018, 11:26:45 PM
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
Title: Re: Run Script to get DCI Data
Post by: alike767 on January 31, 2018, 11:40:30 PM
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. 
Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on February 01, 2018, 12:13:16 AM
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
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 01, 2018, 09:52:53 PM
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. 
Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on February 05, 2018, 10:12:36 AM
Seems to be packaging error. We will check.

Best regards,
Victor
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 05, 2018, 11:02:17 PM
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?
Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on February 06, 2018, 11:01:22 AM
Hi,

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

Best regards,
Victor
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 06, 2018, 05:42:54 PM
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? 
Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on February 06, 2018, 05:55:39 PM
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
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 06, 2018, 11:08:33 PM
I'm up to date now and the ssh.nsm is loaded.

On the properties for my client where I want to run the script, I have SSH with proper credentials and the Proxy set to my NetXMS server.

On the General Tab of the DCI for my client I have Origin SSH, Data Type String, Parameter uname -a.

I have not done anything to the NetXMS server other than confirm ssh.nsm is loaded.

I get a "Not supported" for the DCI configuration.  Have I done all of the steps?

Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on February 07, 2018, 01:06:25 PM
Hi,

description looks correct. Please send your nxagentd.conf (from server machine) and check agent log file on debug level 6 for any messages with prefix "SSH".

Best regards,
Victor
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 08, 2018, 12:49:04 AM
nxagentd.conf from NetXMS Agent

# Log File
LogFile=/var/log/nxagentd
DebugLevel=6

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

SubAgent = ssh.nsm


cat /var/log/nxagentd | grep ssh from NetXMS Agent which acts as Proxy

2018.02.01 13:33:25.204 *E* Error loading subagent module "ssh.nsm": /usr/lib/x86_64-linux-gnu/netxms/ssh.nsm: cannot open shared object file: No such file or directory
2018.02.06 09:37:39.437 *E* Error loading subagent module "ssh.nsm": /usr/lib/x86_64-linux-gnu/netxms/ssh.nsm: cannot open shared object file: No such file or directory
2018.02.06 13:57:35.483 *I* Subagent "SSH" (ssh.nsm) loaded successfully (version 2.2.3)
2018.02.06 15:02:40.687 *I* Subagent "SSH" (ssh.nsm) loaded successfully (version 2.2.3)
2018.02.07 16:05:19.093 *I* Subagent "SSH" (ssh.nsm) loaded successfully (version 2.2.3)
2018.02.07 16:09:25.185 *D* SSH: using libssh version 0.6.1/openssl/zlib
2018.02.07 16:09:25.185 *I* Subagent "SSH" (ssh.nsm) loaded successfully (version 2.2.3)


Am I correct that you were not asking for any logs on the server that the script is stored?  That doesn't have the agent on it as I didn't think it was needed. 

Thanks for your continued help and patience on this.
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 16, 2018, 07:07:36 PM
I noticed that on my NetXMS server, where the agent is installed, and the machine I want to be a proxy, where it says isagent it says no.  Is that a display bug, or is my NetXMS server not seeing itself as an agent.  As shown above, my agent service is running. 

Could this be the issue?
Title: Re: Run Script to get DCI Data
Post by: Victor Kirhenshtein on February 20, 2018, 08:49:27 PM
Hi,

yes, that's definitely an issue. Check that you have NetXMS server's external address in MasterServers on local agent.

Best regards,
Victor
Title: Re: Run Script to get DCI Data
Post by: alike767 on February 21, 2018, 02:24:04 AM
That was it!!

Thanks for your patience on this.  I know it took awhile.