/usr/bin/fusioninventory-netdiscovery is in fusioninventory-agent-task-network 1:2.3.5.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
use strict;
use warnings;
use lib "/usr/share/fusioninventory/lib";
use English qw(-no_match_vars);
use Getopt::Long;
use Pod::Usage;
use FusionInventory::Agent::Task::NetDiscovery;
use FusionInventory::Agent::Logger;
my $options = {
community => 'public',
threads => 1
};
my %setup = (
confdir => "/etc/fusioninventory",
datadir => "/usr/share/fusioninventory",
libdir => "/usr/share/fusioninventory/lib",
vardir => "/var/lib/fusioninventory-agent",
);
GetOptions(
$options,
'first=s',
'last=s',
'dictionnary=s',
'community=s',
'entity=s',
'threads=i',
'timeout=i',
'verbose',
'debug+',
'help',
'version'
) or pod2usage(-verbose => 0);
if ($options->{version}) {
print "NetDiscovery task $FusionInventory::Agent::Task::NetDiscovery::VERSION\n";
exit 0;
}
pod2usage(-verbose => 0, -exitval => 0) if $options->{help};
pod2usage(
-message => "no first address, aborting\n", -verbose => 0
) unless $options->{first};
pod2usage(
-message => "no last address, aborting\n", -verbose => 0
) unless $options->{last};
my $discovery = FusionInventory::Agent::Task::NetDiscovery->new(
%setup,
target => FusionInventory::Agent::Task::NetInventory::Target->new(
dictionnary => $options->{dictionnary}
),
logger => FusionInventory::Agent::Logger->new(
debug => $options->{debug}
)
);
$discovery->{options} = {
NAME => 'NETDISCOVERY',
PARAM => [
{
PID => 1,
THREADS_DISCOVERY => $options->{threads},
TIMEOUT => $options->{timeout},
}
],
RANGEIP => [
{
ID => 1,
IPSTART => $options->{first},
IPEND => $options->{last},
}
],
AUTHENTICATION => [
{
ID => 1,
COMMUNITY => $options->{community},
VERSION => '1'
},
{
ID => 2,
COMMUNITY => $options->{community},
VERSION => '2c'
},
]
};
if ($options->{dictionnary}) {
die "no such file $options->{dictionnary}"
unless -f $options->{dictionnary};
$discovery->{options}->{DICO} = getDictionnary($options->{dictionnary});
}
if (defined($options->{entity})) {
$discovery->{options}->{RANGEIP}->[0]->{ENTITY} = $options->{entity};
}
$discovery->{client} =
FusionInventory::Agent::Task::NetInventory::Client->new(
verbose => $options->{verbose}
);
$discovery->{deviceid} = 'foo';
$discovery->run();
sub getDictionnary {
my ($file) = @_;
open (my $handle, '<', $file) or die "Can't open $file: $ERRNO";
local $INPUT_RECORD_SEPARATOR;
my $string = <$handle>;
close $handle;
return $string;
}
package FusionInventory::Agent::Task::NetInventory::Client;
sub new {
my ($class, %params) = @_;
return bless {
verbose => $params{verbose}
}, $class;
}
sub send {
my ($self, %params) = @_;
# don't display control message by default
return unless $self->{verbose}
or $params{message}->{h}->{CONTENT}->{DEVICE};
print $params{message}->getContent();
}
package FusionInventory::Agent::Task::NetInventory::Target;
sub new {
my ($class, %params) = @_;
my $storage = FusionInventory::Agent::Task::NetInventory::Storage->new();
return bless {
storage => $storage
}, $class;
}
sub getStorage {
my ($self, %params) = @_;
return $self->{storage};
}
sub getUrl {
my ($self, %params) = @_;
## no critic (ExplicitReturnUndef)
return undef;
}
package FusionInventory::Agent::Task::NetInventory::Storage;
sub new {
my ($class) = @_;
return bless {}, $class;
}
sub save {
}
sub restore {
return {
dictionary =>
FusionInventory::Agent::Task::NetDiscovery::Dictionary->new()
};
}
__END__
=head1 NAME
fusioninventory-netdiscovery - Standalone network discovery
=head1 SYNOPSIS
fusioninventory-netdiscovery [options] --first <start> --last <stop>
Options:
--first address IP range first address
--last address IP range last address
--dictionnary dictionnary file
--community community string (default: public)
--entity GLPI entity
--threads nb number of discovery threads (default: 1)
--timeout val SNMP timeout (default: 1s)
--verbose verbose output (control messages)
--debug debug output (execution traces)
-h --help print this message and exit
--version print the task version and exit
=head1 DESCRIPTION
F<fusioninventory-netdiscovery> allows to run a network discovery task without a
GLPI server.
|