Commit graph

95 commits

Author SHA1 Message Date
Sami Kerola
37563d8d59 build-sys: create only xz compressed distribution package
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-26 10:10:40 +02:00
Sami Kerola
7600d32b89 contrib: add nagios.conf example
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-26 10:06:27 +02:00
Sami Kerola
a05d793378 docs: add note how to limit alarming scope
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-24 16:51:33 +02:00
Sami Kerola
dd5bc03f12 docs: add examples to manual page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-24 16:41:22 +02:00
Sami Kerola
42dd80aeac alarming: make native nagios support to dhcpd-pools
This commit makes integrating the command with nagios much easier.

$ dhcpd-pools -c dhcpd.conf -l dhcpd.leases --critical 80 --warning 75
CRITICAL: dhcpd-pools: Ranges; crit: 14 warn: 22 ok: 220 Shared nets; crit: 1 warn: 0 ok: 4

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-24 16:40:25 +02:00
Sami Kerola
5a307703c9 Prepare release v2.18
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-13 22:51:22 +02:00
Sami Kerola
8f3d8ceae7 analyze: a lot of IP counts being missed
Fix to a very severe bug.  In cases when IP addresses in lease file had
a range of using highest bit, e.g.  signed int minus, the sort caused
high ranges to be counted first and low ranges skipped.  The usual case
when this happen was when ranges contained 10.0.0.0/8 addresses
together with addresses greater than 128.0.0.0/32.

Reported-by: Ryan Malek <rmalek@osage.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-13 21:44:24 +02:00
Sami Kerola
3c9226752b build-sys: add --with-uthash=DIR ./configure option
Allow program builder to specify where uthash.h is.

Proposed-by: Ryan Steinmetz <zi@freebsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-06 22:09:49 +02:00
Ryan Steinmetz
1c40d8ac1e build-sys: make build work under FreeBSD
Signed-off-by: Ryan Steinmetz <zi@freebsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-06 20:53:20 +02:00
Sami Kerola
7c337de651 build-sys: update news for release v2.17
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-02 20:17:28 +02:00
Enno Grper
ae7747db87 analyse: critical bug in the counting code
The problem is, that you simply count all lease occurrences in
dhcpd.leases, but only the last ones for each ip address are
valid.  The lease file is more like a logfile of what has been
done, than a real database.  To fix the counting issue, I'm using
a single hash (from uthash.h [1]) for the counting.  This way
only the last lease entry for each IP gets into my counting
structure.

When you remove the duplicates in prepare_data(), you don't have
the information anymore, if the active lease entry or the free
lease entry came last.  Simply deleting each ip from the touches
array, that is already in the leases array, gives you a big
chance to count wrong.  Another way of fixing this would be to
not only store the ips in your arrays, but a structure containing
the ip and a global lease entry counter.  Then you could delete
all entries except for the latest.

[1] http://uthash.sourceforge.net/

