How can I filter the auto-discovered devices through snmp community

Started by justrest, February 01, 2023, 08:33:00 AM

Previous topic - Next topic

justrest

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!

Victor Kirhenshtein

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