1 #ifndef MTETRIGGER_H 2 #define MTETRIGGER_H 3 4 extern oid _sysUpTime_instance[]; 5 extern size_t _sysUpTime_inst_len; 6 /* 7 * Flags relating to the mteTriggerTable and related tables 8 */ 9 #define MTE_TRIGGER_FLAG_DELTA 0x01 /* for mteTriggerSampleType */ 10 #define MTE_TRIGGER_FLAG_VWILD 0x02 /* for mteTriggerValueIDWildcard */ 11 #define MTE_TRIGGER_FLAG_CWILD 0x04 /* for mteTriggerContextWildcard */ 12 #define MTE_TRIGGER_FLAG_DWILD 0x08 /* for mteTriggerDeltaDIDWildcard */ 13 #define MTE_TRIGGER_FLAG_SYSUPT 0x10 /* using default mteTriggerDeltaID */ 14 15 #define MTE_TRIGGER_FLAG_BSTART 0x20 /* for mteTriggerBooleanStartup */ 16 17 #define MTE_TRIGGER_FLAG_ENABLED 0x0100 /* for mteTriggerEnabled */ 18 #define MTE_TRIGGER_FLAG_ACTIVE 0x0200 /* for mteTriggerEntryStatus */ 19 #define MTE_TRIGGER_FLAG_FIXED 0x0400 /* for snmpd.conf persistence */ 20 #define MTE_TRIGGER_FLAG_VALID 0x0800 /* for row creation/undo */ 21 22 23 /* 24 * Values for the mteTriggerTest field 25 */ 26 #define MTE_TRIGGER_EXISTENCE 0x80 /* mteTriggerTest values */ 27 #define MTE_TRIGGER_BOOLEAN 0x40 28 #define MTE_TRIGGER_THRESHOLD 0x20 29 30 /* 31 * Values for the mteTriggerSampleType field 32 */ 33 #define MTE_SAMPLE_ABSOLUTE 1 /* mteTriggerSampleType values */ 34 #define MTE_SAMPLE_DELTA 2 35 36 /* 37 * Values for the mteTriggerDeltaDiscontinuityIDType field 38 */ 39 #define MTE_DELTAD_TTICKS 1 40 #define MTE_DELTAD_TSTAMP 2 41 #define MTE_DELTAD_DATETIME 3 42 43 /* 44 * Values for the mteTriggerExistenceTest 45 * and mteTriggerExistenceStartup fields 46 */ 47 #define MTE_EXIST_PRESENT 0x80 48 #define MTE_EXIST_ABSENT 0x40 49 #define MTE_EXIST_CHANGED 0x20 50 51 /* 52 * Values for the mteTriggerBooleanComparison field 53 */ 54 #define MTE_BOOL_UNEQUAL 1 55 #define MTE_BOOL_EQUAL 2 56 #define MTE_BOOL_LESS 3 57 #define MTE_BOOL_LESSEQUAL 4 58 #define MTE_BOOL_GREATER 5 59 #define MTE_BOOL_GREATEREQUAL 6 60 61 /* 62 * Values for the mteTriggerThresholdStartup field 63 */ 64 #define MTE_THRESH_START_RISE 1 65 #define MTE_THRESH_START_FALL 2 66 #define MTE_THRESH_START_RISEFALL 3 67 /* Note that RISE and FALL values can be used for bit-wise 68 tests as well, since RISEFALL = RISE | FALL */ 69 70 71 /* 72 * Flags to indicate which triggers are armed, and ready to fire. 73 */ 74 #define MTE_ARMED_TH_RISE 0x01 75 #define MTE_ARMED_TH_FALL 0x02 76 #define MTE_ARMED_TH_DRISE 0x04 77 #define MTE_ARMED_TH_DFALL 0x08 78 #define MTE_ARMED_BOOLEAN 0x10 79 #define MTE_ARMED_ALL 0x1f 80 81 /* 82 * All Event-MIB OCTET STRING objects are either short (32-character) 83 * tags, or SnmpAdminString/similar values (i.e. 255 characters) 84 */ 85 #define MTE_STR1_LEN 32 86 #define MTE_STR2_LEN 255 87 88 /* 89 * Data structure for a (combined) trigger row. Covers delta samples, 90 * and all types (Existence, Boolean and Threshold) of trigger. 91 */ 92 struct mteTrigger { 93 /* 94 * Index values 95 */ 96 char mteOwner[MTE_STR1_LEN+1]; 97 char mteTName[MTE_STR1_LEN+1]; 98 99 /* 100 * Column values for the main mteTriggerTable 101 */ 102 char mteTriggerComment[MTE_STR2_LEN+1]; 103 char mteTriggerTest; 104 oid mteTriggerValueID[MAX_OID_LEN]; 105 size_t mteTriggerValueID_len; 106 char mteTriggerTarget[ MTE_STR2_LEN+1]; 107 char mteTriggerContext[MTE_STR2_LEN+1]; 108 u_long mteTriggerFrequency; 109 char mteTriggerOOwner[ MTE_STR1_LEN+1]; 110 char mteTriggerObjects[MTE_STR1_LEN+1]; 111 112 netsnmp_session *session; 113 long flags; 114 115 /* 116 * Column values for the mteTriggerDeltaTable 117 */ 118 oid mteDeltaDiscontID[MAX_OID_LEN]; 119 size_t mteDeltaDiscontID_len; 120 long mteDeltaDiscontIDType; 121 122 /* 123 * Column values for Existence tests (mteTriggerExistenceTable) 124 */ 125 u_char mteTExTest; 126 u_char mteTExStartup; 127 char mteTExObjOwner[MTE_STR1_LEN+1]; 128 char mteTExObjects[ MTE_STR1_LEN+1]; 129 char mteTExEvOwner[ MTE_STR1_LEN+1]; 130 char mteTExEvent[ MTE_STR1_LEN+1]; 131 132 /* 133 * Column values for Boolean tests (mteTriggerBooleanTable) 134 */ 135 long mteTBoolComparison; 136 long mteTBoolValue; 137 char mteTBoolObjOwner[MTE_STR1_LEN+1]; 138 char mteTBoolObjects[ MTE_STR1_LEN+1]; 139 char mteTBoolEvOwner[ MTE_STR1_LEN+1]; 140 char mteTBoolEvent[ MTE_STR1_LEN+1]; 141 142 /* 143 * Column values for Threshold tests (mteTriggerThresholdTable) 144 */ 145 long mteTThStartup; 146 long mteTThRiseValue; 147 long mteTThFallValue; 148 long mteTThDRiseValue; 149 long mteTThDFallValue; 150 char mteTThObjOwner[ MTE_STR1_LEN+1]; 151 char mteTThObjects[ MTE_STR1_LEN+1]; 152 char mteTThRiseOwner[ MTE_STR1_LEN+1]; 153 char mteTThRiseEvent[ MTE_STR1_LEN+1]; 154 char mteTThFallOwner[ MTE_STR1_LEN+1]; 155 char mteTThFallEvent[ MTE_STR1_LEN+1]; 156 char mteTThDRiseOwner[MTE_STR1_LEN+1]; 157 char mteTThDRiseEvent[MTE_STR1_LEN+1]; 158 char mteTThDFallOwner[MTE_STR1_LEN+1]; 159 char mteTThDFallEvent[MTE_STR1_LEN+1]; 160 161 /* 162 * Additional fields for operation of the Trigger tables: 163 * monitoring... 164 */ 165 unsigned int alarm; 166 long sysUpTime; 167 netsnmp_variable_list *old_results; 168 netsnmp_variable_list *old_deltaDs; 169 170 /* 171 * ... stats... 172 */ 173 long count; 174 175 /* 176 * ... and firing. 177 */ 178 char *mteTriggerXOwner; 179 char *mteTriggerXObjects; 180 netsnmp_variable_list *mteTriggerFired; 181 }; 182 183 /* 184 * Container structure for the (combined) mteTrigger*Tables, 185 * and routine to create this. 186 */ 187 extern long mteTriggerFailures; 188 extern netsnmp_tdata *trigger_table_data; 189 extern void init_trigger_table_data(void); 190 191 void init_mteTrigger(void); 192 void mteTrigger_removeEntry(netsnmp_tdata_row *row); 193 netsnmp_tdata_row *mteTrigger_createEntry(const char *mteOwner, 194 char *mteTriggerName, int fixed); 195 void mteTrigger_enable( struct mteTrigger *entry ); 196 void mteTrigger_disable( struct mteTrigger *entry ); 197 198 long mteTrigger_getNumEntries(int max); 199 200 #endif /* MTETRIGGER_H */ 201