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
blacksun
Forum Newbie
Posts: 4 Joined: Fri Apr 21, 2006 9:02 am
Post
by blacksun » Fri Apr 21, 2006 9:12 am
I want to check if SNMP on (port 161) is running on a remote host.
SNMP uses UDP and I know that you should send data to UDP in order to know if the the service is
running
Consider the code :
Code: Select all
/*Check UPD protocol : services NTP , NFS, SNMP*/
function checkPortUDP($host,$port,$timeout = 2){
$fp = @fsockopen("udp://".$host, $port, $errno, $errstr, $timeout);
if (!$fp) return false;
else return false;
}//end function
How do I check if SNMP is running?
Last edited by
blacksun on Fri Apr 21, 2006 9:22 am, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Apr 21, 2006 9:13 am
Help with what?
blacksun
Forum Newbie
Posts: 4 Joined: Fri Apr 21, 2006 9:02 am
Post
by blacksun » Fri Apr 21, 2006 9:22 am
how do i check if the udp port is running snmpd?
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Fri Apr 21, 2006 9:28 am
talk some snmp to it? :p (Btw, there is an
snmp extension)
blacksun
Forum Newbie
Posts: 4 Joined: Fri Apr 21, 2006 9:02 am
Post
by blacksun » Fri Apr 21, 2006 9:31 am
i already have that in my application; before I talk SNMP;
i want to check the UDP ports for (SNMP, NTP etc).
how do i check if the UDP port is up?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Apr 21, 2006 9:35 am
You have to talk SNMP to it. There's no way around that as the socket may open without knowing if the connection failed or not.
blacksun
Forum Newbie
Posts: 4 Joined: Fri Apr 21, 2006 9:02 am
Post
by blacksun » Fri Apr 21, 2006 9:48 am
ok; i see.