1 /*****************************************************************************\ 2 * $Id: ipmiseld.h,v 1.11 2010-02-08 22:02:30 chu11 Exp $ 3 ***************************************************************************** 4 * Copyright (C) 2012-2015 Lawrence Livermore National Security, LLC. 5 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). 6 * Written by Albert Chu <chu11@llnl.gov> 7 * LLNL-CODE-559172 8 * 9 * This file is part of Ipmiseld, an IPMI SEL syslog logging daemon. 10 * For details, see http://www.llnl.gov/linux/. 11 * 12 * Ipmiseld is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by the 14 * Free Software Foundation; either version 3 of the License, or (at your 15 * option) any later version. 16 * 17 * Ipmiseld is distributed in the hope that it will be useful, but 18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 * for more details. 21 * 22 * You should have received a copy of the GNU General Public License along 23 * with Ipmiseld. If not, see <http://www.gnu.org/licenses/>. 24 \*****************************************************************************/ 25 26 #ifndef IPMISELD_H 27 #define IPMISELD_H 28 29 #ifdef HAVE_CONFIG_H 30 #include "config.h" 31 #endif /* HAVE_CONFIG_H */ 32 33 #if TIME_WITH_SYS_TIME 34 #include <sys/time.h> 35 #include <time.h> 36 #else /* !TIME_WITH_SYS_TIME */ 37 #if HAVE_SYS_TIME_H 38 #include <sys/time.h> 39 #else /* !HAVE_SYS_TIME_H */ 40 #include <time.h> 41 #endif /* !HAVE_SYS_TIME_H */ 42 #endif /* !TIME_WITH_SYS_TIME */ 43 44 #include <freeipmi/freeipmi.h> 45 46 #include "tool-cmdline-common.h" 47 #include "tool-oem-common.h" 48 #include "tool-sensor-common.h" 49 50 #define IPMISELD_WARNING_THRESHOLD_DEFAULT 80 51 52 #define IPMISELD_CLEAR_THRESHOLD_DEFAULT 0 53 54 #define IPMISELD_SYSTEM_EVENT_FORMAT_STR_DEFAULT "SEL System Event: %d, %t, %s, %I, %E" 55 56 #define IPMISELD_OEM_TIMESTAMPED_EVENT_FORMAT_STR_DEFAULT "SEL OEM Event: %d, %t, %I, %o" 57 58 #define IPMISELD_OEM_NON_TIMESTAMPED_EVENT_FORMAT_STR_DEFAULT "SEL OEM Event: %I, %o" 59 60 #define IPMISELD_SYSTEM_EVENT_FORMAT_OUTOFBAND_STR_DEFAULT "SEL System Event(%h): %d, %t, %s, %I, %E" 61 62 #define IPMISELD_OEM_TIMESTAMPED_EVENT_FORMAT_OUTOFBAND_STR_DEFAULT "SEL OEM Event(%h): %d, %t, %I, %o" 63 64 #define IPMISELD_OEM_NON_TIMESTAMPED_EVENT_FORMAT_OUTOFBAND_STR_DEFAULT "SEL OEM Event(%h): %I, %o" 65 66 #define IPMISELD_POLL_INTERVAL_DEFAULT 300 67 68 #define IPMISELD_THREADPOOL_COUNT 8 69 70 #define IPMISELD_ERROR_OUTPUT_LIMIT 20 71 72 enum ipmiseld_argp_option_keys 73 { 74 IPMISELD_VERBOSE_KEY = 'v', 75 IPMISELD_SENSOR_TYPES_KEY = 't', 76 IPMISELD_EXCLUDE_SENSOR_TYPES_KEY = 'T', 77 IPMISELD_SYSTEM_EVENT_ONLY_KEY = 160, 78 IPMISELD_OEM_EVENT_ONLY_KEY = 161, 79 IPMISELD_EVENT_STATE_CONFIG_FILE_KEY = 162, 80 IPMISELD_INTERPRET_OEM_DATA_KEY = 163, 81 IPMISELD_OUTPUT_OEM_EVENT_STRINGS_KEY = 164, 82 IPMISELD_ENTITY_SENSOR_NAMES_KEY = 165, 83 IPMISELD_NON_ABBREVIATED_UNITS_KEY = 166, 84 IPMISELD_EVENT_STATE_FILTER_KEY = 167, 85 IPMISELD_WARNING_THRESHOLD_KEY = 168, 86 IPMISELD_CLEAR_THRESHOLD_KEY = 169, 87 IPMISELD_SYSTEM_EVENT_FORMAT_KEY = 170, 88 IPMISELD_OEM_TIMESTAMPED_EVENT_FORMAT_KEY = 171, 89 IPMISELD_OEM_NON_TIMESTAMPED_EVENT_FORMAT_KEY = 172, 90 IPMISELD_POLL_INTERVAL_KEY = 173, 91 IPMISELD_LOG_FACILITY_KEY = 174, 92 IPMISELD_LOG_PRIORITY_KEY = 175, 93 IPMISELD_CACHE_DIRECTORY_KEY = 176, 94 IPMISELD_IGNORE_SDR_KEY = 177, 95 IPMISELD_RE_DOWNLOAD_SDR_KEY = 178, 96 IPMISELD_CLEAR_SEL_KEY = 179, 97 IPMISELD_THREADPOOL_COUNT_KEY = 180, 98 IPMISELD_TEST_RUN_KEY = 181, 99 IPMISELD_FOREGROUND_KEY = 182, 100 }; 101 102 struct ipmiseld_arguments 103 { 104 struct common_cmd_args common_args; 105 unsigned int verbose_count; 106 char sensor_types[MAX_SENSOR_TYPES][MAX_SENSOR_TYPES_STRING_LENGTH+1]; 107 unsigned int sensor_types_length; 108 char exclude_sensor_types[MAX_SENSOR_TYPES][MAX_SENSOR_TYPES_STRING_LENGTH+1]; 109 unsigned int exclude_sensor_types_length; 110 int system_event_only; 111 int oem_event_only; 112 char *event_state_config_file; 113 int interpret_oem_data; 114 int output_oem_event_strings; 115 int entity_sensor_names; 116 int non_abbreviated_units; 117 char *event_state_filter_str; 118 unsigned int warning_threshold; 119 unsigned int clear_threshold; 120 char *system_event_format_str; 121 char *oem_timestamped_event_format_str; 122 char *oem_non_timestamped_event_format_str; 123 unsigned int poll_interval; 124 char *log_facility_str; 125 char *log_priority_str; 126 char *cache_directory; 127 int ignore_sdr; 128 int re_download_sdr; 129 int clear_sel; 130 unsigned int threadpool_count; 131 int test_run; 132 int foreground; 133 }; 134 135 typedef struct ipmiseld_prog_data 136 { 137 char *progname; 138 int event_state_filter_mask; 139 int log_facility; 140 int log_priority; 141 struct ipmiseld_arguments *args; 142 } ipmiseld_prog_data_t; 143 144 typedef struct ipmiseld_last_record_id 145 { 146 uint16_t record_id; 147 int loaded; 148 } ipmiseld_last_record_id_t; 149 150 typedef struct ipmiseld_sel_info 151 { 152 uint16_t entries; 153 uint16_t free_space; 154 uint32_t most_recent_addition_timestamp; 155 uint32_t most_recent_erase_timestamp; 156 uint8_t delete_sel_command_supported; 157 uint8_t reserve_sel_command_supported; 158 uint8_t overflow_flag; 159 } ipmiseld_sel_info_t; 160 161 typedef struct ipmiseld_host_state 162 { 163 ipmiseld_last_record_id_t last_record_id; 164 unsigned int last_percent_full; 165 ipmiseld_sel_info_t sel_info; 166 int initialized; 167 } ipmiseld_host_state_t; 168 169 typedef struct ipmiseld_host_poll 170 { 171 ipmi_ctx_t ipmi_ctx; 172 ipmi_sdr_ctx_t sdr_ctx; 173 ipmi_sel_ctx_t sel_ctx; 174 ipmi_interpret_ctx_t interpret_ctx; 175 struct ipmi_oem_data oem_data; 176 } ipmiseld_host_poll_t; 177 178 typedef struct ipmiseld_host_data 179 { 180 ipmiseld_prog_data_t *prog_data; 181 char *hostname; 182 ipmiseld_host_state_t last_host_state; 183 ipmiseld_host_state_t now_host_state; 184 ipmiseld_host_poll_t *host_poll; 185 int re_download_sdr_done; 186 int clear_sel_done; 187 time_t next_poll_time; 188 int last_ipmi_errnum; 189 unsigned int last_ipmi_errnum_count; 190 } ipmiseld_host_data_t; 191 192 #endif /* IPMISELD_H */ 193