NetXMS Support Forum

English Support => General Support => Topic started by: Egert143 on September 15, 2022, 01:45:53 PM

Title: Instance discovery.
Post by: Egert143 on September 15, 2022, 01:45:53 PM
Hello

Could use help with dci instance discovery.

I have 2 Mikrotik wifi devices where i would like to poll ssid name. On one device it reports with .1.3.6.1.4.1.14988.1.1.1.3.1.4.1 on another one with .1.3.6.1.4.1.14988.1.1.1.3.1.4.2. The end number is changing. How can i discover that dynamicaly?

Egert
Title: Re: Instance discovery.
Post by: Filipp Sudanov on September 16, 2022, 07:25:58 AM
Pls see DCI configuration in the attached images. It will perform SNMP walk starting from specified OID and create DCIs for all OIDs encountered in this walk. {instance} macro will contain last part of OID, {instance-name} - value from that OID.

My Mikrotik device has two items there:
.1.3.6.1.4.1.14988.1.1.1.3.1.4.1
.1.3.6.1.4.1.14988.1.1.1.3.1.4.2
so two DCIs would been created.


The other approach is to make a script DCI, perform SNMP walk from the script and may be join results into one DCI. I can prepare example of this if needed.
Title: Re: Instance discovery.
Post by: Egert143 on September 16, 2022, 09:43:09 AM
Hello

i Did exactly as in picture, but for me i dont see any dci discoveries for some reason.

Edit:
When i move the dci directly to node then it works, but under template it doesn't. Maybe it needs longer time?

Edit:
After waitng for hour and no dci-s from template appeared. i deleted template and made it again, this time dci-s started apearing and it seems to work.

Second question. I have script to filter what nodes get applied to template. How can i improve on it to match different oid endings and not manualy add them?

if( $node->isSNMP ) {

    if( $node->sysDescription like "*RouterOS *" && ($node->name like "*[Ap] *") ) {
   
        transport = CreateSNMPTransport($node);
        if ( transport == null ) return NULL;

        ssid = SNMPGetValue(transport,".1.3.6.1.4.1.14988.1.1.1.3.1.4.1");
        freq = SNMPGetValue(transport,".1.3.6.1.4.1.14988.1.1.1.3.1.7.1");
       
        ssidB = SNMPGetValue(transport,".1.3.6.1.4.1.14988.1.1.1.3.1.4.2");
        freqB = SNMPGetValue(transport,".1.3.6.1.4.1.14988.1.1.1.3.1.7.2");
       
        if(ssid != null && freq != null) {
            return true;
        }else if(ssidB != null && freqB != null) {
            return true;
        }
    }
}


return false;
Title: Re: Instance discovery.
Post by: Filipp Sudanov on September 20, 2022, 01:32:13 PM
Yes, you can use snmpwalk from nxsl script, e.g.

transport = CreateSNMPTransport($node);
if (transport != null) {
    oid = ".1.2.840.10036.1.1.1.7";
    vars = SNMPWalk(transport, oid);
    if (vars != null) {
      foreach (v: vars) {
          println(v->name." = ".v->value);
      }
    }
}

Then you just need some logic how to parse the results returned by SNMPWalk