forked from ziutek/rrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrrdfunc.c
41 lines (36 loc) · 1.05 KB
/
rrdfunc.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
#include <stdlib.h>
#include <rrd.h>
char *rrdError() {
char *err = NULL;
if (rrd_test_error()) {
// RRD error is local for thread so other gorutine can call some RRD
// function in the same thread before we use C.GoString. So we need to
// copy current error before return from C to Go. It need to be freed
// after C.GoString in Go code.
err = strdup(rrd_get_error());
if (err == NULL) {
abort();
}
}
return err;
}
char *rrdCreate(const char *filename, unsigned long step, time_t start, int argc, const char **argv) {
rrd_clear_error();
rrd_create_r(filename, step, start, argc, argv);
return rrdError();
}
char *rrdUpdate(const char *filename, const char *template, int argc, const char **argv) {
rrd_clear_error();
rrd_update_r(filename, template, argc, argv);
return rrdError();
}
char *rrdGraph(rrd_info_t **ret, int argc, char **argv) {
rrd_clear_error();
*ret = rrd_graph_v(argc, argv);
return rrdError();
}
char *rrdInfo(rrd_info_t **ret, char *filename) {
rrd_clear_error();
*ret = rrd_info_r(filename);
return rrdError();
}