Commit 1f8ca818 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add wrsBootSuccessful to wrsOSStatusGroup

wrsBootSuccessful object check content of wrsOSStatusGroup
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 019aa4c1
......@@ -57,6 +57,26 @@ wrsDetailedStatusesGroup OBJECT IDENTIFIER ::= { wrsStatus 2 }
-- wrsOSStatusGroup (.6.2.1)
wrsOSStatusGroup OBJECT IDENTIFIER ::= { wrsDetailedStatusesGroup 1 }
wrsBootSuccessful OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
error(2),
warning(3),
warningNA(4),
bug(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Grouped status of wrsBootStatusGroup
ok - values in wrsBootStatusGroup are correct
error - there is an error in wrsBootStatusGroup
warning - there is a warning in wrsBootStatusGroup
warningNA - there is N/A field in wrsBootStatusGroup
bug - bug in checking conditions of wrsBootStatusGroup, please report"
::= { wrsOSStatusGroup 1 }
wrsTemperatureWarning OBJECT-TYPE
SYNTAX INTEGER {
na(0),
......
#include "wrsSnmp.h"
#include "wrsBootStatusGroup.h"
#include "wrsTemperatureGroup.h"
#include "wrsOSStatusGroup.h"
......@@ -13,17 +14,99 @@ time_t wrsOSStatus_data_fill(void)
{
static time_t time_update; /* time of last update */
time_t time_temp; /* time when temperature data was updated */
time_t time_boot; /* time when boot data was updated */
struct wrsBootStatus_s *b;
time_boot = wrsBootStatus_data_fill();
time_temp = wrsTemperature_data_fill();
if (time_temp <= time_update) {
if (time_boot <= time_update
&& time_temp <= time_update) {
/* cache not updated, return last update time */
return time_update;
}
time_update = time(NULL);
memset(&wrsOSStatus_s, 0, sizeof(wrsOSStatus_s));
/* wrsTemperatureWarning */
/*********************************************************************\
|************************* wrsBootSuccessful *************************|
\*********************************************************************/
b = &wrsBootStatus_s;
if ( /* check if error */
b->wrsBootCnt == 0
|| b->wrsRestartReason == WRS_RESTART_REASON_ERROR
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_ERROR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_ERROR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_DL_ERROR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_CHECK_ERROR
|| b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_ERROR
|| b->wrsBootLoadFPGA == WRS_BOOT_LOAD_FPGA_ERROR
|| b->wrsBootLoadFPGA == WRS_BOOT_LOAD_FPGA_FILE_NOT_FOUND
|| b->wrsBootLoadLM32 == WRS_BOOT_LOAD_LM32_ERROR
|| b->wrsBootLoadLM32 == WRS_BOOT_LOAD_LM32_FILE_NOT_FOUND
|| b->wrsBootKernelModulesMissing > 0 /* contain number of missing modules */
|| b->wrsBootUserspaceDaemonsMissing > 0 /* contain number of missing deamons */
) {
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
} else if ( /* check if warning */
b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_ERROR_MINOR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_ERROR_MINOR
|| b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_ERROR_MINOR
|| b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_WARNING
|| b->wrsBootLoadFPGA == WRS_BOOT_LOAD_FPGA_ERROR_MINOR
|| b->wrsBootLoadLM32 == WRS_BOOT_LOAD_LM32_ERROR_MINOR
) { /* warning */
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
} else if ( /* check if any of fields equal to 0 */
b->wrsRestartReason == 0
|| b->wrsConfigSource == 0
|| b->wrsBootConfigStatus == 0
|| b->wrsBootHwinfoReadout == 0
|| b->wrsBootLoadFPGA == 0
|| b->wrsBootLoadLM32 == 0
) { /* warning NA */
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
} else if ( /* check if OK */
b->wrsBootCnt != 0
&& b->wrsRestartReason != WRS_RESTART_REASON_ERROR
&& b->wrsConfigSource != WRS_CONFIG_SOURCE_PROTO_ERROR
&& b->wrsConfigSource != WRS_CONFIG_SOURCE_PROTO_ERROR_MINOR /* warning */
&& b->wrsBootConfigStatus == WRS_CONFIG_STATUS_OK
&& b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_OK
&& b->wrsBootLoadFPGA == WRS_BOOT_LOAD_FPGA_OK
&& b->wrsBootLoadLM32 == WRS_BOOT_LOAD_LM32_OK
&& b->wrsBootKernelModulesMissing == 0
&& b->wrsBootUserspaceDaemonsMissing == 0
) { /* OK, but check source */
/* additional check of source */
if (
b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_LOCAL
|| (
(
b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_TFTP
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_HTTP
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_FTP
)
&& strnlen(b->wrsConfigSourceHost, WRS_CONFIG_SOURCE_HOST_LEN + 1)
&& strnlen(b->wrsConfigSourceFilename, WRS_CONFIG_SOURCE_FILENAME_LEN + 1)
)
) { /* OK */
/* when dotconfig is local or (remote and host not empty and filename not empty) */
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_OK;
} else { /* error because of source */
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
}
} else { /* probably bug in previous conditions,
* this should never happen */
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_BUG;
}
/*********************************************************************\
|*********************** wrsTemperatureWarning ***********************|
\*********************************************************************/
if (!wrsTemperature_s.temp_fpga_thold
&& !wrsTemperature_s.temp_pll_thold
&& !wrsTemperature_s.temp_psl_thold
......
......@@ -3,6 +3,14 @@
#define WRSOSSTATUS_OID WRS_OID, 6, 2, 1
#define WRS_BOOT_SUCCESSFUL_OK 1 /* ok */
#define WRS_BOOT_SUCCESSFUL_ERROR 2 /* error */
#define WRS_BOOT_SUCCESSFUL_WARNING 3 /* warning */
#define WRS_BOOT_SUCCESSFUL_WARNING_NA 4 /* warning, at least one field is
* equal to 0 (NA),shouldn't happen in
* normal operation */
#define WRS_BOOT_SUCCESSFUL_BUG 5 /* warning */
#define WRS_TEMPERATURE_WARNING_THOLD_NOT_SET 1 /* warning */
#define WRS_TEMPERATURE_WARNING_OK 2 /* ok */
#define WRS_TEMPERATURE_WARNING_TOO_HIGH 3 /* warning */
......
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