-
Notifications
You must be signed in to change notification settings - Fork 6
/
apermon.c
55 lines (42 loc) · 952 Bytes
/
apermon.c
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
#include <signal.h>
#include "sflow.h"
#include "log.h"
#include "config.h"
#include "net.h"
#include "trigger.h"
static const apermon_net_handler handlers[] = {
handle_sflow_packet
};
static void handler_signal(__attribute__((unused)) int sig) {
stop_servers(0);
}
static void help(const char *this) {
fprintf(stderr, "usage: %s <config-file-path>\n", this);
}
int main(int argc, char **argv) {
if (argc < 2) {
help(argv[0]);
return 1;
}
apermon_config *config;
int ret;
ret = parse_config(argv[1], &config);
if (ret < 0) {
return 1;
}
signal(SIGTERM, handler_signal);
signal(SIGINT, handler_signal);
ret = init_servers(config, handlers);
if (ret < 0) {
return 1;
}
init_sflow(config);
init_triggers(config);
ret = start_servers();
if (ret < 0) {
return 1;
}
free_severs();
free_config(config);
return 0;
}