Difficult SNMP question, please help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sathi
Forum Newbie
Posts: 5
Joined: Mon Jun 12, 2006 11:53 am

Difficult SNMP question, please help.

Post by Sathi »

I have been trying to Google this for three days with no luck, here is my problem...

I am developing an application that does certain scripted functions for our helpdesk and networking groups and delivers the results via web interface. An example of some of the functionality is port status of a switch, router error tracking, performance monitoring, utilization...that kind of stuff. I'm using snmp to do pretty much everything and it works great and all is good *except* when 2 users try and do something invoking snmp calls at the exact same time. I did a line sniff to see what the deal was and this is what happens as an example:

User (A) requests port speed/duplex settings for a switch on the network, php starts sending out the snmpget calls needed...

User (B) initiates a check for router errors a split second after User (A), while User (A)'s script is still doing its thing. The instant User(B)
does this User(A) stops making the needed snmp calls and just stops. They then need to close out of their web browser and log back in.

User (B)'s request completes without a problem.

I am guessing this is caused by contention for the snmp port and php gets confused. What I don't get is I have some scripts that rely on telnet and they all go out on port 23 and can run at the same time with no problem, why not snmp? My google searches turned up AgentX and smux protocols, but I could not really tell if they are relevant to my problem. Am I trying to do something that snmp is not capable of?

The only idea I had for a work around for this is anytime PHP goes to do an snmp query it can check to see if port 161 is in use, and if it is sleep for a period of time and then try again. Does that sound like it would work? Any input would be greatly appreciated, thanks.

I am running the following configuration on windows 2003

Apache version 2.2.0
PHP version 5.1.2
MySQL version 5.0.18
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

You could make a MySQL Database that has only one value in it, when UserA starts it changes the value to 1 which would be someone is running the test, and when UserA is done then it would be set to 0. When userB goes on it checks the database and if the value is = to 1 then it continues to check until the value becomes 0, and then sets it back to 1 until userB is done.

You could do it just like that or you could do it by test so if you have 4 tests you would have 4 values that would be turned on and off, so that the different Users would have to "wait" until they can run the test.

Hope that helps!
Sathi
Forum Newbie
Posts: 5
Joined: Mon Jun 12, 2006 11:53 am

Post by Sathi »

Hmmm, that is a pretty good idea. It would probably be allot faster than if I actually checked to see if the port was in use. My only concern would be if a script terminated abnormaly then maybe the flag wouldn't get set back to 0 and then no one would be able to do anything until an admin manually set the flag back to the ready state.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Yeah, but you can make another field for each test, and make it the time it was set to 1, and when its set to 0 the time is set to '' (or a blank field). And then make a cron job that would check the values and if the time is greater than 2 mintues set the value to 0 and set time to ''.
Sathi
Forum Newbie
Posts: 5
Joined: Mon Jun 12, 2006 11:53 am

Post by Sathi »

Well the problem is it doesn't matter which of my scripts are running, if any of them make a snmp call it hoses up any other script doing something with snmp. So it would be an all or nothing kind of thing.

Now that you mention a 2 minute timeout on a script for the snmp flag I realize I have a bigger problem than I thought. I have some bandwidth gauges that poll every three seconds and some scripts that use snmp to auto scan the network. We have 250 remote locations and it takes it a good 20 minutes to scan the whole network. If I can't figure out how to run simultaneous snmp requests I am not going to be able to do what I was hoping to do.

Would it even help to write the pollers in another language? I don't know if this is a php problem, a limitation of snmp, or more likely a limitation of my skill as a programmer :)
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I am still not sure what your trying to do, but this program might do the job for you:
http://www.netsupport-inc.com/dna/netsu ... erview.htm
http://www.netsupport-inc.com/dna/netsupport_dna_overview.htm wrote:Overview

NetSupport DNA (Dynamic Network Administration) facilitates central management of your enterprise PCs in a secure, coordinated and efficient manner.

Combining powerful Hardware and Software Inventory with Software Distribution, Application and Internet Metering, Web based Helpdesk, PC Remote Control and more, NetSupport DNA ensures compliance with corporate configuration standards whilst simultaneously reducing the Total Cost of Ownership (TCO).
Sathi
Forum Newbie
Posts: 5
Joined: Mon Jun 12, 2006 11:53 am

Post by Sathi »

Thanks for the response. I checked out that link but it doesn't do what I am after. I am making a network management app that is customized for what we do here.

What I tried doing today is see if another network application that uses SNMP would duplicate the same problem. To my surprise, it didn't.
For example we have the Solar winds network management application running on the same machine as my web server. Solar Winds has a circuit utilization gauge that works by making SNMP calls to the router. I pretty much made an exact copy of this functionality, i.e. gathering utilization of the router by making SNMP calls to it. I was able to run both my utilization gauge and the solarwinds utilization gauge at the exact same time and both worked with no problem. So there goes my theory that it is a port contention problem. Maybe the problem is just with PHP itself?
Post Reply