]> git.pld-linux.org Git - packages/bandwidthd.git/commitdiff
- new from Artur Makutunowicz <nail2k (at) freesco.pl>
authorkolodko <kolodko@pld-linux.org>
Sat, 22 Jan 2005 11:12:05 +0000 (11:12 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    bandwidthd-makefile.patch -> 1.1
    bandwidthd-path.patch -> 1.1
    bandwidthd-pgsql.patch -> 1.1
    bandwidthd.conf -> 1.1
    bandwidthd.init -> 1.1
    bandwidthd.sysconfig -> 1.1

bandwidthd-makefile.patch [new file with mode: 0644]
bandwidthd-path.patch [new file with mode: 0644]
bandwidthd-pgsql.patch [new file with mode: 0644]
bandwidthd.conf [new file with mode: 0644]
bandwidthd.init [new file with mode: 0644]
bandwidthd.sysconfig [new file with mode: 0644]

diff --git a/bandwidthd-makefile.patch b/bandwidthd-makefile.patch
new file mode 100644 (file)
index 0000000..b94bf82
--- /dev/null
@@ -0,0 +1,15 @@
+--- ../mejkfajl        2005-01-19 22:25:42.827289408 +0100
++++ Makefile.in        2005-01-19 23:31:45.894389864 +0100
+@@ -1,10 +1,11 @@
+ exec_prefix = @exec_prefix@
+ prefix = @prefix@
++sysconfdir = @sysconfdir@
+ CC = @CC@
+ LDFLAGS = @LDFLAGS@ @LIBS@
+ OBS= bandwidthd.o graph.o conf.tab.o conf.l.o
+-CFLAGS= -Wall @CFLAGS@ @CPPFLAGS@ @DEFS@ -DINSTALL_DIR="\"$(exec_prefix)/bandwidthd\""
++CFLAGS= -Wall @CFLAGS@ @CPPFLAGS@ @DEFS@ -DCONFIG="\"$(sysconfdir)/bandwidthd.conf\"" -DWWWROOT="\"/home/services/httpd/html/bandwidthd\""
+ NONWALLCFLAGS= @CFLAGS@ @CPPFLAGS@ @DEFS@
+ # Debugging stuff
diff --git a/bandwidthd-path.patch b/bandwidthd-path.patch
new file mode 100644 (file)
index 0000000..eed43c4
--- /dev/null
@@ -0,0 +1,153 @@
+diff -urN bandwidthd-2.0.1/bandwidthd.c bandwidthd-2.0.1-new/bandwidthd.c
+--- bandwidthd-2.0.1/bandwidthd.c      2005-01-11 22:27:26.000000000 +0100
++++ bandwidthd-2.0.1-new/bandwidthd.c  2005-01-18 21:42:56.000000000 +0100
+@@ -209,20 +209,20 @@
+       {
+       FILE *pidfile;
+-      pidfile = fopen("/var/run/bandwidthd.pid", "wt");
++      pidfile = fopen(PIDFILE, "wt");
+       if (pidfile) 
+               {
+               if (fprintf(pidfile, "%d\n", pid) == 0) 
+                       {
+-                      syslog(LOG_ERR, "Bandwidthd: failed to write '%d' to /var/run/bandwidthd.pid", pid);
++                      syslog(LOG_ERR, "Bandwidthd: failed to write '%d' to %s", pid, PIDFILE);
+                       fclose(pidfile);
+-                      unlink("/var/run/bandwidthd.pid");
++                      unlink(PIDFILE);
+                       }
+               else
+                       fclose(pidfile);                
+               }
+       else
+-              syslog(LOG_ERR, "Could not open /var/run/bandwidthd.pid for write");
++              syslog(LOG_ERR, "Could not open %s for write", PIDFILE);
+       }
+@@ -254,23 +254,23 @@
+       config.sensor_id = "unset";  
+       openlog("bandwidthd", LOG_CONS, LOG_DAEMON);
++      chdir(WWWROOT);
+-      if (stat("./etc/bandwidthd.conf", &StatBuf))
++      if (stat(CONFIG, &StatBuf))
+               {
+-              chdir(INSTALL_DIR);
+-              if (stat("./etc/bandwidthd.conf", &StatBuf))
++              if (stat(CONFIG, &StatBuf))
+                       {
+-                      printf("Cannot find ./etc/bandwidthd.conf or %s/etc/bandwidthd.conf\n", INSTALL_DIR);
+-                      syslog(LOG_ERR, "Cannot find ./etc/bandwidthd.conf or %s/etc/bandwidthd.conf", INSTALL_DIR);
++                      printf("Cannot find %s\n", CONFIG);
++                      syslog(LOG_ERR, "Cannot find %s", CONFIG);
+                       exit(1);
+                       }
+               }
+-      bdconfig_in = fopen("./etc/bandwidthd.conf", "rt");
++      bdconfig_in = fopen(CONFIG, "rt");
+       if (!bdconfig_in)
+               {
+-              syslog(LOG_ERR, "Cannot open bandwidthd.conf");
+-              printf("Cannot open ./etc/bandwidthd.conf\n");
++              syslog(LOG_ERR, "Cannot open %s", CONFIG);
++              printf("Cannot open %s\n", CONFIG);
+               exit(1);
+               }
+       bdconfig_parse();
+@@ -333,10 +333,10 @@
+       if (config.graph)
+               {
+-              bd_CollectingData("htdocs/index.html");
+-              bd_CollectingData("htdocs/index2.html");
+-              bd_CollectingData("htdocs/index3.html");
+-              bd_CollectingData("htdocs/index4.html");
++              bd_CollectingData("index.html");
++              bd_CollectingData("index2.html");
++              bd_CollectingData("index3.html");
++              bd_CollectingData("index4.html");
+               }
+       /* detach from console. */
+diff -urN bandwidthd-2.0.1/bandwidthd.h bandwidthd-2.0.1-new/bandwidthd.h
+--- bandwidthd-2.0.1/bandwidthd.h      2005-01-11 22:15:49.000000000 +0100
++++ bandwidthd-2.0.1-new/bandwidthd.h  2005-01-19 20:15:27.168848712 +0100
+@@ -100,6 +100,7 @@
+ #define DB_PGSQL 1
++#define PIDFILE       "/var/run/bandwidthd.pid"
+ struct config
+       {
+       char *dev;
+diff -urN bandwidthd-2.0.1/graph.c bandwidthd-2.0.1-new/graph.c
+--- bandwidthd-2.0.1/graph.c   2005-01-11 22:15:49.000000000 +0100
++++ bandwidthd-2.0.1-new/graph.c       2005-01-18 21:44:37.000000000 +0100
+@@ -199,7 +199,7 @@
+       int SubnetCounter;
+       int Counter, tCounter;
+       time_t WriteTime;
+-      char filename[] = "./htdocs/index2.html";
++      char filename[] = "index2.html";
+       char *PeriodDesc;
+       
+       FILE *file;
+@@ -217,15 +217,15 @@
+       
+       if (config.tag == '1')
+               {
+-              if ((file = fopen("./htdocs/index.html", "wt")) == NULL)
++              if ((file = fopen("index.html", "wt")) == NULL)
+                       {
+-                      syslog(LOG_ERR, "Failed to open ./htdocs/index.html");
++                      syslog(LOG_ERR, "Failed to open %s/index.html", WWWROOT);
+                       exit(1);
+                       }
+               }
+       else
+               {
+-              filename[14] = config.tag;
++              filename[strlen(filename) - 6] = config.tag;
+               if ((file = fopen(filename, "wt")) == NULL)
+                       {
+                       syslog(LOG_ERR, "Failed to open %s", filename);
+@@ -307,7 +307,7 @@
+       for (SubnetCounter = 0; SubnetCounter < SubnetCount; SubnetCounter++)
+               {
+               HostIp2CharIp(SubnetTable[SubnetCounter].ip, Buffer1);
+-              sprintf(Buffer2, "./htdocs/Subnet-%c-%s.html", config.tag, Buffer1);
++              sprintf(Buffer2, "Subnet-%c-%s.html", config.tag, Buffer1);
+               file = fopen(Buffer2, "wt");
+               fprintf(file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
+               fprintf(file, "<HTML>\n<HEAD><TITLE>Bandwidthd - Subnet %s</TITLE>\n", Buffer1);
+@@ -411,12 +411,12 @@
+         PrepareXAxis(im2, timestamp);
+         PrepareYAxis(im2, YMax);
+-        sprintf(outputfilename, "./htdocs/%s-%c-S.png", CharIp, config.tag);
++        sprintf(outputfilename, "%s-%c-S.png", CharIp, config.tag);
+         OutputFile = fopen(outputfilename, "wb");    
+         gdImagePng(im, OutputFile);
+         fclose(OutputFile);
+-        sprintf(outputfilename, "./htdocs/%s-%c-R.png", CharIp, config.tag);
++        sprintf(outputfilename, "%s-%c-R.png", CharIp, config.tag);
+         OutputFile = fopen(outputfilename, "wb");
+         gdImagePng(im2, OutputFile);
+         fclose(OutputFile);
+@@ -424,9 +424,9 @@
+     else
+         {
+         // The graph isn't worth clutering up the web pages with
+-        sprintf(outputfilename, "./htdocs/%s-%c-R.png", CharIp, config.tag);
++        sprintf(outputfilename, "%s-%c-R.png", CharIp, config.tag);
+         unlink(outputfilename);
+-        sprintf(outputfilename, "./htdocs/%s-%c-S.png", CharIp, config.tag);
++        sprintf(outputfilename, "%s-%c-S.png", CharIp, config.tag);
+         unlink(outputfilename);
+         }
diff --git a/bandwidthd-pgsql.patch b/bandwidthd-pgsql.patch
new file mode 100644 (file)
index 0000000..eea5314
--- /dev/null
@@ -0,0 +1,29 @@
+--- ../bandwidthd-2.0.1/configure.in   2005-01-11 22:15:49.000000000 +0100
++++ configure.in       2005-01-18 22:46:18.680509176 +0100
+@@ -25,9 +25,9 @@
+ fi
+ # May be equired for BSD
+-LDFLAGS="$LDFLAGS -L/usr/local/lib"
++#LDFLAGS="$LDFLAGS -L/usr/local/lib"
+-CPPFLAGS="$CPPFLAGS -I/usr/local/include"
++#CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+ #Check for Darwin sw directory
+ AC_CHECK_FILE(/sw/lib, LDFLAGS="$LDFLAGS -L/sw/lib")
+@@ -55,10 +55,10 @@
+       [AC_CHECK_LIB(wpcap, pcap_open_live, ,[AC_MSG_ERROR([Bandwidthd requires but cannot find libpcap])])])
+ # Optional Library
+-AC_CHECK_FILE(/usr/local/pgsql/lib, LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib")
+-AC_CHECK_FILE(/usr/local/pgsql/include, CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include")
+-AC_CHECK_LIB(pq, PQconnectdb,
+-      [AC_CHECK_LIB(pq,PQexecParams, ,AC_MSG_WARN([libpq exists but is too old... bandwidthd requires support for PQexecParams]))])
++#AC_CHECK_FILE(/usr/local/pgsql/lib, LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib")
++#AC_CHECK_FILE(/usr/local/pgsql/include, CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include")
++#AC_CHECK_LIB(pq, PQconnectdb,
++#     [AC_CHECK_LIB(pq,PQexecParams, ,AC_MSG_WARN([libpq exists but is too old... bandwidthd requires support for PQexecParams]))])
+ # Checks for header files.
+ AC_HEADER_DIRENT
diff --git a/bandwidthd.conf b/bandwidthd.conf
new file mode 100644 (file)
index 0000000..8388584
--- /dev/null
@@ -0,0 +1,53 @@
+####################################################
+# Bandwidthd.conf
+# 
+# Commented out options are here to provide
+# documentation and represent defaults
+
+# Subnets to collect statistics on.  Traffic that 
+# matches none of these subnets will be ignored.
+# Syntax is either IP Subnet Mask or CIDR
+#subnet 10.0.0.0 255.0.0.0
+subnet 192.168.0.0/24
+#subnet 172.16.0.0/12
+
+# Device to listen on
+# Bandwidthd listens on the first device it detects
+# by default.  Run "bandwidthd -l" for a list of 
+# devices. 
+#dev "eth0"
+
+###################################################
+# Options that don't usually get changed
+
+# An interval is 2.5 minutes, this is how many 
+# intervals to skip before doing a graphing run
+#skip_intervals 0
+
+# Graph cutoff is how many k must be transfered by an
+# ip before we bother to graph it
+#graph_cutoff 1024
+
+#Put interface in promiscuous mode to score to traffic
+#that may not be routing through the host machine.
+promiscuous false
+
+#Log data to cdf file htdocs/log.cdf
+output_cdf true
+
+#Read back the cdf file on startup
+recover_cdf true
+
+#Libpcap format filter string used to control what bandwidthd see's
+#Please always include "ip" in the string to avoid strange problems
+#filter "ip"
+
+#Draw Graphs - This default to true to graph the traffic bandwidthd is recording
+#Usually set this to false if you only want cdf output or
+#you are using the database output option.  Bandwidthd will use very little
+#ram and cpu if this is set to false.
+graph true
+
+#Set META REFRESH seconds (default 150, use 0 to disable).
+meta_refresh 150
+
diff --git a/bandwidthd.init b/bandwidthd.init
new file mode 100644 (file)
index 0000000..92296a4
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# bandwidthd   This shell script takes care of starting and stopping
+#              bandwidthd.
+#
+# chkconfig:   2345 60 60
+#
+# description: BandwidthD tracks usage of TCP/IP network subnets and 
+#              builds html files with graphs to display utilization.
+#
+# processname: bandwidthd
+# config:      /etc/bandwidthd.conf
+
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config
+[ -f /etc/sysconfig/bandwidthd ] && . /etc/sysconfig/bandwidthd
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down bandwidthd
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+# Sanity check
+[ -f /etc/bandwidthd.conf ] || exit 0
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       # Check if the service is already running?
+       if [ ! -f /var/lock/subsys/bandwidthd ]; then
+               msg_starting bandwidthd
+               daemon bandwidthd
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bandwidthd
+       else
+               msg_already_running "bandwidthd"
+       fi
+       ;;
+  stop)
+       if [ -f /var/lock/subsys/bandwidthd ]; then
+               msg_stopping "bandwidthd"
+               killproc bandwidthd
+               rm -f /var/lock/subsys/bandwidthd >/dev/null 2>&1
+       else
+               msg_not_running "bandwidthd"
+       fi
+       ;;
+  status)
+       status bandwidthd
+       exit $?
+       ;;
+  restart|force-reload)
+       $0 stop
+       $0 start
+       exit $?
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/bandwidthd.sysconfig b/bandwidthd.sysconfig
new file mode 100644 (file)
index 0000000..1783784
--- /dev/null
@@ -0,0 +1,4 @@
+# Customized setings for bandwidthd
+
+# Define nice level for bandwidthd
+SERVICE_RUN_NICE_LEVEL="+5"
This page took 0.090728 seconds and 4 git commands to generate.