NetXMS Support Forum

English Support => General Support => Topic started by: justrest on February 01, 2023, 08:33:00 AM

Title: How can I filter the auto-discovered devices through snmp community
Post by: justrest on February 01, 2023, 08:33:00 AM
How can I filter the auto-discovered devices through snmp community, the current script is
sub main()
{
    transport = $1->createSNMPTransport(161,"stonewell2000");
    if(transport != null)
    {
        sysname = transport->getValue(".1.3.6.1.2.1.1.5.0"); 
        if(sysname != null && sysname !="" && sysname !=" ")
        {
            return true;
        }
    } 
    return false;
}

But the script reports an error, suggesting that if $1 is replaced by $node or $ NewNode , it will also report the same error, please ask the experts for guidance, thank you very much!
Title: Re: How can I filter the auto-discovered devices through snmp community
Post by: Victor Kirhenshtein on February 01, 2023, 09:01:26 AM
You cannot create SNMP transport because node object is not created yet. Currently community string used for discovery is not accessible to filtering script. Closest thing that you can do is to leave only one community string in network credentials and require SNMP support for newly discovered nodes. That way automatic discovery will only try that one community string, and devices that will not respond will not be marked as SNMP capable and will not pass filter. However, you will have to manually enter correct community string for devices that added manually and use different community string.

Best regards,
Victor
Title: Re: How can I filter the auto-discovered devices through snmp community
Post by: justrest on February 01, 2023, 10:35:39 AM
ok,thank you very much!!