Exemple #1
0
void
init_notification_log(void)
{
    static oid      my_nlmStatsGlobalNotificationsLogged_oid[] =
        { 1, 3, 6, 1, 2, 1, 92, 1, 2, 1, 0 };
    static oid      my_nlmStatsGlobalNotificationsBumped_oid[] =
        { 1, 3, 6, 1, 2, 1, 92, 1, 2, 2, 0 };
    static oid      my_nlmConfigGlobalEntryLimit_oid[] =
        { 1, 3, 6, 1, 2, 1, 92, 1, 1, 1, 0 };
    static oid      my_nlmConfigGlobalAgeOut_oid[] =
        { 1, 3, 6, 1, 2, 1, 92, 1, 1, 2, 0 };

    /*
     * static variables 
     */
    netsnmp_register_read_only_counter32_instance
        ("nlmStatsGlobalNotificationsLogged",
         my_nlmStatsGlobalNotificationsLogged_oid,
         OID_LENGTH(my_nlmStatsGlobalNotificationsLogged_oid),
         &num_received, NULL);

    netsnmp_register_read_only_counter32_instance
        ("nlmStatsGlobalNotificationsBumped",
         my_nlmStatsGlobalNotificationsBumped_oid,
         OID_LENGTH(my_nlmStatsGlobalNotificationsBumped_oid),
         &num_deleted, NULL);

    netsnmp_register_ulong_instance("nlmConfigGlobalEntryLimit",
                                    my_nlmConfigGlobalEntryLimit_oid,
                                    OID_LENGTH
                                    (my_nlmConfigGlobalEntryLimit_oid),
                                    &max_logged,
                                    notification_log_config_handler);

    netsnmp_register_ulong_instance("nlmConfigGlobalAgeOut",
                                    my_nlmConfigGlobalAgeOut_oid,
                                    OID_LENGTH
                                    (my_nlmConfigGlobalAgeOut_oid),
                                    &max_age,
                                    notification_log_config_handler);

    /*
     * tables 
     */
    initialize_table_nlmLogTable();
    initialize_table_nlmLogVariableTable();

    /*
     * disable flag 
     */
    netsnmp_ds_register_config(ASN_BOOLEAN, "snmptrapd", "dontRetainLogs",
			   NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_APP_DONT_LOG);
}
/************************************************************
 *
 * Initialize the saHpiWatchdogTable table by defining its contents and how it's structured
 */
void
initialize_table_saHpiWatchdogTable(void)
{
    netsnmp_table_registration_info *table_info;

    if (my_handler) {
        snmp_log(LOG_ERR,
                 "initialize_table_saHpiWatchdogTable_handler called again\n");
        return;
    }

    memset(&cb, 0x00, sizeof(cb));

    /** create the table structure itself */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);

    /*
     * if your table is read only, it's easiest to change the
     * HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY 
     */
    my_handler = netsnmp_create_handler_registration("saHpiWatchdogTable",
                                                     netsnmp_table_array_helper_handler,
                                                     saHpiWatchdogTable_oid,
                                                     saHpiWatchdogTable_oid_len,
                                                     HANDLER_CAN_RWRITE);

    if (!my_handler || !table_info) {
        snmp_log(LOG_ERR, "malloc failed in "
                 "initialize_table_saHpiWatchdogTable_handler\n");
        return; /** mallocs failed */
    }

    /***************************************************
     * Setting up the table's definition
     */
    /*
     * TODO: add any external indexes here.
     */

    /*
     * internal indexes
     */
        /** index: saHpiWatchdogNum */
    netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

    table_info->min_column = saHpiWatchdogTable_COL_MIN;
    table_info->max_column = saHpiWatchdogTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
    cb.get_value = saHpiWatchdogTable_get_value;
    cb.container = netsnmp_container_find("saHpiWatchdogTable_primary:"
                                          "saHpiWatchdogTable:"
                                          "table_container");
