Commit d3a86278 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add verbosity to the wrsNetworkingStatusGroup

There are some side effects of this commit:
--add macro SLOG_IF_COMP_WNSG
--fields in the struct wrsNetworkingStatus_config are changed from int to float
  to avoid warning about a wrong parameter for macro SLOG_IF_COMP_WNSG (printf)
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 6b20626b
......@@ -14,6 +14,12 @@ static struct pickinfo wrsNetworkingStatus_pickinfo[] = {
struct wrsNetworkingStatus_s wrsNetworkingStatus_s;
static struct wrsNetworkingStatus_config ns_dotconfig;
static struct ns_pstats ns_pstats_copy[WRS_N_PORTS];
static char *slog_obj_name;
static char *wrsSFPsStatus_str = "wrsSFPsStatus";
static char *wrsEndpointStatus_str = "wrsEndpointStatus";
static char *wrsSwcoreStatus_str = "wrsSwcoreStatus";
static char *wrsRTUStatus_str = "wrsRTUStatus";
static void copy_pstats(struct ns_pstats *copy, struct wrsPstatsHCTable_s *org,
unsigned int rows)
......@@ -56,25 +62,19 @@ static int get_endpoint_status(struct ns_pstats *old,
int ret;
ret = 0;
slog_obj_name = wrsEndpointStatus_str;
/* values from 2.2.2 "Fault in the Endpoint’s transmission/reception
* path" in wrs_failures document shouldn't change faster than 1
* per second */
for (i = 0; i < rows; i++) {
if (
((new[i].wrsPstatsHCTXUnderrun - old[i].wrsPstatsHCTXUnderrun)/t_delta > 1.0)
|| ((new[i].wrsPstatsHCRXOverrun - old[i].wrsPstatsHCRXOverrun)/t_delta > 1.0)
|| ((new[i].wrsPstatsHCRXInvalidCode - old[i].wrsPstatsHCRXInvalidCode)/t_delta > 1.0)
|| ((new[i].wrsPstatsHCRXSyncLost - old[i].wrsPstatsHCRXSyncLost)/t_delta > 1.0)
|| ((new[i].wrsPstatsHCRXPfilterDropped - old[i].wrsPstatsHCRXPfilterDropped)/t_delta > 1.0)
|| ((new[i].wrsPstatsHCRXPCSErrors - old[i].wrsPstatsHCRXPCSErrors)/t_delta > 1.0)
|| ((new[i].wrsPstatsHCRXCRCErrors - old[i].wrsPstatsHCRXCRCErrors)/t_delta > 1.0)
) {
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for "
"port %d (wri %d)\n", i + 1, i + 1);
}
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCTXUnderrun, new, old, i, t_delta, 1.0, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXOverrun, new, old, i, t_delta, 1.0, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXInvalidCode, new, old, i, t_delta, 1.0, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXSyncLost, new, old, i, t_delta, 1.0, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPfilterDropped, new, old, i, t_delta, 1.0, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPCSErrors, new, old, i, t_delta, 1.0, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXCRCErrors, new, old, i, t_delta, 1.0, ret = 1);
}
return ret;
}
......@@ -92,6 +92,8 @@ static int get_swcore_status(struct ns_pstats *old,
/* don't use this function for now, return OK */
return ret;
slog_obj_name = wrsSwcoreStatus_str;
for (i = 0; i < rows; i++) {
/* TXFrames and Forwarded described in 2.2.3 "Problem with the
* SwCore or Endpoint HDL module" in wrs_failures document
......@@ -113,24 +115,16 @@ static int get_swcore_status(struct ns_pstats *old,
/* values from 2.2.5 "Too much HP traffic / Per-priority queue
* full" in wrs_failures document shouldn't change faster
* than parameters defined in dotconfig per second */
if ( /* shouldn't differ more than FORWARD_DELTA */
((new[i].wrsPstatsHCRXFrames - old[i].wrsPstatsHCRXFrames)/t_delta >= ns_dotconfig.rx_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio0 - old[i].wrsPstatsHCRXPrio0)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio1 - old[i].wrsPstatsHCRXPrio1)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio2 - old[i].wrsPstatsHCRXPrio2)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio3 - old[i].wrsPstatsHCRXPrio3)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio4 - old[i].wrsPstatsHCRXPrio4)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio5 - old[i].wrsPstatsHCRXPrio5)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio6 - old[i].wrsPstatsHCRXPrio6)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCRXPrio7 - old[i].wrsPstatsHCRXPrio7)/t_delta >= ns_dotconfig.rx_prio_frame_rate)
|| ((new[i].wrsPstatsHCFastMatchPriority - old[i].wrsPstatsHCFastMatchPriority)/t_delta >= ns_dotconfig.hp_frame_rate)
) {
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for "
"port %d (wri %d)\n", i + 1, i + 1);
}
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXFrames, new, old, i, t_delta, ns_dotconfig.rx_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio0, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio1, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio2, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio3, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio4, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio5, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio6, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCRXPrio7, new, old, i, t_delta, ns_dotconfig.rx_prio_frame_rate, ret = 1);
SLOG_IF_COMP_WNSG(SL_ER, wrsPstatsHCFastMatchPriority, new, old, i, t_delta, ns_dotconfig.hp_frame_rate, ret = 1);
}
return ret;
}
......@@ -143,6 +137,8 @@ static int get_rtu_status(struct ns_pstats *old,
int ret;
ret = 0;
slog_obj_name = wrsRTUStatus_str;
/* values from 2.2.4 "RTU is full and cannot accept more requests" in
* wrs_failures document shouldn't increase */
for (i = 0; i < rows; i++) {
......@@ -150,8 +146,13 @@ static int get_rtu_status(struct ns_pstats *old,
/* if error, no need to check more, but do it just for
* logs */
ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for "
"port %d (wri %d)\n", i + 1, i + 1);
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"wrsPstatsHCRXDropRTUFull counter for port %i (wri %i) increased by %lld, allowed %d\n",
slog_obj_name, i + 1, i + 1,
new[i].wrsPstatsHCRXDropRTUFull - old[i].wrsPstatsHCRXDropRTUFull, 0);
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"some frames were lost because RTU could not accept new requests\n",
slog_obj_name);
}
}
/* TODO: add 2.2.7 "Network loop - two or more identical MACs on two or
......@@ -182,7 +183,7 @@ time_t wrsNetworkingStatus_data_fill(void)
static time_t time_update; /* time of last update */
time_t time_port_status; /* time when port status table was updated */
time_t time_pstats; /* time when pstats table was updated */
float time_pstats_delta; /* seconds since last update */
time_t time_pstats_delta; /* seconds since last update */
static time_t time_pstats_prev; /* time when previous state of pstats
* table was updated */
unsigned int port_status_nrows; /* number of rows in PortStatusTable */
......@@ -218,6 +219,7 @@ time_t wrsNetworkingStatus_data_fill(void)
|*************************** wrsSFPsStatus ***************************|
\*********************************************************************/
slog_obj_name = wrsSFPsStatus_str;
p_a = wrsPortStatusTable_array;
port_status_n_ok = 0;
port_status_n_error = 0;
......@@ -228,24 +230,28 @@ time_t wrsNetworkingStatus_data_fill(void)
if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_SFP_OK) {
port_status_n_ok++;
}
if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR) {
port_status_n_error++;
}
if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) {
port_status_n_down++;
}
if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR) {
port_status_n_error++;
}
if (p_a[i].wrsPortStatusSfpError == 0) {
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Unable to read wrsSFPsStatus "
"for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1);
port_status_n_na++;
}
}
if ((port_status_n_error > 0)
|| ((port_status_n_ok + port_status_n_down + port_status_n_na)
!= port_status_nrows)
) {
if (port_status_n_error > 0) {
/* error */
wrsNetworkingStatus_s.wrsSFPsStatus = WRS_SFPS_STATUS_ERROR;
} else if ((port_status_n_ok + port_status_n_down + port_status_n_na)
!= port_status_nrows) {
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: Error reading statuses of SFPs\n",
slog_obj_name);
wrsNetworkingStatus_s.wrsSFPsStatus = WRS_SFPS_STATUS_ERROR;
} else if (port_status_n_na > 0) { /* warning NA */
wrsNetworkingStatus_s.wrsSFPsStatus =
WRS_SFPS_STATUS_WARNING_NA;
......
......@@ -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 */
......@@ -52,6 +52,41 @@ 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
*
......
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