Read text file and count matched items

Started by squeezypiano, June 07, 2016, 10:55:55 PM

Previous topic - Next topic

squeezypiano

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.

tomaskir

#1
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.

squeezypiano

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.

squeezypiano

Hello,

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


  • Set your DCI's origin to Push Agent and configure other properties as usual, excluding polling interval which is meaningless in case of pushed data.
  • Create separate user account or pick an existing one and give "Push Data" access right on the DCI owning node to that user.
  • Use nxapush utility for pushing data.

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

tomaskir

You need to specify object ID for which this data is being pushed for.

Example:

nxapush -o 1001 some_dci=2

squeezypiano

Thanks for replying.  I have tried now with -o using DCI ID and node ID but neither is working still.

tomaskir

#6
It works fine for me:
nxapush -o 4535 test-param=test

Its Object ID and DCI Parameter (NOT Description).

squeezypiano

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?

tomaskir


squeezypiano

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.

tomaskir

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

squeezypiano

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