diff --git a/.cvsignore b/.cvsignore index e69de29..1e42281 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1 @@ +bandwidthd-2.0.1.tgz diff --git a/bandwidthd b/bandwidthd new file mode 100644 index 0000000..0de4c63 --- /dev/null +++ b/bandwidthd @@ -0,0 +1,76 @@ +#! /bin/bash +# +# bandwidthd +# +# chkconfig: - 90 26 +# description: Activates/Deactivates bandwidthd network traffic monitor +PROGNAME=/usr/sbin/bandwidthd + +# Source function library. +. /etc/init.d/functions + +if [ ! -f /etc/sysconfig/network ]; then + exit 0 +fi + +. /etc/sysconfig/network + +if [ -f /etc/sysconfig/bandwidthd ]; then + . /etc/sysconfig/bandwidthd +fi + + + +# Check that networking is up. +[ "${NETWORKING}" = "no" ] && exit 0 + + + +# See how we were called. +case "$1" in + start) + + #Register to dns + echo -n $"Starting Bandwidthd network traffic monitor: " + daemon $PROGNAME $OPTIONS + RETVAL=$? + echo + + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bandwidthd + exit $RETVAL + ;; + + stop) + echo -n $"Shuting down Bandwidthd network traffic monitor: " + killproc `basename $PROGNAME` + RETVAL=$? + echo + + [ $RETVAL -eq 0 ] && success || failure + echo + + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bandwidthd + exit $RETVAL + ;; + + status) + status $PROGNAME + ;; + + condrestart) + if [ -f /var/lock/subsys/bandwidthd ]; then + $0 stop + $0 start + fi + ;; + + restart|reload) + $0 stop + $0 start + ;; + *) + echo $"Usage: $0 {start|stop|restart|reload|status}" + exit 1 +esac + +exit 0 diff --git a/bandwidthd-destdir.patch b/bandwidthd-destdir.patch new file mode 100644 index 0000000..344f517 --- /dev/null +++ b/bandwidthd-destdir.patch @@ -0,0 +1,98 @@ +diff -ru 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-06-19 03:23:49.000000000 +0200 +@@ -255,22 +255,29 @@ + + openlog("bandwidthd", LOG_CONS, LOG_DAEMON); + +- if (stat("./etc/bandwidthd.conf", &StatBuf)) ++ if (stat("/etc/bandwidthd.conf", &StatBuf)) + { + chdir(INSTALL_DIR); + if (stat("./etc/bandwidthd.conf", &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 /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); + exit(1); + } ++ else ++ { ++ bdconfig_in = fopen("./etc/bandwidthd.conf", "rt"); ++ } + } +- +- bdconfig_in = fopen("./etc/bandwidthd.conf", "rt"); ++ else ++ { ++ bdconfig_in = fopen("/etc/bandwidthd.conf", "rt"); ++ } ++ + if (!bdconfig_in) + { + syslog(LOG_ERR, "Cannot open bandwidthd.conf"); +- printf("Cannot open ./etc/bandwidthd.conf\n"); ++ printf("Cannot open bandwidthd.conf\n"); + exit(1); + } + bdconfig_parse(); +@@ -290,6 +297,7 @@ + (unsigned long) (0-1), (unsigned long long) (0-1)); + exit(1); + */ ++ chdir(INSTALL_DIR); + + for(Counter = 1; Counter < argc; Counter++) + { +diff -ru 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-06-19 03:22:21.000000000 +0200 +@@ -100,6 +100,7 @@ + + #define DB_PGSQL 1 + ++ + struct config + { + char *dev; +Only in bandwidthd-2.0.1.new/etc: bandwidthd.conf.orig +Only in bandwidthd-2.0.1.new/etc: bandwidthd.conf.rej +diff -ru bandwidthd-2.0.1/Makefile.in bandwidthd-2.0.1.new/Makefile.in +--- bandwidthd-2.0.1/Makefile.in 2005-01-11 22:15:49.000000000 +0100 ++++ bandwidthd-2.0.1.new/Makefile.in 2005-06-19 03:32:37.000000000 +0200 +@@ -1,10 +1,13 @@ + exec_prefix = @exec_prefix@ + prefix = @prefix@ ++datadir = @datadir@ ++sbindir = @sbindir@ ++ + 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@ -DINSTALL_DIR="\"$(datadir)/bandwidthd\"" + NONWALLCFLAGS= @CFLAGS@ @CPPFLAGS@ @DEFS@ + + # Debugging stuff +@@ -38,12 +41,13 @@ + rm -f conf.tab.c conf.tab.h conf.l.c config.h.in configure + + install: all +- @INSTALL@ -d $(DESTDIR)$(exec_prefix)/bandwidthd/etc +- @INSTALL@ -d $(DESTDIR)$(exec_prefix)/bandwidthd/htdocs +- @INSTALL@ -m755 -s bandwidthd $(DESTDIR)$(exec_prefix)/bandwidthd +- if [ ! -f $(DESTDIR)$(exec_prefix)/bandwidthd/etc/bandwidthd.conf ] ; then @INSTALL@ -m644 etc/bandwidthd.conf $(DESTDIR)$(exec_prefix)/bandwidthd/etc/ ; fi +- @INSTALL@ -m644 htdocs/legend.gif $(DESTDIR)$(exec_prefix)/bandwidthd/htdocs +- @INSTALL@ -m644 htdocs/logo.gif $(DESTDIR)$(exec_prefix)/bandwidthd/htdocs ++ @INSTALL@ -d $(DESTDIR)/etc ++ @INSTALL@ -d $(DESTDIR)$(datadir)/bandwidthd/htdocs ++ @INSTALL@ -d $(DESTDIR)$(sbindir) ++ @INSTALL@ -m755 bandwidthd $(DESTDIR)$(sbindir)/bandwidthd ++ if [ ! -f $(DESTDIR)/etc/bandwidthd.conf ] ; then @INSTALL@ -m644 etc/bandwidthd.conf $(DESTDIR)/etc/ ; fi ++ @INSTALL@ -m644 htdocs/legend.gif $(DESTDIR)$(datadir)/bandwidthd/htdocs ++ @INSTALL@ -m644 htdocs/logo.gif $(DESTDIR)$(datadir)/bandwidthd/htdocs + + #**** Stuff where -WALL is turned off to reduce the noise in a compile so I can see my own errors ******************* + conf.l.o: conf.l.c diff --git a/bandwidthd-pgsql.patch b/bandwidthd-pgsql.patch new file mode 100644 index 0000000..2b5e82c --- /dev/null +++ b/bandwidthd-pgsql.patch @@ -0,0 +1,13 @@ +--- bandwidthd-2.0.1/configure.in 2005-01-11 22:15:49.000000000 +0100 ++++ configure.in 2008-12-08 17:35:42.000000000 +0100 +@@ -55,8 +55,8 @@ + [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_FILE(/usr/lib, LDFLAGS="$LDFLAGS -L/usr/lib") ++AC_CHECK_FILE(/usr/include/pgsql, CPPFLAGS="$CPPFLAGS -I/usr/include/pgsql") + AC_CHECK_LIB(pq, PQconnectdb, + [AC_CHECK_LIB(pq,PQexecParams, ,AC_MSG_WARN([libpq exists but is too old... bandwidthd requires support for PQexecParams]))]) + diff --git a/bandwidthd.spec b/bandwidthd.spec new file mode 100644 index 0000000..119b3b0 --- /dev/null +++ b/bandwidthd.spec @@ -0,0 +1,133 @@ +# You can compile this without postgresql support by running: +# rpmbuild -ba bandwidthd.spec --without pgsql + +Name: bandwidthd +Version: 2.0.1 +Release: 9%{?dist} +Summary: Tracks network usage and builds html and graphs + +Group: System Environment/Daemons +License: GPL+ +URL: http://bandwidthd.sourceforge.net/ +Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tgz +Source1: %{name} +Patch0: bandwidthd-destdir.patch +Patch1: bandwidthd-pgsql.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: autoconf, gd-devel +%{?!_without_pgsql:BuildRequires: postgresql-devel} +%if "0%{?dist}" == "0.el4" +BuildRequires: libpcap +%else +BuildRequires: libpcap-devel +%endif +Requires(post): /sbin/chkconfig +Requires(preun):/sbin/chkconfig +Requires(preun):/sbin/service + +%description +Bandwidthd is a UNIX daemon/Windows service for graphing the traffic +generated by each machine on several configurable subnets. It is much +easier to configure than MRTG, and provides significantly more useful +information. MRTG only tells you how much bandwidth you are using, +Bandwidthd tells you that, and who is using it. + +Each IP address that has moved any significant volume of traffic has its +own graph. The graphs are color coded to help you figure out at a glance +if your user is surfing the web, or surfing Kazaa. + +Bandwidthd is targeted to run on my routing platforms. It is very low +overhead. Easily graphing small business traffic on a 133Mhz Elan 486 +every 2.5 minutes. My entire ISP (2000-3000 IP addresses across 4 states) +is graphed on a Celeron 450 every 10 minutes. + + +%prep +%setup -q +%patch0 -p1 -b .dest +%patch1 -p0 -b .pgsql + + +%build +cp -af /usr/lib/rpm/config.{sub,guess} . +autoconf +%configure --prefix=%{_prefix} \ + --exec-prefix=%{_prefix} \ + --sysconfdir=%{_sysconfdir} \ + --bindir=%{_bindir} \ + --datadir=%{_var}/www +make %{?_smp_mflags} + + +%install +rm -rf $RPM_BUILD_ROOT +make install DESTDIR=$RPM_BUILD_ROOT +# init script +install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d +install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/ +# install apache configuration +install -d $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d +echo "Alias /%{name} %{_var}/www/%{name}/htdocs" \ + > $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/%{name}.conf +# remove execute bit for gif and sh script without #! +chmod -x phphtdocs/* + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%post +/sbin/chkconfig --add bandwidthd + +%preun +if [ $1 = 0 ]; then + /sbin/service bandwidthd stop > /dev/null 2>&1 + /sbin/chkconfig --del bandwidthd +fi + + +%files +%defattr(-,root,root,-) +%doc README CHANGELOG TODO +%{?!_without_pgsql:%doc phphtdocs} +%config(noreplace) %{_sysconfdir}/%{name}.conf +%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf +%attr(755,root,root) %{_sysconfdir}/rc.d/init.d/%{name} +%{_sbindir}/%{name} +%dir %{_var}/www/%{name} +%{_var}/www/%{name}/* + + +%changelog +* Sun Dec 13 2008 Jan ONDREJ (SAL) - 2.0.1-9 +- updated config.sub and config.guess to build on ppc64 + +* Sat Dec 13 2008 Jan ONDREJ (SAL) - 2.0.1-8 +- removed dependency on gd +- removed one line of autoconf +- removed dependency on libpng-devel +- phphtdocs added for pgsql build, execute bit for gif and sh removed + +* Mon Dec 8 2008 Jan ONDREJ (SAL) - 2.0.1-7 +- changed License to GPL+ + +* Mon Dec 8 2008 Jan ONDREJ (SAL) - 2.0.1-6 +- buildroot macro replaced by RPM_BUILD_ROOT variable +- added autoconf into build-requires +- by default compiled with postgresql support +- conditional build without postgresql (--without pgsql) +- libpng removed from requires + +* Mon Dec 8 2008 Jan ONDREJ (SAL) - 2.0.1-5 +- conditional build for el4 + +* Sun Sep 9 2007 Jan ONDREJ (SAL) - 2.0.1-4 +- updated license and summary +- changed init script permissions + +* Tue Mar 13 2007 Jan ONDREJ (SAL) +- updated from version by Michal Ambroz +- added apache configuration script +- moved into /var/www/bandwidthd +- spec file name typo fixed diff --git a/import.log b/import.log new file mode 100644 index 0000000..de208af --- /dev/null +++ b/import.log @@ -0,0 +1 @@ +bandwidthd-2_0_1-9_fc10:EL-4:bandwidthd-2.0.1-9.fc10.src.rpm:1229253096 diff --git a/sources b/sources index e69de29..97f64f8 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +aa79aad7bd489fd2cae1f7dc086ca8b6 bandwidthd-2.0.1.tgz