const stuff
This commit is contained in:
parent
042b7ce9a0
commit
253a79584e
10
network.c
10
network.c
@ -24,7 +24,7 @@ static int fwd_sock;
|
||||
static char *tx_buf, *rx_buf;
|
||||
static int tx_pos;
|
||||
|
||||
int net_submit(const char *hostname, char *plugin, char *filename, int ds_id, char *data)
|
||||
int net_submit(const char *hostname, const char *plugin, const char *filename, int ds_id, const char *data)
|
||||
{
|
||||
int size = snprintf(tx_buf + tx_pos, BUFSIZE - tx_pos, "%s:%s:%s:%d %s\n",
|
||||
hostname, plugin, filename, ds_id, data);
|
||||
@ -39,7 +39,7 @@ int net_submit(const char *hostname, char *plugin, char *filename, int ds_id, ch
|
||||
return 0;
|
||||
}
|
||||
|
||||
int net_submit_flush()
|
||||
int net_submit_flush(void)
|
||||
{
|
||||
if (tx_pos != 0)
|
||||
sendto(fwd_sock, tx_buf, tx_pos, 0, (struct sockaddr *)&fwd_sa, sizeof(fwd_sa));
|
||||
@ -76,7 +76,7 @@ int net_receive(int socket)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int net_config_get_saddr(char *section, char *option, struct sockaddr_in *sa)
|
||||
static int net_config_get_saddr(const char *section, const char *option, struct sockaddr_in *sa)
|
||||
{
|
||||
char *part[2];
|
||||
|
||||
@ -94,7 +94,7 @@ static int net_config_get_saddr(char *section, char *option, struct sockaddr_in
|
||||
return 0;
|
||||
}
|
||||
|
||||
int net_init_cli()
|
||||
int net_init_cli(void)
|
||||
{
|
||||
int ret = net_config_get_saddr("global", "forward", &fwd_sa);
|
||||
if (ret < 0)
|
||||
@ -118,7 +118,7 @@ int net_init_cli()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int net_init_srv()
|
||||
int net_init_srv(void)
|
||||
{
|
||||
struct sockaddr_in sa_srv;
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
#include "plugins.h"
|
||||
|
||||
int net_init_srv();
|
||||
int net_init_cli();
|
||||
int net_init_srv(void);
|
||||
int net_init_cli(void);
|
||||
int net_receive(int sock);
|
||||
|
||||
int net_submit(const char *hostname, char *plugin, char *filename, int ds_id, char *data);
|
||||
int net_submit(const char *hostname, const char *plugin, const char *filename, int ds_id, const char *data);
|
||||
int net_submit_flush();
|
||||
|
||||
#endif /* _NETWORK_H_ */
|
||||
|
@ -39,7 +39,7 @@ struct server_entry {
|
||||
|
||||
static LIST_HEAD(server_list);
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:total_accesses:COUNTER:90:0:U "
|
||||
"DS:total_kbytes:COUNTER:90:0:U "
|
||||
"DS:busy_workers:GAUGE:90:0:U "
|
||||
@ -58,7 +58,7 @@ struct sammler_plugin plugin;
|
||||
static char *rx_buf;
|
||||
static int rx_pos;
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:entries:GAUGE:15:0:U "
|
||||
"DS:searched:DERIVE:15:0:U "
|
||||
"DS:found:DERIVE:15:0:U "
|
||||
@ -47,7 +47,7 @@ static char *ds_def = {
|
||||
"DS:expect_delete:DERIVE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
4
p_load.c
4
p_load.c
@ -25,13 +25,13 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:1min:GAUGE:15:0:U "
|
||||
"DS:5min:GAUGE:15:0:U "
|
||||
"DS:15min:GAUGE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
@ -30,19 +30,19 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *mem_ds_def = {
|
||||
static const char *mem_ds_def = {
|
||||
"DS:total:GAUGE:15:0:U "
|
||||
"DS:free:GAUGE:15:0:U "
|
||||
"DS:buffers:GAUGE:15:0:U "
|
||||
"DS:cached:GAUGE:15:0:U "
|
||||
};
|
||||
|
||||
static char *swap_ds_def = {
|
||||
static const char *swap_ds_def = {
|
||||
"DS:total:GAUGE:15:0:U "
|
||||
"DS:free:GAUGE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
switch (ds_id) {
|
||||
case DS_MEMORY:
|
||||
|
@ -27,12 +27,12 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:block_total:GAUGE:15:0:U "
|
||||
"DS:block_free:GAUGE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
10
p_mysql.c
10
p_mysql.c
@ -41,12 +41,12 @@ struct server_entry {
|
||||
|
||||
static LIST_HEAD(server_list);
|
||||
|
||||
static char *traffic_ds_def = {
|
||||
static const char *traffic_ds_def = {
|
||||
"DS:bytes_received:COUNTER:90:0:U "
|
||||
"DS:bytes_sent:COUNTER:90:0:U "
|
||||
};
|
||||
|
||||
static char *commands_ds_def = {
|
||||
static const char *commands_ds_def = {
|
||||
"DS:com_delete:COUNTER:90:0:U "
|
||||
"DS:com_insert:COUNTER:90:0:U "
|
||||
"DS:com_select:COUNTER:90:0:U "
|
||||
@ -55,7 +55,7 @@ static char *commands_ds_def = {
|
||||
"DS:questions:COUNTER:90:0:U "
|
||||
};
|
||||
|
||||
static char *qcache_ds_def = {
|
||||
static const char *qcache_ds_def = {
|
||||
"DS:qc_free_blocks:GAUGE:90:0:U "
|
||||
"DS:qc_free_memory:GAUGE:90:0:U "
|
||||
"DS:qc_hits:COUNTER:90:0:U "
|
||||
@ -66,14 +66,14 @@ static char *qcache_ds_def = {
|
||||
"DS:qc_total_blocks:GAUGE:90:0:U "
|
||||
};
|
||||
|
||||
static char *threads_ds_def = {
|
||||
static const char *threads_ds_def = {
|
||||
"DS:threads_cached:GAUGE:90:0:U "
|
||||
"DS:threads_connected:GAUGE:90:0:U "
|
||||
"DS:threads_created:COUNTER:90:0:U "
|
||||
"DS:threads_running:GAUGE:90:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
switch (ds_id) {
|
||||
case DS_TRAFFIC:
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "logging.h"
|
||||
#include "p_mysql_helper.h"
|
||||
|
||||
void * init_connection(char *host, char *user, char *pass)
|
||||
void * init_connection(const char *host, const char *user, const char *pass)
|
||||
{
|
||||
MYSQL *con = NULL;
|
||||
|
||||
|
@ -26,7 +26,7 @@ struct mysql_stats {
|
||||
uint64_t threads_running;
|
||||
};
|
||||
|
||||
void * init_connection(char *host, char *user, char *pass);
|
||||
void * init_connection(const char *host, const char *user, const char *pass);
|
||||
int ping_connection(void *mysql);
|
||||
int close_connection(void *mysql);
|
||||
|
||||
|
@ -28,14 +28,14 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:byte_in:COUNTER:15:0:U "
|
||||
"DS:byte_out:COUNTER:15:0:U "
|
||||
"DS:pkt_in:COUNTER:15:0:U "
|
||||
"DS:pkt_out:COUNTER:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:entropy:GAUGE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def_stat = {
|
||||
static const char *ds_def_stat = {
|
||||
"DS:in_hit:DERIVE:15:0:U "
|
||||
"DS:in_slow_tot:DERIVE:15:0:U "
|
||||
"DS:in_slow_mc:DERIVE:15:0:U "
|
||||
@ -46,7 +46,7 @@ static char *ds_def_stat = {
|
||||
"DS:out_hlist_search:DERIVE:15:0:U "
|
||||
};
|
||||
|
||||
static char *ds_def_gc = {
|
||||
static const char *ds_def_gc = {
|
||||
"DS:entries:GAUGE:15:0:U "
|
||||
"DS:gc_total:DERIVE:15:0:U "
|
||||
"DS:gc_ignored:DERIVE:15:0:U "
|
||||
@ -54,7 +54,7 @@ static char *ds_def_gc = {
|
||||
"DS:gc_dst_overflow:DERIVE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
switch (ds_id) {
|
||||
case DS_STAT:
|
||||
|
10
p_stat.c
10
p_stat.c
@ -31,7 +31,7 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *cpu_ds_def = {
|
||||
static const char *cpu_ds_def = {
|
||||
"DS:user:COUNTER:15:0:U "
|
||||
"DS:nice:COUNTER:15:0:U "
|
||||
"DS:system:COUNTER:15:0:U "
|
||||
@ -42,13 +42,13 @@ static char *cpu_ds_def = {
|
||||
"DS:steal:COUNTER:15:0:U "
|
||||
};
|
||||
|
||||
static char *proc_ds_def = {
|
||||
static const char *proc_ds_def = {
|
||||
"DS:intr:COUNTER:15:0:U "
|
||||
"DS:ctxt:COUNTER:15:0:U "
|
||||
"DS:fork:COUNTER:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
switch (ds_id) {
|
||||
case DS_CPU:
|
||||
@ -104,10 +104,10 @@ static int probe(void)
|
||||
|
||||
else if (numfields == 5)
|
||||
val[5] = val[6] = val[7] = val[8] = "0";
|
||||
|
||||
|
||||
else if (numfields == 8)
|
||||
val[8] = "0";
|
||||
|
||||
|
||||
probe_submit(&plugin, filename, DS_CPU,
|
||||
"%s:%s:%s:%s:%s:%s:%s:%s",
|
||||
val[1], val[2], val[3], val[4],
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:uptime:GAUGE:15:0:U "
|
||||
"DS:idletime:GAUGE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
struct sammler_plugin plugin;
|
||||
|
||||
static char *ds_def = {
|
||||
static const char *ds_def = {
|
||||
"DS:pgalloc_high:DERIVE:15:0:U "
|
||||
"DS:pgalloc_normal:DERIVE:15:0:U "
|
||||
"DS:pgalloc_dma:DERIVE:15:0:U "
|
||||
@ -35,7 +35,7 @@ static char *ds_def = {
|
||||
"DS:pgfault:DERIVE:15:0:U "
|
||||
};
|
||||
|
||||
static char * get_ds(int ds_id)
|
||||
static const char * get_ds(int ds_id)
|
||||
{
|
||||
return ds_def;
|
||||
}
|
||||
|
11
plugins.c
11
plugins.c
@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
@ -51,14 +52,14 @@ static int plugin_init_cb(const char *filename, void *privdata)
|
||||
if (plugin_dir == NULL)
|
||||
plugin_dir = config_get_string("global", "plugin_dir", ".");
|
||||
|
||||
buffer = malloc(BUFSIZE);
|
||||
buffer = malloc(PATH_MAX);
|
||||
if (buffer == NULL) {
|
||||
log_print(LOG_ERROR, "plugin_load: out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = snprintf(buffer, BUFSIZE, "%s/%s", plugin_dir, filename);
|
||||
if (len < 0 || len >= BUFSIZE) {
|
||||
len = snprintf(buffer, PATH_MAX, "%s/%s", plugin_dir, filename);
|
||||
if (len < 0 || len >= PATH_MAX) {
|
||||
log_print(LOG_ERROR, "plugin_load: file name too long: %s/%s", plugin_dir, filename);
|
||||
free(buffer);
|
||||
return -1;
|
||||
@ -117,7 +118,7 @@ void plugins_probe(void)
|
||||
net_submit_flush();
|
||||
}
|
||||
|
||||
struct sammler_plugin * plugin_lookup(char *name)
|
||||
struct sammler_plugin * plugin_lookup(const char *name)
|
||||
{
|
||||
struct sammler_plugin *plugin;
|
||||
list_for_each_entry(plugin, &plugin_list, list) {
|
||||
@ -128,7 +129,7 @@ struct sammler_plugin * plugin_lookup(char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int probe_submit(struct sammler_plugin *plugin, char *filename, int ds_id, const char *fmt, ... )
|
||||
int probe_submit(struct sammler_plugin *plugin, const char *filename, int ds_id, const char *fmt, ... )
|
||||
{
|
||||
static const char *hostname = NULL;
|
||||
|
||||
|
@ -9,21 +9,21 @@
|
||||
|
||||
struct sammler_plugin {
|
||||
struct list_head list;
|
||||
char *name;
|
||||
const char *name;
|
||||
unsigned int interval;
|
||||
unsigned long lastprobe;
|
||||
int (*init) (void);
|
||||
int (*fini) (void);
|
||||
int (*probe) (void);
|
||||
char * (*get_ds) (int ds_id);
|
||||
const char * (*get_ds) (int ds_id);
|
||||
};
|
||||
|
||||
void plugin_init(int flags);
|
||||
|
||||
void plugins_probe(void);
|
||||
|
||||
struct sammler_plugin * plugin_lookup(char *name);
|
||||
struct sammler_plugin * plugin_lookup(const char *name);
|
||||
|
||||
int probe_submit(struct sammler_plugin *plugin, char *filename, int ds_id, const char *fmt, ... );
|
||||
int probe_submit(struct sammler_plugin *plugin, const char *filename, int ds_id, const char *fmt, ... );
|
||||
|
||||
#endif /* _PLUGINS_H_ */
|
||||
|
13
rrdtool.c
13
rrdtool.c
@ -73,7 +73,7 @@ static int append_rra_config(char *buffer, int size, int *pos)
|
||||
return config_get_strings("global", "rra", append_rra_config_cb, &data);
|
||||
}
|
||||
|
||||
static int do_rrd(int mode, char *cmd)
|
||||
static int do_rrd(int mode, const char *cmd)
|
||||
{
|
||||
int argc;
|
||||
char *argv[ARGCMAX];
|
||||
@ -103,11 +103,12 @@ static int do_rrd(int mode, char *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rrd_create_file(char *filename, char *plugin_name, int ds_id)
|
||||
static int rrd_create_file(const char *filename, const char *plugin_name, int ds_id)
|
||||
{
|
||||
struct sammler_plugin *plugin;
|
||||
int pos, step, retval;
|
||||
char *ds_def, *buffer;
|
||||
const char *ds_def;
|
||||
char *buffer;
|
||||
|
||||
plugin = plugin_lookup(plugin_name);
|
||||
if (plugin == NULL) {
|
||||
@ -147,7 +148,7 @@ static int rrd_create_file(char *filename, char *plugin_name, int ds_id)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int rrd_update_file(char *filename, char *values)
|
||||
static int rrd_update_file(const char *filename, const char *values)
|
||||
{
|
||||
int pos, retval;
|
||||
char *buffer;
|
||||
@ -171,7 +172,7 @@ static int rrd_update_file(char *filename, char *values)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int check_create_dir(char *dir)
|
||||
static int check_create_dir(const char *dir)
|
||||
{
|
||||
struct stat statbuf;
|
||||
if (stat(dir, &statbuf) == -1) {
|
||||
@ -228,7 +229,7 @@ static int create_parent_dirs(char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rrd_submit(const char *hostname, char *plugin, char *filename, int ds_id, char *data)
|
||||
int rrd_submit(const char *hostname, const char *plugin, const char *filename, int ds_id, const char *data)
|
||||
{
|
||||
struct stat statbuf;
|
||||
static const char *rrd_dir = NULL;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define _RRDTOOL_H_
|
||||
|
||||
#ifdef WITH_RRD
|
||||
int rrd_submit(const char *hostname, char *plugin, char *filename, int ds_id, char *data);
|
||||
int rrd_submit(const char *hostname, const char *plugin, const char *filename, int ds_id, const char *data);
|
||||
#else
|
||||
#define rrd_submit(hostname, plugin, filename, ds_id, data)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user