NetXMS Support Forum

English Support => General Support => Topic started by: squeezypiano on June 07, 2016, 10:55:55 PM

Title: Read text file and count matched items
Post by: squeezypiano on June 07, 2016, 10:55:55 PM
Hi,

As a new user to NetXMS I still cannot believe just how easy it is to use.  I have been looking for a replacement to the old RRD based systems for a while and this is blowing everything else away.  I just have a couple of things I am struggling to get worked out (custom scripting seems the way to go with these) that I would like to iron out before I add it to my production.  I have split them in to two posts to keep it simpler.

This topic is about reading data from a text file.  I am using MikroTik APs managed from a central device.  It is possible, using SNMP, to get a count of all clients attached across all the radios but I am looking to go in to more detail, e.g. clients per radio or clients per SSID.  I cannot get this from SNMP so have scripted the MikroTik to dump a text file at regular intervals listing the SSID and radio ID for each active client.  Here is an example of what it looks like.

ssid1::cap001-1
ssid1::cap001-2
ssid1::cap002-1
ssid1::cap002-2
ssid1::cap001-2
ssid1::cap001-1
ssid1::cap002-2
ssid1::cap001-2
ssid2::cap002-1-1
ssid2::cap001-2-1


The big question is how can I filter that in to results.  So maybe counting all the lines containing cap001 or cap001-2 (for the specific radio in a dual band device) or even more granular for ssid1::cap001-2 for all client connected to that SSID on that band on that radio.

Anything to point me in the right direction would be appreciated.

Many thanks.
Title: Re: Read text file and count matched items
Post by: tomaskir on June 07, 2016, 11:12:00 PM
You can actually get per-ssid client-count on MikroTik.
Check out the .1.3.6.1.4.1.14988.1.1.1.3.1.6 tree.
(each SSID has its own instance, and then client count as value)

As for per wireless card, I dont have a multi-card MirkoTik to test with, but from memory, I think you can get per-card clients as well.

To your actual request tho, you can use 'nxapush' utility from the script which generates the files for you to push the data directly into NetXMS DCIs.
Or even 'ExternalParametersProvider' to provide a whole bunch of values as DCIs through the Agent.

Documentation for both is available on the forums and/or the wiki.
Title: Re: Read text file and count matched items
Post by: squeezypiano on June 07, 2016, 11:58:07 PM
Quote from: tomaskir on June 07, 2016, 11:12:00 PM
You can actually get per-ssid client-count on MikroTik.
Check out the .1.3.6.1.4.1.14988.1.1.1.3.1.6 tree.
(each SSID has its own instance, and then client count as value)

Hi Tomas, thanks for replying.  This OID does not work when the APs are centrally managed, only on standalone access points.  I will try to track down the documentation for nxapush and give it a try.  Thanks.
Title: Re: Read text file and count matched items
Post by: squeezypiano on June 09, 2016, 02:25:36 PM
Hello,

I am having trouble getting the push DCIs to receive values.  I followed these steps so far.


I have tried nxapush with and without the user account I created, e.g.:

./nxapush param1=5

and

./nxapush -u user -P password param1=5

but I do not get any data in NetXMS.  I have used tcpdump on the agent and server machines (both Ubuntu) and can see the data bent sent and received by the OS.  I have also tried the same commands using nxapush on the NetXMS server too.

If I run nxapush with -vv I get only one line out saying 'Connected to NetXMS agent' and that is all (was expecting a full debug).

I guess I'm missing something but I cannot work out what.  Can anyone give me some guidance, please?

Thanks in advance,
P
Title: Re: Read text file and count matched items
Post by: tomaskir on June 09, 2016, 02:47:38 PM
You need to specify object ID for which this data is being pushed for.

Example:

nxapush -o 1001 some_dci=2
Title: Re: Read text file and count matched items
Post by: squeezypiano on June 09, 2016, 03:12:29 PM
Thanks for replying.  I have tried now with -o using DCI ID and node ID but neither is working still.
Title: Re: Read text file and count matched items
Post by: tomaskir on June 09, 2016, 03:39:45 PM
It works fine for me:
nxapush -o 4535 test-param=test

Its Object ID and DCI Parameter (NOT Description).
Title: Re: Read text file and count matched items
Post by: squeezypiano on June 09, 2016, 03:43:00 PM
I am using the paramater not description so should be good there.  Can you confirm which ID the object ID is, please?  Is it the ID of the DCI?
Title: Re: Read text file and count matched items
Post by: tomaskir on June 09, 2016, 03:44:15 PM
Object ID in this case = Node ID.
Title: Re: Read text file and count matched items
Post by: squeezypiano on June 09, 2016, 04:08:44 PM
I have spun up another box in case there was a problem with something on it and can now get data from, for example,

nxapush param1=4

Still cannot get anything using -o to push on behalf of another node.  I can work around this but it would nice if I could work it as it would keep a cleaner config.

Thanks for your help.
Title: Re: Read text file and count matched items
Post by: tomaskir on June 09, 2016, 04:49:52 PM
Check your "CheckTrustedNodes" server config variable (set it to 0 and restart server).
I have a feeling we are running into an issue with security here.

https://wiki.netxms.org/wiki/SG:Security_Issues
Title: Re: Read text file and count matched items
Post by: squeezypiano on June 09, 2016, 05:02:27 PM
Genius! Thank you. Tested that and it all started working.  Switched CheckTrustedNodes back to 1 and added Trusted Nodes to the node containing the DCI and that is working now too.  It seems slightly strange, however, that to use the -o option to send a value for the node doing the actual sending requires it to list itself in Trusted Nodes.

Thanks again :)
P