angelcamposm/snmp-poller

Running into an issue with your examples..

Closed this issue · 2 comments

I have attempted to test your single poller class, and have run into issues where the SNMP version, host and community do not appear to be passed to your functions. I am using PHP 7.4, and have duplicated the failure with PHP8.0 on Ubuntu..

require __DIR__ . '/../vendor/autoload.php';
use Acamposm\SnmpPoller\SnmpPoller;
use Acamposm\SnmpPoller\Pollers\IfTablePoller;
use SNMP;
$session = new SNMP(SNMP::VERSION_2C, '192.168.15.58', 'noyb');
$poller = new SnmpPoller();
$poller->setSnmpSession($session)->addPoller(IfTablePoller::class)->run();

The err returned for above is:

PHP Warning:  The use statement with non-compound name 'SNMP' has no effect in /opt/nmsApi/poller/snmpPoller.php on line 7
PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Acamposm\SnmpPoller\SnmpPoller::__construct(), 0 passed in /opt/nmsApi/poller/snmpPoller.php on line 12 and exactly 1 expected in /opt/nmsApi/vendor/acamposm/snmp-poller/src/SnmpPoller.php:44
Stack trace:
#0 /opt/nmsApi/poller/snmpPoller.php(12): Acamposm\SnmpPoller\SnmpPoller->__construct()
#1 {main}
  thrown in /opt/nmsApi/vendor/acamposm/snmp-poller/src/SnmpPoller.php on line 44

Any suggestions on how I can attack this issue further?

Hi @Guyverix i need a little bit more info.

The SnmpPoller is a wrapper for SNMP, you create a SNMP session, then pass it to setSnmpSession method. The the addPoller method uses a class to load oids, and run method run queries over the oids, then the result is parsed...

Do you have enabled ext-snmp on php.ini?
Are u using with laravel?

Regards.

@Guyverix remove the "use SNMP" from the file... i've removed from a test and it disapears...

regards.