use hostname
This commit is contained in:
parent
e0c7daa6e9
commit
cc227cc7cc
@ -10,9 +10,7 @@
|
||||
static char *pktbuf = NULL;
|
||||
static int pos = 0;
|
||||
|
||||
static char *hostname = NULL;
|
||||
|
||||
void net_submit(char *plugin, char *filename, int ds_id, char *data)
|
||||
void net_submit(char *hostname, char *plugin, char *filename, int ds_id, char *data)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
@ -21,9 +19,6 @@ void net_submit(char *plugin, char *filename, int ds_id, char *data)
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
if (hostname == NULL)
|
||||
hostname = config_get_string("global", "hostname", "localhost");
|
||||
|
||||
if (pos == 0) {
|
||||
len = snprintf(pktbuf, MAX_SIZE - pos, "%s\n", hostname);
|
||||
if (len < 0 || len >= MAX_SIZE - pos)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _NETWORK_H_
|
||||
#define _NETWORK_H_
|
||||
|
||||
void net_submit(char *plugin, char *filename, int ds_id, char *data);
|
||||
void net_submit(char *hostname, char *plugin, char *filename, int ds_id, char *data);
|
||||
void net_commit();
|
||||
|
||||
#endif /* _NETWORK_H_ */
|
||||
|
@ -36,6 +36,8 @@
|
||||
|
||||
static LIST_HEAD(plugin_list);
|
||||
|
||||
static char *hostname = NULL;
|
||||
|
||||
static void plugin_load(char *filename)
|
||||
{
|
||||
struct sammler_plugin *plugin = NULL;
|
||||
@ -127,6 +129,9 @@ void probe_submit(struct sammler_plugin *plugin, char *filename, int ds_id, cons
|
||||
char *buffer;
|
||||
int len;
|
||||
|
||||
if (hostname == NULL)
|
||||
hostname = config_get_string("global", "hostname", "localhost");
|
||||
|
||||
buffer = malloc(BUFSIZE);
|
||||
if (buffer == NULL) {
|
||||
log_print(LOG_ERROR, "probe_submit: out of memory");
|
||||
@ -143,8 +148,8 @@ void probe_submit(struct sammler_plugin *plugin, char *filename, int ds_id, cons
|
||||
return;
|
||||
}
|
||||
|
||||
// rrd_submit(plugin->name, filename, ds_id, buffer);
|
||||
net_submit(plugin->name, filename, ds_id, buffer);
|
||||
rrd_submit(hostname, plugin->name, filename, ds_id, buffer);
|
||||
net_submit(hostname, plugin->name, filename, ds_id, buffer);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ static int create_parent_dirs(char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rrd_submit(char *plugin, char *filename, int ds_id, char *data)
|
||||
void rrd_submit(char *hostname, char *plugin, char *filename, int ds_id, char *data)
|
||||
{
|
||||
struct stat statbuf;
|
||||
static char *rrd_dir = NULL;
|
||||
@ -271,7 +271,7 @@ void rrd_submit(char *plugin, char *filename, int ds_id, char *data)
|
||||
return;
|
||||
}
|
||||
|
||||
len = snprintf(fullfile, BUFSIZE, "%s/%s", rrd_dir, filename);
|
||||
len = snprintf(fullfile, BUFSIZE, "%s/%s/%s", rrd_dir, hostname, filename);
|
||||
if (len < 0 || len >= BUFSIZE) {
|
||||
log_print(LOG_ERROR, "rrd_submit: arguments too long");
|
||||
free(fullfile);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef _RRDTOOL_H_
|
||||
#define _RRDTOOL_H_
|
||||
|
||||
void rrd_submit(char *plugin, char *filename, int ds_id, char *data);
|
||||
void rrd_submit(char *hostname, char *plugin, char *filename, int ds_id, char *data);
|
||||
|
||||
#endif /* _RRDTOOL_H_ */
|
||||
|
@ -4,7 +4,7 @@ hostname localhost
|
||||
logfile sammler.log
|
||||
|
||||
step 10
|
||||
rrd_dir /var/lib/rrd
|
||||
rrd_dir rrd
|
||||
|
||||
plugin_dir .
|
||||
plugin p_stat.so
|
||||
|
Loading…
Reference in New Issue
Block a user