From FreeNATS Wiki
Jump to: navigation, search

FreeNATS comes with a PHP command-line only (not web run for timeout reasons) discovery tool. This tool generates XML output suitable for use with the bulk importing tool.

You will usually have to run this tool as a superuser because it uses low level socket operations to ping each host.

Using the Tool

Change to the FreeNATS bin directory (cd /opt/freenats/server/bin for Virtual Appliance users) to run the script. The usage information provided is as follows:

FreeNATS Discovery Tool
Usage: php discover.php <IP/RANGE> [<IP/RANGE> ...] [options]

Goes through IPs or ranges and discovers nodes, outputting an XML file for
import to FreeNATS with the bulk importer.

IPs or Ranges are Specified as: - single IP address - range of IP addresses - network with numeric netmask - network with IPv4 netmask

Options are:
 --file <filename> - output XML file (defaults to discover.xml)
 --webprobe - do a web probe and add the test if found
 --recorded - set the record data flag for any discovered tests by default

See for more information.

So for example:

php discover.php --file output.xml

Would try and ping a single IP and if the host was up list it for inclusion. Output would go into output.xml

php discover.php --file output.xml --webprobe

Would do the same thing but also try and connect to and add a web time test for this node/URL if successful into the output

php discover.php

Would do a simple discovery of all IPs between and inclusive and output to the standard discovery.xml file

It is essentially the same as:

php discover.php
php discover.php

You can specify multiple IPs and ranges so:

php discover.php

Would probe the IPs, and all from to inclusive

Using the Output

The output is in standard FreeNATS bulk import format and can be edited by hand if required before being imported into FreeNATS with the bulk importer tool.

Virtual Appliance Example

For example on the FreeNATS virtual appliance you would login to the console and then:

cd /opt/freenats/server/bin
php discover.php

To discover nodes from to inclusive. This will generate the output the discover.xml

You may then like to edit/check the file - either in the console text editor:

nano discover.xml

Press Control-X then Return to Save and Exit

or upload the file onto a share and edit it in your preferred text editor

smbclient -U username //server/share
enter password when prompted
put discover.xml

then after editing get it back

smbclient -U username //server/share
enter password when prompted
get discover.xml

Once you're happy with the XML file you can do a trial import with:

php import.php discover.xml

And see if any errors are generated etc. To commit the changes do:

php import.php discover.xml --live