use hostname

This commit is contained in:
Olaf Rempel 2006-08-26 14:01:10 +02:00
parent e0c7daa6e9
commit cc227cc7cc
6 changed files with 13 additions and 13 deletions

View File

@ -10,9 +10,7 @@
static char *pktbuf = NULL; static char *pktbuf = NULL;
static int pos = 0; static int pos = 0;
static char *hostname = NULL; void net_submit(char *hostname, char *plugin, char *filename, int ds_id, char *data)
void net_submit(char *plugin, char *filename, int ds_id, char *data)
{ {
int len = 0; int len = 0;
@ -21,9 +19,6 @@ void net_submit(char *plugin, char *filename, int ds_id, char *data)
pos = 0; pos = 0;
} }
if (hostname == NULL)
hostname = config_get_string("global", "hostname", "localhost");
if (pos == 0) { if (pos == 0) {
len = snprintf(pktbuf, MAX_SIZE - pos, "%s\n", hostname); len = snprintf(pktbuf, MAX_SIZE - pos, "%s\n", hostname);
if (len < 0 || len >= MAX_SIZE - pos) if (len < 0 || len >= MAX_SIZE - pos)

View File

@ -1,7 +1,7 @@
#ifndef _NETWORK_H_ #ifndef _NETWORK_H_
#define _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(); void net_commit();
#endif /* _NETWORK_H_ */ #endif /* _NETWORK_H_ */

View File

@ -36,6 +36,8 @@
static LIST_HEAD(plugin_list); static LIST_HEAD(plugin_list);
static char *hostname = NULL;
static void plugin_load(char *filename) static void plugin_load(char *filename)
{ {
struct sammler_plugin *plugin = NULL; struct sammler_plugin *plugin = NULL;
@ -127,6 +129,9 @@ void probe_submit(struct sammler_plugin *plugin, char *filename, int ds_id, cons
char *buffer; char *buffer;
int len; int len;
if (hostname == NULL)
hostname = config_get_string("global", "hostname", "localhost");
buffer = malloc(BUFSIZE); buffer = malloc(BUFSIZE);
if (buffer == NULL) { if (buffer == NULL) {
log_print(LOG_ERROR, "probe_submit: out of memory"); 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; return;
} }
// rrd_submit(plugin->name, filename, ds_id, buffer); rrd_submit(hostname, plugin->name, filename, ds_id, buffer);
net_submit(plugin->name, filename, ds_id, buffer); net_submit(hostname, plugin->name, filename, ds_id, buffer);
free(buffer); free(buffer);
} }

View File

@ -254,7 +254,7 @@ static int create_parent_dirs(char *filename)
return 0; 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; struct stat statbuf;
static char *rrd_dir = NULL; static char *rrd_dir = NULL;
@ -271,7 +271,7 @@ void rrd_submit(char *plugin, char *filename, int ds_id, char *data)
return; 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) { if (len < 0 || len >= BUFSIZE) {
log_print(LOG_ERROR, "rrd_submit: arguments too long"); log_print(LOG_ERROR, "rrd_submit: arguments too long");
free(fullfile); free(fullfile);

View File

@ -1,6 +1,6 @@
#ifndef _RRDTOOL_H_ #ifndef _RRDTOOL_H_
#define _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_ */ #endif /* _RRDTOOL_H_ */

View File

@ -4,7 +4,7 @@ hostname localhost
logfile sammler.log logfile sammler.log
step 10 step 10
rrd_dir /var/lib/rrd rrd_dir rrd
plugin_dir . plugin_dir .
plugin p_stat.so plugin p_stat.so