Compare commits

...

12 commits

Author SHA1 Message Date
Sami Kerola
92b87896de Version 2.12
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:10:03 +02:00
Sami Kerola
a8eadf78bb Version 2.11
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:09:58 +02:00
Sami Kerola
e4282e8a3d Version 2.10
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:09:52 +02:00
Sami Kerola
573418a9e4 Version 2.9
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:09:43 +02:00
Sami Kerola
40edcd2aba Version 2.8
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:09:34 +02:00
Sami Kerola
625cde6b9c Version 2.7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:09:20 +02:00
Sami Kerola
4f000e7ab6 Version 2.6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:08:48 +02:00
Sami Kerola
8904b5b82c Version 2.5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:08:41 +02:00
Sami Kerola
d28d8feb4f Version 2.4
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:08:34 +02:00
Sami Kerola
609b7faeee Version 2.3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:08:25 +02:00
Sami Kerola
658fe50312 Version 2.2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:08:16 +02:00
Sami Kerola
61b6acf2f5 Version 2.1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 14:07:52 +02:00
27 changed files with 2529 additions and 2779 deletions

View file

@ -1,15 +1,3 @@
2011-01-21 Sami Kerola <kerolasa@iki.fi>
* Autoreconf done & PACKAGE_URL introduced.
* PACKAGE_URL introduced to configure.ac
* Dominic Germain sent xml, and detailed xml, outputs
patch.
* Dominic Germain pointed out include directive bug,
which broke shared network name.
* Anonymous contrib addition snmptest.pl which should
provide some sort of SNMP integration.
* Range statements have dynamic-bootp flag and it no
longer will break analysis.
2009-11-04 Sami Kerola <kerolasa@iki.fi>
* Roar Pettersen pointed out portability bug related to
posixfadvice arguments.

View file

@ -2,4 +2,4 @@
AUTOMAKE_OPTIONS = gnits
SUBDIRS = src man contrib
SUBDIRS = src man

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -136,7 +136,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
@ -186,7 +185,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = gnits
SUBDIRS = src man contrib
SUBDIRS = src man
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@ -250,7 +249,7 @@ distclean-hdr:
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@fail= failcom='exit 1'; \
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
@ -275,7 +274,7 @@ $(RECURSIVE_TARGETS):
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@fail= failcom='exit 1'; \
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
@ -445,8 +444,7 @@ distdir: $(DISTFILES)
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
|| find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
@ -490,17 +488,17 @@ dist dist-all: distdir
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac

11
NEWS
View file

@ -5,17 +5,6 @@ See the end for copying conditions.
Please send dhcpd-pools bug reports to kerolasa@iki.fi.
Version 2.13
* Autoreconf to get ./configure et al up to date.
* PACKAGE_URL introduced to configure.ac
* Dominic Germain sent xml, and detailed xml, outputs patch.
* Dominic Germain pointed out include directive bug, which broke
shared network name.
* Anonymous contrib addition snmptest.pl which should provide
some sort of SNMP integration.
* Range statements have dynamic-bootp flag and it no longer will
break analysis.
Version 2.12
* Dan Thorson fixed formating.

2
README
View file

@ -21,7 +21,7 @@ Source code is pretty printed by using indent command switches.
If you write a patch please use same coding style. In general the
style is copy from Linux kernel.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/CodingStyle;hb=HEAD
http://escher.sourceforge.net/current/etc/linux-coding-style
A dhcpd-pools home page is located at SourceForge.

1
THANKS
View file

@ -14,4 +14,3 @@ Rusty
Fredrik Vöcks
Dan Thorson
Stian Øvrevåge
Dominic Germain

40
TODO
View file

@ -1,22 +1,22 @@
1 Well structured code, with extendible sane architecture.
2 Server, which has analysis in cache for N seconds and will
answer via socket.
3 Configuration file for server.
4 State file, where different ranges, shared networks etc have
unique identifiers (needed for graphs).
5 Support for snmp and munin protocols.
6 SNMP traps when limits get exceeded.
7 Some clever check_dhcpd_pools binary for Nagios & other
monitoring software.
<Todo>
8 Super server support, which will collect analysis from other
dhcpd-pool servers.
9 Nice http view interface on super server, much can be copied
from http://piwik.org/
10 IPv6 support.
11 And some other things perhaps...
* Configuration parser that does not fail.
* Memory allocations to such that recopilation is _never_ needed.
* Bad english to good english translation in all files that
author has touched. Help needed!
* Shared network sorting. Actual data must not be sorted, but perhaps
sorting pointer array might work. That means writing sort
functions and rewrite ouput functions. Don't expect soon.
* All networks analyse.c semantics problem.
* Allocations analysis which is whole new section of output.
* More ./configure options.
When items 1-7 are done v3 can be released. To support rewrite
there should be a design document with nice blue print, which is
a web page. Also getting rid of cvs and taking git in use must
happen.
Version 3.x (not in coming soon)
* Configuration file for this command.
* Convert program to snmp subagent daemon.
* Analysis caching.
* Threshold values -> alarming possibility by snmp traps.
* Template based html page.
</Todo>

10
aclocal.m4 vendored
View file

