瀏覽代碼

bandwidthd: Addition of a variant of the bandwidthd package.

Addition of the bandwidthd-pgsql package variant that can save also
in a postgres database.

Modification of bandwidthd.config to have the default IP address
of an OpenWrt router (192.168.1.1)

Addition of a small OpenWrt logo in the logo.gif

Compile tested on CC and trunk (ar71xx and mvebu in both cases)
run tested on CC (ar71xx) and trunk (r47397 on mvebu)

Signed-off-by: Jean-Michel Lacroix <lacroix@lepine-lacroix.info>
Jean-Michel Lacroix 9 年之前
父節點
當前提交
b885721fa0

+ 63
- 4
utils/bandwidthd/Makefile 查看文件

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=bandwidthd
11 11
 PKG_VERSION:=2.0.1
12
-PKG_RELEASE:=4
12
+PKG_RELEASE:=5
13 13
 
14 14
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz
15 15
 PKG_SOURCE_URL:=@SF/bandwidthd
@@ -18,22 +18,50 @@ PKG_MD5SUM:=aa79aad7bd489fd2cae1f7dc086ca8b6
18 18
 PKG_MAINTAINER:=Jean-Michel Lacroix <lacroix@lepine-lacroix.info>
19 19
 
20 20
 PKG_LICENSE:=GPL-2.0
21
-PKG_LICENSE_FILES:=
21
+
22
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
22 23
 
23 24
 include $(INCLUDE_DIR)/package.mk
24 25
 
25
-define Package/bandwidthd
26
+define Package/bandwidthd/Default
26 27
   SECTION:=utils
27 28
   CATEGORY:=Utilities
28 29
   TITLE:=Bandwidthd
29 30
   URL:=http://bandwidthd.sourceforge.net/
31
+endef
32
+
33
+define Package/bandwidthd
34
+$(call Package/bandwidthd/Default)
35
+  TITLE += (without postgresql)
36
+  VARIANT:=no-pgsql
30 37
   DEPENDS:=+libgd +libpcap
31 38
 endef
32 39
 
40
+define Package/bandwidthd-pgsql
41
+$(call Package/bandwidthd/Default)
42
+  TITLE += (with postgresql enabled)
43
+  VARIANT:=pgsql
44
+  DEPENDS:=+libgd +libpcap +libpq
45
+endef
46
+
47
+define Package/bandwidthd/description
48
+  A bandwidthd tracking utility.
49
+endef
50
+
51
+define Package/bandwidthd-pgsql/description
52
+$(call Package/bandwidthd/description)
53
+With the ability to store in a postgresql database.
54
+endef
55
+
33 56
 define Package/bandwidthd/daemon
34 57
  This package contains bandwidthd a bandwith tracking utility.
35 58
 endef
36 59
 
60
+define Package/bandwidthd-pgsql/daemon
61
+ This package contains bandwidthd a bandwith tracking utility.
62
+endef
63
+
64
+ifeq ($(BUILD_VARIANT),no-pgsql)
37 65
 CONFIGURE_ARGS += \
38 66
 	ac_cv_file__sw_lib=no \
39 67
 	ac_cv_file__sw_include=no \
@@ -41,7 +69,18 @@ CONFIGURE_ARGS += \
41 69
 	ac_cv_file__usr_pkg_include=no \
42 70
 	ac_cv_file__usr_local_pgsql_lib=no \
43 71
 	ac_cv_file__usr_local_pgsql_include=no \
44
-	ac_cv_lib_pq_PQconnectdb=no \
72
+	ac_cv_lib_pq_PQconnectdb=no 
73
+endif
74
+
75
+ifeq ($(BUILD_VARIANT),pgsql)
76
+CONFIGURE_ARGS += \
77
+        ac_cv_file__sw_lib=no \
78
+        ac_cv_file__sw_include=no \
79
+        ac_cv_file__usr_pkg_lib=no \
80
+        ac_cv_file__usr_pkg_include=no \
81
+        ac_cv_file__usr_local_pgsql_lib=no \
82
+        ac_cv_file__usr_local_pgsql_include=no
83
+endif
45 84
 
46 85
 EXTRA_CFLAGS+= $(TARGET_CPPFLAGS)
47 86
 EXTRA_LDFLAGS+= $(TARGET_LDFLAGS) -Wl,-rpath-link,$(STAGING_DIR)/usr/lib
@@ -58,8 +97,28 @@ define Package/bandwidthd/install
58 97
 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/htdocs/logo.gif $(1)/www/
59 98
 endef
60 99
 
100
+define Package/bandwidthd-pgsql/install
101
+	$(INSTALL_DIR) $(1)/usr/sbin
102
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/bandwidthd $(1)/usr/sbin/
103
+	$(INSTALL_DIR) $(1)/etc/config
104
+	$(INSTALL_DATA) ./files/bandwidthd-pgsql.config $(1)/etc/config/bandwidthd
105
+	$(INSTALL_DIR) $(1)/etc/init.d
106
+	$(INSTALL_BIN) ./files/bandwidthd-pgsql.init $(1)/etc/init.d/bandwidthd
107
+	$(INSTALL_DIR) $(1)/www/phphtdocs
108
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/htdocs/legend.gif $(1)/www/
109
+	$(INSTALL_DATA) ./files/logo.gif $(1)/www/
110
+	$(INSTALL_DIR) $(1)/usr/share/postgresql
111
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/schema.postgresql $(1)/usr/share/postgresql
112
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/phphtdocs/bd_pgsql_purge.sh $(1)/usr/share/postgresql
113
+endef
114
+
61 115
 define Package/bandwidthd/conffiles
