diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-10-11 17:53:37 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-10-11 17:53:37 +0300 |
commit | 57bc2c02b09c83cc4e22e9c0c199333cb5ad729b (patch) | |
tree | a6e9aa307b32409b00b5b72673a85cb33302bff8 | |
parent | fd49c1902f656e1cbb407c610764fd2b56ff1985 (diff) | |
download | tallyman-57bc2c02b09c83cc4e22e9c0c199333cb5ad729b.tar.gz tallyman-57bc2c02b09c83cc4e22e9c0c199333cb5ad729b.tar.bz2 |
Optional file for snmp client configuration.
* src/config.c (tallymand_kw): New statement "snmp-client-config".
* src/stevedore.8: Document it.
* src/stevedore.h (snmp_client_config_file): New extern.
* src/subagent.c (snmp_client_config_file): New variable.
(agentx_init): Fix logger configuration.
Parse snmp_client_config_file, if it is supplied.
Disable storing the persistent state configuration.
-rw-r--r-- | src/config.c | 4 | ||||
-rw-r--r-- | src/stevedore.8 | 17 | ||||
-rw-r--r-- | src/stevedore.h | 1 | ||||
-rw-r--r-- | src/subagent.c | 20 |
4 files changed, 34 insertions, 8 deletions
diff --git a/src/config.c b/src/config.c index c076a15..012a096 100644 --- a/src/config.c +++ b/src/config.c | |||
@@ -194,6 +194,10 @@ static struct grecs_keyword tallymand_kw[] = { | |||
194 | { "hostproc-server", "host", | 194 | { "hostproc-server", "host", |
195 | "Sets hostname or IP address of the hostproc agent", | 195 | "Sets hostname or IP address of the hostproc agent", |
196 | grecs_type_string, GRECS_DFLT, &hostproc_server_addr }, | 196 | grecs_type_string, GRECS_DFLT, &hostproc_server_addr }, |
197 | { "snmp-client-config", "file", | ||
198 | "The filename of the SNMP client configuration file containing" | ||
199 | " access credentials for hostproc-server", | ||
200 | grecs_type_string, GRECS_DFLT, &snmp_client_config_file }, | ||
197 | { NULL } | 201 | { NULL } |
198 | }; | 202 | }; |
199 | 203 | ||
diff --git a/src/stevedore.8 b/src/stevedore.8 index 841123d..2b4e7e8 100644 --- a/src/stevedore.8 +++ b/src/stevedore.8 | |||
@@ -1,4 +1,4 @@ | |||
1 | .TH STEVEDORE 8 "October 10, 2020" "TALLYMAN" "Tallyman User Reference" | 1 | .TH STEVEDORE 8 "October 11, 2020" "TALLYMAN" "Tallyman User Reference" |
2 | .SH NAME | 2 | .SH NAME |
3 | stevedore \- container state collector and SNMP agent daemon | 3 | stevedore \- container state collector and SNMP agent daemon |
4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
@@ -123,10 +123,16 @@ using the following statement: | |||
123 | This statement sets the hostname or IP address of the server running | 123 | This statement sets the hostname or IP address of the server running |
124 | \fBhostproc\fR. Optional port can be specified by following the | 124 | \fBhostproc\fR. Optional port can be specified by following the |
125 | argument with a colon and port number. | 125 | argument with a colon and port number. |
126 | .PP | 126 | .TP |
127 | SNMP credentials for the SET operation are taken from the standard | 127 | .BI "snmp-client-config " FILE |
128 | .B net\-snmp | 128 | Sets the filename of the SNMP client configuration file for |
129 | location. | 129 | \fBhostproc\fR notification. The \fIFILE\fR should be in the |
130 | same format as the | ||
131 | .BR snmp.conf (5). | ||
132 | .sp | ||
133 | In the absense of this statement, the system-wide | ||
134 | .B snmp.conf | ||
135 | will be read. | ||
130 | .SS Syslog configuration | 136 | .SS Syslog configuration |
131 | Unless the program is started in foreground mode (see the \fB\-F\fR | 137 | Unless the program is started in foreground mode (see the \fB\-F\fR |
132 | option), its logging output goes to syslog facility \fBdaemon\fR. The | 138 | option), its logging output goes to syslog facility \fBdaemon\fR. The |
@@ -246,6 +252,7 @@ Error message associated with this instance if \fBinstanceState\fR is | |||
246 | .RE | 252 | .RE |
247 | .SH "SEE ALSO" | 253 | .SH "SEE ALSO" |
248 | .BR tallyman (1), | 254 | .BR tallyman (1), |
255 | .BR snmp.conf (5), | ||
249 | .BR hostproc (8), | 256 | .BR hostproc (8), |
250 | or | 257 | or |
251 | .BR http://puszcza.gnu.org.ua/software/hostproc . | 258 | .BR http://puszcza.gnu.org.ua/software/hostproc . |
diff --git a/src/stevedore.h b/src/stevedore.h index 66432bb..12ebb75 100644 --- a/src/stevedore.h +++ b/src/stevedore.h | |||
@@ -23,6 +23,7 @@ extern char *runas_group; | |||
23 | extern unsigned ttl_snmp_table_cache; | 23 | extern unsigned ttl_snmp_table_cache; |
24 | extern unsigned ttl_instance_state; | 24 | extern unsigned ttl_instance_state; |
25 | extern char *hostproc_server_addr; | 25 | extern char *hostproc_server_addr; |
26 | extern char *snmp_client_config_file; | ||
26 | 27 | ||
27 | void config_help(void); | 28 | void config_help(void); |
28 | void readconfig(char const *file); | 29 | void readconfig(char const *file); |
diff --git a/src/subagent.c b/src/subagent.c index 6213cba..522c520 100644 --- a/src/subagent.c +++ b/src/subagent.c | |||
@@ -10,19 +10,33 @@ There is NO WARRANTY, to the extent permitted by law. | |||
10 | #include "tallyman_mib.h" | 10 | #include "tallyman_mib.h" |
11 | #include <signal.h> | 11 | #include <signal.h> |
12 | 12 | ||
13 | char *snmp_client_config_file; | ||
14 | |||
13 | void | 15 | void |
14 | agentx_init(void) | 16 | agentx_init(void) |
15 | { | 17 | { |
16 | if (grecs_log_to_stderr) | 18 | if (grecs_log_to_stderr) { |
17 | snmp_enable_calllog(); | ||
18 | else | ||
19 | snmp_enable_stderrlog(); | 19 | snmp_enable_stderrlog(); |
20 | } else { | ||
21 | snmp_enable_syslog_ident(progname, LOG_DAEMON); | ||
22 | snmp_disable_stderrlog(); | ||
23 | } | ||
20 | netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, | 24 | netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, |
21 | NETSNMP_DS_AGENT_ROLE, 1); | 25 | NETSNMP_DS_AGENT_ROLE, 1); |
26 | if (snmp_client_config_file) { | ||
27 | netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, | ||
28 | NETSNMP_DS_LIB_DONT_READ_CONFIGS, | ||
29 | 1); | ||
30 | } | ||
22 | SOCK_STARTUP; | 31 | SOCK_STARTUP; |
23 | init_agent("stevedore"); | 32 | init_agent("stevedore"); |
24 | init_tallyman_mib(); | 33 | init_tallyman_mib(); |
25 | init_snmp("stevedore"); | 34 | init_snmp("stevedore"); |
35 | if (snmp_client_config_file) { | ||
36 | read_config_with_type(snmp_client_config_file, "snmp"); | ||
37 | } | ||
38 | netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, | ||
39 | NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1); | ||
26 | } | 40 | } |
27 | 41 | ||
28 | time_t start_time; | 42 | time_t start_time; |