Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
74a34027
Commit
74a34027
authored
Jul 18, 2018
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/snmpd: check if monit is running, only if not disabled in dot-config
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
8f5a12fd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
wrsBootStatusGroup.c
userspace/snmpd/wrsBootStatusGroup.c
+29
-1
No files found.
userspace/snmpd/wrsBootStatusGroup.c
View file @
74a34027
#include "wrsSnmp.h"
#include <libwr/util.h>
#include <libwr/config.h>
#include "wrsBootStatusGroup.h"
#define BOOTCOUNT_FILE "/proc/wrs-bootcount"
...
...
@@ -92,6 +93,7 @@ struct wrs_usd_item {
uint32_t
cnt
;
/* number of processes found */
};
#define UDI_MONIT 5
/* index of MONIT in userspace_daemons array */
/* user space daemon list */
/* - key contain process name reported by ps command
* - positive exp describe exact number of expected processes
...
...
@@ -106,7 +108,8 @@ static struct wrs_usd_item userspace_daemons[] = {
[
2
]
=
{
"/wr/bin/wrsw_rtud"
,
1
},
[
3
]
=
{
"/wr/bin/ppsi"
,
1
},
[
4
]
=
{
"/usr/sbin/lighttpd"
,
1
},
[
5
]
=
{
"/usr/bin/monit"
,
1
},
[
UDI_MONIT
]
=
{
"/usr/bin/monit"
,
1
},
/* Monit can be disabled in
* dot-config */
[
6
]
=
{
"/usr/sbin/snmpd"
,
1
},
[
7
]
=
{
"/wr/bin/wrs_watchdog"
,
1
},
};
...
...
@@ -452,6 +455,28 @@ static void get_loaded_kernel_modules_status(void)
fclose
(
f
);
}
static
void
update_daemon_expectancy
(
struct
wrs_usd_item
*
daemon_array
)
{
static
int
run_once
=
1
;
char
*
tmp
;
/* Read the information about disabled daemons from dot-config only
* once. Another read makes no sense, because SNMP daemon reads
* dot-config only once at startup */
if
(
!
run_once
)
return
;
run_once
=
0
;
tmp
=
libwr_cfg_get
(
"MONIT_DISABLE"
);
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:"
" CONFIG_MONIT_DISABLE=y in dot-config
\n
"
);
}
}
/* check if daemons from userspace_daemons array are running */
static
void
get_daemons_status
(
void
)
{
...
...
@@ -470,6 +495,9 @@ static void get_daemons_status(void)
userspace_daemons
[
i
].
cnt
=
0
;
}
/* Check if all daemons are expected */
update_daemon_expectancy
(
userspace_daemons
);
/* Use ps command to get process list, more portable, less error prone
* but probably slower than manually parsing /proc/ */
f
=
popen
(
PROCESS_COMMAND
,
"r"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment