Commit a51052af authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: remove protocol from wrsConfigSource object

NOTE: This commit brings non compatible changes into MIB. It should never
happen after release!

Change wrsConfigSource to inform whether dot-config source was local or remote.
Before it contained also information about remote protocol.
Now information from wrsConfigSource, wrsConfigSourceHost and
wrsConfigSourceFilename is stored in wrsConfigSourceUrl.

wrsRestartReasonMonit is moved into place where wrsConfigSourceFilename was
before.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 745f8d33
......@@ -1477,9 +1477,8 @@ WR-SWITCH-MIB::wrsMainSystemStatus.0 = INTEGER: ok(1)
WR-SWITCH-MIB::wrsOSStatus.0 = INTEGER: ok(1)
WR-SWITCH-MIB::wrsTimingStatus.0 = INTEGER: ok(1)
[...]
WR-SWITCH-MIB::wrsConfigSource.0 = INTEGER: tftp(4)
WR-SWITCH-MIB::wrsConfigSourceHost.0 = STRING: 192.168.1.1
WR-SWITCH-MIB::wrsConfigSourceFilename.0 = STRING: config-192.168.1.10
WR-SWITCH-MIB::wrsConfigSource.0 = INTEGER: remote(4)
WR-SWITCH-MIB::wrsConfigSourceUrl.0 = STRING: tftp://192.168.1.1/config-192.168.1.10
WR-SWITCH-MIB::wrsBootConfigStatus.0 = INTEGER: ok(1)
WR-SWITCH-MIB::wrsBootHwinfoReadout.0 = INTEGER: ok(1)
WR-SWITCH-MIB::wrsBootLoadFPGA.0 = INTEGER: ok(1)
......
......@@ -510,8 +510,7 @@ between devices connected to the ports.\\
\texttt{WR-SWITCH-MIB::wrsRestartReason}\\
\texttt{WR-SWITCH-MIB::wrsRestartReasonMonit}\\
\texttt{WR-SWITCH-MIB::wrsConfigSource}\\
\texttt{WR-SWITCH-MIB::wrsConfigSourceHost}\\
\texttt{WR-SWITCH-MIB::wrsConfigSourceFilename}\\
\texttt{WR-SWITCH-MIB::wrsConfigSourceUrl}\\
\texttt{WR-SWITCH-MIB::wrsBootHwinfoReadout}\\
\texttt{WR-SWITCH-MIB::wrsBootLoadFPGA}\\
\texttt{WR-SWITCH-MIB::wrsBootLoadLM32}\\
......@@ -537,15 +536,13 @@ between devices connected to the ports.\\
to be verified before being applied. If downloading or verification has
failed an alarm is raised.
\item [] \underline{SNMP objects}:\\
\texttt{WR-SWITCH-MIB::wrsBootSuccessful} - status word informing
whether switch booted correctly\\
\texttt{WR-SWITCH-MIB::wrsConfigSource} - source of a dot-config,
local or protocol which was used do fetch the dot-config\\
\texttt{WR-SWITCH-MIB::wrsConfigSourceHost} - address of a server
providing dot-config (if not local)\\
\texttt{WR-SWITCH-MIB::wrsConfigSourceFilename} - path to the dot-config
on a server (if not local)\\
\texttt{WR-SWITCH-MIB::wrsBootConfigStatus} - result of the dot-config verification
\texttt{WR-SWITCH-MIB::wrsBootSuccessful} -- status word informing
whether switch booted correctly\\
\texttt{WR-SWITCH-MIB::wrsConfigSource} -- source of a dot-config,
local or remote\\
\texttt{WR-SWITCH-MIB::wrsConfigSourceUrl} -- path to the dot-config
on a server (if not local)\\
\texttt{WR-SWITCH-MIB::wrsBootConfigStatus} -- result of the dot-config verification
\end{packed_enum}
\subsubsection{\bf Any userspace daemon has crashed/restarted}
......
......@@ -186,8 +186,9 @@ this section can have one of the following values:
\item \texttt{wrsFaultIP} -- Not implemented
\item \texttt{wrsFaultLR} -- Not implemented
\item \texttt{wrsConfigSource}
\item \texttt{wrsConfigSourceHost}
\item \texttt{wrsConfigSourceFilename}
\item \texttt{wrsConfigSourceUrl}
\item \texttt{wrsRestartReasonMonit} -- Process that caused \texttt{monit}
to trigger a restart.
\item \texttt{wrsBootConfigStatus}
%below boot status values
\item \texttt{wrsBootHwinfoReadout}
......@@ -200,8 +201,7 @@ this section can have one of the following values:
\item \texttt{wrsGwWatchdogTimeouts} -- Number of times the watchdog has
restarted the HDL module responsible for the Ethernet switching process
(issue \ref{fail:data:swcore_hang}).
\item \texttt{wrsRestartReasonMonit} -- Process that caused \texttt{monit}
to trigger a restart.
\end{itemize}
\item \texttt{wrsTemperatureGroup}
\begin{itemize}
......
......@@ -12,11 +12,11 @@ tmpdir=/tmp
if [ -f $dotconfig ]; then
. $dotconfig
echo "local" > "$tmpdir"/dot-config_proto
echo "local" > "$tmpdir"/dot-config_source
#assume that local config is always ok
echo "config_ok" > "$tmpdir"/dot-config_status
else
echo "no_config" > "$tmpdir"/dot-config_proto
echo "no_config" > "$tmpdir"/dot-config_source
echo "config_error" > "$tmpdir"/dot-config_status
fi
......@@ -30,6 +30,7 @@ fi
# If we are expected to get a new dot-conf, do it
if [ -n "$CONFIG_DOTCONF_URL" ]; then
echo "remote" > "$tmpdir"/dot-config_source
# replace IPADDR and MACADDR, to have a device-specific name
macaddr=$(cat /sys/class/net/eth0/address)
ipaddr=$(ifconfig eth0 | grep inet | cut -d: -f 2 | cut '-d ' -f 1)
......@@ -46,11 +47,8 @@ if [ -n "$CONFIG_DOTCONF_URL" ]; then
host=$(echo $URL | cut -d/ -f 3)
filename=$(echo $URL | cut -d/ -f 4-)
# save proto, host and filename of dot-config, to be used by SNMPd
echo "$proto" > "$tmpdir"/dot-config_proto
echo "$host" > "$tmpdir"/dot-config_host
echo "$filename" > "$tmpdir"/dot-config_filename
# save URL of dot-config, to be used by SNMPd
echo "$URL" > "$tmpdir"/dot-config_source_url
rm -f $tmpconfig
case $proto in
http|ftp)
......
......@@ -26,7 +26,7 @@ if [ "$1" == "local_config" ]; then
# remove source information in case previous config was received from
# network
rm /tmp/dot-config_*
echo "local" > /tmp/dot-config_proto
echo "local" > /tmp/dot-config_source
#assume that local config is always ok
echo "config_ok" > /tmp/dot-config_status
fi
......
......@@ -579,32 +579,34 @@ wrsConfigSource OBJECT-TYPE
error(1),
errorMinor(2),
local(3),
tftp(4),
http(5),
ftp(6)
remote(4)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Source of used dotconfig, used protocol if config was received from
network
errorMinor - cannot read status file, problem is probably somewhere else"
"Source of used dotconfig
local - used dot-config was stored on the switch
remote - dot-config retrieved from the network check the
wrsConfigSourceUrl for the path
errorMinor - cannot read the status file, problem is probably somewhere
else"
::= { wrsBootStatusGroup 6 }
wrsConfigSourceHost OBJECT-TYPE
wrsConfigSourceUrl OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..64))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Server's address which provided dotconfig"
"Url to the dot-config"
::= { wrsBootStatusGroup 7 }
wrsConfigSourceFilename OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..128))
MAX-ACCESS read-only
STATUS current
wrsRestartReasonMonit OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..32))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Path and filename of dotconfig file on server"
"Program's name which caused the monit to restart the switch due to too
many crashes."
::= { wrsBootStatusGroup 8 }
wrsBootConfigStatus OBJECT-TYPE
......@@ -716,14 +718,6 @@ wrsGwWatchdogTimeouts OBJECT-TYPE
for the Ethernet switching process."
::= { wrsBootStatusGroup 15 }
wrsRestartReasonMonit OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..32))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Program's name that monit failed to start several times"
::= { wrsBootStatusGroup 16 }
-- wrsTemperatureGroup (.7.1.3)
wrsTemperatureGroup OBJECT IDENTIFIER ::= { wrsOperationStatus 3 }
......
......@@ -6,9 +6,8 @@
#define MONIT_REASON_FILE "/tmp/monit_restart_reason"
#define DOTCONFIGDIR "/tmp"
#define DOTCONFIG_PROTO "dot-config_proto"
#define DOTCONFIG_HOST "dot-config_host"
#define DOTCONFIG_FILENAME "dot-config_filename"
#define DOTCONFIG_SOURCE "dot-config_source"
#define DOTCONFIG_SOURCE_URL "dot-config_source_url"
#define DOTCONFIG_STATUS "dot-config_status"
#define HWINFO_FILE "/tmp/hwinfo_read_status"
......@@ -38,8 +37,8 @@ static struct pickinfo wrsBootStatus_pickinfo[] = {
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsFaultIP),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsFaultLR),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsConfigSource),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsConfigSourceHost),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsConfigSourceFilename),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsConfigSourceUrl),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsRestartReasonMonit),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootConfigStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootHwinfoReadout),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootLoadFPGA),
......@@ -47,7 +46,6 @@ static struct pickinfo wrsBootStatus_pickinfo[] = {
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootKernelModulesMissing),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootUserspaceDaemonsMissing),
FIELD(wrsBootStatus_s, ASN_COUNTER, wrsGwWatchdogTimeouts),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsRestartReasonMonit),
};
struct wrsBootStatus_s wrsBootStatus_s;
......@@ -174,7 +172,7 @@ static void get_boot_info(void){
* triggered by monit */
wrsBootStatus_s.wrsRestartReason = WRS_RESTART_REASON_MONIT;
/* try to get program that caused restart */
fscanf(f, LINE_READ_LEN(31),
fscanf(f, LINE_READ_LEN(WRS_RESTART_REASON_MONIT_LEN),
wrsBootStatus_s.wrsRestartReasonMonit);
fclose(f);
}
......@@ -188,62 +186,41 @@ static void get_dotconfig_source(void)
/* Check dotconfig source.
* dotconfig source can change in runtime, i.e. from remote to local by
* web-interface */
/* read protocol used to get dotconfig */
f = fopen(DOTCONFIGDIR "/" DOTCONFIG_PROTO, "r");
/* read source used to get dotconfig */
f = fopen(DOTCONFIGDIR "/" DOTCONFIG_SOURCE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strncmp(buff, "tftp", 10))
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_PROTO_TFTP;
else if (!strncmp(buff, "http", 10))
if (!strncmp(buff, "remote", 10))
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_PROTO_HTTP;
else if (!strncmp(buff, "ftp", 10))
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_PROTO_FTP;
WRS_CONFIG_SOURCE_REMOTE;
else if (!strncmp(buff, "local", 10))
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_PROTO_LOCAL;
else /* unknown proto */
WRS_CONFIG_SOURCE_LOCAL;
else /* unknown source */
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_PROTO_ERROR;
WRS_CONFIG_SOURCE_ERROR;
} else {
/* proto file not found, probably something else caused
/* file with source not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsConfigSource =
WRS_CONFIG_SOURCE_PROTO_ERROR_MINOR;
WRS_CONFIG_SOURCE_ERROR_MINOR;
}
/* read hostname and file name only when config is not local */
if (wrsBootStatus_s.wrsConfigSource != WRS_CONFIG_SOURCE_PROTO_LOCAL) {
/* read host used to get dotconfig */
f = fopen(DOTCONFIGDIR "/" DOTCONFIG_HOST, "r");
if (wrsBootStatus_s.wrsConfigSource != WRS_CONFIG_SOURCE_LOCAL) {
/* read URL used to get dotconfig */
f = fopen(DOTCONFIGDIR "/" DOTCONFIG_SOURCE_URL, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(WRS_CONFIG_SOURCE_HOST_LEN),
wrsBootStatus_s.wrsConfigSourceHost);
fscanf(f, LINE_READ_LEN(WRS_CONFIG_SOURCE_URL_LEN),
wrsBootStatus_s.wrsConfigSourceUrl);
fclose(f);
} else {
/* host file not found, put "error" into
* wrsConfigSourceHost */
strcpy(wrsBootStatus_s.wrsConfigSourceHost, "error");
}
/* read filename used to get dotconfig */
f = fopen(DOTCONFIGDIR "/" DOTCONFIG_FILENAME, "r");
if (f) {
/* readline without newline */
fscanf(f,
LINE_READ_LEN(WRS_CONFIG_SOURCE_FILENAME_LEN),
wrsBootStatus_s.wrsConfigSourceFilename);
fclose(f);
} else {
/* host file not found, put "error" into
* wrsConfigSourceFilename */
strcpy(wrsBootStatus_s.wrsConfigSourceFilename,
"error");
strcpy(wrsBootStatus_s.wrsConfigSourceUrl, "error");
}
}
......
......@@ -4,18 +4,15 @@
#define WRSBOOTSTATUS_CACHE_TIMEOUT 5
#define WRSBOOTSTATUS_OID WRS_OID, 7, 1, 2
#define WRS_RESTART_REASON_MONIT_LEN 32
#define WRS_RESTART_REASON_ERROR 1 /* error */
#define WRS_RESTART_REASON_MONIT 7 /* ok */
#define WRS_CONFIG_SOURCE_HOST_LEN 64
#define WRS_CONFIG_SOURCE_FILENAME_LEN 128
#define WRS_CONFIG_SOURCE_PROTO_ERROR 1 /* error */
#define WRS_CONFIG_SOURCE_PROTO_ERROR_MINOR 2 /* warning */
#define WRS_CONFIG_SOURCE_PROTO_LOCAL 3 /* ok */
/* below proto are ok, if host and filename not empty */
#define WRS_CONFIG_SOURCE_PROTO_TFTP 4
#define WRS_CONFIG_SOURCE_PROTO_HTTP 5
#define WRS_CONFIG_SOURCE_PROTO_FTP 6
#define WRS_CONFIG_SOURCE_URL_LEN 128
#define WRS_CONFIG_SOURCE_ERROR 1 /* error */
#define WRS_CONFIG_SOURCE_ERROR_MINOR 2 /* warning */
#define WRS_CONFIG_SOURCE_LOCAL 3 /* ok */
#define WRS_CONFIG_SOURCE_REMOTE 4 /* ok */
#define WRS_CONFIG_STATUS_OK 1 /* ok */
#define WRS_CONFIG_STATUS_ERROR 2 /* error */
......@@ -46,8 +43,8 @@ struct wrsBootStatus_s {
char wrsFaultIP[11]; /* faulty instruction pointer as string */
char wrsFaultLR[11]; /* link register at fault as string */
int32_t wrsConfigSource;
char wrsConfigSourceHost[WRS_CONFIG_SOURCE_HOST_LEN+1];
char wrsConfigSourceFilename[WRS_CONFIG_SOURCE_FILENAME_LEN+1];
char wrsConfigSourceUrl[WRS_CONFIG_SOURCE_URL_LEN+1];
char wrsRestartReasonMonit[WRS_RESTART_REASON_MONIT_LEN+1];
int32_t wrsBootConfigStatus;
int32_t wrsBootHwinfoReadout;
int32_t wrsBootLoadFPGA;
......@@ -55,7 +52,6 @@ struct wrsBootStatus_s {
int32_t wrsBootKernelModulesMissing;
int32_t wrsBootUserspaceDaemonsMissing;
int32_t wrsGwWatchdogTimeouts;
char wrsRestartReasonMonit[32];
};
extern struct wrsBootStatus_s wrsBootStatus_s;
......
......@@ -70,7 +70,7 @@ time_t wrsOSStatus_data_fill(void)
if ( /* check if error */
b->wrsBootCnt == 0
|| b->wrsRestartReason == WRS_RESTART_REASON_ERROR
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_ERROR
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_ERROR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_ERROR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_DL_ERROR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_CHECK_ERROR
......@@ -85,7 +85,7 @@ time_t wrsOSStatus_data_fill(void)
wrsOSStatus_s.wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
} else if ( /* check if warning */
b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_ERROR_MINOR
b->wrsConfigSource == WRS_CONFIG_SOURCE_ERROR_MINOR
|| b->wrsBootConfigStatus == WRS_CONFIG_STATUS_ERROR_MINOR
|| b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_ERROR_MINOR
|| b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_WARNING
......@@ -107,8 +107,8 @@ time_t wrsOSStatus_data_fill(void)
} 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->wrsConfigSource != WRS_CONFIG_SOURCE_ERROR
&& b->wrsConfigSource != WRS_CONFIG_SOURCE_ERROR_MINOR /* warning */
&& b->wrsBootConfigStatus == WRS_CONFIG_STATUS_OK
&& b->wrsBootHwinfoReadout == WRS_BOOT_HWINFO_OK
&& b->wrsBootLoadFPGA == WRS_BOOT_LOAD_FPGA_OK
......@@ -118,15 +118,12 @@ time_t wrsOSStatus_data_fill(void)
) { /* OK, but check source */
/* additional check of source */
if (
b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_LOCAL
b->wrsConfigSource == WRS_CONFIG_SOURCE_LOCAL
|| (
(
b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_TFTP
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_HTTP
|| b->wrsConfigSource == WRS_CONFIG_SOURCE_PROTO_FTP
b->wrsConfigSource == WRS_CONFIG_SOURCE_REMOTE
)
&& strnlen(b->wrsConfigSourceHost, WRS_CONFIG_SOURCE_HOST_LEN + 1)
&& strnlen(b->wrsConfigSourceFilename, WRS_CONFIG_SOURCE_FILENAME_LEN + 1)
&& strnlen(b->wrsConfigSourceUrl, WRS_CONFIG_SOURCE_URL_LEN + 1)
)
) { /* OK */
/* when dotconfig is local or (remote and host not empty and filename not empty) */
......
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