Edit report at https://bugs.php.net/bug.php?id=54502&edit=1
ID: 54502 Updated by: lytbo...@php.net Reported by: c...@php.net Summary: Add support for the "BITS" datatype -Status: Feedback +Status: Closed Type: Feature/Change Request Package: SNMP related PHP Version: trunk-SVN-2011-04-10 (SVN) Assigned To: lytboris Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. It seems that parseBitName should not go into php-snmp library, at least it works only for "BITS: " string. Not sure that general parsing function will be sufficient for all users though, not taking into account the fact that this function will be complicated. As an example of such complicated function you may take a look on format_snmp_string() function in Cacti's repo lib/snmp.php [ http://svn.cacti.net/viewvc/cacti/branches/0.8.7/lib/snmp.php?view=log ]. Previous Comments: ------------------------------------------------------------------------ [2011-07-29 00:27:25] c...@php.net The new default SNMP->valueretrieval = SNMP_VALUE_LIBRARY gives at least the amount of information that snmpwalk does. Still, before you close this bug, please consider at least adding something like the following method. It would add a bit of the convenience that one expects from a PHP class while still leave the low-level methods untouched. /** Returns the name of a bit value. * * The NetSNMP library returns values of OIDs of the BIT type like * "BITS: 80 notification(0)". This method can be used to extract * just the name "notification" from this output. * * @param string $raw_value The return of a walk() or get() request. * @return string The name of the BIT value. */ public static function parseBitName($raw_value) { preg_match('/^BITS: [0-9a-f]+ (.*)\(\d+\)\s+$/i', $raw_value, $match); if (!isset($match[1])) { throw new Exception("Cannot parse BIT value from '$raw_value'!"); } return $match[1]; } ------------------------------------------------------------------------ [2011-07-17 13:26:55] lytbo...@php.net Automatic comment from SVN on behalf of lytboris Revision: http://svn.php.net/viewvc/?view=revision&revision=313333 Log: fix FR #54502: allow user to change OID value output mode when SNMP_VALUE_OBJECT is used. ------------------------------------------------------------------------ [2011-07-17 13:25:30] lytbo...@php.net Please try using this snapshot: http://snaps.php.net/php5.4-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Now you can combine SNMP_VALUE_OBJECT with one of SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY to alter 'value' output mode. As for >The value is not even numerical, it has to be converted to 0x80 using >bin2hex()! This is normal, because this is exactly what php-snmp receives from remote SNMP agent. ------------------------------------------------------------------------ [2011-07-17 13:18:27] lytbo...@php.net Automatic comment from SVN on behalf of lytboris Revision: http://svn.php.net/viewvc/?view=revision&revision=313331 Log: fix FR #54502: allow user to change OID value output mode when SNMP_VALUE_OBJECT is used. ------------------------------------------------------------------------ [2011-07-17 09:18:04] lytbo...@php.net There is support for BITS datatype actually when SNMP_VALUE_LIBRARY is enabled for value processing. When you enable other SNMP_VALUE_* modes no value processing is performed and output from remote SNMP agent is passed through SNMP library. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=54502 -- Edit this bug report at https://bugs.php.net/bug.php?id=54502&edit=1