netdisco - Internal API
This is the inside guts of the Netdisco executable. You should be looking in README for how to use Netdisco.
discover(host)
refresh_all()
discover()
for each file already in device table.
run()
discover()
as long as the @Discover_Queue has something in it.
schlop(file,topo_only_flag)
mac_suck()
and arp_nip()
unless the topo_only_flag is set.
topo_add_link([{},{}])
topo_load_file(filename)
add_user()
If all 4 are not there, then interactive mode is entered and prompts are given.
batch_mode(name,time_too?)
Can be called recursively. call batch_mode_end()
to return to previous Output.
batch_mode_end(no_compress_flag)
Function returns file name of closed output file.
Pass something as first parameter to force no compression.
end()
Prints various statistics to stdout or batch_redirect()
and calls Netdisco::log().
load_old_devices()
load_old_nodes(days)
Nodes will have to have been seen in the last DAYS days.
parse_oui()
timeout()
arpnip()
node_ip
table.
Cheers to Jim Warner for the original arpnip.
arpwalk()
Calls arpnip()
for each device.
If an optional version and subclass are given, no device type discovery is done.
If a more specific device type is not found (is probably not a network device) then -1 is returned.
device_root()
root_ip()
method, then tries to lookup the reverse entry for sysName.0
find_neighbors()
Adds to the @Discover_Queue
get_device(host)
create_device()
with a community string
If cached values are stored in the database for the SNMP version and community strings, they are used.
If no cached values are available, or if they fail, then the values from the config file are tried.
get_device_rw(device[,version])
Returns undef or -1 on error.
get_subnets(device)
create_device()
for a given VLAN using the modified community string.
mac_getportmacs()
macsuck()
mac_savecache({},{})
1. Checks for detected uplinks, warns of such and removes nodes on these uplinks from additions list
2. Stores the found forwarding table entries to the database.
macwalk()
macsuck()
on each device that has layer2 capabilites.
port_control(switch,port,direction)
port_switch({})
store_device()
store_interfaces()
Deletes the old interface entries in device_port and puts in new ones.
walk_fwtable()
BRIDGE-MIB
for the given device, and then adds MAC addresses to the node
table.
nbtstat(host)
Returns whether a node is answering netbios calls or not.
Based on Remo Rickli's nbtstat.pl
nbtwalk()
Calls nbtstat()
for each device.
alias_clean()
arp_dump(dir)
db_clean()
node
that are switch ports.
Checks for nodes on non existant ports and prints a warning
Removes nodes that are on uplink ports.
dev_dump()
expire_data(type,days,archive_only)
type
can be : node,device
days
is a positive integer number of days in which an entry
has not been updated.
archive_only
for node only.
Removes devices and nodes that haven't been updated in days
days.
Called from nightly()
and controlled through the expire_*
directives
in the config file.
Cheers to Brian Wilson for his patch for the start of this feature.
expire_device(device,expire_nodes?)
Set second argument to true to remove all the connected nodes and their IP mappings as well.
expire_nodes(device,archive_only,port)
Set port to limit the expiration to a specific port.
Set archive_only to 1 to archive the nodes on the device.
expire_nodes_subnet(subnet)
192.168.0.0/24
Runs expire_ips afterwards to cleanup.
expire_ips()
select i.mac from node_ip i where not exists (select 1 from node n where n.mac = i.mac limit 1 ) and not exists (select 1 from device_port p where p.mac = i.mac limit 1) group by i.mac;
mac_dump()
May need to be changed if $nodes takes up too much memory.
netbios_dump()
May need to be changed if $nodes takes up too much memory.
nightly(no_batch)
Calls mac_dump(), arp_dump(), and dev_dump(), db_clean()
and VACUUM ANALYZE
nmis_dump()
graph(no_batch)
graph_each()
Does actual GraphViz calls.
graph_addnode(graphviz_obj,node_ip)
admin_daemon_ctl(cmd)
admin_daemon_status(pid)
pid argument is optional, used in stop function
admin_daemon()
admin_daemon_pid(pid_to_write)
If supplied arguments, writes the pid out to that file.
admin_daemon_job(job_obj)
Changes in code from 0.92 on: Copyright (c) 2003,2004 Max Baker - All Rights Reserved
Original Code: Copyright (c) 2002,2003 Regents of the University of California All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Santa Cruz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%text>