misc fixes

This commit is contained in:
Olaf Rempel 2010-06-12 15:36:12 +02:00
parent 1c13dd3f58
commit 7aa19ecade
5 changed files with 21 additions and 14 deletions

View File

@ -2,7 +2,7 @@
WITH_RRD=yes WITH_RRD=yes
PLUGINS := ctstat diskstat hwmon load memory mount netdev random rtstat stat uptime vmstat PLUGINS := ctstat diskstat hwmon load memory mount netdev random rtstat stat uptime vmstat
PLUGINS += apache mysql conntrack alixusv ts2 diskstandby #PLUGINS += apache mysql conntrack alixusv ts2 diskstandby
DESTDIR = DESTDIR =
BINARY_DIR = /usr/local/bin BINARY_DIR = /usr/local/bin
@ -19,23 +19,28 @@ WWW_OWNER = www-data
SRC := configfile.c event.c helper.c linebuffer.c logging.c network.c pidfile.c SRC := configfile.c event.c helper.c linebuffer.c logging.c network.c pidfile.c
SRC += plugins.c probe.c sammler.c signals.c sockaddr.c SRC += plugins.c probe.c sammler.c signals.c sockaddr.c
CFLAGS := -O2 -Wall -Wno-unused-result -MMD -fno-stack-protector -I. CFLAGS := -O2 -Wall -MMD -I.
LDFLAGS := -ldl -rdynamic LDFLAGS := -ldl -rdynamic
# ############################ # ############################
ifeq ("$(WITH_RRD)", "yes") ifeq ("$(WITH_RRD)", "yes")
SRC += rrdtool.c SRC += rrdtool.c
CFLAGS_TARGET = -DWITH_RRD CFLAGS += -DWITH_RRD
LDFLAGS_TARGET = -lrrd LDFLAGS_TARGET = -lrrd
TARGET = sammler TARGET = sammler
else else
SRC += rrdtool-fake.c SRC += rrdtool-fake.c
CFLAGS_TARGET =
LDFLAGS_TARGET = LDFLAGS_TARGET =
TARGET = sammler_norrd TARGET = sammler_norrd
endif endif
ifeq ($(strip $(wildcard $(DESTDIR)$(CONFIG_DIR)/sammler.conf)),)
NEWCONF=sammler.conf
else
NEWCONF=sammler.conf.dist
endif
# ############################ # ############################
all: $(TARGET) plugins all: $(TARGET) plugins
@ -46,7 +51,7 @@ $(TARGET): $(SRC:%.c=%.o)
%.o: %.c %.o: %.c
@echo " Building file: $<" @echo " Building file: $<"
@$(CC) $(CFLAGS) $(CFLAGS_TARGET) -o $@ -c $< @$(CC) $(CFLAGS) -o $@ -c $<
.PHONY: plugins .PHONY: plugins
plugins: $(PLUGINS:%=plugins/%.o) $(PLUGINS:%=plugins/%.so) plugins: $(PLUGINS:%=plugins/%.o) $(PLUGINS:%=plugins/%.so)
@ -73,12 +78,12 @@ plugins/diskstandby.so: plugins/diskstandby.o plugins/sgio.o
install: all install: all
install -D -m 755 -s $(TARGET) $(DESTDIR)$(BINARY_DIR)/$(TARGET) install -D -m 755 -s $(TARGET) $(DESTDIR)$(BINARY_DIR)/$(TARGET)
install -D -m 644 sammler.conf $(DESTDIR)$(CONFIG_DIR)/sammler.conf install -D -m 644 sammler.conf $(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
sed -i -e "s:^logfile .*$$:logfile $(LOG_DIR)/sammler.log:" \ sed -i -e "s:^logfile .*$$:logfile $(LOG_DIR)/sammler.log:" \
-e "s:^pidfile .*$$:pidfile $(PID_DIR)/sammler.pid:" \ -e "s:^pidfile .*$$:pidfile $(PID_DIR)/sammler.pid:" \
-e "s:^rrd_dir .*$$:rrd_dir $(DATA_DIR):" \ -e "s:^rrd_dir .*$$:rrd_dir $(DATA_DIR):" \
-e "s:^plugin_dir .*$$:plugin_dir $(PLUGIN_DIR):" \ -e "s:^plugin_dir .*$$:plugin_dir $(PLUGIN_DIR):" \
$(DESTDIR)$(CONFIG_DIR)/sammler.conf $(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
install -d -m 755 $(DESTDIR)$(PLUGIN_DIR) install -d -m 755 $(DESTDIR)$(PLUGIN_DIR)
install -m 755 -s plugins/*.so $(DESTDIR)$(PLUGIN_DIR) install -m 755 -s plugins/*.so $(DESTDIR)$(PLUGIN_DIR)
install -d -m 755 $(DESTDIR)$(LOG_DIR) install -d -m 755 $(DESTDIR)$(LOG_DIR)
@ -90,10 +95,12 @@ ifeq ("$(WITH_RRD)", "yes")
sed -i -e "s:%%WWW_CONFIG%%:$(WWW_CONFIG):" \ sed -i -e "s:%%WWW_CONFIG%%:$(WWW_CONFIG):" \
-e "s:%%DATA_DIR%%:$(DATA_DIR)/:" \ -e "s:%%DATA_DIR%%:$(DATA_DIR)/:" \
$(DESTDIR)$(WWW_DIR)/sammler.php $(DESTDIR)$(WWW_DIR)/sammler.php
ifeq ($(strip $(wildcard $(DESTDIR)$(WWW_CONFIG))),)
-install -D -m 644 -o $(WWW_OWNER) /dev/null $(DESTDIR)$(WWW_CONFIG) -install -D -m 644 -o $(WWW_OWNER) /dev/null $(DESTDIR)$(WWW_CONFIG)
endif
else else
sed -i -e "s:^forward_only .*$$:forward_only true:" \ sed -i -e "s:^forward_only .*$$:forward_only true:" \
$(DESTDIR)$(CONFIG_DIR)/sammler.conf $(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
endif endif
clean: clean:

View File

@ -234,7 +234,7 @@ struct strtoken * strtokenize(const char *input, const char *delim, int maxfield
{ {
struct strtoken *tokens = malloc(sizeof(struct strtoken) + struct strtoken *tokens = malloc(sizeof(struct strtoken) +
maxfields * sizeof(char *) + maxfields * sizeof(char *) +
strlen(input)); strlen(input) +1);
if (tokens == NULL) if (tokens == NULL)
return NULL; return NULL;

View File

@ -120,7 +120,7 @@ static int init_cb(struct strtoken *tokens, void *privdata)
entry->devpath = strdup(tokens->field[0]); entry->devpath = strdup(tokens->field[0]);
log_print(LOG_INFO, "%s: added server '%s'", plugin.name, entry->devpath); log_print(LOG_INFO, "%s: added device '%s'", plugin.name, entry->devpath);
list_add_tail(&entry->list, &device_list); list_add_tail(&entry->list, &device_list);
return 0; return 0;
} }

View File

@ -28,7 +28,7 @@ plugin random.so
#plugin hwmon.so #plugin hwmon.so
#plugin alixusv.so #plugin alixusv.so
#plugin ts2.so #plugin ts2.so
plugin diskstandby.so #plugin diskstandby.so
# 1h(10s), 12h(1min), 48h(2min), 14d(15min), 4w(60min), 2y(12h) # 1h(10s), 12h(1min), 48h(2min), 14d(15min), 4w(60min), 2y(12h)
rra RRA:MIN:0.5:1:360 RRA:AVERAGE:0.5:1:360 RRA:MAX:0.5:1:360 rra RRA:MIN:0.5:1:360 RRA:AVERAGE:0.5:1:360 RRA:MAX:0.5:1:360
@ -55,4 +55,4 @@ rra RRA:MIN:0.5:4320:1440 RRA:AVERAGE:0.5:4320:1440 RRA:MAX:0.5:4320:1440
#server localhost,127.0.0.1:51234 #server localhost,127.0.0.1:51234
[p_diskstandby] [p_diskstandby]
device /dev/sda #device /dev/sda

View File

@ -542,8 +542,8 @@ function show_rrd($conf) {
"CDEF:b=1,a,- ". "CDEF:b=1,a,- ".
'CDEF:err=a,UN,INF,UNKN,IF '. 'CDEF:err=a,UN,INF,UNKN,IF '.
'AREA:err#FFD0D0 '. 'AREA:err#FFD0D0 '.
'AREA:a#FF0000:"Active\n "'. 'AREA:a#FF0000:"Active\n" '.
'STACK:b#00CF00:"Standby "'; 'STACK:b#00CF00:"Standby" ';
break; break;
case 'hwmon': case 'hwmon':