Class Scanner

java.lang.Object
org.networkupstools.jnut.Scanner

public class Scanner extends Object
jNut scanner. Wrap calls to nut-scanner in java.

Just instantiate it, set options and nut-scanner program path, then scan().

Scanner scanner = new Scanner();
scanner.setExecName("/usr/local/ups/bin/nut-scanner");
scanner.setExecPath("/usr/local/ups/bin");
scanner.setParam(Scanner.OPTION_MASK_CIDR, "192.168.1.1/24");
Scanner.DiscoveredDevice[] devs = scanner.scan();
Author:
Emilien Kia
  • Field Details

  • Constructor Details

    • Scanner

      public Scanner()
      Default constructor (scan for all device types).
    • Scanner

      public Scanner(int scanType)
      Constructor with device types. Construct a scanner object with specifying what type of scan to do.
      Parameters:
      scanType - Type of scan, union of SCAN_* flags.
    • Scanner

      public Scanner(int scanType, Map config)
      Constructor with device types and scan parameters. Construct a scanner object with specifying what type of scan to do and extra scan parameters.
      Parameters:
      scanType - Type of scan, union of SCAN_* flags.
      config - Map of extra parameters, names are OPTION_*.
  • Method Details

    • getExecName

      public String getExecName()
      Retrieve nut-scanner executable name (with location if any). Default to "nut-scanner".
      Returns:
      nut-scanner executable name
    • setExecName

      public void setExecName(String value)
      Set the nut-scanner executable name (with location if any).
      Parameters:
      value - nut-scanner executable name
    • getExecPath

      public String getExecPath()
      Retrieve the nut-scanner executable path. The directory in which nut-scanner will be launched.
      Returns:
      nut-scanner executable path
    • setExecPath

      public void setExecPath(String value)
      Set the nut-scanner executable path. The directory in which nut-scanner will be launched.
      Parameters:
      value - nut-scanner executable path
    • getConfig

      public Map getConfig()
      Retrieve scanner extra parameters like snmp community name or passwords.
      Returns:
      Map of parameters.
    • setConfig

      public void setConfig(Map config)
      Set the scanner extra parameters.
      Parameters:
      config - Map of parameters.
    • setParam

      public void setParam(String name, String value)
      Set a scanner extra parameter.
      Parameters:
      name - Name of the parameter.
      value - Value of the parameter.
    • removeParam

      public void removeParam(String name)
      Remove a scanner extra parameter.
      Parameters:
      name - Name of the parameter to remove.
    • getParam

      public String getParam(String name)
      Retrieve a scanner extra parameter.
      Parameters:
      name - Name of the parameter.
      Returns:
      Value of the parameter, null if not found.
    • hasParam

      public boolean hasParam(String name)
      Test if a scanner has an extra parameter.
      Parameters:
      name - Name of the parameter.
      Returns:
      True if the scanner has the parameter set.
    • getScanType

      public int getScanType()
      Retrieve the scan type.
      Returns:
      Union of SCAN_* flags.
    • setScanType

      public void setScanType(int scanType)
      Set the scan type.
      Parameters:
      scanType - Union of SCAN_* flags.
    • scan

      public Scanner.DiscoveredDevice[] scan() throws IOException
      Execute the scan.
      Returns:
      Array of found DiscoveredDevice, null if a problem occurs, empty if no one found.
      Throws:
      IOException