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)
if (libwr_cfg_read_file(DOTCONFIG_FILE)) {
/* unable to read dot-config,
* 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);
}
init_wrsScalar();
......
......@@ -32,13 +32,16 @@ static int init_shm_hald(void)
/* start printing error after 5 messages */
if (n_wait > 5) {
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) {
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) {
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");
}
}
......@@ -49,7 +52,8 @@ static int init_shm_hald(void)
/* check hal's shm 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,
HAL_SHMEM_VERSION);
return 3;
......@@ -59,7 +63,8 @@ static int init_shm_hald(void)
/* Assume number of ports does not change in runtime */
hal_nports_local = hal_shmem->nports;
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",
hal_nports_local, WRS_N_PORTS);
return 3;
......@@ -68,7 +73,8 @@ static int init_shm_hald(void)
* addresses. No need to re-dereference pointer at each read. */
hal_ports = wrs_shm_follow(hal_head, hal_shmem->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");
return 3;
}
......@@ -88,13 +94,16 @@ static int init_shm_ppsi(void)
if (n_wait > 5) {
/* timeout! */
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) {
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) {
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");
}
}
......@@ -105,7 +114,8 @@ static int init_shm_ppsi(void)
/* check ppsi's shm 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",
ppsi_head->version, WRS_PPSI_SHMEM_VERSION);
return 3;
......@@ -116,13 +126,15 @@ static int init_shm_ppsi(void)
ppsi_servo=NULL;
// ppsi_servo = wrs_shm_follow(ppsi_head, ppg->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;
// }
ppsi_ppi = wrs_shm_follow(ppsi_head, ppg->pp_instances);
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;
}
/* use pointer instead of copying */
......@@ -140,13 +152,16 @@ static int init_shm_rtud(void)
/* start printing error after 5 messages */
if (n_wait > 5) {
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) {
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) {
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");
}
}
......@@ -157,7 +172,8 @@ static int init_shm_rtud(void)
/* check rtud's shm 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,
RTU_SHMEM_VERSION);
return 3;
......
......@@ -480,7 +480,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect monit to be running */
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");
}
......@@ -488,7 +489,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect lighttpd (web server) to be running*/
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");
}
......@@ -496,7 +498,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect lldpd to be running */
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");
}
......@@ -505,7 +508,8 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect nslcd/LDAP to be running */
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");
}
}
......
......@@ -27,7 +27,8 @@ time_t wrsCpuLoad_data_fill(void)
memset(&wrsCpuLoad_s, 0, sizeof(wrsCpuLoad_s));
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");
}
......
......@@ -56,7 +56,7 @@ time_t wrsDiskTable_data_fill(unsigned int *ret_n_rows)
f = popen(DISKUSAGE_COMMAND, "r");
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");
return time_cur;
}
......
......@@ -25,7 +25,7 @@ static int group_handler(netsnmp_mib_handler *handler,
requests->requestvb->name_length - 2];
obj--; /* we are 0-based */
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",
obj + 1);
return SNMP_ERR_GENERR;
......@@ -48,8 +48,9 @@ static int group_handler(netsnmp_mib_handler *handler,
pi->type, ptr, len);
break;
default:
snmp_log(LOG_ERR, "unknown mode (%d) in "GT_GROUP_NAME"\n",
reqinfo->mode);
snmp_log(LOG_ERR, "SNMP: " SL_ER
"unknown mode (%d) in "GT_GROUP_NAME"\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
......
......@@ -41,8 +41,8 @@ time_t wrsMemory_data_fill(void)
f = fopen(MEMINFO_FILE, "r");
if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsMemoryGroup filed to open "
MEMINFO_FILE"\n");
snmp_log(LOG_ERR, "SNMP: " SL_ER
" wrsMemoryGroup filed to open " MEMINFO_FILE"\n");
/* notify snmp about error in kernel modules */
return time_update;
......@@ -80,7 +80,8 @@ time_t wrsMemory_data_fill(void)
wrsMemory_s.wrsMemoryFree = (int) (mem_free + mem_buffers
+ mem_cached);
} 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");
}
......
......@@ -269,7 +269,7 @@ time_t wrsNetworkingStatus_data_fill(void)
port_status_n_error++;
}
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",
slog_obj_name, i + 1, i + 1);
port_status_n_na++;
......
......@@ -235,77 +235,77 @@ time_t wrsOSStatus_data_fill(void)
if (b->wrsConfigSource == WRS_CONFIG_SOURCE_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsConfigSource\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsConfigSource\n",
slog_obj_name);
}
if (b->wrsBootConfigStatus == WRS_CONFIG_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsBootConfigStatus\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsBootConfigStatus\n",
slog_obj_name);
}
if (b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsBootHwinfoReadout\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsBootHwinfoReadout\n",
slog_obj_name);
}
if (b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_WARNING) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: HWINFO partition not found\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: HWINFO partition not found\n",
slog_obj_name);
}
if (b->wrsBootLoadFPGA == WRS_BOOT_LOAD_FPGA_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsBootLoadFPGA\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsBootLoadFPGA\n",
slog_obj_name);
}
if (b->wrsBootLoadLM32 == WRS_BOOT_LOAD_LM32_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsBootLoadLM32\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsBootLoadLM32\n",
slog_obj_name);
}
if (b->wrsFwUpdateStatus == WRS_FW_UPDATE_STATUS_CHECKSUM_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Last update of the firmware failed\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Last update of the firmware failed\n",
slog_obj_name);
}
if (!strcmp(v->wrsVersions[wrsVersionFpgaType_i], unknown)) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: wrong data in hwinfo, unknown version of FPGA\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: wrong data in hwinfo, unknown version of FPGA\n",
slog_obj_name);
}
if (!strcmp(v->wrsVersions[wrsVersionSwitchSerialNumber_i], unknown)) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: wrong data in hwinfo, unknown Switch's serial number\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: wrong data in hwinfo, unknown Switch's serial number\n",
slog_obj_name);
}
if (!strcmp(v->wrsVersions[wrsVersionScbVersion_i], "000")) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: wrong data in hwinfo, unknown version of SCB\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: wrong data in hwinfo, unknown version of SCB\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptSource == WRS_CUSTOM_BOOT_SCRIPT_SOURCE_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsCustomBootScriptSource\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsCustomBootScriptSource\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptStatus == WRS_CUSTOM_BOOT_SCRIPT_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsCustomBootScriptStatus\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsCustomBootScriptStatus\n",
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsAuxClkSetStatus\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsAuxClkSetStatus\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsThrottlingSetStatus\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsThrottlingSetStatus\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsVlansSetStatus\n",
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: Unable to read status file of wrsVlansSetStatus\n",
slog_obj_name);
}
}
......@@ -314,57 +314,57 @@ time_t wrsOSStatus_data_fill(void)
if (!o->wrsBootSuccessful) {
if (b->wrsRestartReason == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsRestartReason not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsRestartReason not available\n",
slog_obj_name);
}
if (b->wrsBootConfigStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsBootConfigStatus not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsBootConfigStatus not available\n",
slog_obj_name);
}
if (b->wrsBootHwinfoReadout == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsBootHwinfoReadout not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsBootHwinfoReadout not available\n",
slog_obj_name);
}
if (b->wrsBootLoadFPGA == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsBootLoadFPGA not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsBootLoadFPGA not available\n",
slog_obj_name);
}
if (b->wrsBootLoadLM32 == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsBootLoadLM32 not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsBootLoadLM32 not available\n",
slog_obj_name);
}
if (b->wrsFwUpdateStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsFwUpdateStatus not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsFwUpdateStatus not available\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptSource == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsCustomBootScriptSource not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsCustomBootScriptSource not available\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsCustomBootScriptStatus not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsCustomBootScriptStatus not available\n",
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsAuxClkSetStatus not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsAuxClkSetStatus not available\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsThrottlingSetStatus not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsThrottlingSetStatus not available\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsVlansSetStatus not available\n",
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: Status of wrsVlansSetStatus not available\n",
slog_obj_name);
}
}
......@@ -443,25 +443,25 @@ time_t wrsOSStatus_data_fill(void)
/* warning when at least temperature threshold is not set (is 0) */
if (t->wrsTempThresholdFPGA == 0) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_THOLD_NOT_SET;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature threshold for the FPGA is not set\n",
slog_obj_name);
}
if (t->wrsTempThresholdPLL == 0) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_THOLD_NOT_SET;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature threshold for the PLL is not set\n",
slog_obj_name);
}
if (t->wrsTempThresholdPSL == 0) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_THOLD_NOT_SET;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature threshold for the Power Supply Left is not set\n",
slog_obj_name);
}
if (t->wrsTempThresholdPSR == 0) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_THOLD_NOT_SET;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature threshold for the Power Supply Right is not set\n",
slog_obj_name);
}
......@@ -470,25 +470,25 @@ time_t wrsOSStatus_data_fill(void)
* is exceeded */
if (t->wrsTempThresholdFPGA && (t->wrsTempFPGA > t->wrsTempThresholdFPGA)) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_TOO_HIGH;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature of the FPGA (%d) exceeded threshold value (%d)\n",
slog_obj_name, t->wrsTempFPGA, t->wrsTempThresholdFPGA);
}
if (t->wrsTempThresholdPLL && (t->wrsTempPLL > t->wrsTempThresholdPLL)) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_TOO_HIGH;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature of the PLL (%d) exceeded threshold value (%d)\n",
slog_obj_name, t->wrsTempPLL, t->wrsTempThresholdPLL);
}
if (t->wrsTempThresholdPSL && (t->wrsTempPSL > t->wrsTempThresholdPSL)) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_TOO_HIGH;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature of the Power Supply Left (%d) exceeded threshold value (%d)\n",
slog_obj_name, t->wrsTempPSL, t->wrsTempThresholdPSL);
}
if (t->wrsTempThresholdPSR && (t->wrsTempPSR > t->wrsTempThresholdPSR)) {
o->wrsTemperatureWarning = WRS_TEMPERATURE_WARNING_TOO_HIGH;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Temperature of the Power Supply Right (%d) exceeded threshold value (%d)\n",
slog_obj_name, t->wrsTempPSR, t->wrsTempThresholdPSR);
}
......@@ -509,13 +509,13 @@ time_t wrsOSStatus_data_fill(void)
}
if (!o->wrsMemoryFreeLow && (f->wrsMemoryUsedPerc > WRSMEMORYFREELOW_TRESHOLD_WARNING)) {
o->wrsMemoryFreeLow = WRS_MEMORY_FREE_LOW_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Percentage of used memory (%d) exceeded threshold of warning level (%d)\n",
slog_obj_name, f->wrsMemoryUsedPerc, WRSMEMORYFREELOW_TRESHOLD_WARNING);
}
if (!o->wrsMemoryFreeLow && (f->wrsMemoryUsedPerc == 0)) {
o->wrsMemoryFreeLow = WRS_MEMORY_FREE_LOW_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Unable to read percentage of used memory\n",
slog_obj_name);
}
......@@ -556,19 +556,19 @@ time_t wrsOSStatus_data_fill(void)
/* CPU load above warning threshold level */
if (c->wrsCPULoadAvg1min > WRSCPULOAD_1MIN_WARNING) {
o->wrsCpuLoadHigh = WRS_CPU_LOAD_HIGH_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Average CPU load for 1 min (%d) exceeded threshold of warning level (%d)\n",
slog_obj_name, c->wrsCPULoadAvg1min, WRSCPULOAD_1MIN_WARNING);
}
if (c->wrsCPULoadAvg5min > WRSCPULOAD_5MIN_WARNING) {
o->wrsCpuLoadHigh = WRS_CPU_LOAD_HIGH_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Average CPU load for 5 min (%d) exceeded threshold of warning level (%d)\n",
slog_obj_name, c->wrsCPULoadAvg5min, WRSCPULOAD_5MIN_WARNING);
}
if (c->wrsCPULoadAvg15min > WRSCPULOAD_15MIN_WARNING) {
o->wrsCpuLoadHigh = WRS_CPU_LOAD_HIGH_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Average CPU load for 15 min (%d) exceeded threshold of warning level (%d)\n",
slog_obj_name, c->wrsCPULoadAvg15min, WRSCPULOAD_15MIN_WARNING);
}
......@@ -606,7 +606,7 @@ time_t wrsOSStatus_data_fill(void)
* errors/warnings nor warning_na */
o->wrsDiskSpaceLow = WRS_DISK_SPACE_LOW_WARNING;
}
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_W " %s: "
"Percentage of used disk space (%d) exceeded threshold of warning level (%d) "
"for disk mounted at %s\n", slog_obj_name,
d[i].wrsDiskUseRate,
......@@ -618,7 +618,7 @@ time_t wrsOSStatus_data_fill(void)
if (o->wrsDiskSpaceLow == WRS_DISK_SPACE_LOW_OK) {
o->wrsDiskSpaceLow = WRS_DISK_SPACE_LOW_WARNING_NA;
}
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: "
snmp_log(LOG_WARNING, "SNMP: " SL_NA " %s: "
"Unable to read percentage of used disk space"
"for disk mounted at %s\n", slog_obj_name,
d[i].wrsDiskMountPath);
......
......@@ -60,7 +60,8 @@ 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 shmem\n", __func__);
snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read HAL shmem\n", __func__);
n_rows_local = 0;
return time_cur;
} else {
......@@ -159,7 +160,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
retries++;
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__);
retries = 0;
}
......@@ -209,7 +211,8 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
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",
wrsPortStatusTable_array[i].wrsPortStatusPortName,
wrsPortStatusTable_array[i].wrsPortStatusLink,
......@@ -221,7 +224,8 @@ 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 shmem\n",
snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read PPSI shmem\n",
__func__);
return time_cur;
}
......@@ -258,8 +262,9 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
}
retries++;
if (retries > 100) {
snmp_log(LOG_ERR, "%s: Unable to read PPSI, too many retries\n",
__func__);
snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: Unable to read PPSI, too many retries\n",
__func__);
retries = 0;
break;
}
......
......@@ -66,7 +66,9 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
/* check whether shmem is available */
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
* disappear */
n_rows_local = 1;
......@@ -111,7 +113,8 @@ time_t wrsPtpDataTable_data_fill(unsigned int *n_rows)
// //JCB TODO + (ppsi_servo->update_time.scaled_nsecs >> 16);
retries++;
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__);
retries = 0;
}
......
......@@ -73,8 +73,8 @@ handle_wrsScalarOne(netsnmp_mib_handler *handler,
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR, "unknown mode (%d) in handle_wrsScalarOne\n",
reqinfo->mode);
snmp_log(LOG_ERR, "SNMP: " SL_ER
"unknown mode (%d) in handle_wrsScalarOne\n", reqinfo->mode);
return SNMP_ERR_GENERR;
}
......
......@@ -103,11 +103,14 @@ struct pickinfo {
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"
/* String definitions for functions SLOG*, the same lenght of string
for better visual experience... */
#define SL_ER "Error "
#define SL_W "Warning "
#define SL_NA "Warn(NA)"
#define SL_BUG "Err(BUG)"
#define SL_INFO "Info "
#define SL_DEBUG "DEBUG "
#endif /* WRS_SNMP_H */
......@@ -44,7 +44,7 @@ time_t wrsSpllStatus_data_fill(void)
/* check magic number in SPLL stat memory */
if (spll_stats_p->magic != SPLL_MAGIC) {
/* wrong magic */
snmp_log(LOG_ERR,
snmp_log(LOG_ERR,"SNMP: " SL_ER
"wrsSpllStatusGroup Wrong SPLL magic number\n");
return time_update;
}
......
......@@ -38,7 +38,7 @@ time_t wrsSpllVersion_data_fill(void)
/* check magic number in SPLL stat memory */
if (spll_stats_p->magic != SPLL_MAGIC) {
/* wrong magic */
snmp_log(LOG_ERR,
snmp_log(LOG_ERR, "SNMP: " SL_ER
"wrsSpllVersionGroup Wrong SPLL magic number\n");
return time_update;
}
......
......@@ -32,8 +32,8 @@ static void read_start_count(char *file, uint32_t *counter)
f = fopen(file, "r");
if (!f) {
snmp_log(LOG_ERR, "SNMP: wrsStartCntGroup filed to open file "
"%s\n", file);
snmp_log(LOG_ERR, "SNMP: " SL_ER
" wrsStartCntGroup filed to open file %s\n", file);
} else {
/* ignore fscanf errors */
fscanf(f, "%d", counter);
......@@ -60,17 +60,20 @@ time_t wrsStartCnt_data_fill(void){
if (shmem_ready_hald()) {
wrsStartCnt_s.wrsStartCntHAL = hal_head->pidsequence;
} 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()) {
wrsStartCnt_s.wrsStartCntPTP = ppsi_head->pidsequence;
} 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()) {
wrsStartCnt_s.wrsStartCntRTUd = rtud_head->pidsequence;
} 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);
......
......@@ -58,7 +58,8 @@ time_t wrsTemperature_data_fill(void)
if (!shmem_ready_hald()) {
/* 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;
}
......@@ -72,8 +73,8 @@ time_t wrsTemperature_data_fill(void)
retries++;
if (retries > 100) {
snmp_log(LOG_ERR, "%s: too many retries to read HAL\n",
__func__);
snmp_log(LOG_ERR, "SNMP: " SL_ER
"%s: too many retries to read HAL\n", __func__);
retries = 0;
}
if (!wrs_shm_seqretry(hal_head, ii))
......
......@@ -258,14 +258,14 @@ static void get_wrsSoftPLLStatus(void)
if (!t->wrsSoftPLLStatus) {
if (s->wrsSpllMode == WRS_SPLL_MODE_GRAND_MASTER && s->wrsSpllDelCnt > 0) {