GithubHelp home page GithubHelp logo

snmp's People

Contributors

chadsikorra avatar simpod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

snmp's Issues

Finding issues with Exception class..

I have begun working on using this class, and it works great. However I am running into trouble when invalid information is passed to the class.
I specifically am testing an invalid IP address, as well as invalid community names. Currently I am getting fatal errors in PHP for both. This is against both PHP7.4, as well as PHP8.2 and am having a hell of a time getting the try catch block to work as you designed.

I have been attempting to alter the throw so it does not spew these errors but have not been having any luck there or in making a __construct() within the ConnectionException to attempt to grab the error. I do see the error information when I do a print_r and it returns the object, but suspect that I am not getting all the way to the \Exception class for some reason..

Any suggestions or guidance on how to fix this would be appreciated.. ( Still learning the more complex areas of PHP, and it is biting me in the rear end)

chubbard@lnms01:/opt/nmsApi/testing/freedsx$ /usr/bin/php7.4 ./testDisc.php 
PHP Fatal error:  Uncaught FreeDSx\Snmp\Exception\ConnectionException in /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php:152
Stack trace:
#0 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php(122): FreeDSx\Snmp\Protocol\ClientProtocolHandler->sendRequestGetResponse()
#1 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(233): FreeDSx\Snmp\Protocol\ClientProtocolHandler->handle()
#2 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(113): FreeDSx\Snmp\SnmpClient->send()
#3 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(126): FreeDSx\Snmp\SnmpClient->get()
#4 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(139): FreeDSx\Snmp\SnmpClient->getOid()
#5 /opt/nmsApi/testing/freedsx/testDisc.php(15): FreeDSx\Snmp\SnmpClient->getValue()
#6 {main}
  thrown in /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php on line 152


chubbard@nms01:/opt/nmsApi/testing/freedsx$ /usr/bin/php8.2 ./testDisc.php 
PHP Fatal error:  Uncaught FreeDSx\Snmp\Exception\ConnectionException in /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php:152
Stack trace:
#0 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php(122): FreeDSx\Snmp\Protocol\ClientProtocolHandler->sendRequestGetResponse()
#1 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(233): FreeDSx\Snmp\Protocol\ClientProtocolHandler->handle()
#2 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(113): FreeDSx\Snmp\SnmpClient->send()
#3 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(126): FreeDSx\Snmp\SnmpClient->get()
#4 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(139): FreeDSx\Snmp\SnmpClient->getOid()
#5 /opt/nmsApi/testing/freedsx/testDisc.php(15): FreeDSx\Snmp\SnmpClient->getValue()
#6 {main}
  thrown in /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php on line 152

This is what I am attempting to run:

cat testDisc.php 
<?php
require  __DIR__ . '/../../vendor/autoload.php';
use \FreeDSx\Snmp\SnmpClient;
$snmp = new SnmpClient([
    'host' => '192.168.15.589',
    'version' => 2,
    'community' => 'public2',
    'timeout_connect' => 1,
    'timeout_read' => 1,
]);
# Get a specific OID value as a string...
$data= $snmp->getValue('1.3.6.1.2.1.1.1.0');
echo $data . "\n\n";
?>

SnmpWalk method not working

Hello @ChadSikorra,

I am taking look at this libary and I would like to use it in my project. But, how to use SnmpWalk ?

For example I wan to read values of oid 1.3.6.1.2.1.2.2.1.1. With classic snmpwalk I can get values with:

snmpwalk -v2c -c ${COMMUNITY) ${HOST_IP} 1.3.6.1.2.1.2.2.1.1
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifIndex.5 = INTEGER: 5
IF-MIB::ifIndex.6 = INTEGER: 6
IF-MIB::ifIndex.7 = INTEGER: 7
IF-MIB::ifIndex.8 = INTEGER: 8
IF-MIB::ifIndex.9 = INTEGER: 9
IF-MIB::ifIndex.10 = INTEGER: 10
IF-MIB::ifIndex.11 = INTEGER: 11
IF-MIB::ifIndex.12 = INTEGER: 12
IF-MIB::ifIndex.13 = INTEGER: 13
IF-MIB::ifIndex.14 = INTEGER: 14
IF-MIB::ifIndex.15 = INTEGER: 15
IF-MIB::ifIndex.16 = INTEGER: 16
IF-MIB::ifIndex.17 = INTEGER: 17
IF-MIB::ifIndex.18 = INTEGER: 18
IF-MIB::ifIndex.19 = INTEGER: 19
IF-MIB::ifIndex.20 = INTEGER: 20
IF-MIB::ifIndex.21 = INTEGER: 21
IF-MIB::ifIndex.22 = INTEGER: 22
IF-MIB::ifIndex.23 = INTEGER: 23
IF-MIB::ifIndex.24 = INTEGER: 24
IF-MIB::ifIndex.25 = INTEGER: 25
IF-MIB::ifIndex.26 = INTEGER: 26
IF-MIB::ifIndex.27 = INTEGER: 27
IF-MIB::ifIndex.28 = INTEGER: 28

