note 40199 added to ref.snmp

From: Date: Wed, 25 Feb 2004 03:37:28 +0000
Subject: note 40199 added to ref.snmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-65681@lists.php.net to get a copy of this message
Hi all, I had a need for mass polling of many devices and bulkgets were very desirable. It turns out the change was simpler than I thought. One word of warning, however. The version is set in such a way that if I were to keep the changes to a minimum all operations that weren't v3 needed to be set to v2c. This isn't a problem for us because we have no v1 specific devices. If you're polling any v1 ONLY agents then you will have issues with this patch. Here's the patch. I hope this helps. Just save it to /tmp/patch cd ext/snmp/ patch snmp.c /tmp/patch 'njoy, Mark --- snmp.c 2003-08-07 12:44:11.000000000 -0400 +++ /tmp/snmp.c 2004-02-24 22:03:22.000000000 -0500 @@ -405,7 +405,11 @@ RETURN_FALSE; } } else if (st >= 2) { - pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); + int reps = 20, non_reps = 0; + + pdu = snmp_pdu_create(SNMP_MSG_GETBULK); + pdu->non_repeaters = non_reps; + pdu->max_repetitions = reps; /* fill the packet */ snmp_add_null_var(pdu, name, name_length); } @@ -471,7 +475,7 @@ goto retry; } } else if (st >= 2) { - if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) { + if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETBULK)) != NULL) { goto retry; } } @@ -579,7 +583,7 @@ session.peername = hostname; session.remote_port = remote_port; - session.version = SNMP_VERSION_1; + session.version = SNMP_VERSION_2c; /* * FIXME: potential memory leak * This is a workaround for an "artifact" (Mike Slifcak) ---- Manual Page -- http://www.php.net/manual/en/ref.snmp.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40199 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40199&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40199&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65681) next »