62 116
 /etc/config/bandwidthd
63 117
 endef
64 118
 
119
+define Package/bandwidthd-pgsql/conffiles
120
+/etc/config/bandwidthd
121
+endef
122
+
65 123
 $(eval $(call BuildPackage,bandwidthd))
124
+$(eval $(call BuildPackage,bandwidthd-pgsql))

+ 13
- 0
utils/bandwidthd/files/bandwidthd-pgsql.config 查看文件

@@ -0,0 +1,13 @@
1
+config bandwidthd
2
+	option dev	br-lan
3
+	option subnets		"192.168.1.0/24"
4
+	option skip_intervals	0
5
+	option graph_cutoff	1024
6
+	option promiscuous	true
7
+	option output_cdf	false
8
+	option recover_cdf	false
9
+	option filter		ip
10
+	option graph		true
11
+	option meta_refresh	150
12
+	option disabled_pgsql_connect_string	"user = postgres dbname = bandwidthd host = 192.168.1.1"
13
+	option disabled_sensor_id	"openwrt.mydomain.domain"

+ 90
- 0
utils/bandwidthd/files/bandwidthd-pgsql.init 查看文件

@@ -0,0 +1,90 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2008-2015 OpenWrt.org
3
+
4
+START=99
5
+
6
+config_cb() {
7
+	local cfg_type="$1"
8
+	local cfg_name="$2"
9
+
10
+	case "$cfg_type" in
11
+	        bandwidthd)
12
+	                append cfgs "$cfg_name"
13
+	        ;;
14
+	esac
15
+}
16
+
17
+export_bool() {
18
+	local option="$1"
19
+	local section="$2"
20
+	local _loctmp
21
+	config_get_bool _loctmp "$section" "$option"
22
+	if [ -n "$_loctmp" ]; then
23
+		conffile="${conffile}$option "
24
+		if [ 1 -eq "$_loctmp" ]; then
25
+			conffile="${conffile}true"
26
+		else
27
+			conffile="${conffile}false"
28
+		fi
29
+		conffile="${conffile}\n"
30
+	fi
31
+}
32
+
33
+export_number() {
34
+	local option="$1"
35
+	local section="$2"
36
+	local _loctmp
37
+	config_get _loctmp "$section" "$option"
38
+	if [ -n "$_loctmp" ]; then
39
+		conffile="${conffile}$option ${_loctmp}\n"
40
+	fi
41
+}
42
+
43
+export_string() {
44
+	local option="$1"
45
+	local section="$2"
46
+	local _loctmp
47
+	config_get _loctmp "$section" "$option"
48
+	if [ -n "$_loctmp" ]; then
49
+		conffile="${conffile}$option \"${_loctmp}\"\n"
50
+	fi
51
+}
52
+
53
+start() {
54
+	local subnet conffile
55
+
56
+	[ -d /tmp/bandwidthd ] || mkdir -p /tmp/bandwidthd && cp /www/legend.gif /www/logo.gif /tmp/bandwidthd/
57
+	[ -e /htdocs ] || ln -s /tmp/bandwidthd /htdocs
58
+	[ -e /www/bandwidthd ] || ln -s /tmp/bandwidthd /www/bandwidthd
59
+	rm -f /tmp/bandwidthd.conf
60
+	touch /tmp/bandwidthd.conf
61
+	[ -e /etc/bandwidthd.conf ] || ln -s /tmp/bandwidthd.conf /etc/bandwidthd.conf
62
+	
63
+	
64
+	config_load bandwidthd
65
+	for cfg in $cfgs; do
66
+		config_get subnets $cfg subnets
67
+			for subnet in $subnets; do
68
+				conffile="${conffile}subnet ${subnet}\n"
69
+			done
70
+		export_string dev $cfg
71
+		export_number skip_intervals $cfg
72
+		export_number graph_cutoff $cfg
73
+		export_bool promiscuous $cfg
74
+		export_bool output_cdf $cfg
75
+		export_bool recover_cdf $cfg
76
+		export_string filter $cfg
77
+		export_bool graph $cfg
78
+		export_number meta_refresh $cfg
79
+		export_string pgsql_connect_string $cfg
80
+		export_string sensor_id $cfg
81
+		[ -n "$conffile" ] && echo -e "$conffile" >>/tmp/bandwidthd.conf
82
+		unset conffile
83
+	done
84
+	cd /
85
+	service_start /usr/sbin/bandwidthd
86
+}
87
+
88
+stop() {
89
+	service_stop /usr/sbin/bandwidthd
90
+}

+ 1
- 1
utils/bandwidthd/files/bandwidthd.config 查看文件

@@ -1,6 +1,6 @@
1 1
 config bandwidthd
2 2
 	option dev	br-lan
3
-	option subnets		"192.168.0.0/16 10.0.0.0/8 172.16.0.0/12"
3
+	option subnets		"192.168.1.0/24"
4 4
 	option skip_intervals	0
5 5
 	option graph_cutoff	1024
6 6
 	option promiscuous	true

二進制
utils/bandwidthd/files/logo.gif 查看文件