-
Notifications
You must be signed in to change notification settings - Fork 0
Sample with Plain Text
Lee Thompson edited this page Jun 23, 2015
·
1 revision
#-------------------------------------------------------------
# Sample script for the ReadyNAS Perl library
#-------------------------------------------------------------
#-------------------------------------------------------------
# Load the library
#-------------------------------------------------------------
require 'readynas.pl'; # Loader
loadReadyNASLibrary("HYBRID"); # Select Library to Use
# SNMP = SNMP
# MULTICAST = UPNP
# UNICAST = UPNP
# HYBRID = UNICAST/SNMP
#--------------------------------------------------#
# You can alternately use the libraries directly. #
# #
# e.g. require 'readynas-unicast.pl'; #
#--------------------------------------------------#
#-------------------------------------------------------------
# Set Options
#-------------------------------------------------------------
setOptionRequireUniqueHosts(1); # Filter duplicate hostnames (0=off, 1=on)
setOptionVerbose(0); # Verbose Messages (0=off, 1=on)
setOptionDebug(0); # Debug Messages (0=off, 1=on)
setOptionDebugFile("console"); # Output to CONSOLE
setOptionDumpPackets(0); # Write packets to disk (UPNP Only)
setOptionDumpBadPacketsOnly(0); # Write ONLY bad packets to disk (UPNP Only)
setSocketTimeout(1); # Set Socket Timeout (Seconds)
setSocketErrorTimeout(0); # Set Socket Error Timeout (Seconds) (MULTICAST ONLY)
setCommunity("public") ; # Set SNMP Community (SNMP Only)
#-------------------------------------------------------------
# ReadyNAS Units to Scan
#-------------------------------------------------------------
setBroadcastAddress("192.168.0.255");
#------------------------------------------------------------#
# Look for units in the subnet (UPNP only) #
# #
# * If not set, defaults to 255.255.255.255 which will only #
# work with UPNP MULTICAST. #
# #
# * If using UPNP to detect units, do NOT specify any units #
# below. #
# #
# * If using SNMP you MUST specify each unit below. #
# (No discovery is available) #
#------------------------------------------------------------#
# addUnit("192.168.0.1");
# addUnit("192.168.0.2");
# addUnit("192.168.0.3");
# addUnit("192.168.0.4");
# addUnit("192.168.0.5");
#------------------------------------------------------------#
# Add NETGEAR ReadyNAS unit at IP address to the list to #
# gather information from. #
#------------------------------------------------------------#
#-------------------------------------------------------------
# Display Banner
#-------------------------------------------------------------
print "NETGEAR ReadyNAS Status\n";
print "Using " . getLibraryTitle() . " v" . getLibraryVersion() . "\n\n";
print "Please Wait...\n";
#-------------------------------------------------------------
# Gather ReadyNAS Data
#-------------------------------------------------------------
loadReadyNASData(); # if for some reason you want the packets for your
# own purposes, simply assign a variable.
# (UNICAST and MULTICAST libraries only.)
if (getBytesRead() < 1) {
print "No Data Received.\n";
exit(1);
}
#-------------------------------------------------------------
# Get a list of IP addresses of Units we now have data on
#-------------------------------------------------------------
$units = getUnitAddresses(); # Get a list of ReadyNAS units addresses (sorted by IP)
$unitcount = getUnitCount(); # Get a count of ReadyNAS units
print "Received Data for $unitcount Unit(s)\n";
#-------------------------------------------------------------
# Process the Data
#-------------------------------------------------------------
my $i = 0;
for ( split /\|/, $units ) {
/\|/;
if ($_ ne "") {
$i++;
#----------------------------------------
# parse the UDP data record for each unit
#----------------------------------------
$macindex = parseReadyNASData(getUnitData($_));
#----------------------------------------
# display the parsed data for each unit
#----------------------------------------
print "Unit #$i:\n";
print " Model: $unit{$macindex}{models}{0}\n";
print " OS: $unit{$macindex}{os}{0}\n";
print " Host: $unit{$macindex}{hostname}{0}\n";
print " IP: $unit{$macindex}{ipaddr}{0}\n";
print " MAC: $unit{$macindex}{mac}{0}\n";
print " Cooling: $unit{$macindex}{fan}{0}\n";
print "System Temp: $unit{$macindex}{tmps}{0}\n";
print " UPS: $unit{$macindex}{ups}{0}\n";
print " Volumes: $unit{$macindex}{volumes}{0}\n";
print " Disks: $unit{$macindex}{disks}{0}\n";
print " Uptime: $unit{$macindex}{system}{uptime}{0}\n";
print " Memory: $unit{$macindex}{system}{memory}{0}\n";
print " Processes: $unit{$macindex}{system}{processes}{0}\n";
print " uname: $unit{$macindex}{system}{uname}{0}\n";
print " Boot: $unit{$macindex}{boot}{0}\n";
print "------------\n";
}
}
exit(0);
NETGEAR ReadyNAS Status
Using UPNP-MULTICAST NETGEAR ReadyNAS Perl Communications Library v201003141246
Please Wait...
Received Data for 5 Unit(s)
Unit #1:
Model: ReadyNAS NV
OS: RAIDiator v4.1.6 (Mon Jul 13 13:56:24 2009)
Host: NAS03
IP: 192.168.0.53
MAC: 00:0D:A2:01:0D:F8
Cooling: 1829RPM (OK)
System Temp: 29.5C/85.1F (OK)
UPS: (NOT_PRESENT)
Volumes: Volume C: RAID Level X, Redundant. 881199 MB (31%) of 2743 GB used (OK)
Disks: 1: 29C/84F (OK); 2: 32C/89F (OK); 3: 32C/89F (OK); 4: 30C/86F (OK)
Uptime: N/A
Memory: N/A
Processes: N/A
uname: N/A
Boot: Normal
------------
Unit #2:
Model: ReadyNAS NV
OS: RAIDiator v4.1.6 (Mon Jul 13 13:56:24 2009)
Host: NAS04
IP: 192.168.0.54
MAC: 00:0D:A2:01:16:9B
Cooling: 1875RPM (OK)
System Temp: 31.0C/87.8F (OK)
UPS: (NOT_PRESENT)
Volumes: Volume C: RAID Level X, Redundant. 1278173 MB (45%) of 2743 GB used (OK)
Disks: 1: 33C/91F (OK); 2: 35C/95F (OK); 3: 33C/91F (OK); 4: 30C/86F (OK)
Uptime: N/A
Memory: N/A
Processes: N/A
uname: N/A
Boot: Normal
------------
Unit #3:
Model: ReadyNAS NV
OS: RAIDiator v4.1.6 (Mon Jul 13 13:56:24 2009)
Host: NAS05
IP: 192.168.0.55
MAC: 00:0D:A2:01:23:9D
Cooling: 2027RPM (OK)
System Temp: 28.5C/83.3F (OK)
UPS: (NOT_PRESENT)
Volumes: Volume C: RAID Level X, Redundant. 2248480 MB (80%) of 2738 GB used (OK)
Disks: 1: 30C/86F (OK); 2: 34C/93F (OK); 3: 42C/107F (OK); 4: 36C/96F (OK)
Uptime: N/A
Memory: N/A
Processes: N/A
uname: N/A
Boot: Normal
------------
Unit #4:
Model: ReadyNAS NV+
OS: RAIDiator v4.1.6 (Mon Jul 13 13:56:24 2009)
Host: NAS06
IP: 192.168.0.56
MAC: 00:0D:A2:01:81:11
Cooling: 2083RPM (OK)
System Temp: 27.5C/81.5F (OK)
UPS: (NOT_PRESENT)
Volumes: Volume C: RAID Level X, Redundant. 1266988 MB (45%) of 2743 GB used (OK)
Disks: 1: 26C/78F (OK); 2: 28C/82F (OK); 3: 30C/86F (OK); 4: 27C/80F (OK)
Uptime: N/A
Memory: N/A
Processes: N/A
uname: N/A
Boot: Normal
------------
Unit #5:
Model: ReadyNAS NV
OS: RAIDiator v4.1.6 (Mon Jul 13 13:56:24 2009)
Host: NAS07
IP: 192.168.0.57
MAC: 00:0D:A2:01:18:17
Cooling: 2027RPM (OK)
System Temp: 29.5C/85.1F (OK)
UPS: (NOT_PRESENT)
Volumes: Volume C: RAID Level X, Redundant. 1554916 MB (54%) of 2776 GB used (OK)
Disks: 1: 28C/82F (OK); 2: 35C/95F (OK); 3: 34C/93F (OK); 4: 30C/86F (OK)
Uptime: N/A
Memory: N/A
Processes: N/A
uname: N/A
Boot: Normal
------------