Witam! Przesyłam speca + łatki na ten dość ciekawy programik do rysowania wykresów zużycia sieci. Po poprawkach(jeżeli takie będą konieczne) prosiłbym o umieszczenie tego w CVSie. Pakiet buduje się i działa.
Pozdrawiam. -- Artur Makutunowicz <nail2k%freeco.pl> | GSM +48508912928 GG #4657066 | Linux User #324974 | http://www.nail2k.int.pl Linux 2.6.8 AMD_Athlon(tm)_XP_2000+ PLD Linux
#################################################### # 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
--- ../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
Summary: Network traffic tracking tool Summary(pl): Narz�dzie do �ledzenia ruchu sieciowego Name: bandwidthd Version: 2.0.1 Release: 1 Epoch: 1 License: GPL Group: Networking/Admin Source0: http://dl.sourceforge.net/bandwidthd/%{name}-%{version}.tgz # Source0-md5: aa79aad7bd489fd2cae1f7dc086ca8b6 Source1: %{name}.init Source2: %{name}.sysconfig Source3: %{name}.conf Patch0: %{name}-makefile.patch Patch1: %{name}-pgsql.patch Patch2: %{name}-path.patch URL: http://bandwidthd.sourceforge.net/ BuildRequires: libpng-devel BuildRequires: gd-devel BuildRequires: libpcap-devel BuildRequires: autoconf PreReq: rc-scripts Requires: httpd Requires(post,preun): /sbin/chkconfig BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) %define _htmldir /home/services/httpd/html/bandwidthd %description BandwidthD tracks usage of TCP/IP network subnets and builds html files with graphs to display utilization. Charts are built by individual IPs, and by default display utilization over 2 day, 8 day, 40 day, and 400 day periods. Furthermore, each ip address's utilization can be logged out at intervals of 3.3 minutes, 10 minutes, 1 hour or 12 hours in cdf format, or to a backend database server. HTTP, TCP, UDP, ICMP, VPN, and P2P traffic are color coded. %description -l pl BandwidthD �ledzi u�ycie sieci TCP/IP i buduje pliki html wy�wietlaj�ce ruch sieciowy. Wykresy pokazuj� IP u�ytkownik�w i domy�lnie wy�wietlaj� zu�ycie na przestrzeni 2, 8, 40 i 400 dni. Ponadto udzia� ka�dego adresu IP w ruchu sieciowym mo�e by� zapisywany w przedzia�ach 3.3 minut, 10 minut, 1 godziny lub 12 godzin w formacie cdf, albo zapisywany do bazy danych. Ruch HTTP, TCP, UDP, ICMP, VPN, i P2P jest kodowany w r�nych kolorach. %prep %setup -q %patch0 -p0 %patch1 -p0 %patch2 -p1 %build %{__autoconf} %{__autoheader} %configure %{__make} %install rm -rf $RPM_BUILD_ROOT install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_sbindir},%{_htmldir},/etc/{sysconfig,rc.d/init.d,cron.d}} install bandwidthd $RPM_BUILD_ROOT%{_sbindir} install htdocs/* $RPM_BUILD_ROOT%{_htmldir} install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/bandwidthd install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/bandwidthd install %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir} cat << EOF > $RPM_BUILD_ROOT/etc/cron.d/bandwidthd 0 0 * * * root /bin/kill -HUP \`cat /var/run/bandwidthd.pid\` EOF %clean rm -rf $RPM_BUILD_ROOT %post /sbin/chkconfig --add bandwidthd if [ -f /var/lock/subsys/bandwidthd ]; then /etc/rc.d/init.d/bandwidthd restart 1>&2 else echo "Run \"/etc/rc.d/init.d/bandwidthd start\" to start bandwidthd." fi %preun if [ "$1" = "0" ]; then if [ -f /var/lock/subsys/bandwidthd ]; then /etc/rc.d/init.d/bandwidthd stop 1>&2 fi /sbin/chkconfig --del bandwidthd fi %files %defattr(644,root,root,755) %doc CHANGELOG README TODO %attr(755,root,root) %{_sbindir}/bandwidthd %dir %{_htmldir} %{_htmldir}/* %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/%{name}.conf %attr(755,root,root) /etc/rc.d/init.d/bandwidthd %config(noreplace) %verify(not size mtime md5) %attr(640,root,root) /etc/cron.d/bandwidthd /etc/sysconfig/bandwidthd %define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`) %changelog * %{date} PLD Team <[EMAIL PROTECTED]> All persons listed below can be reached at <cvs_login>@pld-linux.org
# Customized setings for bandwidthd # Define nice level for bandwidthd SERVICE_RUN_NICE_LEVEL="+5"
bandwidthd.init
Description: application/shellscript
--- ../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 -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);
}
_______________________________________________ pld-devel-pl mailing list [email protected] http://lists.pld-linux.org/mailman/listinfo/pld-devel-pl
