Commit 6726a0d9 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add 3 objects to the wrsBootStatusGroup

--Add new SNMP objects indicating the status of scripts run at boot
  --wrsAuxClkSetStatus
  --wrsThrottlingSetStatus
  --wrsVlansSetStatus
--Update wrsBootSuccessful to take into account status of objects above
--Update corresponding scripts to save status information at the execution:
  --etc/init.d/vlan.sh
  --etc/init.d/wrs_auxclk.sh
  --etc/init.d/wrs_throttling.sh
--Update MIB
--Update wrs-user-manual
--Update wrs_failures
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 2474f280
......@@ -577,10 +577,10 @@ value is changed by the web interface, proper action is taken.
Logging options for the three main WRS processes and other programs.
@t{CONFIG_WRS_LOG_OTHER} is currently used by:
@itemize
@item @t{wrs_watchdog}
@item @t{wrs_auxclk}
@item @t{wrs_custom_boot_script.sh}
@item @t{vlan.sh}
@item @t{wrs_watchdog} daemon
@item @t{wrs_auxclk} executed at boot up
@item @t{wrs_custom_boot_script.sh} executed at boot up
@item Setting VLANs with @t{vlan.sh} at boot up
@end itemize
Each value
can be a pathname, to select logging to file (and @t{/dev/kmsg}
......
......@@ -626,6 +626,10 @@ list of faults leading to a data error.
\item status of loading kernel modules
\item status of starting userspace daemons
\item status of execution of a custom boot script
\item status of setting up auxclk on connector clk2
\item status of setting up a limit on the Rx bandwidth of the traffic that
goes from WR ports to Linux (throttling)
\item status of setting up VLANs
\end{itemize}
\item [] \underline{SNMP objects}:\\
{\footnotesize
......@@ -642,6 +646,9 @@ list of faults leading to a data error.
\snmpadd{WR-SWITCH-MIB::wrsCustomBootScriptSource}\\
\snmpadd{WR-SWITCH-MIB::wrsCustomBootScriptSourceUrl}\\
\snmpadd{WR-SWITCH-MIB::wrsCustomBootScriptStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsAuxClkSetStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsThrottlingSetStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsVlansSetStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsBootSuccessful} \\
\snmpadd{WR-SWITCH-MIB::wrsOSStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsMainSystemStatus} }
......
......@@ -55,7 +55,10 @@
errors, unable to read the hwinfo, unable to load the FPGA bitstream, unable
to load the LM32 software, any kernel modules or userspace daemons are
missing, failed to update firmware due to checksum error, unable to
download custom boot script, custom boot script fails during execution.\\
download custom boot script, custom boot script fails during execution,
fails setting up auxclk on connector clk2, fails setting up a limit on
the Rx bandwidth of the traffic that goes from WR ports to Linux
(throttling), fails setting up VLANs.\\
\underline{On error:}
\begin{pck_proc}
\item Dump state
......@@ -445,12 +448,19 @@
Status of the last firmware update}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsCustomBootScriptSource}{
Source of the custom script that can be executed once at boot time. It can
be used to setup a switch in a way not supported by dot-config.}
be used to setup a switch in a way not supported by dot-config}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsCustomBootScriptSourceUrl}{
Path to the custom boot script on a remote server (if local scripts is not
used).}
used)}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsCustomBootScriptStatus}{
Result of custom boot script execution.}
Result of custom boot script execution}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsAuxClkSetStatus}{
Result of setting up auxclk on connector clk2}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsThrottlingSetStatus}{
Result of setting up a limit on the Rx bandwidth of the traffic that
goes from WR ports to Linux (throttling)}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsVlansSetStatus}{
Result of setting up auxclk on connector clk2}
\snmpentrye{WR-SWITCH-MIB}{wrsOperationStatus}{wrsTemperatureGroup}{}
\snmpentrye{WR-SWITCH-MIB}{wrsTemperatureGroup}{wrsTempFPGA}{}
......
#!/bin/sh
tmpdir=/tmp
vlans_status_file="$tmpdir"/vlans_status
vlans_set_status_file="$tmpdir"/vlans_set_status
dotconfig=/wr/etc/dot-config
......@@ -38,10 +38,13 @@ start() {
ret=$?
if [ $ret -eq 0 ]; then
echo "OK"
echo "ok" > $vlans_set_status_file
elif [ $ret -eq 2 ]; then
echo "Disabled"
echo "disabled" > $vlans_set_status_file
else
echo "Failed"
echo "failed" > $vlans_set_status_file
fi
}
......
......@@ -2,6 +2,9 @@
# Script read wrs_auxclk parameters from dot-config, then start wrs_auxclk.
tmpdir=/tmp
wrs_auxclk_set_status_file="$tmpdir"/wrs_auxclk_set_status
# First, read dot-config to get wrs_auxclk parameters
dotconfig=/wr/etc/dot-config
set -o pipefail
......@@ -55,6 +58,8 @@ eval /wr/bin/wrs_auxclk $p_freq $p_duty $p_cshift $p_sigdel $p_ppshift $LOGPIPE
ret=$?
if [ $ret -eq 0 ]; then
echo "OK"
echo "ok" > $wrs_auxclk_set_status_file
else
echo "Failed"
echo "failed" > $wrs_auxclk_set_status_file
fi
#!/bin/sh
tmpdir=/tmp
wrs_throttling_set_status_file="$tmpdir"/wrs_throttling_set_status
# this script shall be called before enabling the switching
dotconfig=/wr/etc/dot-config
......@@ -36,11 +39,14 @@ start() {
ret=$?
if [ $ret -eq 0 ]; then
echo "OK"
echo "ok" > $wrs_throttling_set_status_file
else
echo "Failed"
echo "failed" > $wrs_throttling_set_status_file
fi
else
echo "throttling disabled"
echo "Disabled"
echo "disabled" > $wrs_throttling_set_status_file
fi
}
......
......@@ -800,6 +800,71 @@ wrsCustomBootScriptStatus OBJECT-TYPE
errorMinor - cannot read the status file, problem is probably somewhere else"
::= { wrsBootStatusGroup 19 }
wrsAuxClkSetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
failed(2),
disabled(3),
error(4),
errorMinor(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of setting up auxclk on connector clk2
ok - successful set pu of the auxclk
failed - error while setting up the auxclk
disabled - the setting up of the auxclk disabled in dot-config
error - unsuported status
errorMinor - cannot read the status file, the problem is probably
somewhere else"
::= { wrsBootStatusGroup 20 }
wrsThrottlingSetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
failed(2),
disabled(3),
error(4),
errorMinor(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of setting up a limit on the Rx bandwidth of the traffic that
goes from WR ports to Linux.
ok - successful set up of the throttling
failed - error while setting up the throttling
disabled - the setting up of the throttling disabled in dot-config
error - unsuported status
errorMinor - cannot read the status file, the problem is probably
somewhere else"
::= { wrsBootStatusGroup 21 }
wrsVlansSetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
failed(2),
disabled(3),
error(4),
errorMinor(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of setting up VLANs
ok - successful set up of VLANs
failed - error while setting up VLANs
disabled - the setting up of VLANs disabled in dot-config
error - unsuported status
errorMinor - cannot read the status file, the problem is probably
somewhere else"
::= { wrsBootStatusGroup 22 }
-- wrsTemperatureGroup (.7.1.3)
wrsTemperatureGroup OBJECT IDENTIFIER ::= { wrsOperationStatus 3 }
......
......@@ -27,6 +27,10 @@
#define CUSTOM_BOOT_SCRIPT_SOURCE_FILE "/tmp/custom_boot_script_source"
#define CUSTOM_BOOT_SCRIPT_SOURCE_URL_FILE "/tmp/custom_boot_script_url"
#define WRS_AUXCLK_SET_STATUS_FILE "/tmp/wrs_auxclk_set_status"
#define WRS_THROTTLING_SET_STATUS_FILE "/tmp/wrs_throttling_set_status"
#define WRS_VLANS_SET_STATUS_FILE "/tmp/vlans_set_status"
/* Macros for fscanf function to read line with maximum of "x" characters
* without new line. Macro expands to something like: "%10[^\n]" */
#define LINE_READ_LEN_HELPER(x) "%"#x"[^\n]"
......@@ -56,6 +60,9 @@ static struct pickinfo wrsBootStatus_pickinfo[] = {
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsCustomBootScriptSource),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsCustomBootScriptSourceUrl),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsCustomBootScriptStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsAuxClkSetStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsThrottlingSetStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsVlansSetStatus),
};
struct wrsBootStatus_s wrsBootStatus_s;
......@@ -670,6 +677,103 @@ static void get_custom_boot_script_status(void)
}
static void get_wrs_aux_clk_set_status(void)
{
char buff[21]; /* 1 for null char */
FILE *f;
f = fopen(WRS_AUXCLK_SET_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strcmp(buff, "ok"))
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_OK;
else if (!strcmp(buff, "failed"))
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_FAILED;
else if (!strcmp(buff, "disabled"))
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_DISABLED;
else /* unknown status */
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_ERROR;
} else {
/* file with status not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsAuxClkSetStatus: failed to "
"open " WRS_AUXCLK_SET_STATUS_FILE "\n");
}
}
static void get_wrs_throttling_set_status(void)
{
char buff[21]; /* 1 for null char */
FILE *f;
f = fopen(WRS_THROTTLING_SET_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strcmp(buff, "ok"))
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_OK;
else if (!strcmp(buff, "failed"))
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_FAILED;
else if (!strcmp(buff, "disabled"))
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_DISABLED;
else /* unknown status */
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_ERROR;
} else {
/* file with status not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsThrottlingSetStatus: failed"
"to open " WRS_THROTTLING_SET_STATUS_FILE "\n");
}
}
static void get_wrs_vlans_set_status(void)
{
char buff[21]; /* 1 for null char */
FILE *f;
f = fopen(WRS_VLANS_SET_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strcmp(buff, "ok"))
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_OK;
else if (!strcmp(buff, "failed"))
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_FAILED;
else if (!strcmp(buff, "disabled"))
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_DISABLED;
else /* unknown status */
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_ERROR;
} else {
/* file with status not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsVlansSetStatus: failed"
"to open " WRS_VLANS_SET_STATUS_FILE "\n");
}
}
time_t wrsBootStatus_data_fill(void)
{
static time_t time_update;
......@@ -703,9 +807,18 @@ time_t wrsBootStatus_data_fill(void)
/* get info about the firmware update status */
get_fw_update_status();
/* get info about the firmware update status */
/* get info about the status of custom boot script execution */
get_custom_boot_script_status();
/* get info about the status of auxclk setting */
get_wrs_aux_clk_set_status();
/* get info about the status of wrs_throttling setting */
get_wrs_throttling_set_status();
/* get info about the status of vlans setup */
get_wrs_vlans_set_status();
/* there was an update, return current time */
return time_update;
}
......
......@@ -56,9 +56,27 @@
#define WRS_CUSTOM_BOOT_SCRIPT_STATUS_ERROR 6 /* error */
#define WRS_CUSTOM_BOOT_SCRIPT_STATUS_ERROR_MINOR 7 /* warning */
#define WRS_CUSTOM_BOOT_SCRIPT_SOURCE_URL_LEN 128
#define WRS_AUXCLK_SET_STATUS_OK 1 /* ok */
#define WRS_AUXCLK_SET_STATUS_FAILED 2 /* error */
#define WRS_AUXCLK_SET_STATUS_DISABLED 3 /* ok */
#define WRS_AUXCLK_SET_STATUS_ERROR 4 /* error */
#define WRS_AUXCLK_SET_STATUS_ERROR_MINOR 5 /* warning */
#define WRS_THROTTLING_SET_STATUS_OK 1 /* ok */
#define WRS_THROTTLING_SET_STATUS_FAILED 2 /* error */
#define WRS_THROTTLING_SET_STATUS_DISABLED 3 /* ok */
#define WRS_THROTTLING_SET_STATUS_ERROR 4 /* error */
#define WRS_THROTTLING_SET_STATUS_ERROR_MINOR 5 /* warning */
#define WRS_VLANS_SET_STATUS_OK 1 /* ok */
#define WRS_VLANS_SET_STATUS_FAILED 2 /* error */
#define WRS_VLANS_SET_STATUS_DISABLED 3 /* ok */
#define WRS_VLANS_SET_STATUS_ERROR 4 /* error */
#define WRS_VLANS_SET_STATUS_ERROR_MINOR 5 /* warning */
struct wrsBootStatus_s {
uint32_t wrsBootCnt; /* boots since power-on must be != 0 */
uint32_t wrsRebootCnt; /* soft reboots since hard reboot
......@@ -80,6 +98,9 @@ struct wrsBootStatus_s {
int32_t wrsCustomBootScriptSource;
char wrsCustomBootScriptSourceUrl[WRS_CUSTOM_BOOT_SCRIPT_SOURCE_URL_LEN + 1];
int32_t wrsCustomBootScriptStatus;
int32_t wrsAuxClkSetStatus;
int32_t wrsThrottlingSetStatus;
int32_t wrsVlansSetStatus;
};
extern struct wrsBootStatus_s wrsBootStatus_s;
......
......@@ -170,7 +170,6 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: unrecognized source of custom boot script\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptStatus == WRS_CUSTOM_BOOT_SCRIPT_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: custom boot script failed during execution\n",
......@@ -191,7 +190,6 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of custom boot script execution\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptSource == WRS_CUSTOM_BOOT_SCRIPT_SOURCE_REMOTE
&& strnlen(b->wrsCustomBootScriptSourceUrl, WRS_CUSTOM_BOOT_SCRIPT_SOURCE_URL_LEN) == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
......@@ -199,6 +197,39 @@ time_t wrsOSStatus_data_fill(void)
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: setting up auxclk on connector clk2 failed\n",
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of setting up auxclk on connector clk2\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: setting up a throttling limit failed\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of setting up a throttling limit\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: setting up a throttling limit failed\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of setting up a throttling limit\n",
slog_obj_name);
}
/* check if warning */
if (!o->wrsBootSuccessful) {
......@@ -262,6 +293,21 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "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",
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",
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",
slog_obj_name);
}
}
/* check if any of fields equal to 0 */
......@@ -306,6 +352,21 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "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",
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",
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",
slog_obj_name);
}
}
if ((!o->wrsBootSuccessful)
......@@ -334,6 +395,12 @@ time_t wrsOSStatus_data_fill(void)
&& b->wrsCustomBootScriptStatus == WRS_CUSTOM_BOOT_SCRIPT_STATUS_OK
)
)
&& (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_OK
|| b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_DISABLED)
&& (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_OK
|| b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_DISABLED)
&& (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_OK
|| b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_DISABLED)
)
) { /* OK, but check source */
/* additional check of source */
......
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