@ -1,4 +1,4 @@
# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
# generated automatically by aclocal 1.11 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
@ -13,8 +13,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67.69-a1ef66],,
[m4_warning([this file was generated for autoconf 2.67.69-a1ef66.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
[m4_warning([this file was generated for autoconf 2.63.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
@ -34,7 +34,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.11.1], [],
m4_if([$1], [1.11], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -50,7 +50,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.11.1])dnl
[AM_AUTOMAKE_VERSION([1.11])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])

View file

@ -94,9 +94,6 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION

3863
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.63)
AC_INIT([dhcpd-pools],[2.13],[kerolasa@iki.fi],,[http://dhcpd-pools.sourceforge.net/])
AM_INIT_AUTOMAKE(dhcpd-pools, 2.13)
AC_INIT([dhcpd-pools],[1.12],[kerolasa@iki.fi])
AM_INIT_AUTOMAKE(dhcpd-pools, 1.12)
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
@ -29,8 +29,7 @@ AC_CHECK_HEADERS(getopt.h, AC_DEFINE(HAVE_GETOPT_H),
AC_CONFIG_FILES([Makefile
man/Makefile
src/Makefile
contrib/Makefile])
src/Makefile])
AC_ARG_WITH(dhcpd-conf,
[AC_HELP_STRING([--with-dhcpd-conf], [default path of dhcpd.conf])],

View file

@ -1,2 +0,0 @@
contribdir = $(datadir)/dhcpd-pools/
dist_contrib_SCRIPTS = dhcpd-pools.cgi snmptest.pl

View file

@ -1,379 +0,0 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = contrib
DIST_COMMON = $(dist_contrib_SCRIPTS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(contribdir)"
SCRIPTS = $(dist_contrib_SCRIPTS)
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
contribdir = $(datadir)/dhcpd-pools/
dist_contrib_SCRIPTS = dhcpd-pools.cgi snmptest.pl
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu contrib/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu contrib/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-dist_contribSCRIPTS: $(dist_contrib_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(contribdir)" || $(MKDIR_P) "$(DESTDIR)$(contribdir)"
@list='$(dist_contrib_SCRIPTS)'; test -n "$(contribdir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n' \
-e 'h;s|.*|.|' \
-e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) { files[d] = files[d] " " $$1; \
if (++n[d] == $(am__install_max)) { \
print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
else { print "f", d "/" $$4, $$1 } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(contribdir)$$dir'"; \
$(INSTALL_SCRIPT) $$files "$(DESTDIR)$(contribdir)$$dir" || exit $$?; \
} \
; done
uninstall-dist_contribSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(dist_contrib_SCRIPTS)'; test -n "$(contribdir)" || exit 0; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 's,.*/,,;$(transform)'`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(contribdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(contribdir)" && rm -f $$files
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(SCRIPTS)
installdirs:
for dir in "$(DESTDIR)$(contribdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-dist_contribSCRIPTS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-dist_contribSCRIPTS
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am \
install-dist_contribSCRIPTS install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
pdf-am ps ps-am uninstall uninstall-am \
uninstall-dist_contribSCRIPTS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -1,472 +0,0 @@
#!/usr/bin/perl
# <Note from="Sami Kerola">
# This script is anonymous user contribution (due legal
# department did not let the person the get credit because
# they are afraid open source contributions). You know who you
# are, and I am graceful to get this to be part of the
# package.
# </Note>
# 1) modify snmpd.conf and add the following line. Note that the
# last field must match the path/name of the script:
#
# pass_persist .1.3.6.1.4.1.2021.250.255 /root/snmptest.pl
#
# This assumes you've already configured snmpd, i.e. community
# strings, etc.
#
# 2) Install the following script. Note that if you changed the
# OID string above, then you'll need to change the value for
# $root in this file, too. Be sure that $datafile is set to
# the location of the .CSV output from dhcpd-pools. NOTE: if
# you set $dbg to 1 then output will be generated in /tmp.
use strict;
# Version info:
my $SNMPver = "snmp1.0";
my $DHCPver = "dhcp1.0";
my $VERSION = "$SNMPver/$DHCPver";
#
# set $dbg to a non-zero value to get debug output in /tmp
#
my $dbg=0;
#
# Here's an example entry for snmpd.conf:
# pass_persist .1.3.6.1.4.1.2021.250.255 /path/to/this/script.pl
# so in this case $root should be '.1.3.6.1.4.1.2021.250.255'
#
# $root.1.x : shared network name for index x
# $root.2.x : IP range name for index x
# $root.3.x : Range Contained-In for index x
# $root.4.x : Shared Net Stats for index x
# $root.5.x : IP range stats for index x
#
# $root.4.1.x : 'max' value for shared network at index=x
# $root.4.2.x : 'cur' value for shared network at index=x
# $root.4.3.x : 'tou' value for shared network at index=x
#
# $root.5.1.x : 'max' value for IP range at index=x
# $root.5.2.x : 'cur' value for IP range at index=x
# $root.5.3.x : 'tou' value for IP range at index=x
#
# $root must match pass_persis entry in snmpd.conf
#
my $root='.1.3.6.1.4.1.2021.250.255';
#
# $datafile is the location of the .CSV file created by dhcpd-pools.
# NOTE: It is assumed that this file is routinely updated, i.e. at least
# every 5 minutes, by some other process, i.e. cron.
#
my $datafile='/var/lib/dhcp/dhcpstats.csv';
#
# $cachetime determines how long we can cache parse data from $datafile. If
# more than $cachetime has elapsed we'll re-read $datafile, otherwise we'll
# just send back the last-parsed data
#
# Generally 60 seconds seems pretty reasonable, but any positive value is
# permitted.
#
my $cachetime = 60;
#
# global variables for DHCP
#
my %SharedNetwork;
my %RangeName;
my %RangeContained;
my @SNNindex;
my @IPRNindex;
#
# global variables for SNMP
#
my @validoidlist;
########## BEGIN UNIQUE-CODE FOR YOUR SNMP-QUERY NEEDS
#
# ParseDataFile does just that, and stores info in %SharedNetwork for later
# processing.
#
# The routine ParseDataFile is calls at invocation to initialize all
# datasets and also periodically (based on $cachetime).
#
my @where = qw( unknown Ranges SharedNets SumData );
sub ParseDataFile () {
print DBG "ParseDataFile\n" if $dbg;
my $where = 0; # location in file unknown
# used to generate ifIndex-like values for each Shared network
my $shareindex = 1;
# used to generate ifIndex-like values for each Shared network
my $rangeindex = 1;
undef %SharedNetwork;
undef %RangeName;
undef %RangeContained;
undef @SNNindex;
undef @IPRNindex;
@validoidlist = ();
open(IN, $datafile) || return undef;
while (<IN>) {
chomp;
print DBG "...Read: $_\n" if $dbg;
next if /^\s*$/; # skip blank lines
next if /^"shared net name"/; # skip titles
next if /^"name","max","cur"/; # skip titles
if (/^"Ranges/) { $where = 1; next; }
if (/^"Shared/) { $where = 2; next; }
if (/^"Sum of/) { $where = 3; next; }
print DBG "...Found data for @where[$where]: $_\n" if $dbg;
#
# "Ranges:"
# 0 1 2 3 4 5 6 7 8
# "shared net name","1stIP","lastIP","max","cur","%","touch","t+c","t+c %"
#
# "Shared networks:" and "Sum of all ranges:"
# 0 1 2 3 4 5 6
# "name","max","cur","%","touch","t+c","t+c %"
#
my @data = split /,/;
my ($nam, $max, $cur, $tou, $fir);
($nam = @data[0]) =~ s/"//g; # shared net name
($fir = @data[1]) =~ s/"//g if ($where == 1); # Range ID (1st IP)
($max = @data[3]) =~ s/"//g if ($where == 1); # max # of IPs
($max = @data[1]) =~ s/"//g if ($where > 1); # max # of IPs
($cur = @data[4]) =~ s/"//g if ($where == 1); # cur # of IPs
($cur = @data[2]) =~ s/"//g if ($where > 1); # cur # of IPs
($tou = @data[6]) =~ s/"//g if ($where == 1); # touched IP's
($tou = @data[4]) =~ s/"//g if ($where > 1); # touched IP's
print DBG "...idx sh/rg=$shareindex/$rangeindex : nam=$nam : max=$max : cur=$cur : tou=$tou\n" if $dbg;
#
# Summary data for each IP range
#
if ($where == 1) { # Store IP range data
if (defined($RangeName{$fir})) {
print DBG "...WARNING: duplicate name '$fir'\n" if $dbg
}
$IPRNindex[$rangeindex] = $fir;
$RangeName{$fir} = pack("LLLL", $rangeindex, $max, $cur, $tou);
$RangeContained{$fir} = $nam;
push @validoidlist, "$root.2.$rangeindex"; # IP range name
push @validoidlist, "$root.3.$rangeindex"; # Contained In
push @validoidlist, "$root.5.1.$rangeindex"; # range stats
push @validoidlist, "$root.5.2.$rangeindex"; # range stats
push @validoidlist, "$root.5.3.$rangeindex"; # range stats
$rangeindex++;
}
#
# Summary data for each Shared network
#
if ($where == 2) { # Store Shared network summary data
if (defined($SharedNetwork{$nam})) {
print DBG "...WARNING: duplicate name '$nam'\n" if $dbg
}
$SNNindex[$shareindex] = $nam;
$SharedNetwork{$nam} = pack("LLLL", $shareindex, $max, $cur, $tou);
push @validoidlist, "$root.1.$shareindex"; # shared name
push @validoidlist, "$root.4.1.$shareindex"; # shared stats
push @validoidlist, "$root.4.2.$shareindex"; # shared stats
push @validoidlist, "$root.4.3.$shareindex"; # shared stats
$shareindex++;
}
#
# Summary data for everything
#
if ($where == 3) { # Store "All" network summary data
print DBG "...We don't store 'All' info yet!\n" if $dbg;
}
}
close IN;
if ($dbg) {
foreach (sort @validoidlist) { print DBG "ValidOID: $_\n"; }
}
if ($dbg) {
foreach (@IPRNindex) {
print DBG "IP range $_\n";
}
foreach (@SNNindex) {
print DBG "Shared Net $_\n";
}
}
}
#############################################################################
#############################################################################
#############################################################################
# Forward Declarations
#
sub SendReturnNone ();
sub SendReturn($$$);
#
# GetData gets data, but will leverage caching of data if last parse was
# over 60 seconds ago
#
my $lasttime = 0;
sub GetData ($) {
my $oid = shift;
(my $suboid = $oid) =~ s/$root//;
#
# If enough time has elapsed, go fetch fresh data, otherwise use cached
# data
#
print DBG "GetData: Time is: ", time, " : oid $oid->$suboid\n" if $dbg;
if ((time - $lasttime) > $cachetime) {
ParseDataFile();
$lasttime = time;
}
#
# Quick sanity check of OID string:
#
if ( (!($oid =~ /^$root/)) ||
($suboid eq '') ) {
SendReturnNone();
return;
}
#
# split the remaining OID pieces to analyse
#
my @oidlist = split(/\./, $suboid);
###################### EDIT THIS FOR YOUR APPLICATION ######################
#
# If we only get a single value, then barf (we need 2)
#
my $good = 0;
$good = 1 if (($oidlist[1] eq '1') && ($#oidlist == 2)); # shared name
$good = 1 if (($oidlist[1] eq '2') && ($#oidlist == 2)); # ip range name
$good = 1 if (($oidlist[1] eq '3') && ($#oidlist == 2)); # contained in
$good = 1 if (($oidlist[1] eq '4') && ($#oidlist == 3)); # shared-range stats
$good = 1 if (($oidlist[1] eq '5') && ($#oidlist == 3)); # ip-range stats
if (!$good) {
print DBG "oidlistcount = $#oidlist and oidlist1 is ", $oidlist[1], "\n" if $dbg;
SendReturnNone();
return;
}
# $oidlist[1] = 1-5
# $oidlist[2] = index for shared-name or range-name
# or datatype to return
# $oidlist[3] = index for datatype
#
if ($oidlist[1] eq '1') { # looking for name associated with shared net
SendReturn($oid, 'string', $SNNindex[$oidlist[2]]);
return;
}
if ($oidlist[1] eq '2') { # looking for name associated with ip range
print DBG "Responding with IPRNindex[$oidlist[2]]\n" if $dbg;
SendReturn($oid, 'string', $IPRNindex[$oidlist[2]]);
return;
}
if ($oidlist[1] eq '3') { # looking for contained-in info
if (defined($IPRNindex[$oidlist[2]])) { # valid subnet!
my $fir = $IPRNindex[$oidlist[2]];
my $con = $RangeContained{$fir};
my @vals= unpack("LLLL", $SharedNetwork{$con});
print DBG "fir=$fir : con=$con : vals=@vals : vals0=$vals[0]\n" if $dbg;
SendReturn($oid, 'integer', @vals[0]);
return;
} else {
SendReturnNone();
return;
}
}
if ($oidlist[1] eq '4') {
if (defined($SNNindex[$oidlist[3]])) { # valid subnet!
my $nam = $SNNindex[$oidlist[3]];
my @vals= unpack("LLLL", $SharedNetwork{$nam});
print DBG "nam=$nam, vals=@vals, oidlist[2]=$oidlist[2]\n" if $dbg;
SendReturn($oid, 'integer', @vals[$oidlist[2]]);
return;
} else {
print DBG "invalid subnet SNN $oidlist[3]\n" if $dbg;
SendReturnNone();
return;
}
}
if ($oidlist[1] eq '5') {
if (defined($IPRNindex[$oidlist[3]])) { # valid subnet!
my $fir = $IPRNindex[$oidlist[3]];
my @vals= unpack("LLLL", $RangeName{$fir});
print DBG "fir=$fir, vals=@vals, oidlist[2]=", $oidlist[2], "\n" if $dbg;
SendReturn($oid, 'integer', @vals[$oidlist[2]]);
return;
} else {
print DBG "invalid subnet IPRN $oidlist[3]\n" if $dbg;
SendReturnNone();
return;
}
}
################## END EDIT THIS FOR YOUR APPLICATION ######################
}
#############################################################################
#############################################################################
#############################################################################
#
# From here down the routines should NEVER change
#
#
# SNMP-specific routines
#
{ ######## limit scope for some variable
#
# Compare looks at the OID validoid and userquery
# and returns +1 if userquery > validoid
# and returns -1 if userquery < validoid
# and returns 0 if userquery = validoid
#
my @validoid;
my @userquery;
sub Compare () {
my $i=1;
while (($i <= $#validoid) && ($i <= $#userquery)) {
# print DBG "Comparing $validoid[$i] vs $userquery[$i]\n" if $dbg;
if ($userquery[$i] > $validoid[$i]) { return +1; }
if ($userquery[$i] < $validoid[$i]) { return -1; }
$i++;
}
$i--;
my $returnval = 0;
$returnval = +1 if (($i < $#userquery) && ($i == $#validoid));
$returnval = -1 if (($i == $#userquery) && ($i < $#validoid));
return $returnval;
}
#
# FindNext looks through the list of validoid's trying to find the Next
# oid after $oid (aka @userquery)
#
sub FindNext ($) {
my $userqueryoid = shift;
print DBG "FindNext($userqueryoid)\n" if $dbg;
my $next = $validoidlist[0];
@userquery = split (/\./, $userqueryoid);
my $found = 0;
foreach (sort @validoidlist) {
$next = $_;
print DBG "Comparing $userqueryoid vs. $_\n" if $dbg;
@validoid = split (/\./, $_);
my $x = Compare();
if ($x < 0) {
$found = 1;
last;
}
}
if (!$found) { return undef; }
print DBG "Returning $next as next valid OID\n" if $dbg;
return $next;
}
} ######### end scope limit
sub SendReturnNone () {
print "NONE\n";
print DBG "Sent NONE\n" if $dbg;
}
sub SendReturn($$$) {
printf "%s\n%s\n%s\n", shift, shift, shift;
}
my $line=0;
sub Get ($$) {
my $cmd = shift;
my $oid = shift;
GetData($oid);
$line = 0;
}
sub GetNext ($$) {
my $cmd = shift;
my $oid = shift;
$oid = FindNext($oid);
if (defined($oid)) {
GetData($oid);
} else {
SendReturnNone();
}
$line = 0;
}
sub Set ($$$) {
my $cmd = shift;
my $oid = shift;
my $tv = shift;
print "not-writable\n"; # we don't support snmpset
print DBG "Sent not-writable\n" if $dbg;
$line = 0;
}
sub Pong {
print "PONG\n";
print DBG "PONG Sent\n" if $dbg;
$line = 0;
}
################################## START ##################################
#
# Main
#
select((select(STDOUT), $| = 1)[0]);
if ($dbg) {
open(DBG, ">/tmp/snmp.dbg") || die ("Can't open debug!");
select((select(DBG), $| = 1)[0]);
print DBG "Version $VERSION\n";
}
# Initialize Data
ParseDataFile();
my $cmd;
my $oid;
my $tv;
while (<STDIN>) {
$line++;
chomp;
s/ //g;
tr/A-Z/a-z/;
printf DBG "%3d '%s'\n", $line, $_ if $dbg;
last if ($_ eq '');
$cmd = $_ if ($line == 1);
$oid = $_ if ($line == 2);
$tv = $_ if ($line == 3);
Pong() if ($cmd eq 'ping');
Get($cmd, $oid) if (($cmd eq 'get') && ($line == 2));
GetNext($cmd, $oid) if (($cmd eq 'getnext') && ($line == 2));
Set($cmd, $oid, $tv) if (($cmd eq 'set') && ($line == 3));
}
print DBG "Clean Exit\n" if $dbg;
close DBG if $dbg;
exit 0;

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -106,7 +106,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@

View file

@ -5,12 +5,12 @@
.\" Add'l ontributions by:
.\" Dan Thorson
.\"
.TH DHCPD-POOLS 1 "Jan 21 2011" "SourceForge" "ISC dhcpd analysis"
.TH DHCPD-POOLS 1 "Feb 11 2009" "SourceForge" "ISC dhcpd analysis"
.SH NAME
dhcpd-pools \- ISC dhcpd pools usage analysis
.SH SYNOPSIS
.B dhcpd-pools
[-c file] [-l file] [-f thcxX] [-s nimcptTe] [-r] [-o file] [-L nr] [-v] [-h]
[-c file] [-l file] [-f thHc] [-s nimcptTe] [-r] [-o file] [-L nr] [-v] [-h]
.SH DESCRIPTION
The program analyses ISC dhcpd shared network and pool usage and outputs the
results in a user selectable format.
@ -71,11 +71,9 @@ Sort results in reverse order.
.TP
.I "\-f, \-\-format"
Output format. Currently there is text, html, full-html and csv
(comma-separated values). Default is text. Standard html (h) outputs only
the HTML tables, and is useful for embeding more complex web pages.
(comma-separated values). Default is text. Standard html (h) outputs only
the HTML tables, and is useful for embeding more complex web pages.
Full-html (H) provides complete HTML headers, etc., including in-line CSS.
Output format xml (x) is similar to the dhcpstatus Perl module output. The
extended xml (X) format will print ethernet address details.
.TP
.I "\-o, \-\-output"
File where output is written. Default is stdout.

View file

@ -3,6 +3,6 @@
bin_PROGRAMS = dhcpd-pools
AC_PROG_RANLIB = resolv
dhcpd_pools_SOURCES = dhcpd-pools.h defaults.h dhcpd-pools.c analyze.c getdata.c getopt1.c getopt.c other.c sort.c output.c getopt.h
dhcpd_pools_SOURCES = dhcpd-pools.c analyze.c getdata.c getopt1.c getopt.c other.c sort.c output.c getopt.h
INCLUDES = -I. -I..

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -100,7 +100,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
@ -150,7 +149,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AC_PROG_RANLIB = resolv
dhcpd_pools_SOURCES = dhcpd-pools.h defaults.h dhcpd-pools.c analyze.c getdata.c getopt1.c getopt.c other.c sort.c output.c getopt.h
dhcpd_pools_SOURCES = dhcpd-pools.c analyze.c getdata.c getopt1.c getopt.c other.c sort.c output.c getopt.h
INCLUDES = -I. -I..
all: all-am

View file

@ -81,7 +81,8 @@ int do_counting(void)
/* Walk through ranges */
for (k = 0; k < num_ranges; k++) {
/* Count IPs in use */
for (; range_p->last_ip > leases[i]
for (;
range_p->last_ip > leases[i]
&& (unsigned long) i < num_leases; i++) {
if (range_p->first_ip > leases[i]) {
continue;
@ -94,7 +95,8 @@ int do_counting(void)
}
/* Count touched IPs */
for (; range_p->last_ip > touches[j]
for (;
range_p->last_ip > touches[j]
&& (unsigned long) j < num_touches; j++) {
if (range_p->first_ip > touches[j]) {
continue;

View file

@ -29,7 +29,7 @@ static const int SHARED_NETWORKS_NAMES = 24576;
static const int SHARED_NETWORKS = 1024;
/* Maximum number of ranges */
static const unsigned int RANGES = 65536;
static const int RANGES = 65536;
/* Merge sort split size */
static const int MIN_MERGE_SIZE = 8;

View file

@ -42,7 +42,7 @@ extern char *malloc();
int main(int argc, char **argv)
{
int c, sorts = 0;
int c, i, sorts = 0;
int option_index = 0;
char *tmp;
struct range_t *tmp_ranges;
@ -110,7 +110,8 @@ int main(int argc, char **argv)
} else {
eprintf
("main: for argument configuration file parameter not set");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
break;
case 'l':
@ -121,7 +122,8 @@ int main(int argc, char **argv)
} else {
eprintf
("main: for argument lease file parameter not set");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
break;
case 'f':
@ -132,7 +134,8 @@ int main(int argc, char **argv)
} else {
eprintf
("main: for argument output format parameter not set");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
break;
case 's':
@ -152,7 +155,8 @@ int main(int argc, char **argv)
} else {
eprintf
("main: for argument sort order parameter not set");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
break;
case 'r':
@ -167,7 +171,8 @@ int main(int argc, char **argv)
} else {
eprintf
("main: for argument output file parameter not set");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
break;
case 'L':
@ -180,7 +185,8 @@ int main(int argc, char **argv)
eprintf
("main: output mask %s illegal",
argv[optind]);
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
if (optarg[1] >= '0' && optarg[1] < '8') {
config.output_limit[1] =
@ -189,12 +195,14 @@ int main(int argc, char **argv)
eprintf
("main: output mask %s illegal",
optarg);
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
} else {
eprintf
("main: for argument output mask parameter not set");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
break;
case 'v':
@ -203,9 +211,11 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
case 'h':
/* Print help */
usage(EXIT_SUCCESS);
print_help();
exit(EXIT_SUCCESS);
default:
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
}
@ -221,12 +231,6 @@ int main(int argc, char **argv)
output_analysis = output_html;
fullhtml = true;
break;
case 'x':
output_analysis = output_xml;
break;
case 'X':
output_analysis = output_xml;
break;
case 'c':
output_analysis = output_csv;
break;
@ -236,20 +240,15 @@ int main(int argc, char **argv)
break;
default:
eprintf("main: unknown ouput format");
usage(EXIT_FAILURE);
print_help();
exit(EXIT_FAILURE);
}
/* Do the job */
prepare_memory();
parse_config(true, config.dhcpdconf_file, shared_net_names,
parse_config(config.dhcpdconf_file, shared_net_names,
shared_net_names + strlen(shared_net_names) + 1,
shared_networks);
if ((config.output_format[0] == 'x')
|| (config.output_format[0] == 'X')) {
printf("<dhcpstatus>\n");
};
parse_leases();
prepare_data();
do_counting();
@ -263,11 +262,6 @@ int main(int argc, char **argv)
free(tmp_ranges);
output_analysis();
if ((config.output_format[0] == 'x')
|| (config.output_format[0] == 'X')) {
printf("</dhcpstatus>\n");
};
exit(EXIT_SUCCESS);
}

View file

@ -91,7 +91,7 @@ unsigned long int num_backups;
/* Function prototypes */
int prepare_memory (void);
int parse_leases (void);
char * parse_config (int, char *, char *, char *, struct shared_network_t *);
char * parse_config (char *, char *, char *, struct shared_network_t *);
int nth_field (int n, char *dest, const char *src);
int prepare_data (void);
int do_counting (void);
@ -100,7 +100,7 @@ void flip_ranges(struct range_t *ranges, struct range_t *tmp_ranges);
void *safe_malloc (size_t size);
void eprintf (char *, ...);
void print_version (void);
void usage (int status);
void print_help (void);
/* qsort required functions... */
/* ...for ranges and... */
int intcomp (const void *x, const void *y);
@ -122,7 +122,6 @@ void mergesort_ranges (struct range_t *orig, int size, struct range_t *temp);
int (*output_analysis) (void);
int output_txt (void);
int output_html (void);
int output_xml (void);
int output_csv (void);
/* Memory release, file closing etc */
void clean_up (void);

View file

@ -1,5 +1,5 @@
/*
** Copyright (C) 2006- Sami Kerola < >
** Copyright (C) 2006- Sami Kerola <kerolasa@iki.fi>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -48,8 +48,6 @@ extern char *malloc();
#define _XOPEN_SOURCE 600
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <limits.h>
#include "dhcpd-pools.h"
#include "defaults.h"
@ -59,13 +57,12 @@ extern char *malloc();
int parse_leases(void)
{
FILE *dhcpd_leases;
char *line, *ipstring, *macstring, *macstring2;
char *line, *ipstring;
struct in_addr inp;
struct stat lease_file_stats;
unsigned long leasesmallocsize;
unsigned long touchesmallocsize;
unsigned long backupsmallocsize;
int sw_active_lease = 0;
num_touches = num_leases = num_backups = 0;
@ -80,14 +77,14 @@ int parse_leases(void)
eprintf("parse_leases: fadvise:");
exit(EXIT_FAILURE);
}
#endif /* POSIX_FADV_NOREUSE */
#endif /* POSIX_FADV_NOREUSE */
#ifdef POSIX_FADV_SEQUENTIAL
posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_SEQUENTIAL);
if (errno) {
eprintf("parse_leases: fadvise:");
exit(EXIT_FAILURE);
}
#endif /* POSIX_FADV_SEQUENTIAL */
#endif /* POSIX_FADV_SEQUENTIAL */
/* I found out that there's one lease address per 300 bytes in
* dhcpd.leases file. Malloc is little bit pessimistic and uses
* 250. If someone has higher density in lease file I'm
@ -96,17 +93,16 @@ int parse_leases(void)
eprintf("parse_leases: %s:", config.dhcpdlease_file);
exit(EXIT_FAILURE);
}
leasesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
leasesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
touchesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
backupsmallocsize = (lease_file_stats.st_size / 120) + MAXLEN - 2;
leases = safe_malloc(sizeof(long int) * leasesmallocsize);
leases =
safe_malloc(sizeof(long int) * leasesmallocsize);
touches =
safe_malloc((size_t) sizeof(long int) * touchesmallocsize);
line = safe_malloc(sizeof(long int) * MAXLEN);
ipstring = safe_malloc(sizeof(long int) * MAXLEN);
macstring = safe_malloc(sizeof(long int) * MAXLEN);
macstring2 = safe_malloc(sizeof(long int) * MAXLEN);
while (!feof(dhcpd_leases)) {
fgets(line, MAXLEN, dhcpd_leases);
@ -115,49 +111,29 @@ int parse_leases(void)
strncpy(ipstring, line, (size_t) MAXLEN);
nth_field(2, ipstring, ipstring);
inet_aton(ipstring, &inp);
sw_active_lease = 0;
}
/* Copy IP to correct array */
else if (strstr(line, "binding state active")) {
leases[num_leases] = htonl(inp.s_addr);
num_leases++;
sw_active_lease = 1;
} else if (strstr(line, " binding state free")) {
touches[num_touches] = htonl(inp.s_addr);
num_touches++;
} else if (strstr(line, " binding state backup")) {
if (num_backups == 0) {
backups =
safe_malloc((size_t) sizeof(long int) *
backupsmallocsize);
safe_malloc((size_t) sizeof(long int) * backupsmallocsize);
}
backups[num_backups] = htonl(inp.s_addr);
num_backups++;
}
if ((sw_active_lease == 1)
&& (strstr(line, "hardware ethernet"))) {
nth_field(3, macstring, line);
macstring[strlen(macstring) - 1] = '\0';
if (config.output_format[0] == 'X') {
printf
("<active_lease>\n\t<ip>%s</ip>\n\t<macaddress>%s</macaddress>\n</active_lease>\n",
ipstring, macstring);
};
}
if ((num_leases > leasesmallocsize) ||
if ((num_leases > leasesmallocsize) ||
(num_touches > touchesmallocsize) ||
(num_backups > backupsmallocsize)) {
printf("WARNING: running out of memory\n");
printf("\tlease/touch/backup = %lu/%lu/%lu\n",
leasesmallocsize, touchesmallocsize,
backupsmallocsize);
printf("\tlease/touch/backup = %lu/%lu/%lu\n",
num_leases, num_touches, num_backups);
printf
("Code should realloc() and init new memory, but no time to write that now!\n");
printf("\tlease/touch/backup = %lu/%lu/%lu\n", leasesmallocsize, touchesmallocsize, backupsmallocsize);
printf("\tlease/touch/backup = %lu/%lu/%lu\n", num_leases, num_touches, num_backups);
printf("Code should realloc() and init new memory, but no time to write that now!\n");
exit(EXIT_FAILURE);
}
}
@ -212,15 +188,14 @@ int is_interesting_config_clause(char *s)
/* TODO: This spagetti monster function need to be rewrote at
* least ones. */
char *parse_config(int is_include, char *config_file,
char *current_shared_name,
char *parse_config(char *config_file, char *current_shared_name,
char *next_free_shared_name,
struct shared_network_t *shared_p)
{
FILE *dhcpd_config;
int i = 0, newclause = true, argument = false, comment =
false, braces = 0, quote = false;
char *word, c;
char word[MAXLEN], c;
int braces_shared = 1000;
struct in_addr inp;
struct range_t *range_p;
@ -228,12 +203,9 @@ char *parse_config(int is_include, char *config_file,
char *last_shared_name;
last_shared_name = SHARED_NETWORKS_NAMES + shared_net_names;
word = safe_malloc(sizeof(char) * MAXLEN);
if (is_include) {
/* Default place holder for ranges "All networks". */
shared_p->name = current_shared_name;
}
/* Default place holder for ranges "All networks".
* If this is include file basicly nothing happens. */
shared_p->name = current_shared_name;
/* Open configuration file */
dhcpd_config = fopen(config_file, "r");
@ -247,14 +219,14 @@ char *parse_config(int is_include, char *config_file,
eprintf("parse_config: fadvise:");
exit(EXIT_FAILURE);
}
#endif /* POSIX_FADV_NOREUSE */
#endif /* POSIX_FADV_NOREUSE */
#ifdef POSIX_FADV_SEQUENTIAL
posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_SEQUENTIAL);
if (errno) {
eprintf("parse_config: fadvise:");
exit(EXIT_FAILURE);
}
#endif /* POSIX_FADV_SEQUENTIAL */
#endif /* POSIX_FADV_SEQUENTIAL */
/* Very hairy stuff begins. */
while (!feof(dhcpd_config)) {
c = fgetc(dhcpd_config);
@ -427,17 +399,13 @@ char *parse_config(int is_include, char *config_file,
range_p = ranges + num_ranges;
inet_aton(word, &inp);
range_p->first_ip = htonl(inp.s_addr) - 1;
if (range_p->first_ip == UINT_MAX) {
/* word was not ip, try again */
break;
}
argument = 2;
break;
case 4:
/* printf ("include file: %s\n", word); */
argument = 0;
next_free_shared_name =
parse_config(false, word, current_shared_name,
parse_config(word, current_shared_name,
next_free_shared_name,
shared_p);
newclause = true;
@ -449,6 +417,5 @@ char *parse_config(int is_include, char *config_file,
}
}
}
free(word);
return next_free_shared_name;
}

View file

@ -425,7 +425,8 @@ const char *optstring;
strlen(orig_str);
if (nonoption_flags_max_len < argc)
nonoption_flags_max_len = argc;
__getopt_nonoption_flags = (char *)
__getopt_nonoption_flags =
(char *)
malloc(nonoption_flags_max_len);
if (__getopt_nonoption_flags == NULL)
nonoption_flags_max_len = -1;
@ -700,7 +701,8 @@ int long_only;
_
("%s: option `--%s' doesn't allow an argument\n"),
argv[0],
pfound->name);
pfound->
name);
else
/* +option or -option */
fprintf(stderr,
@ -710,7 +712,8 @@ int long_only;
argv[optind
-
1][0],
pfound->name);
pfound->
name);
}
nextchar += strlen(nextchar);
@ -884,7 +887,8 @@ int long_only;
else {
if (print_errors)
fprintf(stderr, _("\
%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name);
%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->
name);
nextchar +=
strlen(nextchar);

View file

@ -76,7 +76,7 @@ void eprintf(char *fmt, ...)
void flip_ranges(struct range_t *ranges, struct range_t *tmp_ranges)
{
unsigned int i = num_ranges - 1, j;
int i = num_ranges - 1, j;
for (j = 0; j < num_ranges; j++) {
*(tmp_ranges + j) = *(ranges + i);
@ -92,9 +92,7 @@ void clean_up(void)
{
int ret;
if (errno) {
eprintf
("clean_up: errno (%d) set but not checked in correct place; if this is repeatable send strace output as a bug report:",
errno);
eprintf("clean_up: errno (%d) set but not checked in correct place; if this is repeatable send strace output as a bug report:", errno);
}
/* Just in case there something in buffers */
ret = fflush(stdout);
@ -116,8 +114,6 @@ void clean_up(void)
void print_version(void)
{
fprintf(stdout, "%s\n", PACKAGE_STRING);
fprintf(stdout,
"Written by Sami Kerola.\nXML support by Dominic Germain, Sogetel inc.\n\n");
fprintf(stdout,
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
fprintf(stdout,
@ -126,31 +122,25 @@ void print_version(void)
"There is NO WARRANTY, to the extent permitted by law.\n");
}
void usage(int status)
void print_help(void)
{
FILE *out;
out = status != 0 ? stderr : stdout;
fprintf(out, "\
Usage: %s [OPTIONS]\n", program_name);
fprintf(out, "\
fprintf(stdout, "Usage: %s [OPTIONS]\n", program_name);
fprintf(stdout, "\
This is ISC dhcpd pools usage analyzer.\n\
\n");
fprintf(out, "\
fprintf(stdout, "\
-c --config file path to the dhcpd.conf file\n\
-l --leases file path to the dhcpd.leases file\n\
-f --format [thcxX] output format\n");
fprintf(out, "\
-f --format [thc] output format\n");
fprintf(stdout, "\
t for text\n\
h for html table\n\
H for full html page\n\
x for xml\n\
X for xml with active lease details\n\
c for comma separated values\n");
/* TODO
s for snmp\n");
*/
fprintf(out, "\
fprintf(stdout, "\
-s --sort [nimcptTe] sort ranges by\n\
n name\n\
i IP\n\
@ -160,15 +150,12 @@ This is ISC dhcpd pools usage analyzer.\n\
t touched\n\
T t+c\n\
e t+c perc\n");
fprintf(out, "\
fprintf(stdout, "\
-r --reverse reverse order sort\n\
-o --output file output into a file\n\
-L --limit nr output limit mask 77 - 00\n\
-v --version version information\n\
-h --help this screen\n\
\n\
Report bugs to <%s>\n\
Homepage: %s\n", PACKAGE_BUGREPORT, PACKAGE_URL);
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
Report bugs to <%s>\n", PACKAGE_BUGREPORT);
}

View file

@ -184,119 +184,14 @@ int output_txt(void)
return 0;
}
int output_xml(void)
void html_header(FILE *f)
{
unsigned int i;
struct in_addr first, last;
struct range_t *range_p;
struct shared_network_t *shared_p;
int ret;
FILE *outfile;
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
eprintf("output_xml: %s:", config.output_file);
exit(EXIT_FAILURE);
}
} else {
outfile = stdout;
}
range_p = ranges;
shared_p = shared_networks;
if (config.output_limit[1] & output_limit_bit_1) {
for (i = 0; i < num_ranges; i++) {
first.s_addr = ntohl(range_p->first_ip + 1);
last.s_addr = ntohl(range_p->last_ip - 1);
fprintf(outfile, "<subnet>\n");
if (range_p->shared_net) {
fprintf(outfile,
"\t<location>%s</location>\n",
range_p->shared_net->name);
} else {
fprintf(outfile,
"\t<location></location>\n");
}
fprintf(outfile, "\t<network></network>\n");
fprintf(outfile, "\t<netmask></netmask>\n");
fprintf(outfile, "\t<range>%s ", inet_ntoa(first));
fprintf(outfile, "- %s</range>\n",
inet_ntoa(last));
fprintf(outfile, "\t<gateway></gateway>\n");
fprintf(outfile, "\t<defined>%lu</defined>\n",
range_p->last_ip - range_p->first_ip - 1);
fprintf(outfile, "\t<used>%lu</used>\n",
range_p->count);
fprintf(outfile, "\t<free>%lu</free>\n",
range_p->last_ip - range_p->first_ip - 1 -
range_p->count);
range_p++;
fprintf(outfile, "</subnet>\n");
}
}
if (config.output_limit[1] & output_limit_bit_2) {
for (i = 0; i < num_shared_networks; i++) {
shared_p++;
fprintf(outfile, "<shared-network>\n");
fprintf(outfile, "\t<location>%s</location>\n",
shared_p->name);
fprintf(outfile, "\t<defined>%lu</defined>\n",
shared_p->available);
fprintf(outfile, "\t<used>%lu</used>\n",
shared_p->used);
fprintf(outfile, "\t<free>%lu</free>\n",
shared_p->available - shared_p->used);
fprintf(outfile, "</shared-network>\n");
}
}
if (config.output_limit[0] & output_limit_bit_3) {
fprintf(outfile, "<summary>\n");
fprintf(outfile, "\t<location>%s</location>\n",
shared_networks->name);
fprintf(outfile, "\t<defined>%lu</defined>\n",
shared_networks->available);
fprintf(outfile, "\t<used>%lu</used>\n",
shared_networks->used);
fprintf(outfile, "\t<free>%lu</free>\n",
shared_networks->available -
shared_networks->used);
fprintf(outfile, "</summary>\n");
}
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
eprintf("output_xml: fflush:");
}
} else {
ret = fclose(outfile);
if (ret) {
eprintf("output_xml: fclose:");
}
}
return 0;
}
void html_header(FILE * f)
{
fprintf(f,
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \n");
fprintf(f, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \n");
fprintf(f, " \"http://www.w3.org/TR/html4/strict.dtd\">\n");
fprintf(f, "<html>\n");
fprintf(f, "<head>\n");
fprintf(f, "<meta http-equiv=\"Content-Type\" ");
fprintf(f, "content=\"text/html; charset=iso-8859-1\">\n");
fprintf(f, "content=\"text/html; charset=iso-8859-1\">\n");
fprintf(f, " <title>ISC dhcpd stats</title>\n");
fprintf(f, " <style TYPE=\"text/css\">\n");
fprintf(f, " <!--\n");
@ -348,12 +243,12 @@ void html_header(FILE * f)
fprintf(f, "<body>\n");
}
void html_footer(FILE * f)
void html_footer(FILE *f)
{
fprintf(f, "<p><br></p>\n");
fprintf(f, "<hr>\n");
fprintf(f, "<p class=created>\nData generated by ");
fprintf(f, "<a href=\"%s\">", PACKAGE_URL);
fprintf(f, "<a href=\"http://dhcpd-pools.sourceforge.net/\">");
fprintf(f, "dhcpd-pools</a>.\n</p>\n");
fprintf(f, "<p class=updated>\n");
@ -365,44 +260,35 @@ void html_footer(FILE * f)
fprintf(f, "</html>\n");
}
void newrow(FILE * f)
{
fprintf(f, "<tr>\n");
}
void newrow(FILE *f) { fprintf(f, "<tr>\n"); }
void endrow(FILE *f) { fprintf(f, "</tr>\n\n"); }
void endrow(FILE * f)
{
fprintf(f, "</tr>\n\n");
}
void output_line(FILE * f, char *type, char *class, char *text)
void output_line(FILE *f, char *type, char *class, char *text)
{
fprintf(f, " <%s class=%s>%s</%s>\n", type, class, text, type);
}
void output_long(FILE * f, char *type, unsigned long unlong)
void output_long(FILE *f, char *type, unsigned long unlong)
{
fprintf(f, " <%s class=ralign>%lu</%s>\n", type, unlong, type);
}
void output_float(FILE * f, char *type, float fl)
void output_float(FILE *f, char *type, float fl)
{
fprintf(f, " <%s class=ralign>%.3f</%s>\n", type, fl, type);
}
void table_start(FILE * f)
void table_start(FILE *f)
{
fprintf(f, "<table width=\"75%%\" ");
fprintf(f, "class=\"dhcpd-pools\" ");
fprintf(f, "summary=\"ISC dhcpd pool usage report\">\n");
fprintf(f, "class=\"dhcpd-pools\" ");
fprintf(f, "summary=\"ISC dhcpd pool usage report\">\n");
}
void table_end(FILE * f)
void table_end(FILE *f)
{
fprintf(f, "</table>\n");
}
void newsection(FILE * f, char *title)
void newsection(FILE *f, char *title)
{
newrow(f);
output_line(f, "td", "calign", "&nbsp;");
@ -435,9 +321,7 @@ int output_html(void)
range_p = ranges;
shared_p = shared_networks;
if (fullhtml) {
html_header(outfile);
}
if (fullhtml) { html_header(outfile); }
table_start(outfile);
if (config.output_limit[0] & output_limit_bit_1) {
newsection(outfile, "Ranges:");
@ -464,41 +348,26 @@ int output_html(void)
newrow(outfile);
if (range_p->shared_net) {
output_line(outfile, "td", "calign",
range_p->shared_net->name);
output_line(outfile, "td", "calign", range_p->shared_net->name);
} else {
output_line(outfile, "td", "calign",
"not_defined");
output_line(outfile, "td", "calign", "not_defined");
}
output_line(outfile, "td", "calign",
inet_ntoa(first));
output_line(outfile, "td", "calign",
inet_ntoa(last));
output_long(outfile, "td",
range_p->last_ip - range_p->first_ip -
1);
output_long(outfile, "td", range_p->count);
output_float(outfile, "td",
(float) (100 * range_p->count) /
(range_p->last_ip -
range_p->first_ip - 1));
output_long(outfile, "td", range_p->touched);
output_long(outfile, "td",
range_p->touched + range_p->count);
output_float(outfile, "td",
(float) (100 *
(range_p->touched +
range_p->count)) /
(range_p->last_ip -
range_p->first_ip - 1));
output_line(outfile, "td", "calign", inet_ntoa(first));
output_line(outfile, "td", "calign", inet_ntoa(last));
output_long(outfile, "td", range_p->last_ip - range_p->first_ip - 1);
output_long(outfile, "td", range_p->count);
output_float(outfile, "td", (float) (100 * range_p->count) /
(range_p->last_ip - range_p->first_ip - 1));
output_long(outfile, "td", range_p->touched);
output_long(outfile, "td", range_p->touched + range_p->count);
output_float(outfile, "td", (float) (100 *
(range_p->touched +
range_p->count)) /
(range_p->last_ip - range_p->first_ip - 1));
if (num_backups > 0) {
output_long(outfile, "td",
range_p->backups);
output_float(outfile, "td",
(float) (100 *
range_p->backups) /
(range_p->last_ip -
range_p->first_ip - 1));
output_long(outfile, "td", range_p->backups);
output_float(outfile, "td", (float) (100 * range_p->backups) /
(range_p->last_ip - range_p->first_ip - 1));
}
endrow(outfile);
range_p++;
@ -527,28 +396,21 @@ int output_html(void)
for (i = 0; i < num_shared_networks; i++) {
shared_p++;
newrow(outfile);
output_line(outfile, "td", "calign",
shared_p->name);
output_long(outfile, "td", shared_p->available);
output_long(outfile, "td", shared_p->used);
output_float(outfile, "td",
(float) (100 * shared_p->used) /
shared_p->available);
output_long(outfile, "td", shared_p->touched);
output_long(outfile, "td",
shared_p->touched + shared_p->used);
output_float(outfile, "td",
(float) (100 *
(shared_p->touched +
shared_p->used)) /
shared_p->available);
output_line(outfile, "td", "calign", shared_p->name);
output_long(outfile, "td", shared_p->available);
output_long(outfile, "td", shared_p->used);
output_float(outfile, "td", (float) (100 * shared_p->used) /
shared_p->available);
output_long(outfile, "td", shared_p->touched);
output_long(outfile, "td", shared_p->touched + shared_p->used);
output_float(outfile, "td", (float) (100 *
(shared_p->touched +
shared_p->used)) /
shared_p->available);
if (num_backups > 0) {
output_long(outfile, "td",
shared_p->backups);
output_float(outfile, "td",
(float) (100 *
shared_p->backups) /
shared_p->available);
output_long(outfile, "td", shared_p->backups);
output_float(outfile, "td", (float) (100 * shared_p->backups) /
shared_p->available);
}
endrow(outfile);
@ -574,36 +436,26 @@ int output_html(void)
}
if (config.output_limit[1] & output_limit_bit_3) {
newrow(outfile);
output_line(outfile, "td", "calign",
shared_networks->name);
output_long(outfile, "td", shared_networks->available);
output_long(outfile, "td", shared_networks->used);
output_float(outfile, "td",
(float) (100 * shared_networks->used) /
shared_networks->available);
output_long(outfile, "td", shared_networks->touched);
output_long(outfile, "td",
shared_networks->touched +
shared_networks->used);
output_float(outfile, "td",
(float) (100 *
(shared_networks->touched +
shared_networks->used)) /
shared_networks->available);
output_line(outfile, "td", "calign", shared_networks->name);
output_long(outfile, "td", shared_networks->available);
output_long(outfile, "td", shared_networks->used);
output_float(outfile, "td", (float) (100 * shared_networks->used) /
shared_networks->available);
output_long(outfile, "td", shared_networks->touched);
output_long(outfile, "td", shared_networks->touched + shared_networks->used);
output_float(outfile, "td", (float) (100 *
(shared_networks->touched +
shared_networks->used)) /
shared_networks->available);
if (num_backups > 0) {
output_long(outfile, "td",
shared_networks->backups);
output_float(outfile, "td",
(float) (100 *
shared_networks->backups) /
shared_networks->available);
output_long(outfile, "td", shared_networks->backups);
output_float(outfile, "td", (float) (100 * shared_networks->backups) /
shared_networks->available);
}
endrow(outfile);
}
table_end(outfile);
if (fullhtml) {
html_footer(outfile);
}
if (fullhtml) { html_footer(outfile); }
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
@ -614,6 +466,7 @@ int output_html(void)
if (ret) {
eprintf("output_html: fclose:");
}
}
return 0;
}

View file

@ -118,7 +118,8 @@ void field_selector(char c)
default:
eprintf("field_selector: unknown sort order: %c",
config.sort[0]);
usage(EXIT_FAILURE);
print_help;
exit(EXIT_FAILURE);
}
}
@ -165,6 +166,7 @@ int get_order(struct range_t *left, struct range_t *right)
void mergesort_ranges(struct range_t *orig, int size, struct range_t *temp)
{
int left, right, i;
long int val;
struct range_t hold;
if (size < MIN_MERGE_SIZE) {