FreeDSx / SNMP

A Pure PHP SNMP Library.
MIT License
57 stars 13 forks source link

How used other MIBs #9

Open nfast opened 3 years ago

nfast commented 3 years ago

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

ChadSikorra commented 3 years ago

Hi @nfast. Unfortunately this library doesn't really have a concept of MIBs. The main reason is that there is no PHP library capable of parsing the SMI-v2 format (which is the format a MIB is in). The SMI format is basically a subset of the X.681 spec, which is essentially a very complex syntax for describing data structures. It doesn't surprise me that such a parser doesn't exist in PHP because it's use is very limited outside of a few protocols / niche cases nowadays, and implementing the spec correctly is a huge undertaking. (Spec can be found here: https://www.itu.int/ITU-T/studygroups/com17/languages/X.681-0207.pdf).

That said, I did attempt to implement a pure PHP based MIB parser and made it quite far. But I just haven't had the time to finish it. I'd like to pick up my work again. I'm just not sure when I'll be able to.

JeroenSteen commented 2 years ago

I'm trying to get Xerox printer health values, like amount of toner-percentage of a certain color. And I'm also looking for those MIB files.

Snmp is new for me, but reading a MIB can be done with: _snmp_readmib and snmprealwalk right?

ChadSikorra commented 2 years ago

I'm trying to get Xerox printer health values, like amount of toner-percentage of a certain color. And I'm also looking for those MIB files.

Snmp is new for me, but reading a MIB can be done with: _snmp_readmib and snmprealwalk right?

Yes, you could use the SNMP extension instead if you have it available. This library just implements the raw SNMP protocol, without any dependencies / the need for an extension. As such, I don't want to introduce a requirement for it.

I mostly started this as a fun project in my free time. But there are advantages to this library. Such as, there's no way to receive traps and parse them using the PHP SNMP extension, like you can with this library.

Regarding the Xerox printer health status, it looks like you'd want to read / interpret this OID for it:

OID: 1.3.6.1.2.1.25.3.5.1.2 Reference: https://oidref.com/1.3.6.1.2.1.25.3.5.1.2

It looks like the value uses a series on / off bits to represent different statuses for various printer parts.

JeroenSteen commented 2 years ago

With your SNMP-library I found these OID's indeed, but those don't give percentages or such. That's why I think I need a MIB file.

1.3.6.1.2.1.43.11.1.1.6.1.5 = Waste Toner Container
1.3.6.1.2.1.43.11.1.1.6.1.6 = Black Drum Cartridge
1.3.6.1.2.1.43.11.1.1.6.1.7 = Yellow Drum Cartridge
1.3.6.1.2.1.43.11.1.1.6.1.8 = Magenta Drum Cartridge
1.3.6.1.2.1.43.11.1.1.6.1.9 = Cyan Drum Cartridge
1.3.6.1.2.1.43.11.1.1.6.1.12 = Fuser Assembly

Do you think it's possible without a MIB, to check for example if a printer door is open, with doorOpen? Does it work something like this 1.3.6.1.2.1.25.3.5.1.2 adding the .4, to make 1.3.6.1.2.1.25.3.5.1.2.4?