[SNMP4J] Re: Basic Question
Petro Peter
petropeter at gmail.com
Sat May 5 19:13:34 CEST 2007
Hi,
I used notification using in my project. please follow the below steps.
- Create Java file for the new MIB file created usinf AgenPro tool.
- Then create the SNMP4J agent, please refer the TestAgent code for example.
- Load the newly created Mib file into the agent.
- While creating the istance of Mib, pass the reference of Notification
Originator
- Now, whenever a value is set on a given mib object, Mib class's validation
class methods will be called.
- We can send the notification from the validation class, using the
reference.
Find below the code snippet fromm the Mib file.
[code]
public class NotificationLevel extends MOScalar
{
NotificationLevel(OID oid, MOAccess access)
{
super(oid, access, new Integer32());
//--AgentGen BEGIN=notificationLevel
//--AgentGen END
}
public int isValueOK(SubRequest request)
{
Variable newValue =
request.getVariableBinding().getVariable();
int valueOK = super.isValueOK(request);
if (valueOK != SnmpConstants.SNMP_ERROR_SUCCESS)
{
return valueOK;
}
//--AgentGen BEGIN=notificationLevel::isValueOK
//--AgentGen END
return valueOK;
}
public Variable getValue()
{
//--AgentGen BEGIN=notificationLevel::getValue
//--AgentGen END
return super.getValue();
}
public int setValue(Variable newValue)
{
//Using the NotificationOriginator reference, sends notification
//whenever this value is set
sendNotification();
return super.setValue(newValue);
}
//--AgentGen BEGIN=notificationLevel::_METHODS
//--AgentGen END
}
[/code]
For any queries, kindly let me know
--
regards,
petro
More information about the SNMP4J
mailing list