Reported-by: Huangy
Signed-off-by: Enno Grper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-02 19:57:45 +02:00
Sami Kerola
3ef5d6c07f output: verify stream status when closing files
Includes also closing stdout and stderr at the end of execution.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-22 21:35:25 +01:00
Sami Kerola
97e5b59b78 getdata: do not mix boolean and int data types [cppcheck]
[src/getdata.c:307]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:324]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:340]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:362]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:366]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:371]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:372]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:385]: (warning) Comparison of a boolean with integer that is neither 1 nor 0

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 22:41:51 +01:00
Sami Kerola
c5b12e4368 getdata: fix configuration parser bug
When { is wrote together with a word, such as

pool{
        range 10.0.0.100 100.0.0.200;
        range ..

the parser ignored first range, resulting it to disappear from analysis.

Reported-by: Robert Viou <robert.viou@ndsu.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-02 10:13:33 +01:00
Sami Kerola
f3181bd1e4 docs: update TODO
Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
2011-12-15 10:06:31 +01:00
Sami Kerola
80fd81a443 contrib: add first .awk algorithm test version to contrib
The script is not maintained, but perhaps nice to have a
reference how the IP sorting & range matching was done in demo
version. Actually more proper version number would have been 0.x
but it was not.

Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
2011-12-14 10:08:20 +01:00
Sami Kerola
05cdc1bdee TODO: update bugs
Two bugs reported by anonymous.

Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
2011-12-14 09:52:28 +01:00
Sami Kerola
91f303055c docs: update thanks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-14 09:51:45 +01:00
Sami Kerola
5ea17c9754 build-sys: C99 has true and false
It is pointless to define true and false when standard headers can do
that.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-13 22:09:10 +01:00
Sami Kerola
6b47d9ffaf all files: use restrict key word for all pointer arguments
Limit the effects of pointer aliasing and aiding caching
optimizations.

http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-10-23 22:40:10 +02:00
Sami Kerola
235825b084 docs: enhance manual page readability
This patch adds consistant underlining to arguments, and unifies
spacing. Also the wording for -L is made much better, it's been
common to hear the manual was unclear about that option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-18 00:34:23 +02:00
Sami Kerola
f6807f8a6d build: smatch compiler warnings fixed
dhcpd-pools.c:221:20: warning: non-ANSI function declaration of function 'prepare_memory'
getdata.c +178 parse_leases(112) error: potential null derefence 'macstring'.
getdata.c +179 parse_leases(113) error: potential null derefence 'macaddr_p'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-10 11:21:19 +02:00
Sami Kerola
cf2b3ace16 Merge branch 'master' of ssh://dhcpd-pools.git.sourceforge.net/gitroot/dhcpd-pools/dhcpd-pools 2011-08-02 18:49:36 +02:00
Sami Kerola
2747b0667b docs: TODO update
Feature requests added.

Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
2011-08-02 11:51:33 +02:00
Sami Kerola
f2d86d9a83 dhcpd-pools.h: move string.h to include
Version 2.16 needs the patche to compile correctly and without
warnings (tested on NetBSD, Mac OS X and Debian/Ubuntu).

Signed-off-by: Adam Ciarcinski <adam@netbsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 09:21:47 +02:00
Sami Kerola
bf5375df3f dhcpd-pools.h: move string.h to include
Version 2.16 needs the patche to compile correctly and without
warnings (tested on NetBSD, Mac OS X and Debian/Ubuntu).

Signed-off-by: Adam Ciarcinski <adam@netbsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 09:10:22 +02:00
Sami Kerola
e3911bf367 build-sys: update news for release v2.16
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 01:05:23 +02:00
Sami Kerola
d6e691bbe4 other: fix two warnings
other.c:77:7: warning: ISO C90 does not support the 'z' gnu_printf length modifier [-Wformat]
other.c:169:2: warning: string length '1046' is greater than the length '509' ISO C90 compilers are required to support [-Woverlength-strings]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 00:50:05 +02:00
Sami Kerola
b1cd84e804 getdata: new xstrstr function for performance
The strstr is changed to xstrstr, which short cuts to points in
string where first differences are expected to found. This made
the tool tiny bit quicker.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-11 00:38:35 +02:00
Sami Kerola
8c6a3d9a4a build-sys: ignore gprof & gcov files
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-10 22:01:57 +02:00
Sami Kerola
f9eb53a215 bug: use uint32_t for IP numbers
The commit 1e82461875 was
incomplete, and at the end was a cause of off by one miscount.
The reason was bsearch where long int needed to be unsigned.
Weird that the original had work while there where so many type
mismatches.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-09 23:32:25 +02:00
Sami Kerola
f51f2e9fe1 licensing: set placeholder properly
I should have done this at commit a31fd0d97a

sed -i 's/<COPYRIGHT HOLDER>/THE AUTHOR AND CONTRIBUTORS/'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-09 10:18:53 +02:00
Sami Kerola
648891d8bd docs: remove version from manual page
Command version number in manual page output prone to be forgot
at the release time, so it is best to remove it completely.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 23:10:15 +02:00
Sami Kerola
1822439bfd docs: NEWS update
The update was not done at last release.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 23:07:05 +02:00
Sami Kerola
704e0fdd4a build-sys: autotools configure.ac update
Add recent changes to autotools header, function and compiler
capability checks. The patch also adds to .gitignore autoscan
outputs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 22:58:38 +02:00
Sami Kerola
cef03de0a9 output: change to full html behaviour
The full html will now print the mtime of dhcpd.leases file in
header. Additionally at the footer of the page the dhcpd-pools
will have package name and version number.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 22:33:13 +02:00
Sami Kerola
76915512b2 maint: coding style fixes
Remove unnecessary type casting, move .gitignore file contents to
right location, reindent to use Linux coding style, fix few type
mismatches, clean up to help & version output and hint compiler
call to these functions will end program.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 21:41:35 +02:00
Sami Kerola
68c2d7b8cc THANKS: add Ahmed AL Dakhil
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 20:04:17 +02:00
Sami Kerola
d29fd809c9 analyze: debugging leftover removed
My stupid mistake to leave statement hanging around while I where
wondering where the uninitialized memory came from.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 18:05:20 +02:00
Sami Kerola
26db4eafdc all: include-what-you-see fixes
After uint32_t fix from 1e82461875
it was good idea to check which headers where needed where. And
generally clean up the includes while doing the check.
2011-07-08 18:02:36 +02:00
Sami Kerola
d02b684133 getdata: initialize memory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 17:34:39 +02:00
Sami Kerola
12271887db analyze: use more logical variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 17:03:12 +02:00
Sami Kerola
1e82461875 bug: use uint32_t for IP numbers
There where long and unsigned long used for IPs in use which
caused occasional off by one errors. The word occasional should
be read: pretty much every one with large enough configuration
has been affected.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 16:28:22 +02:00
Sami Kerola
3c1d033a79 getdata: potential overflow due unit change
The commit c28488cbe8 introduced
potential memory overflow due unintentional unit change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 15:27:15 +02:00
Sami Kerola
c28488cbe8 getdata: realloc instead of asserting
Ahmed reported he saw the following error with version 2.15 which
is an indication of unusual high number of clients that has been
seen. I am not sure where that happen, but I suspect an airport
or some other 'lots of mobiles getting leases' might be able to
case same situation.

dhcpd-pools: getdata.c:136: parse_leases: Assertion `!(touchesmallocsize < num_touches)' failed.

The problem was quite easy to fix simply getting rid of assert
and putting realloc in place.

Reported-by: Ahmed AL Dakhil <a.aldakhil@go.com.sa>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 14:36:47 +02:00
Sami Kerola
8d94580c3d parse_leases: exit at read error
Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
2011-06-23 15:59:06 +02:00
Sami Kerola
a31fd0d97a licensing: use FreeBSD license (was GNUv3)
This change will also remove getopt source code and headers,
which has GNU license that I cannot change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-21 22:54:03 +02:00
Sami Kerola
dd5b77b62c prepare_memory bug: initialization missing
The lack of initialization may have cause unexpected outputs to
some users some times. That sort of behavior is also known by
name a bug.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-21 22:39:17 +02:00
Sami Kerola
55ab31e482 other: free backup ranges
Fix to memory leak I overlooked earlier.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-21 22:39:09 +02:00
Sami Kerola
e299e7fce2 headers: include-what-you-use fixes
Usage of includes are set up the way found to be in use, with a help of
magnificent utility.

http://code.google.com/p/include-what-you-use/

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-08 20:59:56 +02:00