SNMP++, Didacticiel N.1

SNMP++, Didacticiel N.1

Le SNMP avec Net-SNMP, c’est chouette,
mais c’est lent!

Voici un moyen d’y remedier : SNMP++

[cpp]
#define SYSDESCR "1.3.6.1.2.1.1.1"

using namespace Snmp_pp;
using namespace std;

int main(int argc,char *argv[]){
int status = 0;
CTarget ctarget((IpAddress)"192.168.2.1","public","private");
Vb vb(SYSDESCR);
Pdu pdu;
Snmp snmp(status);
if(status != SNMP_CLASS_SUCCESS ){
cout << snmp.error_msg(status);
}
pdu += vb;
if((status=snmp.get(pdu,ctarget))!= SNMP_CLASS_SUCCESS)
cout<<snmp.error_msg(status);
else {
pdu.get_vb( vb,0);
cout << "System Descriptor = "<< vb.get_printable_value();
}
if((status=snmp.get_next(pdu,ctarget))!= SNMP_CLASS_SUCCESS)
cout<<snmp.error_msg(status);
else {
pdu.get_vb( vb,0);
cout << "System Descriptor = "<< vb.get_printable_value();
}
if((status=snmp.get(pdu,ctarget))!= SNMP_CLASS_SUCCESS)
cout<<snmp.error_msg(status);
else {
pdu.get_vb( vb,0);
cout << "System Descriptor = "<< vb.get_printable_value();
}
exit(0);
}
[/cpp]

Leave a Reply

Your email address will not be published. Required fields are marked *