7. NUT device discovery

7.1. Introduction

nut-scanner(8) is available to discover supported NUT devices (USB, SNMP, Eaton XML/HTTP and IPMI) and NUT servers (using Avahi or the classic connection method).

This tool actually use a library, called libnutscan, to perform actual processing.

Client access library

The nutscan library can be linked into other programs to give access to NUT discovery. Both static and shared versions are provided.

nut-scanner(8) is provided as an example of how to use the nutscan functions.

Here is a simple example that scans for USB devices, and use its own iteration function to display results:

Scanning and reporting example. 

        #include <stdlib.h>
        #include <unistd.h>
        #include <string.h>

        /* Only enable USB scan */
        #define HAVE_USB_H

        #include "nut-scan.h"

        int main()
                nutscan_options_t * opt;
                nutscan_device_t *device;
                nutscan_usb_t usb_scanopts;


                if ((device = nutscan_scan_usb(&usb_scanopts)) == NULL) {
                        printf("No device found\n");

                /* Rewind the list */
                while(device->prev != NULL) {
                        device = device->prev;

                /* Print results */
                do {
                        printf("USB device found\n\tdriver: \"%s\"\n\tport: \"%s\"\n",
                                device->driver, device->port);

                        /* process options (serial number, bus, ...) */
                        opt = &(device->opt);
                        do {
                                if( opt->option != NULL ) {
                                        if( opt->value != NULL ) {
                                                printf(": \"%s\"", opt->value);
                                opt = opt->next;
                        } while( opt != NULL );

                        device = device->next;
                while( device != NULL );


This library file and the associated header files are not installed by default. You must ./configure --with-dev to enable building and installing these files. The libraries can then be built and installed with make and make install as usual. This must be done before building other (non-NUT) programs which depend on them.

For more information, refer to the nutscan(3), manual page and the various nutscan_*(3) functions documentation referenced in the same file.

Configuration helpers

NUT provides helper scripts to ease the configuration step of your program, by detecting the right compilation and link flags.

For more information, refer to a Appendix B: NUT libraries complementary information.

7.2. Python

Python support for NUT discovery features is not yet available.

7.3. Perl

Perl support for NUT discovery features is not yet available.

7.4. Java

Java support for NUT discovery features is not yet available.