[patchteam] Add two new packages, hsflowd and sflowovsd - Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>

git-svn-id: svn://svn.openwrt.org/openwrt/packages@31051 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
dingo 2012-03-21 12:36:52 +00:00
parent 9b54ca4728
commit 8ffd268207
8 changed files with 346 additions and 0 deletions

72
net/hsflowd/Makefile Normal file
View File

@ -0,0 +1,72 @@
#
# Copyright (C) 2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=hsflowd
PKG_RELEASE:=1
PKG_SOURCE_URL:=@SF/host-sflow
PKG_VERSION:=1.20
PKG_MD5SUM:=0bfc0b05fbab27a80557c5efb5e66693
PKG_SOURCE:=hsflowd-$(PKG_VERSION).tar.gz
include $(INCLUDE_DIR)/package.mk
define Package/hsflowd
SECTION:=net
CATEGORY:=Base system
TITLE:=Host sFlow export agent
URL:=http://host-sflow.sourceforge.net/
endef
define Package/sflowovsd
SECTION:=net
CATEGORY:=Base system
DEPENDS:=+hsflowd
TITLE:=Host sFlow Open vSwitch agent
URL:=http://host-sflow.sourceforge.net/
endef
define Package/hsflowd/description
The Host sFlow agent exports server performance metrics using the sFlow
protocol. The agent is intended to provide scalable, multi-vendor,
multi-OS performance monitoring with minimal impact on the systems being
monitored.
endef
define Package/sflowovsd/description
The Host sFlow agent can automatically configure the sFlow settings in
the Open vSwitch.
endef
MAKE_VARS += \
LIBVIRT=no \
XEN_DDK=no \
DEBIAN=no \
PLATFORM=Linux \
OPT="$(TARGET_CFLAGS) -std=c99"
define Package/hsflowd/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/Linux/hsflowd $(1)/usr/sbin
$(INSTALL_BIN) ./files/hsflowd.init $(1)/etc/init.d/hsflowd
$(INSTALL_CONF) ./files/hsflowd.config $(1)/etc/config/hsflowd
endef
define Package/sflowovsd/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/Linux/sflowovsd $(1)/usr/sbin
$(INSTALL_BIN) ./files/sflowovsd.init $(1)/etc/init.d/sflowovsd
endef
$(eval $(call BuildPackage,hsflowd))
$(eval $(call BuildPackage,sflowovsd))

View File

@ -0,0 +1,11 @@
config hsflowd config
option enabled '0'
option dnssd '0'
option polling '30'
option sampling '512'
option uuid ''
config collector
option ip '192.168.123.123'
option port '6343'

View File

@ -0,0 +1,72 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 OpenWrt.org
START=50
SERVICE_USE_PID=1
start() {
config_load hsflowd
local args agent conffile dnssd polling sampling uuid
getcollectors() {
echo " collector {" >> $tmpconf
config_get ip "$1" ip
[ -n "$ip" ] && echo " ip=${ip}" >> $tmpconf
config_get port "$1" port
[ -n "$port" ] && echo " udpport=${port}" >> $tmpconf
echo " }" >> $tmpconf
}
config_get agent config agent_iface "br-lan"
config_get conffile config config_file
config_get_bool dnssd config dnssd 1
config_get polling config polling 30
config_get sampling config sampling 512
config_get uuid config uuid
[ -z "$uuid" ] && {
uuid="$(cat /proc/sys/kernel/random/uuid)"
uci set hsflowd.config.uuid=$uuid
uci commit hsflowd
}
args=""
append args "-u $uuid"
if [ -n "$conffile" ]; then
append args "-f $conffile"
else
tmpconf="/var/etc/hsflowd.conf"
append args "-f $tmpconf"
mkdir -p /var/etc
echo "sFlow {" > $tmpconf
echo " agent=${agent}" >> $tmpconf
if [ "$dnssd" -eq 1 ]; then
echo " DNSSD=on" >> $tmpconf
else
echo " DNSSD=off" >> $tmpconf
echo " polling=${polling}" >> $tmpconf
echo " sampling=${sampling}" >> $tmpconf
config_foreach getcollectors collector
fi
echo "}" >> $tmpconf
fi
service_start /usr/sbin/hsflowd $args
}
stop() {
service_stop /usr/sbin/hsflowd
pid_file="/var/run/hsflowd.pid"
[ -f "$pid_file" ] && rm -f "$pid_file"
}

View File

@ -0,0 +1,17 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 OpenWrt.org
START=50
SERVICE_USE_PID=1
start() {
service_start /usr/sbin/sflowovsd -f /var/run/hsflowd.auto
}
stop() {
service_stop /usr/sbin/sflowovsd
pid_file="/var/run/sflowovsd.pid"
[ -f "$pid_file" ] && rm -f "$pid_file"
}

View File