but when I am trying to get values with SnmpWalk function from this libaray I can't get values for example:

    public function get()
    {
        $snmp = new SnmpClient([
            'host' => ${HOST_IP},
            'version' => 2,
            'community' => ${COMMUNITY},
        ]);

        $walk = $snmp->walk('1.3.6.1.2.1.2.2.1.1');

        return $walk;
    }

I expect that count can't be 0

Snímka obrazovky 2021-12-14 o 15 56 19

@ChadSikorra can you help me what I am doing wrong ?

Thank you.

Authentication was requested, but the received header has none specified.

Hi,

I'm trying to connect to Dell Switch using following code:

$snmp = new SnmpClient([
    'host' => '1.2.3.4',
    'version' => 3,
    'user' => 'user',
    'use_auth' => true,
    'auth_pwd' => 'PWD',
    'auth_mech' => 'md5',
    'use_priv' => true,
    'priv_pwd' => 'PWD',
    'priv_mech' => 'des',
]);

$uptime = $snmp->getValue('1.3.6.1.2.1.1.3.0');

But I get the following error:

Authentication was requested, but the received header has none specified.

The when I'm using the native php method all is ok:

snmp3_get('1.2.3.4', 'user', 'authPriv', 'MD5', 'PWD', 'DES', 'PWD', '1.3.6.1.2.1.1.3.0');

Could you please help?

reactPHP

hey! your lib seems to be in the right direction! what do you think to add reactPHP support?

Equivalent for snmp_bulk_walk

Is there a way, how to get sub tree for lets say 1.3.6.1.2.1.47.1.1.1.1.2? I studied the docs but couldn't find a way how to get array of sub tree results. Thanks!

Do I need to close SnmpClient?

Hello.
Do I need to close SnmpClient after usage? For example if I have several instances of this class.
I don't see any corresponding method in SnmpClient.php.

No message received from host.

Hello, I constantly get the error of the first attached image. Is this is caused by CPU usage of the device, connection, or what? And how to avoid that? Is there any change on the device that I should do?

More details:

  • I'm trying to do a walk() on two distinct devices.
  • First device, I do a walk() through 800 Oids. The second, through 1700 Oids.
  • Both devices sometime fail with that error.
  • Using wireshark, I see that my server send a SNMP packet (getBulkRequest), but get no packet back (get-response).
  • I already tried with various maxRepetitions(), from 1 to 100.

image

screely-1639269036958

Certain return types do not get interpeted correctly in walks

I have begun testing with your example, and the walks are going really well, now that I installed GMP and it can handle the 64 bit counters correctly. However I am currently seeing issues where a return is a Hex-STRING value, and the returns get mangled.

snmpwalk -v2c -c noyb 192.168.15.58 1.3.6.1.2.1.92.1.3.1.1.3.7.100.101.102.97.117.108.116.1
iso.3.6.1.2.1.92.1.3.1.1.3.7.100.101.102.97.117.108.116.1 = Hex-STRING: 07 E5 0C 11 0A 19 36 00 2D 08 00 

From the walk example:

1.3.6.1.2.1.92.1.3.1.1.3.7.100.101.102.97.117.108.116.1 = �

6-

Another using the example code:

1.3.6.1.2.1.55.1.5.1.8.2 = 8�G��}

manually:

snmpwalk -v2c -c noyb 192.168.15.58 1.3.6.1.2.1.55.1.5.1.8.2
iso.3.6.1.2.1.55.1.5.1.8.2 = Hex-STRING: 38 D5 47 DF DA 7D 

Is there additional information that I can provide to assist in debugging this?
Ubuntu 20.04
PHP 7.4.26

send string value

Hi, happy afternoon friend. i am trying to get the name of a computer. using a snmp search engine, it tells me that its oid is <<sysName.0>>, but when i put that value like that i never get the result.

How can I get the value by passing that string?

How used other MIBs

please ask me, where is mibs data ? i have add my mibs.
My MIBs location /usr/share/snmp/mibs, but laravel not see.

Counter64 Values Can Exceed the PHP Max Int Value

The PHP max int is limited to the 64 bit signed integer value of 9,223,372,036,854,775,807. However, the Counter64 value of SNMP can be the maximum value of a 64 bit unsigned integer, which is 18,446,744,073,709,551,615.

This presents a real issue with integer type hinting across FreeDSx libraries. This will need to be solved in the ASN.1 library than decide how to handle it elsewhere.

What is the purpose of 1.3.6.1.2.1

I have gone exploring internals of this lib. I'd like to ask about this line

$this->startAt = $startAt ?? '1.3.6.1.2.1';

Shouldn't it rather throw exception when no startAt is provided? Or just type string $startAt? I don't get the reason for default '1.3.6.1.2.1'. Thanks!

SNMP Server Component

This library should have some sort of general SNMP server component for replying to SNMP client requests. There is already a Trap Sink component capable of handling incoming client requests. Some prerequisite work is need:

  • MIB support based on SMIv1/SMIv2 (separate library)
  • Some sort or persistence in general for MIBs
  • Additional logic in the UserSecurityModel to handle client discovery / time synchronization.
  • Possible ServerListener API for programmatically handling requests

Related work in progress in the ASN.1 library, needed for MIB support: FreeDSx/ASN1#3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.