Commit graph

281 commits

Author SHA1 Message Date
Sami Kerola
7685d08cf0 man: fix errors in alarm warning and critical options text
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-25 18:23:38 +00:00
Sami Kerola
9df90042e2 build-sys: make alarm warning & critical default configurable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-25 18:03:19 +00:00
Sami Kerola
7e403b50b4 build-sys: clean up configure.ac
Remove checks that are done in gnulib, and reindent autotools code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-25 18:03:19 +00:00
Sami Kerola
c66d13774b build-sys: update gitignore
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-25 18:03:19 +00:00
Sami Kerola
c48a8d411f man: use configured dhcpd.conf and dhcpd.leases paths
Making dhcpd.conf and dhcpd.leases file references being dynamic causes
manual contents being replaced at compile time, so make some other data
items dynamic as well.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-25 18:03:13 +00:00
Sami Kerola
822ca33804 getdata & analyze: fix first_ip and last_ip arithmetics
There were too clever tricks done with first and last.  Earlier the aim
was to minimize '<=' and '>=' by fiddling with the numbers at the time
when they were saved.  While the program logic seemed to work there were
some off by one mistakes, resulting to a count error.  Even worse there
is not even that many of such comparisons, so that one cannot really even
justify added complexity.  I really hope this patch is last this kind fix
ever needed.

Reported-by: Cheer Xiao <xiaqqaix@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-21 21:50:09 +00:00
Sami Kerola
83e12457bc docs: fix spelling mistakes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-20 21:09:53 +00:00
Cheer Xiao
88d989bbe2 Fix spelling mistakes. 2012-11-20 20:53:30 +00:00
Cheer Xiao
1b56bafaf5 Replace all htonl in getdata.c with ntohl.
They are always the same macro, but the semantics was wrong.
2012-11-20 20:53:30 +00:00
Cheer Xiao
dc83f1ffd4 ignore /gnulib/ 2012-11-20 20:53:29 +00:00
Sami Kerola
0a0fea05ad xstrstr: add function attributes
The pointers arguments are never null, and the function should be
optimized as much as possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-12 19:19:18 +00:00
Sami Kerola
34f99d2f08 header: let gnulib do what it is best of
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-12 19:19:17 +00:00
Sami Kerola
acba2e265e (un)likely: use __builtin_expect to inform expected path
Remove also unnecessary comparison in getdata nth_field().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-12 19:19:01 +00:00
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