@ -0,0 +1,91 @@
--- a/src/Linux/Makefile
+++ b/src/Linux/Makefile
@@ -74,7 +74,7 @@ HEADERS= hsflowd.h hsflowtokens.h sflowo
SFLOWDIR=../sflow
#CC= g++
-CC= gcc -std=gnu99
+CC?= gcc -std=gnu99
OPT_FULL = -O3 -DNDEBUG
OPT_DEBUG = -g -ggdb
--- a/src/sflow/Makefile
+++ b/src/sflow/Makefile
@@ -3,7 +3,7 @@
HEADERS= sflow_api.h sflow.h Makefile
-OPT = -O3 -DNDEBUG
+OPT ?= -O3 -DNDEBUG
#OPT = -g -ggdb -O2
#OPT= -g -ggdb
@@ -12,7 +12,7 @@ LDFLAGS=
#CC= g++
#CC= gcc -std=c99
-CC= gcc
+CC?= gcc
OBJS= sflow_agent.o \
sflow_sampler.o \
@@ -20,8 +20,8 @@ OBJS= sflow_agent.o \
sflow_receiver.o
libsflow.a: $(OBJS)
- ar cru $@ $(OBJS)
- ranlib $@
+ $(AR) cru $@ $(OBJS)
+ $(RANLIB) $@
all: libsflow.a
--- a/Makefile
+++ b/Makefile
@@ -11,32 +11,32 @@ all: $(PROG)
$(PROG):
cd src/sflow; $(MAKE)
- PLATFORM=`uname`; \
+ PLATFORM?=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL
clean:
cd src/sflow; $(MAKE) clean
- PLATFORM=`uname`; \
+ PLATFORM?=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL clean
install:
- PLATFORM=`uname`; \
+ PLATFORM?=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL install
schedule:
- PLATFORM=`uname`; \
+ PLATFORM?=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL schedule
rpm:
- PLATFORM=`uname`; \
+ PLATFORM?=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
MYSRCDIR=$(RPM_SOURCES_DIR)/$(PROG)-$$MYVER; \
@@ -46,7 +46,7 @@ rpm:
rpmbuild -ba $(PROG).spec
deb: $(PROG)
- PLATFORM=`uname`; \
+ PLATFORM?=`uname`; \
MYARCH=`uname -m`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \

View File

@ -0,0 +1,55 @@
--- a/src/Linux/hsflowd.c
+++ b/src/Linux/hsflowd.c
@@ -1408,13 +1408,12 @@ extern "C" {
signal(SIGXFSZ, SIG_DFL);
// ask for the backtrace pointers
- size_t siz = backtrace(backtracePtrs, HSP_NUM_BACKTRACE_PTRS);
+ size_t siz = 0;
if(f_crash == NULL) {
f_crash = stderr;
}
- backtrace_symbols_fd(backtracePtrs, siz, fileno(f_crash));
fflush(f_crash);
// Do something useful with siginfo_t
if (sig == SIGSEGV) {
@@ -2005,7 +2004,6 @@ extern "C" {
if(debug) {
myLog(LOG_INFO, "initAgent suceeded");
// print some stats to help us size HSP_RLIMIT_MEMLOCK etc.
- malloc_stats();
}
if(sp->dropPriv) {
--- a/src/Linux/hsflowd.h
+++ b/src/Linux/hsflowd.h
@@ -34,9 +34,7 @@ extern "C" {
#include <limits.h> // for UINT_MAX
// for signal backtrace
-#include <execinfo.h>
#include <signal.h>
-#include <ucontext.h>
#include <stdarg.h> // for va_start()
#include "util.h"
--- a/src/Linux/util.c
+++ b/src/Linux/util.c
@@ -39,7 +39,6 @@ extern "C" {
void *mem = SYS_CALLOC(1, bytes);
if(mem == NULL) {
myLog(LOG_ERR, "calloc() failed : %s", strerror(errno));
- if(debug) malloc_stats();
exit(EXIT_FAILURE);
}
return mem;
@@ -51,7 +50,6 @@ extern "C" {
void *mem = SYS_REALLOC(ptr, bytes);
if(mem == NULL) {
myLog(LOG_ERR, "realloc() failed : %s", strerror(errno));
- if(debug) malloc_stats();
exit(EXIT_FAILURE);
}
return mem;

View File

@ -0,0 +1,16 @@
diff -Nurb a/src/Linux/hsflowd.h b/src/Linux/hsflowd.h
--- a/src/Linux/hsflowd.h 2012-03-01 18:16:09.000000000 +0100
+++ b/src/Linux/hsflowd.h 2012-03-18 18:56:58.689852282 +0100
@@ -72,9 +72,9 @@
#define HSP_DAEMON_NAME "hsflowd"
#define HSP_DEFAULT_PIDFILE "/var/run/hsflowd.pid"
#define HSP_DEFAULT_CONFIGFILE "/etc/hsflowd.conf"
-#define HSP_DEFAULT_OUTPUTFILE "/etc/hsflowd.auto"
-#define HSP_DEFAULT_VMSTORE_FILE "/etc/hsflowd.data"
-#define HSP_DEFAULT_CRASH_FILE "/etc/hsflowd.crash"
+#define HSP_DEFAULT_OUTPUTFILE "/var/run/hsflowd.auto"
+#define HSP_DEFAULT_VMSTORE_FILE "/var/run/hsflowd.data"
+#define HSP_DEFAULT_CRASH_FILE "/var/run/hsflowd.crash"
/* Numbering to avoid clash. See http://www.sflow.org/developers/dsindexnumbers.php */
#define HSP_DEFAULT_PHYSICAL_DSINDEX 1

View File

@ -0,0 +1,12 @@
diff -Nurb a/src/Linux/Makefile b/src/Linux/Makefile
--- a/src/Linux/Makefile 2011-09-07 01:15:22.000000000 +0200
+++ b/src/Linux/Makefile 2012-03-21 01:55:40.468569332 +0100
@@ -97,7 +97,7 @@
SFLOWOVS_OBJS=sflowovsd.o util.o
-CFLAGS+= -I. -I$(SFLOWDIR) $(OPT) -Wall -D_GNU_SOURCE -DHSP_VERSION=$(VERSION) -DUTHEAP
+CFLAGS+= -I. -I$(SFLOWDIR) $(OPT) -Wall -D_GNU_SOURCE -DHSP_VERSION=$(VERSION)
LIBS+= $(SFLOWDIR)/libsflow.a -lresolv -lpthread
#### BUILD ####