Class Scanner
java.lang.Object
org.networkupstools.jnut.Scanner
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieve scanner extra parameters like snmp community name or passwords.Retrieve nut-scanner executable name (with location if any).Retrieve the nut-scanner executable path.Retrieve a scanner extra parameter.intRetrieve the scan type.booleanTest if a scanner has an extra parameter.voidremoveParam(String name) Remove a scanner extra parameter.scan()Execute the scan.voidSet the scanner extra parameters.voidsetExecName(String value) Set the nut-scanner executable name (with location if any).voidsetExecPath(String value) Set the nut-scanner executable path.voidSet a scanner extra parameter.voidsetScanType(int scanType) Set the scan type.
-
Field Details
-
SCAN_USB
public static final int SCAN_USB- See Also:
-
SCAN_SNMP
public static final int SCAN_SNMP- See Also:
-
SCAN_XML
public static final int SCAN_XML- See Also:
-
SCAN_OLDNUT
public static final int SCAN_OLDNUT- See Also:
-
SCAN_AVAHI
public static final int SCAN_AVAHI- See Also:
-
SCAN_IPMI
public static final int SCAN_IPMI- See Also:
-
SCAN_COMPLETE
public static final int SCAN_COMPLETE- See Also:
-
OPTION_SCANNER_EXEC
- See Also:
-
OPTION_SCANNER_PATH
- See Also:
-
OPTION_TIMEOUT
- See Also:
-
OPTION_START_IP
- See Also:
-
OPTION_END_IP
- See Also:
-
OPTION_MASK_CIDR
- See Also:
-
OPTION_SNMPv1_COMMUNITY
- See Also:
-
OPTION_SNMPv3_SECURITY_LEVEL
- See Also:
-
OPTION_SNMPv3_SECURITY_NAME
- See Also:
-
OPTION_SNMPv3_AUTHENTICATION_PROTOCOL
- See Also:
-
OPTION_SNMPv3_AUTHENTICATION_PASSWORD
- See Also:
-
OPTION_SNMPv3_PRIVACY_PROTOCOL
- See Also:
-
OPTION_SNMPv3_PRIVACY_PASSWORD
- See Also:
-
OPTION_NUT_UPSD_PORT
- See Also:
-
-
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
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
Retrieve nut-scanner executable name (with location if any). Default to "nut-scanner".- Returns:
- nut-scanner executable name
-
setExecName
Set the nut-scanner executable name (with location if any).- Parameters:
value- nut-scanner executable name
-
getExecPath
Retrieve the nut-scanner executable path. The directory in which nut-scanner will be launched.- Returns:
- nut-scanner executable path
-
setExecPath
Set the nut-scanner executable path. The directory in which nut-scanner will be launched.- Parameters:
value- nut-scanner executable path
-
getConfig
Retrieve scanner extra parameters like snmp community name or passwords.- Returns:
- Map of parameters.
-
setConfig
Set the scanner extra parameters.- Parameters:
config- Map of parameters.
-
setParam
-
removeParam
Remove a scanner extra parameter.- Parameters:
name- Name of the parameter to remove.
-
getParam
-
hasParam
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
Execute the scan.- Returns:
- Array of found DiscoveredDevice, null if a problem occurs, empty if no one found.
- Throws:
IOException
-