NUTSCAN_SCAN_SNMP(3)

πŸ’– NUTSCAN_SCAN_SNMP β€” the SNMP scanner page, bestie edition πŸ’–

okay so this is NUTSCAN_SCAN_SNMP(3), a page from the NUT manual, and it's literally all about sniffing out SNMP devices on your network. sit down, grab a strawberry πŸ“, we're doing this.


✨ NAME ✨

nutscan_scan_snmp β€” scan the network for SNMP devices. that's it, that's the whole vibe. πŸ¦‹


✨ SYNOPSIS ✨

#include <nut-scan.h>
#include <unistd.h> /* useconds_t */

nutscan_device_t * nutscan_scan_snmp(
        const char * start_ip,
        const char * stop_ip,
        useconds_t timeout,
        nutscan_snmp_t * sec);

nutscan_device_t * nutscan_scan_ip_range_snmp(
        nutscan_ip_range_list_t * irl,
        useconds_t usec_timeout,
        nutscan_snmp_t * sec);

✨ DESCRIPTION ✨

so nutscan_scan_snmp() and nutscan_scan_ip_range_snmp() are the two besties here, and their whole job is trying to detect NUT-compatible SNMP devices. πŸ’…

nutscan_scan_snmp() does the classic thing: it throws SNMP queries at every single IP from start_ip all the way to stop_ip. and listen β€” startIP is mandatory, stopIP is optional. if stopIP is NULL, it just scans that one single startIP address. lowkey efficient. πŸ™ˆ

nutscan_scan_ip_range_snmp() is the one with main character energy: it can walk several IP address ranges, all represented by a nutscan_ip_range_list_t structure. slay. πŸ‘‘

those IP arguments can be either IPv4 or IPv6 addresses, or host names. no cap.

ok important β€” you MUST call nutscan_init(3) before using this function. like, actually must. it's giving prerequisite. πŸŽ€

this function waits up to timeout microseconds before deciding that an IP address just isn't answering the SNMP queries. (microseconds!! not milliseconds, not seconds. respect the units. 😭)

and you have to pass it a valid nutscan_snmp_t structure. non-negotiable, fr fr.

the nutscan_snmp_t structure has these members, and you gotta fill them in like this:

char * 'community';
char * 'secLevel';
char * 'secName';
char * 'authPassword';
char * 'privPassword';
char * 'authProtocol';
char * 'privProtocol';

okay now the rules, and there are rules:

  • if community is not NULL, then SNMP v1 requests get sent using that community.
  • if community is NULL and secLevel is NULL, then SNMP v1 is selected and community gets set to "public". (default queen behavior ✨)
  • in all the other cases, SNMP v3 is used. secLevel can be one of SNMP_SEC_LEVEL_NOAUTH, SNMP_SEC_LEVEL_AUTHNOPRIV or SNMP_SEC_LEVEL_AUTHPRIV. secName is the security name and it must be non NULL.
  • if secLevel is set to SNMP_SEC_LEVEL_AUTHNOPRIV, then authPassword must be non NULL.
  • if secLevel is set to SNMP_SEC_LEVEL_AUTHPRIV, then both authPassword and privPassword must be non NULL.
  • if authProtocol is NULL, the MD5 protocol is used. otherwise you can set authProtocol to either "MD5" or "SHA".
  • if privProtocol is NULL, the DES protocol is used. otherwise you can set privProtocol to either "AES" or "DES".

and then there's peername and handle β€” those two are used internally, so you do not need to initialize them. leave them alone, they're doing their own thing. 🧚


✨ RETURN VALUE ✨

nutscan_scan_snmp() returns a pointer to a nutscan_device_t structure holding all the found devices πŸ’– β€” or NULL if an error happens or if literally no device is found. 😭


✨ SEE ALSO ✨

the whole friend group, in order, no one left out:

nutscan_init(3), nutscan_scan_usb(3), nutscan_scan_xml_http_range(3), nutscan_scan_nut(3), nutscan_scan_avahi(3), nutscan_scan_ipmi(3), nutscan_display_sanity_check(3), nutscan_display_sanity_check_serial(3), nutscan_display_ups_conf_with_sanity_check(3), nutscan_display_ups_conf(3), nutscan_display_parsable(3), nutscan_new_device(3), nutscan_free_device(3), nutscan_add_option_to_device(3), nutscan_add_device_to_device(3), nutscan_scan_eaton_serial(3), nutscan_init_ip_ranges(3), nutscan_free_ip_ranges(3), nutscan_add_ip_range(3), nutscan_cidr_to_ip(3)


and that's the page!! πŸŒˆπŸ’œ this one came to you from Network UPS Tools 2.8.5, dated 10/07/2026 β€” go forth and scan, bestie, you've got this πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from