Commit graph

418 commits

Author SHA1 Message Date
Sami Kerola
6f179db03d sort: fix get_order() if else return statement
Another instance of where returns happen in else clause removed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-10 00:22:32 +00:00
Sami Kerola
6f4104acbc analyze: use gnulib
The gnulib is grippled without config.h in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-10 00:09:43 +00:00
Sami Kerola
4341d92d41 getdata: skip strings before nth_field analysis
This will allow nth_field function to begin from first field, and stop
immediately when it ends, which makes function much more simple and quite
a bit quicker.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-10 00:07:09 +00:00
Sami Kerola
b918e9157d getdata: stop looking after interesting field
The nth_field function continued looking for words after they where known
not to be interesting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-09 22:52:30 +00:00
Sami Kerola
5f59daa692 analyze, getdata: write functions in frequency order
According to test data free is seen most often in leases file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-09 22:20:04 +00:00
Sami Kerola
72a41d8086 getdata: fix if else return statements
If something is true, and it returns using else is pointless.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-09 21:39:43 +00:00
Sami Kerola
629796cce7 sort: fix if else return statements
If something is true, and it returns using else is pointless.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-09 07:55:48 +00:00
Sami Kerola
18f2835fd5 analyze: sort ranges before analysis
At the other day I where wondering why so much time was spent on analysis
function, when I realized regression.  At the time uthash was introduced
to the project range sorting got to be dropped, which caused same leases
to be walked in analysis time after time.

Now when the regression is removed, and the test cases run about 28% over
all quicker.  The rule of thumb is that the greater the data set the
bigger is the benefit having this fix.  My largest test data is now
roughly 35% faster.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-08 22:02:02 +00:00
Sami Kerola
7a86746710 analyze: use simpler comparison
In some cases the this can make run time to take 2.5% less time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-07 21:42:18 +00:00
Sami Kerola
5714e95228 release: 2.19
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 20:15:59 +00:00
Sami Kerola
31c506ee73 build-sys: update gitignore
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 20:09:48 +00:00
Sami Kerola
22bf014ab5 docs: mention gnulib in README file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 19:59:32 +00:00
Sami Kerola
c8a348e93b build-sys: remove files which where added by accident
Sometimes I do not seem to be careful enough when committing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 19:50:54 +00:00
Sami Kerola
b61c93b7a1 performance: add few restict and const key words
This should make the run to be couple percentages quicker.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-05 21:05:42 +00:00
Sami Kerola
dbf3927c39 build-sys: clean gnulib & autotools checks
Add gnulib modules which make sense and remove few.  The stuff gnulib
takes care can be dropped from configure.am.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-05 20:30:53 +00:00
Sami Kerola
ab699e71ad build-sys: add gnulib
This will mean better portability, and a good reason to get rid of
various portability autotools directives which where part of this
project.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-05 00:03:03 +00:00
Sami Kerola
b5e518cd5e docs: clarify man page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-09 22:01:49 +01:00
Sami Kerola
7eb2e42625 build-sys: be conservative about posix_fadvice
Check that function availability before use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-09 21:52:19 +01:00
Sami Kerola
14d7183c3d build-sys: add what autoscan found bein missing
configure.ac: warning: missing AC_CHECK_FUNCS([atexit]) wanted by: src/dhcpd-pools.c:88
configure.ac: warning: missing AC_CHECK_HEADERS([limits.h]) wanted by: src/dhcpd-pools.c:55
configure.ac: warning: missing AC_FUNC_ERROR_AT_LINE wanted by: src/other.c:213
configure.ac: warning: missing AC_FUNC_STRTOD wanted by: src/other.c:148

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-09 21:31:43 +01:00
Sami Kerola
b15e63afd2 output: fix sign-compare warning [clang]
output.c:819:17: warning: comparison of integers of different signs:
'int' and ' unsigned int' [-Wsign-compare]
                for (i = 0; i < num_ranges; i++) {
                            ~ ^ ~~~~~~~~~~
output.c:832:17: warning: comparison of integers of different signs:
'int' and ' unsigned int' [-Wsign-compare]
                for (i = 0; i < num_shared_networks; i++) {
                            ~ ^ ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-08 19:39:26 +01:00
Sami Kerola
e8acaa42c8 build-sys: use AM_CPPFLAGS rather than INCLUDES
The INCLUDES is an older name for the same functionality as AM_CPPFLAGS.

References: http://www.gnu.org/software/automake/manual/html_node/Program-Variables.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-09-30 20:45:35 +01:00
Sami Kerola
6817d234ca style: fix few indentation issues
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-17 17:59:39 +02:00
Sami Kerola
b3e02ce0ba all: fix compiler warninings
Use compiler warnings from coreutils to check nothing complains, and
fix everything that did.

CFLAGS='-Wall -W -Wformat-y2k -Wformat-security -Winit-self
-Wmissing-include-dirs -Wunused -Wunknown-pragmas -Wstrict-aliasing
-Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align
-Wwrite-strings -Wmissing-declarations -Wmissing-noreturn -Wpacked
-Winvalid-pch -Wvolatile-register-var -Wdisabled-optimization
-Woverlength-strings -Wbuiltin-macro-redefined -Wmudflap
-Wpacked-bitfield-compat -Wsync-nand -Wattributes -Wcoverage-mismatch
-Wabi -Wcpp -Wdeprecated -Wdeprecated-declarations -Wdiv-by-zero
-Wendif-labels -Wextra -Wformat-contains-nul -Wformat-extra-args
-Wformat-zero-length -Wformat=2 -Wmultichar -Wnormalized=nfc -Woverflow
-Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=noreturn
-Wtrampolines -Wno-sign-compare -Wno-unused-parameter
-Wsuggest-attribute=noreturn -Wno-format-nonliteral -Wno-logical-op
-fdiagnostics-show-option -funit-at-a-time'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-17 17:59:39 +02:00
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