It's been over a month, and I realise Christmas and New Year have been in the middle, but I'm just wondering if anyone had any thoughts on my problem here...
It's less important now, since I've put a nasty, nasty, hack around it; by putting the necessary work I wanted doing in the script that calls the command to add rows the table instead, but it would be nice to know how I should have done it properly. Is there any information missing that I should have included in my original request, that would enable anyone to help me, so if/when I come to modify the module I can get rid of the hack? On Thu, Dec 12, 2019 at 1:50 PM Paul Herring <pauljherr...@gmail.com> wrote: > TLDR: Programmatically... > 1) How can I delete other 'unrelated' rows from a table when adding a row > to that same table. > 2) How can I read/write data elsewhere? > > == > > Setup: > I have a table with details of 'alarms' (think alerts) - one per line - > with various data associated with each alarm (id, source, other data.) in > the columns > I also have a set of scalars associated with this table under a group > that's a sibling to the table. Things like max number of alarms to > currently hold, and other meta data. > > myExampleAlarmHistory > ..+..myExampleAlarmHistoryMeta > ..|....+ myExampleAlarmHistoryMetaCount - max to hold > ..|....+ myExampleAlarmHistoryMetaMin - min index used > ..|....+ myExampleAlarmHistoryMetaMax - max index used > ..|....` myExampleAlarmHistoryMetaNext - next index to use (?) > ..`..myExampleAlarmHistoryTable - table > .....`..myExampleAlarmHistoryEntry - entry for an alarm > .........+..myExampleAlarmHistoryIndex - index > .........+..myExampleAlarmHistoryId - data > .........+..myExampleAlarmHistoryRuleId - data > > (Partial MIB for this available at https://pastebin.com/pVARXLsv) > > Every time an alarm happens, another line of the table is added (I have > this bit working; both createAndGo and createAndWait - under the > presumption that I know which index to add it under) > > However when that line is added (I'm presuming in > myExampleAlarmHistoryTable_commit() in > myExampleAlarmHistoryTable_data_set.c) what I'd like to do is > > 1) examine the scalar myExampleAlarmHistoryMetaCount to determine how many > rows I should currently be holding (to compare with > myExampleAlarmHistoryTable_container_size()) > 2) delete earlier rows if I currently hold too many > 3) update the other scalars under myExampleAlarmHistoryMeta > > The code I'm working with was produced using mib2c.mfd.conf against > myExampleAlarmHistoryTable, so it doesn't have direct sight of the sibling > myExampleAlarmHistoryMeta group or anything in it. > > Is there any way of using the API to do these things, if so which > functions do I need? > Is there a canonical way of doing this? (My google-foo hasn't found any > source code doing similar - are there any specific examples around?) > Do I need to set up the code differently somehow? > > > Possibly pertinent info: > $ cat .mib2c-updaterc > UPDATE_OID=myExampleAlarmHistoryTable > UPDATE_CONF=mib2c.mfd.conf > > $ grep eval defaults/table-MyExampleAlarmHistoryTable.m2d > @eval $m2c_context_reg = "netsnmp_data_list"@ > @eval $m2c_data_allocate = 0@ > @eval $m2c_data_cache = 0@ > @eval $m2c_data_context = "generated"@ [generated|NAME] > @eval $m2c_data_init = 1@ > @eval $m2c_data_transient = 2@ > @eval $m2c_include_examples = 1@ > @eval $m2c_irreversible_commit = 0@ > @eval $m2c_table_access = "container-cached"@ > @eval $m2c_table_dependencies = 1@ > @eval $m2c_table_persistent = 1@ > @eval $m2c_table_row_creation = 1@ > @eval $m2c_table_settable = 1@ > @eval $m2c_table_skip_mapping = -1@ > @eval $m2c_table_sparse = 1@ > @eval $mfd_generate_makefile = 0@ > @eval $mfd_generate_subagent = 0@ > > $ 2>/dev/null yum info net-snmp-perl | egrep -i "version|release" > *Version : 5.7.2* > Release : 43.el7 > > -- > PJH > > -- PJH
_______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users