Thu May 6 20:25:15 2021 UTC ()
Improves NetBSD suport: use (and parse) /var/run/dmesg.boot if present,
use pcictl if present, use NetBSD sysctls when present.
Bump PKGREVISION
(bouyer)
diff -r1.19 -r1.20 pkgsrc/net/p5-FusionInventory-Agent/Makefile
diff -r1.6 -r1.7 pkgsrc/net/p5-FusionInventory-Agent/distinfo
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm
--- pkgsrc/net/p5-FusionInventory-Agent/Makefile 2021/05/03 17:12:23 1.19
+++ pkgsrc/net/p5-FusionInventory-Agent/Makefile 2021/05/06 20:25:15 1.20
| @@ -1,17 +1,18 @@ | | | @@ -1,17 +1,18 @@ |
1 | # $NetBSD: Makefile,v 1.19 2021/05/03 17:12:23 bouyer Exp $ | | 1 | # $NetBSD: Makefile,v 1.20 2021/05/06 20:25:15 bouyer Exp $ |
2 | | | 2 | |
3 | DISTNAME= FusionInventory-Agent-2.6 | | 3 | DISTNAME= FusionInventory-Agent-2.6 |
4 | PKGNAME= p5-${DISTNAME} | | 4 | PKGNAME= p5-${DISTNAME} |
| | | 5 | PKGREVISION= 1 |
5 | CATEGORIES= net perl5 | | 6 | CATEGORIES= net perl5 |
6 | MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=../../authors/id/G/GB/GBOUGARD/} | | 7 | MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=../../authors/id/G/GB/GBOUGARD/} |
7 | | | 8 | |
8 | MAINTAINER= bouyer@NetBSD.org | | 9 | MAINTAINER= bouyer@NetBSD.org |
9 | HOMEPAGE= https://metacpan.org/release/FusionInventory-Agent | | 10 | HOMEPAGE= https://metacpan.org/release/FusionInventory-Agent |
10 | COMMENT= Fusion Inventory agent | | 11 | COMMENT= Fusion Inventory agent |
11 | LICENSE= gnu-gpl-v2 | | 12 | LICENSE= gnu-gpl-v2 |
12 | | | 13 | |
13 | PKG_SYSCONFSUBDIR?= fusioninventory | | 14 | PKG_SYSCONFSUBDIR?= fusioninventory |
14 | EGDIR= ${PREFIX}/share/examples/fusioninventory | | 15 | EGDIR= ${PREFIX}/share/examples/fusioninventory |
15 | CONF_FILES+= ${EGDIR}/agent.cfg ${PKG_SYSCONFDIR}/agent.cfg | | 16 | CONF_FILES+= ${EGDIR}/agent.cfg ${PKG_SYSCONFDIR}/agent.cfg |
16 | CONF_FILES+= ${EGDIR}/inventory-server-plugin.cfg ${PKG_SYSCONFDIR}/inventory-server-plugin.cfg | | 17 | CONF_FILES+= ${EGDIR}/inventory-server-plugin.cfg ${PKG_SYSCONFDIR}/inventory-server-plugin.cfg |
17 | CONF_FILES+= ${EGDIR}/server-test-plugin.cfg ${PKG_SYSCONFDIR}/server-test-plugin.cfg | | 18 | CONF_FILES+= ${EGDIR}/server-test-plugin.cfg ${PKG_SYSCONFDIR}/server-test-plugin.cfg |
| @@ -22,26 +23,27 @@ BUILD_DEFS+= VARBASE | | | @@ -22,26 +23,27 @@ BUILD_DEFS+= VARBASE |
22 | OWN_DIRS+= ${VARBASE}/fusioninventory | | 23 | OWN_DIRS+= ${VARBASE}/fusioninventory |
23 | | | 24 | |
24 | DEPENDS+= p5-HTTP-Server-Simple-Authen-[0-9]*:../../www/p5-HTTP-Server-Simple-Authen | | 25 | DEPENDS+= p5-HTTP-Server-Simple-Authen-[0-9]*:../../www/p5-HTTP-Server-Simple-Authen |
25 | DEPENDS+= p5-File-Which-[0-9]*:../../devel/p5-File-Which | | 26 | DEPENDS+= p5-File-Which-[0-9]*:../../devel/p5-File-Which |
26 | DEPENDS+= p5-Net-IP-[0-9]*:../../net/p5-Net-IP | | 27 | DEPENDS+= p5-Net-IP-[0-9]*:../../net/p5-Net-IP |
27 | DEPENDS+= p5-Text-Template-[0-9]*:../../textproc/p5-Text-Template | | 28 | DEPENDS+= p5-Text-Template-[0-9]*:../../textproc/p5-Text-Template |
28 | DEPENDS+= p5-UNIVERSAL-require-[0-9]*:../../devel/p5-UNIVERSAL-require | | 29 | DEPENDS+= p5-UNIVERSAL-require-[0-9]*:../../devel/p5-UNIVERSAL-require |
29 | DEPENDS+= p5-XML-TreePP-[0-9]*:../../textproc/p5-XML-TreePP | | 30 | DEPENDS+= p5-XML-TreePP-[0-9]*:../../textproc/p5-XML-TreePP |
30 | DEPENDS+= p5-HTTP-Proxy-[0-9]*:../../www/p5-HTTP-Proxy | | 31 | DEPENDS+= p5-HTTP-Proxy-[0-9]*:../../www/p5-HTTP-Proxy |
31 | DEPENDS+= p5-HTTP-Server-Simple-[0-9]*:../../www/p5-HTTP-Server-Simple | | 32 | DEPENDS+= p5-HTTP-Server-Simple-[0-9]*:../../www/p5-HTTP-Server-Simple |
32 | DEPENDS+= p5-IO-Capture-[0-9]*:../../devel/p5-IO-Capture | | 33 | DEPENDS+= p5-IO-Capture-[0-9]*:../../devel/p5-IO-Capture |
33 | DEPENDS+= p5-IPC-Run-[0-9]*:../../devel/p5-IPC-Run | | 34 | DEPENDS+= p5-IPC-Run-[0-9]*:../../devel/p5-IPC-Run |
34 | DEPENDS+= p5-YAML-[0-9]*:../../textproc/p5-YAML | | 35 | DEPENDS+= p5-YAML-[0-9]*:../../textproc/p5-YAML |
| | | 36 | DEPENDS+= p5-YAML-Tiny-[0-9]*:../../textproc/p5-YAML-Tiny |
35 | DEPENDS+= p5-SUPER-[0-9]*:../../devel/p5-SUPER | | 37 | DEPENDS+= p5-SUPER-[0-9]*:../../devel/p5-SUPER |
36 | DEPENDS+= p5-Net-SNMP-[0-9]*:../../net/p5-Net-SNMP | | 38 | DEPENDS+= p5-Net-SNMP-[0-9]*:../../net/p5-Net-SNMP |
37 | DEPENDS+= p5-File-Copy-Recursive-[0-9]*:../../sysutils/p5-File-Copy-Recursive | | 39 | DEPENDS+= p5-File-Copy-Recursive-[0-9]*:../../sysutils/p5-File-Copy-Recursive |
38 | # TEST_DEPENDS | | 40 | # TEST_DEPENDS |
39 | BUILD_DEPENDS+= p5-Test-Deep-[0-9]*:../../devel/p5-Test-Deep | | 41 | BUILD_DEPENDS+= p5-Test-Deep-[0-9]*:../../devel/p5-Test-Deep |
40 | BUILD_DEPENDS+= p5-Test-Exception-[0-9]*:../../devel/p5-Test-Exception | | 42 | BUILD_DEPENDS+= p5-Test-Exception-[0-9]*:../../devel/p5-Test-Exception |
41 | BUILD_DEPENDS+= p5-Test-MockModule-[0-9]*:../../devel/p5-Test-MockModule | | 43 | BUILD_DEPENDS+= p5-Test-MockModule-[0-9]*:../../devel/p5-Test-MockModule |
42 | BUILD_DEPENDS+= p5-Test-MockObject-[0-9]*:../../devel/p5-Test-MockObject | | 44 | BUILD_DEPENDS+= p5-Test-MockObject-[0-9]*:../../devel/p5-Test-MockObject |
43 | BUILD_DEPENDS+= p5-Test-NoWarnings-[0-9]*:../../devel/p5-Test-NoWarnings | | 45 | BUILD_DEPENDS+= p5-Test-NoWarnings-[0-9]*:../../devel/p5-Test-NoWarnings |
44 | | | 46 | |
45 | PERL5_PACKLIST= auto/FusionInventory/Agent/.packlist | | 47 | PERL5_PACKLIST= auto/FusionInventory/Agent/.packlist |
46 | | | 48 | |
47 | PERL5_MODULE_TYPE= Module::Install::Bundled | | 49 | PERL5_MODULE_TYPE= Module::Install::Bundled |
--- pkgsrc/net/p5-FusionInventory-Agent/distinfo 2021/05/03 17:12:23 1.6
+++ pkgsrc/net/p5-FusionInventory-Agent/distinfo 2021/05/06 20:25:15 1.7
| @@ -1,7 +1,15 @@ | | | @@ -1,7 +1,15 @@ |
1 | $NetBSD: distinfo,v 1.6 2021/05/03 17:12:23 bouyer Exp $ | | 1 | $NetBSD: distinfo,v 1.7 2021/05/06 20:25:15 bouyer Exp $ |
2 | | | 2 | |
3 | SHA1 (FusionInventory-Agent-2.6.tar.gz) = 288acf5707e550fa10275f8e6fab70b50aa790aa | | 3 | SHA1 (FusionInventory-Agent-2.6.tar.gz) = 288acf5707e550fa10275f8e6fab70b50aa790aa |
4 | RMD160 (FusionInventory-Agent-2.6.tar.gz) = 1d6504f2119bb531c527180c9275bb692b8a1a2a | | 4 | RMD160 (FusionInventory-Agent-2.6.tar.gz) = 1d6504f2119bb531c527180c9275bb692b8a1a2a |
5 | SHA512 (FusionInventory-Agent-2.6.tar.gz) = c4d12b17e87f9b7e59c1a7284fb88bb0ab51c22037624f666469c75b993ec5939f3f88752afdab82b5d35972c76fbc36a49c6fd1f5246481efb8adf893b4fa3f | | 5 | SHA512 (FusionInventory-Agent-2.6.tar.gz) = c4d12b17e87f9b7e59c1a7284fb88bb0ab51c22037624f666469c75b993ec5939f3f88752afdab82b5d35972c76fbc36a49c6fd1f5246481efb8adf893b4fa3f |
6 | Size (FusionInventory-Agent-2.6.tar.gz) = 2819730 bytes | | 6 | Size (FusionInventory-Agent-2.6.tar.gz) = 2819730 bytes |
7 | SHA1 (patch-Makefile.PL) = d01414b74fa3bbd9bedb658b39d3a07074274142 | | 7 | SHA1 (patch-Makefile.PL) = d01414b74fa3bbd9bedb658b39d3a07074274142 |
| | | 8 | SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm) = 7548564a13a16c0f9da9f8d0df5a6fe5e63079f1 |
| | | 9 | SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm) = ba0bd79e697ac5c9a39ffe70ce26575cc88846a2 |
| | | 10 | SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm) = c5449c5181f92984cfe129dbca5e11d69094c424 |
| | | 11 | SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm) = 48fcf497b55efcd17dd34d8807fa6dc091303169 |
| | | 12 | SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm) = a2ffacd0b9ee84accc001b2013aa52a0c0dc419f |
| | | 13 | SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm) = 94f5afb7b4277a1729c322c7111c94481e1cbe34 |
| | | 14 | SHA1 (patch-lib_FusionInventory_Agent_Tools_BSD.pm) = d312bc244889beb7c747a4c8b021590102a8294c |
| | | 15 | SHA1 (patch-lib_FusionInventory_Agent_Tools_Generic.pm) = 1e8cc8d8ff4c03ba563c3c63ed348e22bd665e9d |
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
Adjust for NetBSD's sysctl kern.boottime output
--- lib/FusionInventory/Agent/Task/Inventory/BSD.pm.orig 2021-05-05 00:17:48.974000555 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD.pm 2021-05-05 00:20:26.256041770 +0200
@@ -28,6 +28,12 @@
command => "sysctl -n kern.boottime",
pattern => qr/sec = (\d+)/
);
+ if (! defined($boottime)) {
+ $boottime = getFirstMatch(
+ command => "sysctl -n kern.boottime",
+ pattern => qr/(\d+)/
+ );
+ }
my $name = canRun('lsb_release') ?
getFirstMatch(
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
Use /var/run/dmesg.boot if present
--- lib/FusionInventory/Agent/Task/Inventory/BSD/Alpha.pm.orig 2021-05-04 23:00:51.263555904 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/Alpha.pm 2021-05-04 22:57:35.095417352 +0200
@@ -42,9 +42,16 @@
# CPU: EV45 (21064A) major=6 minor=2
my $cpu;
- foreach my $line (getAllLines(command => 'dmesg')) {
- if ($line =~ /$bios->{SMODEL},\s*(\S+)\s*MHz/) { $cpu->{SPEED} = $1; }
- if ($line =~ /^cpu[^:]*:\s*(.*)$/i) { $cpu->{NAME} = $1; }
+ if ( -r "/var/run/dmesg.boot") {
+ foreach my $line (getAllLines(file => '/var/run/dmesg.boot')) {
+ if ($line =~ /$bios->{SMODEL},\s*(\S+)\s*MHz/) { $cpu->{SPEED} = $1; }
+ if ($line =~ /^cpu[^:]*:\s*(.*)$/i) { $cpu->{NAME} = $1; }
+ }
+ } else {
+ foreach my $line (getAllLines(command => 'dmesg')) {
+ if ($line =~ /$bios->{SMODEL},\s*(\S+)\s*MHz/) { $cpu->{SPEED} = $1; }
+ if ($line =~ /^cpu[^:]*:\s*(.*)$/i) { $cpu->{NAME} = $1; }
+ }
}
$inventory->setBios($bios);
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
Use /var/run/dmesg.boot if present
--- lib/FusionInventory/Agent/Task/Inventory/BSD/MIPS.pm.orig 2021-05-04 23:07:03.767869134 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/MIPS.pm 2021-05-04 23:08:31.241450459 +0200
@@ -48,10 +48,18 @@
# cpu0: cache L1-I 32KB D 32KB 2 way, L2 512KB direct
my $cpu;
- foreach my $line (getAllLines(command => 'dmesg')) {
- if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
- if ($line =~ /cpu0 at mainbus0:\s*(.*)$/) { $cpu->{NAME} = $1; }
- if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/) { $cpu->{SPEED} = $1; }
+ if ( -r "/var/run/dmesg.boot") {
+ foreach my $line (getAllLines(file => '/var/run/dmesg.boot')) {
+ if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
+ if ($line =~ /cpu0 at mainbus0:\s*(.*)$/) { $cpu->{NAME} = $1; }
+ if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/) { $cpu->{SPEED} = $1; }
+ }
+ } else {
+ foreach my $line (getAllLines(command => 'dmesg')) {
+ if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
+ if ($line =~ /cpu0 at mainbus0:\s*(.*)$/) { $cpu->{NAME} = $1; }
+ if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/) { $cpu->{SPEED} = $1; }
+ }
}
$inventory->setBios($bios);
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
Use /var/run/dmesg.boot if present
--- lib/FusionInventory/Agent/Task/Inventory/BSD/SPARC.pm.orig 2021-05-04 23:09:07.913462371 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/SPARC.pm 2021-05-04 23:09:59.586815307 +0200
@@ -57,9 +57,16 @@
# cpu0: Sun Microsystems UltraSparc-I Processor (167.00 MHz CPU)
my $cpu;
- foreach my $line (getAllLines(command => 'dmesg')) {
- if ($line=~ /^mainbus0 \(root\):\s*(.*)$/) { $bios->{SMODEL} = $1; }
- if ($line =~ /^cpu[^:]*:\s*(.*)$/i) { $cpu->{NAME} = $1; }
+ if ( -r "/var/run/dmesg.boot") {
+ foreach my $line (getAllLines(file => '/var/run/dmesg.boot')) {
+ if ($line=~ /^mainbus0 \(root\):\s*(.*)$/) { $bios->{SMODEL} = $1; }
+ if ($line =~ /^cpu[^:]*:\s*(.*)$/i) { $cpu->{NAME} = $1; }
+ }
+ } else {
+ foreach my $line (getAllLines(command => 'dmesg')) {
+ if ($line=~ /^mainbus0 \(root\):\s*(.*)$/) { $bios->{SMODEL} = $1; }
+ if ($line =~ /^cpu[^:]*:\s*(.*)$/i) { $cpu->{NAME} = $1; }
+ }
}
$bios->{SMODEL} =~ s/SUNW,//;
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
Use /var/run/dmesg.boot if present
Use sysctl hw.disknames if present
match NetBSD disk names
--- lib/FusionInventory/Agent/Task/Inventory/BSD/Storages.pm.orig 2020-08-04 09:36:42.000000000 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/Storages.pm 2021-05-06 22:14:19.168779300 +0200
@@ -37,38 +37,68 @@
command => $command,
%params
);
- $lines =~ s/^kern.geom.confxml://;
- my $tpp = XML::TreePP->new();
- my $tree = $tpp->parse($lines);
-
- my @storages = ();
- for my $class (@{$tree->{mesh}->{class}}) {
- my $name = $class->{name} || $class->{'#name'} || '';
- next unless ($name && $name eq 'DISK');
- for my $geom (@{$class->{geom}}) {
- my $device = {};
- $device->{NAME} = $geom->{name} if $geom->{name};
- $device->{DESCRIPTION} = $geom->{provider}->{config}->{descr}
- if ($geom->{provider}
- && $geom->{provider}->{config}
- && $geom->{provider}->{config}->{descr});
- $device->{DISKSIZE} = $geom->{provider}->{mediasize}
- if ($geom->{provider}
- && defined $geom->{provider}->{mediasize});
- $device->{TYPE} = _retrieveDeviceTypeFromName($device->{NAME});
- push @storages, $device;
+ if ($lines =~ /^kern.geom.confxml:/) {
+ $lines =~ s/^kern.geom.confxml://;
+ my $tpp = XML::TreePP->new();
+ my $tree = $tpp->parse($lines);
+
+ my @storages = ();
+ for my $class (@{$tree->{mesh}->{class}}) {
+ my $name = $class->{name} || $class->{'#name'} || '';
+ next unless ($name && $name eq 'DISK');
+ for my $geom (@{$class->{geom}}) {
+ my $device = {};
+ $device->{NAME} = $geom->{name} if $geom->{name};
+ $device->{DESCRIPTION} = $geom->{provider}->{config}->{descr}
+ if ($geom->{provider}
+ && $geom->{provider}->{config}
+ && $geom->{provider}->{config}->{descr});
+ $device->{DISKSIZE} = $geom->{provider}->{mediasize}
+ if ($geom->{provider}
+ && defined $geom->{provider}->{mediasize});
+ $device->{TYPE} = _retrieveDeviceTypeFromName($device->{NAME});
+ push @storages, $device;
+ }
}
+
+ # Unittest support
+ $params{file} = $params{dmesgFile} if ($params{dmesgFile});
+
+ _extractDataFromDmesg(
+ storages => \@storages,
+ %params
+ );
+
+ return @storages;
}
-
- # Unittest support
- $params{file} = $params{dmesgFile} if ($params{dmesgFile});
-
- _extractDataFromDmesg(
- storages => \@storages,
+ $command = 'sysctl hw.disknames';
+ $lines = getAllLines(
+ command => $command,
%params
);
-
- return @storages;
+ if ($lines =~ /^hw.disknames = /) {
+ $lines =~ s/^hw.disknames = //;
+ chop $lines;
+ my @storages = ();
+ foreach my $drive (split / /, $lines) {
+
+ next if $drive =~ /^vnd/;
+ next if $drive =~ /^dk/;
+ next if $drive =~ /^raid/;
+ next if $drive =~ /^cgd/;
+ next if $drive =~ /^ccd/;
+ next if $drive =~ /^dm/;
+ my $device->{NAME} = $drive;
+ push @storages, $device;
+ }
+
+ _extractDataFromDmesg(
+ storages => \@storages,
+ %params
+ );
+
+ return @storages;
+ }
}
sub _retrieveDeviceTypeFromName {
@@ -76,6 +106,10 @@
my $type = not (defined $name) ? 'unknown' :
$name =~ /^da/ ? 'disk' :
$name =~ /^ada/ ? 'disk' :
+ $name =~ /^wd/ ? 'disk' :
+ $name =~ /^sd/ ? 'disk' :
+ $name =~ /^ld/ ? 'disk' :
+ $name =~ /^xbd/ ? 'disk' :
$name =~ /^cd/ ? 'cdrom' :
'unknown';
return $type;
@@ -85,11 +119,19 @@
my (%params) = @_;
my $storages = $params{storages};
+ my $dmesgLines;
- my $dmesgLines = getAllLines(
- command => 'dmesg',
- %params
- );
+ if ( -r "/var/run/dmesg.boot") {
+ $dmesgLines = getAllLines(
+ file => '/var/run/dmesg.boot',
+ %params
+ );
+ } else {
+ $dmesgLines = getAllLines(
+ command => 'dmesg',
+ %params
+ );
+ }
for my $storage (@$storages) {
next unless $storage->{NAME};
$storage->{MODEL} = getFirstMatch(
@@ -105,6 +147,14 @@
string => $dmesgLines,
pattern => qr/^\Q$storage->{NAME}\E: Serial Number (.*)$/
) || '';
+
+ if (!defined($storage->{DISKSIZE})) {
+ my $size = getFirstMatch(
+ string => $dmesgLines,
+ pattern => qr/^\Q$storage->{NAME}\E: .* (\d+) sectors/
+ );
+ $storage->{DISKSIZE} = $size / 2048; # in MB
+ }
if ($storage->{MODEL}) {
if ($storage->{MODEL} =~ s/^(SGI|SONY|WDC|ASUS|LG|TEAC|SAMSUNG|PHILIPS|PIONEER|MAXTOR|PLEXTOR|SEAGATE|IBM|SUN|SGI|DEC|FUJITSU|TOSHIBA|YAMAHA|HITACHI|VERITAS)\s*//i) {
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
accept pcictl as alternative to lspci
--- ./lib/FusionInventory/Agent/Task/Inventory/Generic/PCI.pm.orig 2021-05-06 18:34:38.856037719 +0200
+++ ./lib/FusionInventory/Agent/Task/Inventory/Generic/PCI.pm 2021-05-06 18:35:03.442742192 +0200
@@ -8,7 +8,7 @@
use FusionInventory::Agent::Tools;
sub isEnabled {
- return canRun('lspci');
+ return canRun('lspci') || canRun('pcictl');
}
sub doInventory {}
$NetBSD: patch-lib_FusionInventory_Agent_Tools_BSD.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
Support NetBSD's ifconfig output
--- lib/FusionInventory/Agent/Tools/BSD.pm.orig 2020-08-04 09:36:42.000000000 +0200
+++ lib/FusionInventory/Agent/Tools/BSD.pm 2021-05-05 00:51:31.393670504 +0200
@@ -31,7 +31,7 @@
);
while (my $line = <$handle>) {
- if ($line =~ /^(\S+): flags=\d+<([^>]+)> (?:metric \d+ )?mtu (\d+)/) {
+ if ($line =~ /^(\S+): flags=(?:0x)?[A-Fa-f\d]+<([^>]+)> (?:metric \d+ )?mtu (\d+)/) {
if (@addresses) {
push @interfaces, @addresses;
@@ -75,6 +75,23 @@
MACADDR => $interface->{MACADDR},
MTU => $interface->{MTU}
};
+ } elsif ($line =~ /inet ($ip_address_pattern)\/(\d+) (?:--> $ip_address_pattern )?/) {
+ my $address = $1;
+ my $netbit=$2;
+ my $mask = (2 ** $2 - 1) << (32 - $2);
+ my $netmask = unpack("H8", pack( "N", $mask));
+ $mask = hex2canonical($netmask);
+ my $subnet = getSubnetAddress($address, $mask);
+
+ push @addresses, {
+ IPADDRESS => $address,
+ IPMASK => $mask,
+ IPSUBNET => $subnet,
+ STATUS => $interface->{STATUS},
+ DESCRIPTION => $interface->{DESCRIPTION},
+ MACADDR => $interface->{MACADDR},
+ MTU => $interface->{MTU}
+ };
} elsif ($line =~ /inet6 ([\w:]+)\S* prefixlen (\d+)/) {
my $address = $1;
my $mask = getNetworkMaskIPv6($2);
$NetBSD: patch-lib_FusionInventory_Agent_Tools_Generic.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $
accept pcictl as alternative to lspci
--- lib/FusionInventory/Agent/Tools/Generic.pm.orig 2020-11-09 14:49:31.000000000 +0100
+++ lib/FusionInventory/Agent/Tools/Generic.pm 2021-05-06 21:25:27.448948334 +0200
@@ -217,52 +217,103 @@
}
sub getPCIDevices {
- my (%params) = (
- command => 'lspci -v -nn',
- @_
- );
- my $handle = getFileHandle(%params);
-
- my (@controllers, $controller);
-
- while (my $line = <$handle>) {
- chomp $line;
-
- if ($line =~ /^
- (\S+) \s # slot
- ([^[]+) \s # name
- \[([a-f\d]+)\]: \s # class
- (\S.+) \s # manufacturer
- \[([a-f\d]+:[a-f\d]+)\] # id
- (?:\s \(rev \s (\d+)\))? # optional version
- /x) {
-
- $controller = {
- PCISLOT => $1,
- NAME => $2,
- PCICLASS => $3,
- MANUFACTURER => $4,
- PCIID => $5,
- REV => $6
- };
- next;
- }
-
- next unless defined $controller;
-
- if ($line =~ /^$/) {
- push(@controllers, $controller);
- undef $controller;
- } elsif ($line =~ /^\tKernel driver in use: (\w+)/) {
- $controller->{DRIVER} = $1;
- } elsif ($line =~ /^\tSubsystem: ?.* \[?([a-f\d]{4}:[a-f\d]{4})\]?/) {
- $controller->{PCISUBSYSTEMID} = $1;
+ if (canRun('lspci')) {
+ my (%params) = (
+ command => 'lspci -v -nn',
+ @_
+ );
+ my $handle = getFileHandle(%params);
+
+ my (@controllers, $controller);
+
+ while (my $line = <$handle>) {
+ chomp $line;
+
+ if ($line =~ /^
+ (\S+) \s # slot
+ ([^[]+) \s # name
+ \[([a-f\d]+)\]: \s # class
+ (\S.+) \s # manufacturer
+ \[([a-f\d]+:[a-f\d]+)\] # id
+ (?:\s \(rev \s (\d+)\))? # optional version
+ /x) {
+
+ $controller = {
+ PCISLOT => $1,
+ NAME => $2,
+ PCICLASS => $3,
+ MANUFACTURER => $4,
+ PCIID => $5,
+ REV => $6
+ };
+ next;
+ }
+
+ next unless defined $controller;
+
+ if ($line =~ /^$/) {
+ push(@controllers, $controller);
+ undef $controller;
+ } elsif ($line =~ /^\tKernel driver in use: (\w+)/) {
+ $controller->{DRIVER} = $1;
+ } elsif ($line =~ /^\tSubsystem: ?.* \[?([a-f\d]{4}:[a-f\d]{4})\]?/) {
+ $controller->{PCISUBSYSTEMID} = $1;
+ }
}
+
+ close $handle;
+
+ return @controllers;
}
- close $handle;
-
- return @controllers;
+ if (canRun('pcictl')) {
+ my (%params) = (
+ command => 'pcictl pci0 list -N',
+ @_
+ );
+ my $handle = getFileHandle(%params);
+
+ my (@controllers, $controller);
+
+ while (my $line = <$handle>) {
+ chomp $line;
+
+ if ($line =~ /^(\S+): ([^\(]+) \((.+), revision ([^\)]+)\)(?: \[(\S+)\])?/) {
+ $controller = {
+ PCISLOT => $1,
+ NAME => $3,
+ MANUFACTURER => $2,
+ REV => $4,
+ DRIVER => $5
+ };
+ push(@controllers, $controller);
+ undef $controller;
+ }
+ }
+ close $handle;
+ (%params) = (
+ command => 'pcictl pci0 list -n',
+ @_
+ );
+ $handle = getFileHandle(%params);
+
+ while (my $line = <$handle>) {
+ chomp $line;
+ if ($line =~ /^(\S+): 0x([0-9a-z]{4})([0-9a-z]{4}) \(0x([0-9a-z]{4})([0-9a-z]{4})\)/) {
+ my $slot = $1;
+ my $pciid = $3 . ":" . $2;
+ my $pciclass = $4;
+ foreach $controller (@controllers) {
+ next if ($controller->{PCISLOT} ne $slot);
+ $controller->{PCIID} = $pciid;
+ $controller->{PCICLASS} = $pciclass;
+ }
+ }
+ }
+ close $handle;
+
+ return @controllers;
+ }
}
sub getPCIDeviceVendor {