Servers, routers and switches ... one common community with which they share is the ability to accept SNMP requests when the SNMP service is running. It seems like what you are trying to do is implement a funny workaround for a monitoring system (nagios, etc.).
According to: http://php.net/manual/en/book.snmp.php
<?php $endpoints = array('10.0.0.1','10.0.0.2','10.0.0.3','10.0.0.4','10.0.0.5'); foreach ($endpoints as $endpoint) { $session = new SNMP(SNMP::VERSION_2c, $endpoint, 'boguscommunity'); var_dump($session->getError());
This will show you if the endpoint exists and the SNMP service is running. Specifically, if the port is accessible / open, you can use fsockopen()
:
http://php.net/manual/en/function.fsockopen.php
<?php $fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr); if (!$fp) { echo "ERROR: $errno - $errstr<br />\n"; } ?>
source share