aboutsummaryrefslogtreecommitdiff
path: root/src/subagent.c
blob: 522c52011c2e1fce710f712873fe4bd927dc5e28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* This file is part of tallyman
Copyright (C) 2018-2020 Sergey Poznyakoff
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
*/
#include "stevedore.h"
#include <time.h>
#include <pthread.h>
#include "tallyman_mib.h"
#include <signal.h>

char *snmp_client_config_file;

void
agentx_init(void)
{
	if (grecs_log_to_stderr) {
		snmp_enable_stderrlog();
	} else {
		snmp_enable_syslog_ident(progname, LOG_DAEMON);
                snmp_disable_stderrlog();
	}
	netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
			       NETSNMP_DS_AGENT_ROLE, 1);
	if (snmp_client_config_file) {
		netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
				       NETSNMP_DS_LIB_DONT_READ_CONFIGS,
				       1);
	}
	SOCK_STARTUP;
	init_agent("stevedore");
	init_tallyman_mib();
	init_snmp("stevedore");
	if (snmp_client_config_file) {
		read_config_with_type(snmp_client_config_file, "snmp");
	}
	netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
                               NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
}

time_t start_time;

u_long
servdb_servicesUpTime(void)
{
	return time(NULL) - start_time;
}

void *
agentx_thread(void *p)
{
	start_time = time(NULL);
	while (1) {
		agent_check_and_process(1);
	}
}

Return to:

Send suggestions and report system problems to the System administrator.