Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.12.3 available

The official documentation can be found on https://wiki.ocsinventory-ng.org. Read it before asking your question.

ipdiscover networks and add to OCS

Hello

I would like to discover devices on networks that don’t have an active OCS agent

The wiki says that it is possible to use ipdiscover-util.pl like this to scan and add devices to the OCS database:

perl ipdiscover-util.pl -network=10.1.1.0/24 -scantype=ping

But the current OCS version 2.9 ipdiscover-util.pl does not have these options (scantype, network)

Is there another way to discovery devices in networks that don't have an OCS agent and add to inventory?

wiki reference

in OCS Inventory NG server for Unix by (450 points)

5 Answers

+1 vote

How run IpDiscover ?

First (and usual), IpDiscover could run from agent.

They could only do a discovery on their local network !

(lots of things about election to chose an agent and not another, are described in the link you've supplied)

(be carefull of the size of the local network : /16 means 65534-1 ping !!)

Second, IpDiscover could run from Server, using the supplied (perl) script 'ipdiscover-util.pl'.

IMHO use of this script need to provide all parameters needed like '-h', '-d', '-u' and '-p' as the script put data inside the database.

The script supplied with 2.9 version is well designed with parameters :

(line 66) :

for $option (@ARGV){

  if($option=~/-a$/){

    $analyse = 1;

  }elsif($option=~/-auto$/){

    $auto = 1;

  }elsif($option=~/-cache$/){

    $cache = 1;

    $analyse = 1;

    $xml = 1;

  }elsif($option=~/-path=(\S*)$/){

    $path = $1;

  }elsif($option=~/-ipdiscover=(\d+)$/){

    $ipdiscover = 1;

    $ipd = $1;

  }elsif($option=~/-xml$/){

    $xml = 1;

....

by (20.1k points)
edited by
0 votes

Could not make it work yet…

How do you translate this line of code for the new ipdiscover-util.pl?

perl ipdiscover-util.pl -network=10.1.1.0/24 -scantype=ping

Looks like the functionality of adding discovered ip’s in the network has been removed in the new version…

Thanks

by (450 points)
+1 vote

I just tried the script (from 2.9.0) running

perl ipdiscover-util.pl -h=localhost -d=ocsweb -u=ocsuser -p=passwd -path=/folder -network=10.x.x.x/24 -scantype=ping

The script does the cmd 'fping -g --quiet -a 10.x.x.x/24' and display the ip of host up.

Then the table 'netmap' was filled with a row for each host up.

The script is (line 271-275) :

        foreach (`fping -g --quiet -a $ips`){

          $ip = $macAddr = $_;

          print "Adding $ip\n";

          $dbh->do('INSERT IGNORE INTO netmap(IP,MAC,MASK,NETID) VALUES(?,?,?,?) ', {}, $ip, $macAddr, $mask, $subnet);

So it was quite strange the field 'MAC' is equal the field 'IP' but this is due to the line 272.

IMHO, try before a command like 'fping' and you'll get an idea of execution time (be carefull with large mask !) 

by (20.1k points)
edited by
0 votes

@ I have reinstalled ocs and now my script shows theses options... thanks

Now I will try to  use snmp discovery....

by (450 points)
0 votes
(I have an v2.4 installation but a copy of the script in v2.9 run perfectly. You can enter values in the script to avoid type -h, -u, -p : exemple "my $dbhost='localhost';" avoid '-h localhost'.)

Please note the snmp scan is done
- only by unix agent (elected) (why only Linux ? It's writed like this ??)

- using ip address collected by IpDiscover

- only in their local network (as IpDiscover) ?

(see https://wiki.ocsinventory-ng.org/06.Network-Discovery-with-OCS-Inventory-NG/Using-SNMP-scan-feature/).

Also there is no server script for snmp discovery like for ipdiscovery.

(NB : for my question, MAC Address for hosts outside of your local network is not very relevant !)
by (20.1k points)
edited by
 
Powered by Question2Answer
...