Hi,
how can I get the “timestamp” value inside an agent?
My table is defined like this:
networkAlarmsTable OBJECT-TYPE
SYNTAX SEQUENCE OF NetworkAlarmsEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "system alarm table."
::= { alarms 2 }
networkAlarmsEntry OBJECT-TYPE
SYNTAX NetworkAlarmsEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Row Description."
INDEX { interfaceID, nAlarmCode }
::= { networkAlarmsTable 1 }
NetworkAlarmsEntry ::= SEQUENCE {
nAlarmCode Integer32,
nPerceivedSeverity X733SEVERITY,
nAlarmTimeStamp TimeStamp
}
nAlarmCode OBJECT-TYPE
SYNTAX Integer32 (1..2147483647)
MAX-ACCESS read-only
STATUS current
DESCRIPTION "system alarm code."
::= { networkAlarmsEntry 1 }
nPerceivedSeverity OBJECT-TYPE
SYNTAX X733SEVERITY
MAX-ACCESS read-only
STATUS current
DESCRIPTION "system alarm severity."
::= { networkAlarmsEntry 2 }
nAlarmTimeStamp OBJECT-TYPE
SYNTAX TimeStamp
MAX-ACCESS read-only
STATUS current
DESCRIPTION "System time (in ticks) at wich the alarm was triggered"
::= { networkAlarmsEntry 3 }
The row constructor generated is like this:
mib_networkAlarmsEntry::mib_networkAlarmsEntry():
MibTable(oid_MIB_NetworkAlarmsEntry, ind_MIB_NetworkAlarmsEntry, 2) {
// This table object is a singleton. In order to access it use
// the static pointer mib_networkAlarmsEntry::instance.
instance = this;
add_col(new MibLeaf(col_MIB_NAlarmCode, READONLY, new NS_SNMP SnmpInt32()));
add_col(new MibLeaf(col_MIB_NPerceivedSeverity, READONLY, new NS_SNMP SnmpInt32()));
add_col(new MibLeaf(col_MIB_NAlarmTimeStamp, READONLY, new NS_SNMP TimeTicks()) );
//--AgentGen BEGIN=networkAlarmsEntry::apc_v3_mib_networkAlarmsEntry
//--AgentGen END
}
somewhere in my code I call the function:
std::string idx = "1.3. ...";
My_Object my_object();
auto code = my_object->get_code();
auto sev = my_object->get_severity();
// now I have to compute the current timestamp in timeticks
// how can I generate an appropriate timestamp to populate the field
unsigned long timeTicks; // <= what should I put there to represent the current timestamp (in timeticks) ?
MibTableRow* row = find_index(idx.c_str());
//delete the row
if(NULL != row) remove_row(idx.c_str());
row = add_row(idx.c_str());
set_row(row, code, sev,timeTicks);
``