#ifdef saHpiWatchdogTable_IDX2
    /*
    netsnmp_container_add_index(cb.container,
                                netsnmp_container_find
                                ("saHpiWatchdogTable_secondary:"
                                 "saHpiWatchdogTable:" "table_container"));
     cb.container->next->compare = saHpiWatchdogTable_cmp;
    */
#endif

    cb.can_set = 1;

    cb.create_row = (UserRowMethod *) saHpiWatchdogTable_create_row;

    cb.duplicate_row = (UserRowMethod *) saHpiWatchdogTable_duplicate_row;
    cb.delete_row = (UserRowMethod *) saHpiWatchdogTable_delete_row;
    cb.row_copy =
        (Netsnmp_User_Row_Operation *) saHpiWatchdogTable_row_copy;

    cb.can_delete =
        (Netsnmp_User_Row_Action *) saHpiWatchdogTable_can_delete;

    cb.set_reserve1 = saHpiWatchdogTable_set_reserve1;
    cb.set_reserve2 = saHpiWatchdogTable_set_reserve2;
    cb.set_action = saHpiWatchdogTable_set_action;
    cb.set_commit = saHpiWatchdogTable_set_commit;
    cb.set_free = saHpiWatchdogTable_set_free;
    cb.set_undo = saHpiWatchdogTable_set_undo;

    DEBUGMSGTL(("initialize_table_saHpiWatchdogTable",
                "Registering table saHpiWatchdogTable "
                "as a table array\n"));
    netsnmp_table_container_register(my_handler, table_info, &cb,
                                     cb.container, 1);

 netsnmp_register_read_only_counter32_instance("watchdoig_count",
						  saHpiWatchdogCount_oid,
						  OID_LENGTH(saHpiWatchdogCount_oid),
						  &watchdog_count,
						  NULL);


}
Exemple #3
0
/************************************************************
 *
 * Initialize the saHpiRdrTable table by defining its contents and how it's structured
 */
void
initialize_table_saHpiRdrTable (void)
{
  netsnmp_table_registration_info *table_info;

  if (my_handler)
    {
      snmp_log (LOG_ERR,
		"initialize_table_saHpiRdrTable_handler called again\n");
      return;
    }

  memset (&cb, 0x00, sizeof (cb));

    /** create the table structure itself */
  table_info = SNMP_MALLOC_TYPEDEF (netsnmp_table_registration_info);

  /*
   * if your table is read only, it's easiest to change the
   * HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY 
   */
  my_handler = netsnmp_create_handler_registration ("saHpiRdrTable",
						    netsnmp_table_array_helper_handler,
						    saHpiRdrTable_oid,
						    saHpiRdrTable_oid_len,
						    HANDLER_CAN_RONLY);

  if (!my_handler || !table_info)
    {
      snmp_log (LOG_ERR, "malloc failed in "
		"initialize_table_saHpiRdrTable_handler\n");
      return;	/** mallocs failed */
    }


	/** index: saHpiRdrRecordId */
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
	/** index: saHpiRdrType */
  netsnmp_table_helper_add_index (table_info, ASN_INTEGER);

  table_info->min_column = saHpiRdrTable_COL_MIN;
  table_info->max_column = saHpiRdrTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
  cb.get_value = saHpiRdrTable_get_value;
  cb.container = netsnmp_container_find ("saHpiRdrTable_primary:"
					 "saHpiRdrTable:" "table_container");

  cb.create_row = (UserRowMethod *) saHpiRdrTable_create_row;


  DEBUGMSGTL (("initialize_table_saHpiRdrTable",
	       "Registering table saHpiRdrTable " "as a table array\n"));

  netsnmp_table_container_register (my_handler, table_info, &cb,
				    cb.container, 1);

  netsnmp_register_read_only_counter32_instance ("rdr_count",
						 saHpiRdrCount_oid,
						 OID_LENGTH
						 (saHpiRdrCount_oid),
						 &rdr_count, NULL);

}