Commit 8fa85648 authored by Adam Wujek's avatar Adam Wujek 💬

merge branch "adam-snmp"

Add verbose messages to the SNMP
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents f9332f2d 0bf5f4c0
......@@ -123,8 +123,8 @@ static void get_boot_info(void){
/* get restart reason */
rcsr_map = create_map(ARM_RCSR_ADDR, sizeof(uint32_t));
if (!rcsr_map) {
snmp_log(LOG_ERR, "SNMP: wrsBootStatusGroup unable to map "
"CPU's Reset Controller Status Register\n");
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsRestartReason: unable to"
" map CPU's Reset Controller Status Register\n");
/* pass error to SNMP, assign 1 */
wrsBootStatus_s.wrsRestartReason = WRS_RESTART_REASON_ERROR;
/* try again next time */
......@@ -138,8 +138,8 @@ static void get_boot_info(void){
f = fopen(BOOTCOUNT_FILE, "r");
if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsBootStatusGroup filed to open "
BOOTCOUNT_FILE"\n");
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsRestartReason: failed to"
" open " BOOTCOUNT_FILE "\n");
/* notify snmp about error in restart reason */
wrsBootStatus_s.wrsRestartReason = WRS_RESTART_REASON_ERROR;
/* try again next time */
......@@ -215,6 +215,8 @@ static void get_dotconfig_source(void)
* a problem */
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsConfigSource: failed to "
"open " DOTCONFIGDIR "/" DOTCONFIG_SOURCE "\n");
}
/* read dot-config's URL only when config source is not local */
......@@ -230,6 +232,9 @@ static void get_dotconfig_source(void)
/* host file not found, put "error" into
* wrsConfigSourceHost */
strcpy(wrsBootStatus_s.wrsConfigSourceUrl, "error");
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsConfigSourceUrl:"
" failed to open "
DOTCONFIGDIR "/" DOTCONFIG_SOURCE_URL"\n");
}
} else {
memset(wrsBootStatus_s.wrsConfigSourceUrl, 0,
......@@ -261,6 +266,8 @@ static void get_dotconfig_source(void)
* a problem */
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsConfigSource: failed to "
"open " DOTCONFIGDIR "/" DOTCONFIG_STATUS"\n");
}
}
......@@ -305,6 +312,8 @@ static void get_boot_scripts_status(void){
* a problem */
wrsBootStatus_s.wrsBootHwinfoReadout =
WRS_BOOT_HWINFO_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsBootHwinfoReadout: "
"failed to open " HWINFO_FILE "\n");
/* try again next time */
run_once = 0;
}
......@@ -324,7 +333,7 @@ static void get_boot_scripts_status(void){
/* try again next time */
run_once = 0;
}
else {/* */
else {/* Failed to load FPGA */
wrsBootStatus_s.wrsBootLoadFPGA =
WRS_BOOT_LOAD_FPGA_ERROR;
/* try again next time */
......@@ -336,6 +345,8 @@ static void get_boot_scripts_status(void){
* a problem */
wrsBootStatus_s.wrsBootLoadFPGA =
WRS_BOOT_LOAD_FPGA_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsBootLoadFPGA: failed to "
"open " LOAD_FPGA_STATUS_FILE "\n");
/* try again next time */
run_once = 0;
}
......@@ -367,6 +378,8 @@ static void get_boot_scripts_status(void){
* a problem */
wrsBootStatus_s.wrsBootLoadLM32 =
WRS_BOOT_LOAD_LM32_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsBootLoadLM32: failed to "
"open " LOAD_FPGA_STATUS_FILE "\n");
/* try again next time */
run_once = 0;
}
......@@ -385,8 +398,8 @@ static void get_loaded_kernel_modules_status(void)
f = fopen(MODULES_FILE, "r");
if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsBootStatusGroup filed to open "
MODULES_FILE"\n");
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsBootKernelModulesMissing"
": failed to open " MODULES_FILE "\n");
/* notify snmp about error in kernel modules */
wrsBootStatus_s.wrsBootKernelModulesMissing =
ARRAY_SIZE(kernel_modules);
......@@ -441,8 +454,9 @@ static void get_daemons_status(void)
* but probably slower than manually parsing /proc/ */
f = popen(PROCESS_COMMAND, "r");
if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsBootStatusGroup failed to execute "
PROCESS_COMMAND"\n");
snmp_log(LOG_ERR, "SNMP: " SL_ER
" wrsBootUserspaceDaemonsMissing: failed to execute "
PROCESS_COMMAND "\n");
wrsBootStatus_s.wrsBootUserspaceDaemonsMissing = 0;
/* Notify snmp about error in processes list */
/* Count number of expected processes */
......@@ -505,8 +519,8 @@ static void get_n_watchdog_timouts(void)
f = popen(WDOG_COMMAND, "r");
if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsBootStatusGroup failed to execute "
WDOG_COMMAND"\n");
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsGwWatchdogTimeouts: "
"failed to execute " WDOG_COMMAND "\n");
return;
}
......
This diff is collapsed.
......@@ -63,9 +63,9 @@ struct ns_pstats {
/* parameters read from dot-config */
struct wrsNetworkingStatus_config {
int hp_frame_rate;
int rx_frame_rate;
int rx_prio_frame_rate;
float hp_frame_rate;
float rx_frame_rate;
float rx_prio_frame_rate;
};
#endif /* WRS_NETWORKING_STATUS_GROUP_H */
This diff is collapsed.
......@@ -5,6 +5,9 @@
/* Our data: per-port information */
struct wrsPortStatusTable_s wrsPortStatusTable_array[WRS_N_PORTS];
static char *slog_obj_name;
static char *wrsPortStatusSfpError_str = "wrsPortStatusSfpError";
static struct pickinfo wrsPortStatusTable_pickinfo[] = {
FIELD(wrsPortStatusTable_s, ASN_UNSIGNED, index), /* not reported */
FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusPortName),
......@@ -50,7 +53,7 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* check whether shmem is available */
if (!shmem_ready_hald()) {
/* there was an update, return current time */
snmp_log(LOG_ERR, "%s: Unable to read HAL's shmem\n", __func__);
snmp_log(LOG_ERR, "%s: Unable to read HAL shmem\n", __func__);
n_rows_local = 0;
return time_cur;
} else {
......@@ -101,10 +104,20 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* FIXME: get real peer_id */
memset(&wrsPortStatusTable_array[i].wrsPortStatusPeer, 0xff,
sizeof(ClockIdentity));
wrsPortStatusTable_array[i].wrsPortStatusSfpInDB =
port_state->calib.sfp.flags & SFP_FLAG_IN_DB ? 2 : 1;
wrsPortStatusTable_array[i].wrsPortStatusSfpGbE =
port_state->calib.sfp.flags & SFP_FLAG_1GbE ? 2 : 1;
if (port_state->calib.sfp.flags & SFP_FLAG_IN_DB) {
wrsPortStatusTable_array[i].wrsPortStatusSfpInDB =
WRS_PORT_STATUS_SFP_IN_DB_IN_DATA_BASE;
} else {
wrsPortStatusTable_array[i].wrsPortStatusSfpInDB =
WRS_PORT_STATUS_SFP_IN_DB_NOT_IN_DATA_BASE;
}
if (port_state->calib.sfp.flags & SFP_FLAG_1GbE) {
wrsPortStatusTable_array[i].wrsPortStatusSfpGbE =
WRS_PORT_STATUS_SFP_GBE_LINK_GBE;
} else {
wrsPortStatusTable_array[i].wrsPortStatusSfpGbE =
WRS_PORT_STATUS_SFP_GBE_LINK_NOT_GBE;
}
strncpy(wrsPortStatusTable_array[i].wrsPortStatusSfpVN,
port_state->calib.sfp.vendor_name,
sizeof(wrsPortStatusTable_array[i].wrsPortStatusSfpVN));
......@@ -115,16 +128,26 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
port_state->calib.sfp.vendor_serial,
sizeof(wrsPortStatusTable_array[i].wrsPortStatusSfpVS));
/* sfp error when SFP is not 1 GbE or
* (port is not wr-non mode and sfp not in data base)
* Keep value 0 for Not available
* sfp ok is 1 (WRS_PORT_STATUS_SFP_ERROR_SFP_OK)
* sfp error is 2 WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR
* port down, set above, is 3
* (port is not non-wr mode and sfp not in data base)
* port down, is set above
* (WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = 1 +
((wrsPortStatusTable_array[i].wrsPortStatusSfpGbE == 1) ||
((port_state->mode != HEXP_PORT_MODE_NON_WR) &&
(wrsPortStatusTable_array[i].wrsPortStatusSfpInDB == 1)));
slog_obj_name = wrsPortStatusSfpError_str;
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_OK;
if (wrsPortStatusTable_array[i].wrsPortStatusSfpGbE == WRS_PORT_STATUS_SFP_GBE_LINK_NOT_GBE) {
/* error, SFP is not 1 GbE */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"SFP in port %d (wri%d) is not for Gigabit Ethernet\n",
slog_obj_name, i + 1, i + 1);
}
if ((wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR) &&
(wrsPortStatusTable_array[i].wrsPortStatusSfpInDB == WRS_PORT_STATUS_SFP_IN_DB_NOT_IN_DATA_BASE)) {
/* error, port is not non-wr mode and sfp not in data base */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"SFP in port %d (wri%d) is not in database. Change the SFP or declare port as non-wr\n",
slog_obj_name, i + 1, i + 1);
}
snmp_log(LOG_DEBUG, "reading ports name %s link %d, "
"mode %d, locked %d\n", port_state->name,
......@@ -135,7 +158,7 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
retries++;
if (retries > 100) {
snmp_log(LOG_ERR, "%s: too many retries to read HAL\n",
snmp_log(LOG_ERR, "%s: Unable to read HAL, too many retries\n",
__func__);
retries = 0;
}
......@@ -148,7 +171,7 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* check whether shmem is available */
if (!shmem_ready_ppsi()) {
/* there was an update, return current time */
snmp_log(LOG_ERR, "%s: Unable to read PPSI's shmem\n",
snmp_log(LOG_ERR, "%s: Unable to read PPSI shmem\n",
__func__);
return time_cur;
}
......@@ -185,8 +208,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
}
retries++;
if (retries > 100) {
snmp_log(LOG_ERR, "%s: too many retries to read PPSI "
"shmem\n", __func__);
snmp_log(LOG_ERR, "%s: Unable to read PPSI, too many retries\n",
__func__);
retries = 0;
break;
}
......
......@@ -16,6 +16,11 @@
#define WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR 3
#define WRS_PORT_STATUS_CONFIGURED_MODE_AUTO 4
#define WRS_PORT_STATUS_SFP_IN_DB_NOT_IN_DATA_BASE 1 /* error */
#define WRS_PORT_STATUS_SFP_IN_DB_IN_DATA_BASE 2 /* ok */
#define WRS_PORT_STATUS_SFP_GBE_LINK_NOT_GBE 1 /* error */
#define WRS_PORT_STATUS_SFP_GBE_LINK_GBE 2 /* ok */
struct wrsPortStatusTable_s {
uint32_t index; /* not reported, index fields has to be marked
......
......@@ -52,4 +52,60 @@ struct pickinfo {
.len = sizeof(((struct _struct *)0)->_field), \
}
/*
* Print a message and execute assignment when the value of _object grows
* faster than _rate.
* Special version for wrsNetworkingStatusGroup.
*
* usage:
* _log_type -- on of the SL_* string defines
* _obj -- object to be checked in the arrays
* _new -- array with the new values
* _old -- array with the old values
* _i -- port number
* _t_delta -- time since last read, used to calculate rate
* _rate -- maximum allowed rate
*
* _assign -- assignment to be performed when condition is met
* NOTE:
*
* Valid example:
* strcpy(slog_obj_name, "my_obj");
* SLOG_IF_COMP_WNSG(SL_ER, a, new, old, 1, t_delta, 1.0, ret = 1);
* When condition (new.a[i] - old.a[i])/t_delta > 1.0 is met, macro will assign 1 to ret and print
* the following message:
* SNMP: Error my_obj: a for port 1 (wri1) increased by 10.0, allowed 1.0
*/
/* WNSG = WrsNetworkingStatusGroup */
#define SLOG_IF_COMP_WNSG(_log_type, _obj, _new, _old, _i, _t_delta, _rate, _assign) \
do { if ((_new[_i]._obj - _old[_i]._obj)/_t_delta > _rate) {\
_assign; \
snmp_log(LOG_ERR, "SNMP: " _log_type " %s: " #_obj " for port %i (wri%i) increased by more than %.0f during %.0fs, allowed %.0f\n", \
slog_obj_name, _i + 1, _i + 1, \
(_new[_i]._obj - _old[_i]._obj)/_t_delta, _t_delta, \
_rate); \
} \
} while (0)
/*
* Print a message about an object
*
* Valid example2:
* strcpy(slog_obj_name, "my_obj");
* SLOG(SL_BUG);
* prints:
* SNMP: BUG my_obj
*/
#define SLOG(_log_type) \
do { \
snmp_log(LOG_ERR, "SNMP: " _log_type " %s\n", slog_obj_name); \
} while (0)
/* String definitions for functions SLOG* */
#define SL_ER "Error"
#define SL_W "Warning"
#define SL_NA "Warning NA"
#define SL_BUG "BUG"
#endif /* WRS_SNMP_H */
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment