Commit 3bf0de56 authored by Maciej Lipinski's avatar Maciej Lipinski

[issue #194] updated messages printed by SNMPd to syslog

Updates:
- information in the body of the message about severity was
  not aligned with the severity reported to syslog, now all
  is aligned
- aligned format of all messages from snmpd that use snmp_log()
parent 0513c3ee
...@@ -37,7 +37,8 @@ void init_wrsSnmp(void) ...@@ -37,7 +37,8 @@ void init_wrsSnmp(void)
if (libwr_cfg_read_file(DOTCONFIG_FILE)) { if (libwr_cfg_read_file(DOTCONFIG_FILE)) {
/* unable to read dot-config, /* unable to read dot-config,
* don't crash SNMPd, it will be reported in SNMP objects */ * don't crash SNMPd, it will be reported in SNMP objects */
snmp_log(LOG_ERR, "SNMP: unable to read dot-config file %s\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
"unable to read dot-config file %s\n",
DOTCONFIG_FILE); DOTCONFIG_FILE);
} }
init_wrsScalar(); init_wrsScalar();
......
...@@ -32,13 +32,16 @@ static int init_shm_hald(void) ...@@ -32,13 +32,16 @@ static int init_shm_hald(void)
/* start printing error after 5 messages */ /* start printing error after 5 messages */
if (n_wait > 5) { if (n_wait > 5) {
if (ret == WRS_SHM_OPEN_FAILED) { if (ret == WRS_SHM_OPEN_FAILED) {
snmp_log(LOG_ERR, "Unable to open HAL's shmem!\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to open HAL's shmem!\n");
} }
if (ret == WRS_SHM_WRONG_VERSION) { if (ret == WRS_SHM_WRONG_VERSION) {
snmp_log(LOG_ERR, "Unable to read HAL's version!\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to read HAL's version!\n");
} }
if (ret == WRS_SHM_INCONSISTENT_DATA) { if (ret == WRS_SHM_INCONSISTENT_DATA) {
snmp_log(LOG_ERR, "Unable to read consistent data from" snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to read consistent data from"
" HAL's shmem!\n"); " HAL's shmem!\n");
} }
} }
...@@ -49,7 +52,8 @@ static int init_shm_hald(void) ...@@ -49,7 +52,8 @@ static int init_shm_hald(void)
/* check hal's shm version */ /* check hal's shm version */
if (hal_head->version != HAL_SHMEM_VERSION) { if (hal_head->version != HAL_SHMEM_VERSION) {
snmp_log(LOG_ERR, "unknown hal's shm version %i " snmp_log(LOG_ERR, "SNMP: " SL_ER
"unknown hal's shm version %i "
"(known is %i)\n", hal_head->version, "(known is %i)\n", hal_head->version,
HAL_SHMEM_VERSION); HAL_SHMEM_VERSION);
return 3; return 3;
...@@ -59,7 +63,8 @@ static int init_shm_hald(void) ...@@ -59,7 +63,8 @@ static int init_shm_hald(void)
/* Assume number of ports does not change in runtime */ /* Assume number of ports does not change in runtime */
hal_nports_local = hal_shmem->nports; hal_nports_local = hal_shmem->nports;
if (hal_nports_local > WRS_N_PORTS) { if (hal_nports_local > WRS_N_PORTS) {
snmp_log(LOG_ERR, "Too many ports reported by HAL. " snmp_log(LOG_ERR, "SNMP: " SL_ER
"Too many ports reported by HAL. "
"%d vs %d supported\n", "%d vs %d supported\n",
hal_nports_local, WRS_N_PORTS); hal_nports_local, WRS_N_PORTS);
return 3; return 3;
...@@ -68,7 +73,8 @@ static int init_shm_hald(void) ...@@ -68,7 +73,8 @@ static int init_shm_hald(void)
* addresses. No need to re-dereference pointer at each read. */ * addresses. No need to re-dereference pointer at each read. */
hal_ports = wrs_shm_follow(hal_head, hal_shmem->ports); hal_ports = wrs_shm_follow(hal_head, hal_shmem->ports);
if (!hal_ports) { if (!hal_ports) {
snmp_log(LOG_ERR, "Unalbe to follow hal_ports pointer in HAL's" snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unalbe to follow hal_ports pointer in HAL's"
" shmem"); " shmem");
return 3; return 3;
} }
...@@ -88,13 +94,16 @@ static int init_shm_ppsi(void) ...@@ -88,13 +94,16 @@ static int init_shm_ppsi(void)
if (n_wait > 5) { if (n_wait > 5) {
/* timeout! */ /* timeout! */
if (ret == WRS_SHM_OPEN_FAILED) { if (ret == WRS_SHM_OPEN_FAILED) {
snmp_log(LOG_ERR, "Unable to open shm for PPSI!\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to open shm for PPSI!\n");
} }
if (ret == WRS_SHM_WRONG_VERSION) { if (ret == WRS_SHM_WRONG_VERSION) {
snmp_log(LOG_ERR, "Unable to read PPSI's version!\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to read PPSI's version!\n");
} }
if (ret == WRS_SHM_INCONSISTENT_DATA) { if (ret == WRS_SHM_INCONSISTENT_DATA) {
snmp_log(LOG_ERR, "Unable to read consistent data from" snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to read consistent data from"
" PPSI's shmem!\n"); " PPSI's shmem!\n");
} }
} }
...@@ -105,7 +114,8 @@ static int init_shm_ppsi(void) ...@@ -105,7 +114,8 @@ static int init_shm_ppsi(void)
/* check ppsi's shm version */ /* check ppsi's shm version */
if (ppsi_head->version != WRS_PPSI_SHMEM_VERSION) { if (ppsi_head->version != WRS_PPSI_SHMEM_VERSION) {
snmp_log(LOG_ERR, "unknown PPSI's shm version %i " snmp_log(LOG_ERR, "SNMP: " SL_ER
"unknown PPSI's shm version %i "
"(known is %i)\n", "(known is %i)\n",
ppsi_head->version, WRS_PPSI_SHMEM_VERSION); ppsi_head->version, WRS_PPSI_SHMEM_VERSION);
return 3; return 3;
...@@ -116,13 +126,15 @@ static int init_shm_ppsi(void) ...@@ -116,13 +126,15 @@ static int init_shm_ppsi(void)
ppsi_servo=NULL; ppsi_servo=NULL;
// ppsi_servo = wrs_shm_follow(ppsi_head, ppg->servo); // ppsi_servo = wrs_shm_follow(ppsi_head, ppg->servo);
// if (!ppsi_servo) { // if (!ppsi_servo) {
// snmp_log(LOG_ERR, "Cannot follow ppsi_servo in shmem.\n"); // snmp_log(LOG_ERR, "SNMP: " SL_ER
// "Cannot follow ppsi_servo in shmem.\n");
// return 4; // return 4;
// } // }
ppsi_ppi = wrs_shm_follow(ppsi_head, ppg->pp_instances); ppsi_ppi = wrs_shm_follow(ppsi_head, ppg->pp_instances);
if (!ppsi_ppi) { if (!ppsi_ppi) {
snmp_log(LOG_ERR, "Cannot follow ppsi_ppi in shmem.\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Cannot follow ppsi_ppi in shmem.\n");
return 5; return 5;
} }
/* use pointer instead of copying */ /* use pointer instead of copying */
...@@ -140,13 +152,16 @@ static int init_shm_rtud(void) ...@@ -140,13 +152,16 @@ static int init_shm_rtud(void)
/* start printing error after 5 messages */ /* start printing error after 5 messages */
if (n_wait > 5) { if (n_wait > 5) {
if (ret == WRS_SHM_OPEN_FAILED) { if (ret == WRS_SHM_OPEN_FAILED) {
snmp_log(LOG_ERR, "Unable to open shm for RTUd!\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to open shm for RTUd!\n");
} }
if (ret == WRS_SHM_WRONG_VERSION) { if (ret == WRS_SHM_WRONG_VERSION) {
snmp_log(LOG_ERR, "Unable to read RTUd's version!\n"); snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to read RTUd's version!\n");
} }
if (ret == WRS_SHM_INCONSISTENT_DATA) { if (ret == WRS_SHM_INCONSISTENT_DATA) {
snmp_log(LOG_ERR, "Unable to read consistent data from" snmp_log(LOG_ERR, "SNMP: " SL_ER
"Unable to read consistent data from"
" RTUd's shmem!\n"); " RTUd's shmem!\n");
} }
} }
...@@ -157,7 +172,8 @@ static int init_shm_rtud(void) ...@@ -157,7 +172,8 @@ static int init_shm_rtud(void)
/* check rtud's shm version */ /* check rtud's shm version */
if (rtud_head->version != RTU_SHMEM_VERSION) { if (rtud_head->version != RTU_SHMEM_VERSION) {
snmp_log(LOG_ERR, "unknown RTUd's shm version %i " snmp_log(LOG_ERR, "SNMP: " SL_ER
"unknown RTUd's shm version %i "
"(known is %i)\n", rtud_head->version, "(known is %i)\n", rtud_head->version,
RTU_SHMEM_VERSION); RTU_SHMEM_VERSION);
return 3; return 3;
......
...@@ -480,7 +480,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array) ...@@ -480,7 +480,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) { if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect monit to be running */ /* SNMP should not expect monit to be running */
daemon_array[UDI_MONIT].exp = 0; daemon_array[UDI_MONIT].exp = 0;
snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:" snmp_log(LOG_INFO, "SNMP: " SL_INFO
" wrsBootUserspaceDaemonsMissing:"
" CONFIG_MONIT_DISABLE=y in dot-config\n"); " CONFIG_MONIT_DISABLE=y in dot-config\n");
} }
...@@ -488,7 +489,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array) ...@@ -488,7 +489,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) { if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect lighttpd (web server) to be running*/ /* SNMP should not expect lighttpd (web server) to be running*/
daemon_array[UDI_HTTP].exp = 0; daemon_array[UDI_HTTP].exp = 0;
snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:" snmp_log(LOG_INFO, "SNMP: " SL_INFO
" wrsBootUserspaceDaemonsMissing:"
" CONFIG_HTTPD_DISABLE=y in dot-config\n"); " CONFIG_HTTPD_DISABLE=y in dot-config\n");
} }
...@@ -496,7 +498,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array) ...@@ -496,7 +498,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) { if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect lldpd to be running */ /* SNMP should not expect lldpd to be running */
daemon_array[UDI_LLDP].exp = 0; daemon_array[UDI_LLDP].exp = 0;
snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:" snmp_log(LOG_INFO, "SNMP: " SL_INFO
" wrsBootUserspaceDaemonsMissing:"
" CONFIG_LLDPD_DISABLE=y in dot-config\n"); " CONFIG_LLDPD_DISABLE=y in dot-config\n");
} }
...@@ -505,7 +508,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array) ...@@ -505,7 +508,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) { if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect nslcd/LDAP to be running */ /* SNMP should not expect nslcd/LDAP to be running */
daemon_array[UDI_NSLCD].exp = 1; daemon_array[UDI_NSLCD].exp = 1;
snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:" snmp_log(LOG_INFO, "SNMP: " SL_INFO
" wrsBootUserspaceDaemonsMissing:"
"no CONFIG_LDAP_ENABLE in dot-config\n"); "no CONFIG_LDAP_ENABLE in dot-config\n");
} }
} }
......
...@@ -27,7 +27,8 @@ time_t wrsCpuLoad_data_fill(void) ...@@ -27,7 +27,8 @@ time_t wrsCpuLoad_data_fill(void)
memset(&wrsCpuLoad_s, 0, sizeof(wrsCpuLoad_s)); memset(&wrsCpuLoad_s, 0, sizeof(wrsCpuLoad_s));
if (sysinfo(&info) != 0) { if (sysinfo(&info) != 0) {
snmp_log(LOG_ERR, "SNMP: wrsMemoryGroup error while reading " snmp_log(LOG_ERR, "SNMP: " SL_ER
" wrsMemoryGroup error while reading "
"system statistics with function sysinfo\n"); "system statistics with function sysinfo\n");
} }
......
...@@ -56,7 +56,7 @@ time_t wrsDiskTable_data_fill(unsigned int *ret_n_rows) ...@@ -56,7 +56,7 @@ time_t wrsDiskTable_data_fill(unsigned int *ret_n_rows)
f = popen(DISKUSAGE_COMMAND, "r"); f = popen(DISKUSAGE_COMMAND, "r");
if (!f) { if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsDiskTable filed to execute " snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsDiskTable filed to execute "
DISKUSAGE_COMMAND"\n"); DISKUSAGE_COMMAND"\n");
return time_cur; return time_cur;
} }
......
...@@ -25,7 +25,7 @@ static int group_handler(netsnmp_mib_handler *handler, ...@@ -25,7 +25,7 @@ static int group_handler(netsnmp_mib_handler *handler,
requests->requestvb->name_length - 2]; requests->requestvb->name_length - 2];
obj--; /* we are 0-based */ obj--; /* we are 0-based */
if (obj < 0 || obj >= ARRAY_SIZE(GT_PICKINFO)) { if (obj < 0 || obj >= ARRAY_SIZE(GT_PICKINFO)) {
snmp_log(LOG_ERR, snmp_log(LOG_ERR, "SNMP: " SL_ER
"wrong index (%d) in "GT_GROUP_NAME"\n", "wrong index (%d) in "GT_GROUP_NAME"\n",
obj + 1); obj + 1);
return SNMP_ERR_GENERR; return SNMP_ERR_GENERR;
...@@ -48,8 +48,9 @@ static int group_handler(netsnmp_mib_handler *handler, ...@@ -48,8 +48,9 @@ static int group_handler(netsnmp_mib_handler *handler,
pi->type, ptr, len); pi->type, ptr, len);
break; break;
default: default:
snmp_log(LOG_ERR, "unknown mode (%d) in "GT_GROUP_NAME"\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
reqinfo->mode); "unknown mode (%d) in "GT_GROUP_NAME"\n",
reqinfo->mode);
return SNMP_ERR_GENERR; return SNMP_ERR_GENERR;
} }
return SNMP_ERR_NOERROR; return SNMP_ERR_NOERROR;
......
...@@ -41,8 +41,8 @@ time_t wrsMemory_data_fill(void) ...@@ -41,8 +41,8 @@ time_t wrsMemory_data_fill(void)
f = fopen(MEMINFO_FILE, "r"); f = fopen(MEMINFO_FILE, "r");
if (!f) { if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsMemoryGroup filed to open " snmp_log(LOG_ERR, "SNMP: " SL_ER
MEMINFO_FILE"\n"); " wrsMemoryGroup filed to open " MEMINFO_FILE"\n");
/* notify snmp about error in kernel modules */ /* notify snmp about error in kernel modules */
return time_update; return time_update;
...@@ -80,7 +80,8 @@ time_t wrsMemory_data_fill(void) ...@@ -80,7 +80,8 @@ time_t wrsMemory_data_fill(void)
wrsMemory_s.wrsMemoryFree = (int) (mem_free + mem_buffers wrsMemory_s.wrsMemoryFree = (int) (mem_free + mem_buffers
+ mem_cached); + mem_cached);
} else { /* if not enough entries found */ } else { /* if not enough entries found */
snmp_log(LOG_ERR, "SNMP: wrsMemoryGroup error while reading " snmp_log(LOG_ERR, "SNMP: " SL_ER
" wrsMemoryGroup error while reading "
"values from "MEMINFO_FILE"\n"); "values from "MEMINFO_FILE"\n");
} }
......
...@@ -269,7 +269,7 @@ time_t wrsNetworkingStatus_data_fill(void) ...@@ -269,7 +269,7 @@ time_t wrsNetworkingStatus_data_fill(void)
port_status_n_error++; port_status_n_error++;
} }
if (p_a[i].wrsPortStatusSfpError == 0) { if (p_a[i].wrsPortStatusSfpError == 0) {
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Unable to read wrsSFPsStatus " snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Unable to read wrsSFPsStatus "
"for port %i (wri%i)\n", "for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1); slog_obj_name, i + 1, i + 1);
port_status_n_na++; port_status_n_na++;
......
This diff is collapsed.
...@@ -60,7 +60,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows) ...@@ -60,7 +60,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* check whether shmem is available */ /* check whether shmem is available */
if (!shmem_ready_hald()) { if (!shmem_ready_hald()) {
/* there was an update, return current time */ /* there was an update, return current time */
snmp_log(LOG_ERR, "%s: Unable to read HAL shmem\n", __func__); snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read HAL shmem\n", __func__);
n_rows_local = 0; n_rows_local = 0;
return time_cur; return time_cur;
} else { } else {
...@@ -159,7 +160,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows) ...@@ -159,7 +160,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
retries++; retries++;
if (retries > 100) { if (retries > 100) {
snmp_log(LOG_ERR, "%s: Unable to read HAL, too many retries\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read HAL, too many retries\n",
__func__); __func__);
retries = 0; retries = 0;
} }
...@@ -209,7 +211,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows) ...@@ -209,7 +211,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
slog_obj_name, i + 1, i + 1); slog_obj_name, i + 1, i + 1);
} }
snmp_log(LOG_DEBUG, "reading ports name %s link %d, " snmp_log(LOG_DEBUG, "SNMP: " SL_DEBUG
" reading ports name %s link %d, "
"mode %d, locked %d\n", "mode %d, locked %d\n",
wrsPortStatusTable_array[i].wrsPortStatusPortName, wrsPortStatusTable_array[i].wrsPortStatusPortName,
wrsPortStatusTable_array[i].wrsPortStatusLink, wrsPortStatusTable_array[i].wrsPortStatusLink,
...@@ -221,7 +224,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows) ...@@ -221,7 +224,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* check whether shmem is available */ /* check whether shmem is available */
if (!shmem_ready_ppsi()) { if (!shmem_ready_ppsi()) {
/* there was an update, return current time */ /* there was an update, return current time */
snmp_log(LOG_ERR, "%s: Unable to read PPSI shmem\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read PPSI shmem\n",
__func__); __func__);
return time_cur; return time_cur;
} }
...@@ -258,8 +262,9 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows) ...@@ -258,8 +262,9 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
} }
retries++; retries++;
if (retries > 100) { if (retries > 100) {
snmp_log(LOG_ERR, "%s: Unable to read PPSI, too many retries\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
__func__); "%s: Unable to read PPSI, too many retries\n",
__func__);
retries = 0; retries = 0;
break; break;
} }
......
...@@ -66,7 +66,9 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -66,7 +66,9 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
/* check whether shmem is available */ /* check whether shmem is available */
if (!shmem_ready_ppsi()) { if (!shmem_ready_ppsi()) {
snmp_log(LOG_ERR, "%s: Unable to read PPSI's shmem\n", __func__); snmp_log(LOG_ERR, "SNMP: " SL_ER
" %s: Unable to read PPSI's shmem\n",
__func__);
/* Keep one empty instance. If set to 0 all PPSI related OIDs /* Keep one empty instance. If set to 0 all PPSI related OIDs
* disappear */ * disappear */
n_rows_local = 1; n_rows_local = 1;
...@@ -111,7 +113,8 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows) ...@@ -111,7 +113,8 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
// //JCB TODO + (ppsi_servo->update_time.scaled_nsecs >> 16); // //JCB TODO + (ppsi_servo->update_time.scaled_nsecs >> 16);
retries++; retries++;
if (retries > 100) { if (retries > 100) {
snmp_log(LOG_ERR, "%s: too many retries to read PPSI\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: too many retries to read PPSI\n",
__func__); __func__);
retries = 0; retries = 0;
} }
......
...@@ -73,8 +73,8 @@ handle_wrsScalarOne(netsnmp_mib_handler *handler, ...@@ -73,8 +73,8 @@ handle_wrsScalarOne(netsnmp_mib_handler *handler,
/* /*
* we should never get here, so this is a really bad error * we should never get here, so this is a really bad error
*/ */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_wrsScalarOne\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
reqinfo->mode); "unknown mode (%d) in handle_wrsScalarOne\n", reqinfo->mode);
return SNMP_ERR_GENERR; return SNMP_ERR_GENERR;
} }
......
...@@ -103,11 +103,14 @@ struct pickinfo { ...@@ -103,11 +103,14 @@ struct pickinfo {
snmp_log(LOG_ERR, "SNMP: " _log_type " %s\n", slog_obj_name); \ snmp_log(LOG_ERR, "SNMP: " _log_type " %s\n", slog_obj_name); \
} while (0) } while (0)
/* String definitions for functions SLOG* */ /* String definitions for functions SLOG*, the same lenght of string
#define SL_ER "Error" for better visual experience... */
#define SL_W "Warning" #define SL_ER "Error "
#define SL_NA "Warning NA" #define SL_W "Warning "
#define SL_BUG "BUG" #define SL_NA "Warn(NA)"
#define SL_BUG "Err(BUG)"
#define SL_INFO "Info "
#define SL_DEBUG "DEBUG "
#endif /* WRS_SNMP_H */ #endif /* WRS_SNMP_H */
...@@ -44,7 +44,7 @@ time_t wrsSpllStatus_data_fill(void) ...@@ -44,7 +44,7 @@ time_t wrsSpllStatus_data_fill(void)
/* check magic number in SPLL stat memory */ /* check magic number in SPLL stat memory */
if (spll_stats_p->magic != SPLL_MAGIC) { if (spll_stats_p->magic != SPLL_MAGIC) {
/* wrong magic */ /* wrong magic */
snmp_log(LOG_ERR, snmp_log(LOG_ERR,"SNMP: " SL_ER
"wrsSpllStatusGroup Wrong SPLL magic number\n"); "wrsSpllStatusGroup Wrong SPLL magic number\n");
return time_update; return time_update;
} }
......
...@@ -38,7 +38,7 @@ time_t wrsSpllVersion_data_fill(void) ...@@ -38,7 +38,7 @@ time_t wrsSpllVersion_data_fill(void)
/* check magic number in SPLL stat memory */ /* check magic number in SPLL stat memory */
if (spll_stats_p->magic != SPLL_MAGIC) { if (spll_stats_p->magic != SPLL_MAGIC) {
/* wrong magic */ /* wrong magic */
snmp_log(LOG_ERR, snmp_log(LOG_ERR, "SNMP: " SL_ER
"wrsSpllVersionGroup Wrong SPLL magic number\n"); "wrsSpllVersionGroup Wrong SPLL magic number\n");
return time_update; return time_update;
} }
......
...@@ -32,8 +32,8 @@ static void read_start_count(char *file, uint32_t *counter) ...@@ -32,8 +32,8 @@ static void read_start_count(char *file, uint32_t *counter)
f = fopen(file, "r"); f = fopen(file, "r");
if (!f) { if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsStartCntGroup filed to open file " snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s\n", file); " wrsStartCntGroup filed to open file %s\n", file);
} else { } else {
/* ignore fscanf errors */ /* ignore fscanf errors */
fscanf(f, "%d", counter); fscanf(f, "%d", counter);
...@@ -60,17 +60,20 @@ time_t wrsStartCnt_data_fill(void){ ...@@ -60,17 +60,20 @@ time_t wrsStartCnt_data_fill(void){
if (shmem_ready_hald()) { if (shmem_ready_hald()) {
wrsStartCnt_s.wrsStartCntHAL = hal_head->pidsequence; wrsStartCnt_s.wrsStartCntHAL = hal_head->pidsequence;
} else { } else {
snmp_log(LOG_ERR, "%s: Unable to read HAL's shmem\n", __func__); snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read HAL's shmem\n", __func__);
} }
if (shmem_ready_ppsi()) { if (shmem_ready_ppsi()) {
wrsStartCnt_s.wrsStartCntPTP = ppsi_head->pidsequence; wrsStartCnt_s.wrsStartCntPTP = ppsi_head->pidsequence;
} else { } else {
snmp_log(LOG_ERR, "%s: Unable to read PPSI's shmem\n", __func__); snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read PPSI's shmem\n", __func__);
} }
if (shmem_ready_rtud()) { if (shmem_ready_rtud()) {
wrsStartCnt_s.wrsStartCntRTUd = rtud_head->pidsequence; wrsStartCnt_s.wrsStartCntRTUd = rtud_head->pidsequence;
} else { } else {
snmp_log(LOG_ERR, "%s: Unable to read rtu's shmem\n", __func__); snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read rtu's shmem\n", __func__);
} }
read_start_count(START_CNT_SSHD, &wrsStartCnt_s.wrsStartCntSshd); read_start_count(START_CNT_SSHD, &wrsStartCnt_s.wrsStartCntSshd);
......
...@@ -58,7 +58,8 @@ time_t wrsTemperature_data_fill(void) ...@@ -58,7 +58,8 @@ time_t wrsTemperature_data_fill(void)
if (!shmem_ready_hald()) { if (!shmem_ready_hald()) {
/* Unable to open shmem, return current time */ /* Unable to open shmem, return current time */
snmp_log(LOG_ERR, "%s: Unable to read HAL's shmem\n", __func__); snmp_log(LOG_ERR, "SNMP: " SL_ER
" %s: Unable to read HAL's shmem\n", __func__);
return time_update; return time_update;
} }
...@@ -72,8 +73,8 @@ time_t wrsTemperature_data_fill(void) ...@@ -72,8 +73,8 @@ time_t wrsTemperature_data_fill(void)
retries++; retries++;
if (retries > 100) { if (retries > 100) {
snmp_log(LOG_ERR, "%s: too many retries to read HAL\n", snmp_log(LOG_ERR, "SNMP: " SL_ER
__func__); "%s: too many retries to read HAL\n", __func__);
retries = 0; retries = 0;
} }
if (!wrs_shm_seqretry(hal_head, ii)) if (!wrs_shm_seqretry(hal_head, ii))
......
...@@ -258,14 +258,14 @@ static void get_wrsSoftPLLStatus(void) ...@@ -258,14 +258,14 @@ static void get_wrsSoftPLLStatus(void)
if (!t->wrsSoftPLLStatus) { if (!t->wrsSoftPLLStatus) {
if (s->wrsSpllMode == WRS_SPLL_MODE_GRAND_MASTER && s->wrsSpllDelCnt > 0) { if (s->wrsSpllMode == WRS_SPLL_MODE_GRAND_MASTER && s->wrsSpllDelCnt > 0) {
t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING; t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"SoftPLL in GrandMaster mode has unlocked from " "SoftPLL in GrandMaster mode has unlocked from "
"the external reference. Delock counter is %d\n", "the external reference. Delock counter is %d\n",
slog_obj_name, s->wrsSpllDelCnt); slog_obj_name, s->wrsSpllDelCnt);
} }
if (s->wrsSpllMode == WRS_SPLL_MODE_MASTER && s->wrsSpllDelCnt != spll_DelCnt_prev) { if (s->wrsSpllMode == WRS_SPLL_MODE_MASTER && s->wrsSpllDelCnt != spll_DelCnt_prev) {
t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING; t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"SoftPLL in Master mode has unlocked. Delock " "SoftPLL in Master mode has unlocked. Delock "
"counter insceased by %d\n", "counter insceased by %d\n",
slog_obj_name, slog_obj_name,
...@@ -273,7 +273,7 @@ static void get_wrsSoftPLLStatus(void) ...@@ -273,7 +273,7 @@ static void get_wrsSoftPLLStatus(void)
} }
if (s->wrsSpllMode == WRS_SPLL_MODE_SLAVE && s->wrsSpllDelCnt != spll_DelCnt_prev) { if (s->wrsSpllMode == WRS_SPLL_MODE_SLAVE && s->wrsSpllDelCnt != spll_DelCnt_prev) {
t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING; t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"SoftPLL in Slave mode has unlocked. Delock " "SoftPLL in Slave mode has unlocked. Delock "
"counter insceased by %d\n", "counter insceased by %d\n",
slog_obj_name, slog_obj_name,
...@@ -284,7 +284,7 @@ static void get_wrsSoftPLLStatus(void) ...@@ -284,7 +284,7 @@ static void get_wrsSoftPLLStatus(void)
if (!t->wrsSoftPLLStatus) { if (!t->wrsSoftPLLStatus) {
if (s->wrsSpllMode == 0) { if (s->wrsSpllMode == 0) {
t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING_NA; t->wrsSoftPLLStatus = WRS_SOFTPLL_STATUS_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"SoftPLL mode not set\n", "SoftPLL mode not set\n",
slog_obj_name); slog_obj_name);
} }
...@@ -340,7 +340,7 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) ...@@ -340,7 +340,7 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA; t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA;
} }
/* Log always for every port */ /* Log always for every port */
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusConfiguredMode not available " "Status of wrsPortStatusConfiguredMode not available "
"for port %i (wri%i)\n", "for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1); slog_obj_name, i + 1, i + 1);
...@@ -350,7 +350,7 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) ...@@ -350,7 +350,7 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA; t->wrsSlaveLinksStatus = WRS_SLAVE_LINK_STATUS_WARNING_NA;
} }
/* Log always for every port */ /* Log always for every port */
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusLink not available " "Status of wrsPortStatusLink not available "
"for port %i (wri%i)\n", "for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1); slog_obj_name, i + 1, i + 1);
...@@ -461,7 +461,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows) ...@@ -461,7 +461,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
t->wrsPTPFramesFlowing = WRS_PTP_FRAMES_FLOWING_WARNING_NA; t->wrsPTPFramesFlowing = WRS_PTP_FRAMES_FLOWING_WARNING_NA;
} }
/* Log always for every port */ /* Log always for every port */
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusConfiguredMode not available " "Status of wrsPortStatusConfiguredMode not available "
"for port %i (wri%i)\n", "for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1); slog_obj_name, i + 1, i + 1);
...@@ -474,7 +474,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows) ...@@ -474,7 +474,7 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
t->wrsPTPFramesFlowing = WRS_PTP_FRAMES_FLOWING_WARNING_NA; t->wrsPTPFramesFlowing = WRS_PTP_FRAMES_FLOWING_WARNING_NA;
} }
/* Log always for every port */ /* Log always for every port */
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: " snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Status of wrsPortStatusLink not available " "Status of wrsPortStatusLink not available "
"for port %i (wri%i)\n", "for port %i (wri%i)\n",
slog_obj_name, i + 1, i + 1); slog_obj_name, i + 1, i + 1);
......
...@@ -94,7 +94,7 @@ time_t wrsVersion_data_fill(void) ...@@ -94,7 +94,7 @@ time_t wrsVersion_data_fill(void)
f = popen(VERSION_COMMAND, "r"); f = popen(VERSION_COMMAND, "r");