discovery plugin customization

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

discovery plugin customization

Post by jhollon »

I have searched everywhere and can't find an answer. is it possible to make the plugin only add devices to the discovery list ONLY if they have a good SNMP data rather than just ping alone. what i mean is that instead of anything that responds to a ping showing up on the list, that only items that respond to ping and have SNMP information collected get added to the list?

example

06/18/2013 04:39:30 PM - DISCOVER: Poller[0] 935 IPs Scanned, 30 IPs Responded to Ping, 9 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti

in this run, i would only like the 9 items that respond to SNMP to be added rather than the 30 items that respond to ping.

thanks in advance.

Jeff
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: discovery plugin customization

Post by cigamit »

There is no option for it, but you can easily edit findhosts.php, goto the line that says
}else if ($result) {
and comment out (just put a // at the beginning of the line) everything down to and including
discover_debug(" - Host $dnsname is alive but no SNMP!");
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

cigamit, that was absolutely PERFECT. that did it. thanks for saving me some time, i and another person were trying to figure this out for the better part of a week without doing anything but killing the plugin functionality.

i only have one other issue now, i will pose it, but not sure if this is the correct spot. it does have to do with discovery.

the only thing i can use to do discovery is ICMP. i wanted to do UDP and even tried TCP method, but nothing works. anytime i run anything other than ICMP, i get no responses. what is strange is that i have UDP and ICMP open in my firewall, i guess my question is is there a certain port that the UDP or TCP method uses to ping. i am not sure why this isn't working, was just curious if you knew how to get this part working. no biggie if now, just seems to be slower using ICMP method is all.

thanks again for the script comments-out to get what i needed and any help you can give on the UDP stuff would be greatly appreciated.

thanks,

jeff
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: discovery plugin customization

Post by cigamit »

From the code
$ping->port = 0;
If you want to do a different port, you can easily change that.
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

in the findhosts or discovery script. i did a search in the findhosts and it didn't come up
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

nevermind, i found it.....should i just change it to 161 for udp?
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

update, changed code to ref port 161 for UDP and it is flying now. just not adding the hosts to discovery list. i still have something wrong.

again, thanks for all of your help
Last edited by jhollon on Wed Jun 19, 2013 10:00 am, edited 1 time in total.
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: discovery plugin customization

Post by cigamit »

Ya, that will tell you if SNMP is up but kinda defeats the purpose considering you are only adding them if SNMP is up anyway. If you would rather just ignore the result of ping and test for SNMP, you could just set

Code: Select all

$force = true;
right before.

Code: Select all

if (($result || $force) && discover_valid_snmp_device($device)){
and it will test for SNMP no matter if the ping worked or not (but you still get accurate results of whether or not the ping did work).
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

got it working great now. changed the port to 5813 and left it so that it DOESN'T check each device for SNMP (which slows it down a ton) and everything is blazingly fast now. i have over 60 distinct subnets with a huge network and want this to scan every 4 hours or so becuase there are installs all the time at customer sites and the installers never really tell others that a new node was added and this with autom8 makes things so much better. before with ICMP method it took around 3 minutes to scan a /24 and now with these changes it is only taking roughly 30 seconds. this is going to save me a ton of time.

again, thanks for everything.
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

look at this difference

06/19/2013 10:27:10 AM - DISCOVER: Poller[0] 13730 IPs Scanned, 640 IPs Responded to Ping, 521 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti
06/19/2013 10:14:18 AM - POLLER: Poller[0] Network Discover is now running

keep in mind this same job via ICMP took around 6 hours last time...this is the pull AFTER i have already spent hours on the discovery scan and then added over 600 devices with the old way. this is HUGE.

thanks thanks thanks again.
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

last question, i swear. is there a particular reason that when i run the script from command line it is really fast and when it runs through the scheduler in settings for discovery is take 10 times longer? anyway i can get the same speed from the scheduled job discovery as i get from the command line when i run 'sudo php -q findhosts.php -d -f'?
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: discovery plugin customization

Post by cigamit »

hmm... well since the scheduler just launches the findhosts.php process, not sure where the slowdown would be unless its because other things are also running in the background.
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

do you know where the actual call for discovery is listed in whatever file cacti uses to start it on the scheduler? i think me putting the force (-f) option in commandline is making it take a higher priority than when it is launched by cacti. i am wondering if i edit the exact string for the call from cacti on the scheduler to match that of the command line, if that would make a difference at all. i know, i am a tinkerer for speed's sake.
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: discovery plugin customization

Post by cigamit »

-f just forces the script to run even if it doesn't think its time yet.
But if you want to tinker, check the bottom of setup.php inside the plugin.
jhollon
Cacti User
Posts: 51
Joined: Mon Jan 24, 2011 1:30 pm

Re: discovery plugin customization

Post by jhollon »

thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests