Skip to content

Commit

Permalink
feat: Enhanced Synology NAS support with drives & storages support
Browse files Browse the repository at this point in the history
Closes #500
Co-authored-by: NetItUp-FrancescoPasqualatto <[email protected]>
  • Loading branch information
g-bougard committed Sep 28, 2023
1 parent 11c0469 commit c6cea71
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ netdiscovery/netinventory:
* Enhanced CheckPoint devices support
* Enhanced Cisco devices support
* Enhanced Citrix devices support
* PR #500: Enhanced Synology NAS support with drives & storages support

proxy-server-plugin:
* fix #461: Fix XML content-type support for inventories sent by android agent
Expand Down
2 changes: 1 addition & 1 deletion lib/GLPI/Agent/SNMP/Device.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use constant discovery => [ qw(
# http://fusioninventory.org/documentation/dev/spec/protocol/netinventory.html
# STORAGES is specified in inventory.schema.json and can be used to inventory SAN disks
use constant inventory => [ qw(
INFO PORTS MODEMS FIRMWARES SIMCARDS PAGECOUNTERS CARTRIDGES COMPONENTS STORAGES
INFO PORTS MODEMS FIRMWARES SIMCARDS PAGECOUNTERS CARTRIDGES COMPONENTS STORAGES DRIVES
)];

# common base variables
Expand Down
56 changes: 56 additions & 0 deletions lib/GLPI/Agent/SNMP/MibSupport/LinuxAppliance.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ use constant dsmInfo_modelName => dsmInfo . '.1.0';
use constant dsmInfo_serialNumber => dsmInfo . '.2.0';
use constant dsmInfo_version => dsmInfo . '.3.0';

# SYNOLOGY-DISK-MIB
use constant syno_diskEntry => synology . '.2.1.1';
use constant syno_diskID => syno_diskEntry . '.2';
use constant syno_diskModel => syno_diskEntry . '.3';
use constant syno_diskType => syno_diskEntry . '.4';
use constant syno_diskName => syno_diskEntry . '.12';

# SYNOLOGY-RAID-MIB
use constant syno_raidEntry => synology . '.3.1.1';
use constant syno_raidName => syno_raidEntry . '.2';
use constant syno_raidFreeSize => syno_raidEntry . '.4';
use constant syno_raidTotalSize => syno_raidEntry . '.5';

# CHECKPOINT-MIB
use constant svnProdName => checkpoint . '.1.6.1.0';
use constant svnVersion => checkpoint . '.1.6.4.1.0';
Expand Down Expand Up @@ -257,6 +270,49 @@ sub run {

my $firmware;
if ($manufacturer eq 'Synology') {
my $diskIDs = $self->walk(syno_diskID) // {};
my $diskModels = $self->walk(syno_diskModel) // {};
my $diskTypes = $self->walk(syno_diskType) // {};
my $diskNames = $self->walk(syno_diskName) // {};
my $volumesNames = $self->walk(syno_raidName) // {};
my $volumesFreeSizes = $self->walk(syno_raidFreeSize) // {};
my $volumesTotalSizes = $self->walk(syno_raidTotalSize) // {};

foreach my $key (keys(%{$diskModels})){
my $model = trimWhitespace(getCanonicalString($diskModels->{$key}) // "")
or next;
my $storage = {
MODEL => $model,
TYPE => 'disk',
};
my $diskName = trimWhitespace(getCanonicalString($diskNames->{$key}) // "") || trimWhitespace(getCanonicalString($diskIDs->{$key}) // "");
my $diskManufacturer = trimWhitespace(getCanonicalManufacturer($model) // "");
my $diskType = trimWhitespace(getCanonicalString($diskTypes->{$key}) // "");
$storage->{NAME} = $diskName
if $diskName;
$storage->{MANUFACTURER} = $diskManufacturer
if $diskManufacturer;
$storage->{INTERFACE} = $diskType
if $diskType;
push @{$device->{STORAGES}}, $storage;
}

foreach my $key (keys(%{$volumesNames}))
{
my $name = trimWhitespace(getCanonicalString($volumesNames->{$key}) // "")
or next;

my $volumn = {
VOLUMN => $name,
};
$volumn->{FREE} = getCanonicalSize("$volumesFreeSizes->{$key} bytes")
if $volumesFreeSizes->{$key};
$volumn->{TOTAL} = getCanonicalSize("$volumesTotalSizes->{$key} bytes")
if $volumesTotalSizes->{$key};

push @{$device->{DRIVES}}, $volumn;
}

my $dsmInfo_version = $self->get(dsmInfo_version);
if (defined($dsmInfo_version)) {
$firmware = {
Expand Down

0 comments on commit c6cea71

Please sign in to comment.