Adding details to table threshold alarm / no SNMPReadTable function

Started by mk, November 03, 2014, 11:29:40 AM

Previous topic - Next topic

mk

Right now I get alarm messages like
Quote
Threshold activated on table "prtAlert" row 1 (12)
but I'd prefer to get messages like
Quote
Threshold activated on table "prtAlert": YELLOW CARTRIDGE LOW
i.e. it should pull the message from a cell in row 1 in the table. A screenshot of this table is attached to this post.





I'm trying to put together a script to add more information to the SYS_TABLE_THRESHOLD_ACTIVATED event message. The script is called Table_Alarm_Description, so I added %[Table_Alarm_Description] to the Message field in the Generate alarm action of event number 18 (Generate alarm on table threshold violation). The script gets called when the alarm is triggered and all is well in that regard.

This is the script I'm using:

sub main()
{
table = AgentReadTable($node, $event->parameters[2]);
if (table == null)
{
return "[AgentReadTable(" . $node->name . ", " . $event->parameters[2] . ") failed.]";
}
colNum = 1;
alertMsg = table->get($event->parameters[4], colNum);
if (alertMsg == null)
{
return "[table->get(" . $event->parameters[4] . ", " . colNum . ") failed.]";
}
return alertMsg;
}

I'm seeing that AgentReadTable always fails. I suspect this is due to the fact that my node is monitored via SNMP and not via the agent. How can I fix this? Unfortunately, there is no function named something like SNMPReadTable that could be used instead.

Alternatively, do you know any other way to add more details as in the example above to a table threshold alarm?
Please note that I CANNOT use anything like

transport = CreateSNMPTransport($node);
oid = ".1.3.6.1.2.1.43.18.1.1.8." . $event->parameters[5];
varbind = SNMPGet(transport, oid);
varbind->value

in my script because the OID is different for different tables I have; also the value of $event->parameters[5] is not always the same as the final number in the OID.
I need to have the script read the value from the table.

mk

I figured it out. GetDCIValueByName is able to return table objects, so it's quite simple:

sub main()
{
table = GetDCIValueByName($node, $event->parameters[1]);
if (table == null)
{
return "[GetDCIValueByName(" . $node->name . ", " . $event->parameters[1] . ") failed.]";
}
colNum = 1;
alertMsg = table->get($event->parameters[4], colNum);
if (alertMsg == null)
{
return "[table->get(" . $event->parameters[4] . ", " . colNum . ") failed.]";
}
return alertMsg;
}