Commit 3b03ba45 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add wrsNetworkingStatus to wrsGeneralStatusGroup

Additionally update MIB
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent db86a97f
......@@ -73,6 +73,25 @@ wrsOSStatus OBJECT-TYPE
bug - bug in checking conditions of wrsOSStatusGroup, please report"
::= { wrsGeneralStatusGroup 2 }
wrsNetworkingStatus 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 wrsNetworkingStatusGroup
ok - values in wrsNetworkingStatusGroup are correct
error - there is an error in wrsNetworkingStatusGroup
warning - there is a warning in wrsNetworkingStatusGroup
warningNA - there is N/A field in wrsNetworkingStatusGroup
bug - bug in checking conditions of wrsNetworkingStatusGroup, please report"
::= { wrsGeneralStatusGroup 4 }
wrsDetailedStatusesGroup OBJECT IDENTIFIER ::= { wrsStatus 2 }
......
......@@ -2,6 +2,7 @@
#include "snmp_shmem.h"
#include "wrsCurrentTimeGroup.h"
#include "wrsOSStatusGroup.h"
#include "wrsNetworkingStatusGroup.h"
#include "wrsPortStatusTable.h"
#include "wrsPstatsTable.h"
#include "wrsPtpDataTable.h"
......@@ -14,6 +15,8 @@
static struct pickinfo wrsGeneralStatus_pickinfo[] = {
FIELD(wrsGeneralStatus_s, ASN_INTEGER, wrsMainSystemStatus),
FIELD(wrsGeneralStatus_s, ASN_INTEGER, wrsOSStatus),
FIELD(wrsGeneralStatus_s, ASN_INTEGER, wrsTimingStatus),
FIELD(wrsGeneralStatus_s, ASN_INTEGER, wrsNetworkingStatus),
};
struct wrsGeneralStatus_s wrsGeneralStatus_s;
......@@ -22,17 +25,24 @@ time_t wrsGeneralStatus_data_fill(void)
{
static time_t time_update; /* time of last update */
time_t time_osstatus; /* time when wrsOSStatus data was updated */
time_t time_networking_status; /* time when wrsNetworkingStatus data
* was updated */
struct wrsOSStatus_s *o;
struct wrsNetworkingStatus_s *n;
time_osstatus = wrsOSStatus_data_fill();
time_networking_status = wrsNetworkingStatus_data_fill();
if (time_osstatus <= time_update) {
if (time_osstatus <= time_update
&& time_networking_status <= time_update) {
/* cache not updated, return last update time */
snmp_log(LOG_ERR,
"SNMP: wrsGeneralStatusGroup cache\n");
return time_update;
}
memset(&wrsGeneralStatus_s, 0, sizeof(wrsGeneralStatus_s));
/*********************************************************************\
|**************************** wrsOSStatus ****************************|
\*********************************************************************/
......@@ -49,7 +59,7 @@ time_t wrsGeneralStatus_data_fill(void)
) { /* warning */
wrsGeneralStatus_s.wrsOSStatus = WRS_OS_STATUS_WARNING;
} else if ( /* check if any of fields equal to 0 */
} else if ( /* check if any of fields equal to 0 or WARNING_NA */
o->wrsBootSuccessful == WRS_BOOT_SUCCESSFUL_WARNING_NA
|| o->wrsBootSuccessful == 0
|| o->wrsTemperatureWarning == 0
......@@ -67,6 +77,59 @@ time_t wrsGeneralStatus_data_fill(void)
wrsGeneralStatus_s.wrsOSStatus = WRS_OS_STATUS_BUG;
}
/*********************************************************************\
|************************** wrsTimingStatus **************************|
\*********************************************************************/
/* not implemented */
/*********************************************************************\
|************************ wrsNetworkingStatus ************************|
\*********************************************************************/
n = &wrsNetworkingStatus_s;
if ( /* check if error */
n->wrsSFPsStatus == WRS_SFPS_STATUS_ERROR
|| n->wrsEndpointStatus == WRS_ENDPOINT_STATUS_ERROR
|| n->wrsSwcoreStatus == WRS_SWCORE_STATUS_ERROR
|| n->wrsRTUStatus == WRS_RTU_STATUS_ERROR
) {
wrsGeneralStatus_s.wrsNetworkingStatus =
WRS_NETWORKING_STATUS_ERROR;
} else if ( /* check if warning */
n->wrsSFPsStatus == WRS_SFPS_STATUS_WARNING
) { /* warning */
wrsGeneralStatus_s.wrsNetworkingStatus =
WRS_NETWORKING_STATUS_WARNING;
} else if ( /* check if any of fields equal to 0 or WARNING_NA */
n->wrsSFPsStatus == WRS_SFPS_STATUS_WARNING_NA
|| n->wrsSFPsStatus == 0
|| n->wrsEndpointStatus == 0
|| n->wrsSwcoreStatus == 0
|| n->wrsRTUStatus == 0
) { /* warning NA */
wrsGeneralStatus_s.wrsNetworkingStatus =
WRS_NETWORKING_STATUS_WARNING_NA;
} else if ( /* check if OK, FR (first read) is also ok */
n->wrsSFPsStatus == WRS_SFPS_STATUS_OK
&& (n->wrsEndpointStatus == WRS_ENDPOINT_STATUS_OK
|| n->wrsEndpointStatus == WRS_ENDPOINT_STATUS_FR) /* FR*/
&& (n->wrsSwcoreStatus == WRS_SWCORE_STATUS_OK
|| n->wrsSwcoreStatus == WRS_SWCORE_STATUS_FR) /* FR */
&& (n->wrsRTUStatus == WRS_RTU_STATUS_OK
|| n->wrsRTUStatus == WRS_RTU_STATUS_FR) /* FR */
) { /* OK */
wrsGeneralStatus_s.wrsNetworkingStatus =
WRS_NETWORKING_STATUS_OK;
} else { /* probably bug in previous conditions,
* this should never happen */
wrsGeneralStatus_s.wrsNetworkingStatus =
WRS_NETWORKING_STATUS_BUG;
}
time_update = time(NULL);
wrsCurrentTime_data_fill();
wrsOSStatus_data_fill();
......
......@@ -11,9 +11,19 @@
* normal operation */
#define WRS_OS_STATUS_BUG 5 /* warning */
#define WRS_NETWORKING_STATUS_OK 1 /* ok */
#define WRS_NETWORKING_STATUS_ERROR 2 /* error */
#define WRS_NETWORKING_STATUS_WARNING 3 /* warning */
#define WRS_NETWORKING_STATUS_WARNING_NA 4 /* warning, at least one field is
* equal to 0 (NA),shouldn't happen in
* normal operation */
#define WRS_NETWORKING_STATUS_BUG 5 /* warning */
struct wrsGeneralStatus_s {
int wrsMainSystemStatus;
int wrsOSStatus;
int wrsTimingStatus;
int wrsNetworkingStatus;
};
extern struct wrsGeneralStatus_s wrsGeneralStatus_s;
......
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