~ubuntu-branches/ubuntu/precise/net-snmp/precise

« back to all changes in this revision

Viewing changes to agent/mibgroup/notification-log-mib/notification_log.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-11-26 01:27:00 UTC
  • mfrom: (1.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091126012700-pox7w0a5j2x305h9
Tags: 5.4.2.1~dfsg-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - Set Ubuntu maintainer address.
  - net-snmp-config: Use bash. (LP: #104738)
  - Removed multiuser option when calling update-rc.d. (LP: #254261)
  - debian/snmpd.init: LSBify the init script.
  - debian/patches/52_fix_snmpcmd_1_typo.patch: Adjust a typo in snmpcmd.1
    (LP: #250459)
  - debian/patches/99-fix-ubuntu-div0.patch: Fix dvision by zero.
    (LP: #426813).
 * Dropped patches:
   - debian/patches/101-fix-ipalias.patch: Applied upstream.
   - debian/patches/99-fix-net-snmp-syslog.patch: Applied upstream.
   - debian/patches/99-fix-perl-counter-in-subagent.patch: Applied upstream.
   - ebian/patches/103-fix-ubuntu-lmsensors.patch: No longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <net-snmp/agent/table_dataset.h>
19
19
#include "notification_log.h"
20
20
 
 
21
/*
 
22
 * column number definitions for table nlmLogTable
 
23
 */
 
24
 
 
25
#define COLUMN_NLMLOGINDEX              1
 
26
#define COLUMN_NLMLOGTIME               2
 
27
#define COLUMN_NLMLOGDATEANDTIME        3
 
28
#define COLUMN_NLMLOGENGINEID           4
 
29
#define COLUMN_NLMLOGENGINETADDRESS     5
 
30
#define COLUMN_NLMLOGENGINETDOMAIN      6
 
31
#define COLUMN_NLMLOGCONTEXTENGINEID    7
 
32
#define COLUMN_NLMLOGCONTEXTNAME        8
 
33
#define COLUMN_NLMLOGNOTIFICATIONID     9
 
34
 
 
35
/*
 
36
 * column number definitions for table nlmLogVariableTable
 
37
 */
 
38
#define COLUMN_NLMLOGVARIABLEINDEX              1
 
39
#define COLUMN_NLMLOGVARIABLEID                 2
 
40
#define COLUMN_NLMLOGVARIABLEVALUETYPE          3
 
41
#define COLUMN_NLMLOGVARIABLECOUNTER32VAL       4
 
42
#define COLUMN_NLMLOGVARIABLEUNSIGNED32VAL      5
 
43
#define COLUMN_NLMLOGVARIABLETIMETICKSVAL       6
 
44
#define COLUMN_NLMLOGVARIABLEINTEGER32VAL       7
 
45
#define COLUMN_NLMLOGVARIABLEOCTETSTRINGVAL     8
 
46
#define COLUMN_NLMLOGVARIABLEIPADDRESSVAL       9
 
47
#define COLUMN_NLMLOGVARIABLEOIDVAL             10
 
48
#define COLUMN_NLMLOGVARIABLECOUNTER64VAL       11
 
49
#define COLUMN_NLMLOGVARIABLEOPAQUEVAL          12
 
50
 
21
51
static u_long   num_received = 0;
22
52
static u_long   num_deleted = 0;
23
53
 
24
54
static u_long   max_logged = 1000;      /* goes against the mib default of infinite */
25
55
static u_long   max_age = 1440; /* 1440 = 24 hours, which is the mib default */
26
56
 
27
 
netsnmp_table_data_set *nlmLogTable;
28
 
netsnmp_table_data_set *nlmLogVarTable;
 
57
static netsnmp_table_data_set *nlmLogTable;
 
58
static netsnmp_table_data_set *nlmLogVarTable;
29
59
 
30
 
void
 
60
static void
31
61
netsnmp_notif_log_remove_oldest(int count)
32
62
{
33
63
    netsnmp_table_row *deleterow, *tmprow, *deletevarrow;
90
120
    netsnmp_assert(0 == count);
91
121
}
92
122
 
93
 
void
 
123
static void
94
124
check_log_size(unsigned int clientreg, void *clientarg)
95
125
{
96
126
    netsnmp_table_row *row;
148
178
 
149
179
 
150
180
/** Initialize the nlmLogVariableTable table by defining its contents and how it's structured */
151
 
void
 
181
static void
152
182
initialize_table_nlmLogVariableTable(const char * context)
153
183
{
154
184
    static oid      nlmLogVariableTable_oid[] =
304
334
     */
305
335
    reginfo =
306
336
        netsnmp_create_handler_registration ("nlmLogVariableTable",
307
 
                                             nlmLogVariableTable_handler,
 
337
                                             NULL,
308
338
                                             nlmLogVariableTable_oid,
309
339
                                             nlmLogVariableTable_oid_len,
310
340
                                             HANDLER_CAN_RWRITE);
314
344
}
315
345
 
316
346
/** Initialize the nlmLogTable table by defining its contents and how it's structured */
317
 
void
 
347
static void
318
348
initialize_table_nlmLogTable(const char * context)
319
349
{
320
350
    static oid      nlmLogTable_oid[] = { 1, 3, 6, 1, 2, 1, 92, 1, 3, 1 };
419
449
     * the request, change nlmLogTable_handler to "NULL" 
420
450
     */
421
451
    reginfo =
422
 
        netsnmp_create_handler_registration("nlmLogTable", nlmLogTable_handler,
 
452
        netsnmp_create_handler_registration("nlmLogTable", NULL,
423
453
                                            nlmLogTable_oid,
424
454
                                            nlmLogTable_oid_len,
425
455
                                            HANDLER_CAN_RWRITE);
434
464
    snmp_alarm_register(300, SA_REPEAT, check_log_size, NULL);
435
465
}
436
466
 
437
 
int
 
467
static int
438
468
notification_log_config_handler(netsnmp_mib_handler *handler,
439
469
                                netsnmp_handler_registration *reginfo,
440
470
                                netsnmp_agent_request_info *reqinfo,
683
713
                col = COLUMN_NLMLOGVARIABLEOCTETSTRINGVAL;
684
714
                break;
685
715
 
 
716
            case ASN_IPADDRESS:
 
717
                tmpul = 5;
 
718
                col = COLUMN_NLMLOGVARIABLEIPADDRESSVAL;
 
719
                break;
 
720
 
 
721
            case ASN_COUNTER64:
 
722
                tmpul = 8;
 
723
                col = COLUMN_NLMLOGVARIABLECOUNTER64VAL;
 
724
                break;
 
725
 
 
726
            case ASN_OPAQUE:
 
727
                tmpul = 9;
 
728
                col = COLUMN_NLMLOGVARIABLEOPAQUEVAL;
 
729
                break;
 
730
 
686
731
            default:
687
732
                /*
688
733
                 * unsupported 
689
734
                 */
690
735
                DEBUGMSGTL(("notification_log",
691
736
                            "skipping type %d\n", vptr->type));
 
737
                (void)netsnmp_table_dataset_delete_row(myrow);
692
738
                continue;
693
739
            }
694
740
            netsnmp_set_row_column(myrow, COLUMN_NLMLOGVARIABLEVALUETYPE,
710
756
    check_log_size(0, NULL);
711
757
    DEBUGMSGTL(("notification_log", "done logging something\n"));
712
758
}
713
 
 
714
 
/** handles requests for the nlmLogTable table, if anything else needs to be done */
715
 
int
716
 
nlmLogTable_handler(netsnmp_mib_handler *handler,
717
 
                    netsnmp_handler_registration *reginfo,
718
 
                    netsnmp_agent_request_info *reqinfo,
719
 
                    netsnmp_request_info *requests)
720
 
{
721
 
    /*
722
 
     * perform anything here that you need to do.  The requests have
723
 
     * already been processed by the master table_dataset handler, but
724
 
     * this gives you chance to act on the request in some other way if
725
 
     * need be. 
726
 
     */
727
 
    return SNMP_ERR_NOERROR;
728
 
}
729
 
 
730
 
/** handles requests for the nlmLogVariableTable table, if anything else needs to be done */
731
 
int
732
 
nlmLogVariableTable_handler(netsnmp_mib_handler *handler,
733
 
                            netsnmp_handler_registration *reginfo,
734
 
                            netsnmp_agent_request_info *reqinfo,
735
 
                            netsnmp_request_info *requests)
736
 
{
737
 
    /*
738
 
     * perform anything here that you need to do.  The requests have
739
 
     * already been processed by the master table_dataset handler, but
740
 
     * this gives you chance to act on the request in some other way if
741
 
     * need be. 
742
 
     */
743
 
    return SNMP_ERR_NOERROR;
744
 
}