implementing dynamic variable

Frank Fock Frank.Fock____t-online.de
Sat Apr 7 13:02:38 CEST 2001


Hi Mauro,

The problem is that your object is of type OctetString, but
you are trying to assign a TimeTicks value to it. I wonder
why the agent does not crash?

You should convert the TimeTicks value to a string with
*((OctetStr*)value) = TimeTicks(get()).get_printable();

Regards,
Frank

Mauro Restante wrote:

> Hi frank, and hi to all mailing list,
>
> In order to implement a Mib with Agent++, I first try to implement a dynamic
> variable, only a mib leaf.
> I used AgentGen to compile a Disman-Schedule-Mib.
> Now I try to implement SchedLocalTime variable, and I look the
> implementation of sysUpTime system-group leaf.
> It should be the same!!??!?!?
> When I interrogate the agent I receive a "zero length" answer!!!! The SNMP
> PDU is empty!!!!! Why?
> Should someone help me??
>
> This is my code.......it is the same of sysUpTime....
>
> >>>      schedLocalTime::schedLocalTime()
>                         MibLeaf(oidSchedLocalTime, READONLY, new OctetStr())
> >>>     {
> >>>             // This leaf object is a singleton. In order to access it use
> >>>             // the static pointer schedLocalTime::instance.
> >>>             instance = this;
> >>>             start=get();
> >>>             //--AgentGen BEGIN=schedLocalTime::schedLocalTime
> >>>             //--AgentGen END
> >>>
> >>>      }
>
> >>>     schedLocalTime::~schedLocalTime()
> >>>     {
> >>>
> >>>             //--AgentGen BEGIN=schedLocalTime::~schedLocalTime
> >>>             //--AgentGen END
> >>>     }
>
> >>>     //§§ MR
>
> >>>     time_t schedLocalTime::get_currentTime()
> >>>     {
> >>>             time_t now;
> >>>             time (&now);
> >>>
> >>>             return now;
> >>>     }
>
> >>>     u_int schedLocalTime::get()
> >>>     {
>
> >>>             return get_currentTime();
> >>>     }
> >>>     //§§  MR finish
>
> >>>     void schedLocalTime::get_request(Request* req, int index)
> >>>     {
> >>>
> >>>             //--AgentGen BEGIN=schedLocalTime::get_request
> >>>             //--AgentGen END
> >>>     //§§  MR
> >>>
> >>>     *((TimeTicks*)value) = (unsigned long)get();    /*This is the right
> assignament to retrive the value????*/
> >>>
> >>>     //§§  MR finish
> >>>
> >>>     MibLeaf::get_request(req, index);
> >>>
> >>>     }
>
> Thanks to ALL and forgive my bad english
>
> Mauro Restante




More information about the AGENTPP mailing list