Commit graph

366 commits

Author SHA1 Message Date
Sami Kerola
1875a13733
all files: replace global variables with runtime config state structure
Earlier variables magically appeared to scope of functions that took void as
argument.  One could figure out perhaps they were globals, but programs that
do that are unnessarily hard to follow.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-12 15:12:15 +00:00
Sami Kerola
adda925c1e
clean up: remove unused variable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 23:59:13 +00:00
Sami Kerola
3dda0a77a5
output: deduplicate file closing code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 23:09:33 +00:00
Sami Kerola
7575294c36
usage: add error message informing mustach support is not available
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 21:15:36 +00:00
Sami Kerola
39b2811aa7
build-sys: omit mustach compilation when it cannot work
For example mac does not have open_memstream(3), and strndupa(3) can also be
missing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 16:13:14 +00:00
Sami Kerola
b96f8cd8ad
gnulib: use nstrftime instead of strftime
The strftime module is obsolete.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 15:37:07 +00:00
Sami Kerola
54cedc1001
output: include stdlib.h to avoid compilation error
The stdlib.h has EXIT_FAILURE and free(3).

Reported-by: Sebastián Cramatte <scramatte@nixus.es>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 14:29:00 +00:00
Sami Kerola
e4baff79bd
output: add must_put_err() utility function
This function deals situation when mustach put happens before enter, that is
a sign of an invalid input template.  Good side of adding this function is
that dhcpd-pools does not need to modify code provided by Jose.

Reference: 66183bc7c7
Proposed-by: José Bollo <jobol@nonadev.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 09:00:33 +00:00
Sami Kerola
4fc4bcd083
output: save and reuse output helper results
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 08:39:50 +00:00
Sami Kerola
d5ae2a80c0
output: do not skip over first range in mustach output
Off by one that is caused by must_next_range() advancing pointer, and moving
over the first range.  Fix by setting indexes one step backwards, that is
not excellent but better than copying skip_ok stuff to must_enter().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 08:20:10 +00:00
Sami Kerola
50fc4ebe9d
output: avoid mixing ntop_ipaddr() output buffers
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-11 08:19:56 +00:00
Sami Kerola
66183bc7c7
output: make mustach processing more robust
Fix issues found with afl-fuzz.  It is a pity I had to change mustach.c it
is no longer exactly the same as upstream.  Lets see if Jose will accept
these changes.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-09 19:49:37 +00:00
Sami Kerola
2ec953858b
tests: add mustach check
Use samples directory data as input to ensure they do not break.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-09 19:49:17 +00:00
Sami Kerola
39e6e65201
docs: add mustach sample files
Include samples to installation, and give a hint to user where it can be
found in manual page.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-09 19:49:17 +00:00
Sami Kerola
74fdf90980
output: add separate first_ip and last_ip to json and mustach outputs
This give greater liberty to people who are using these formats to do what
ever they need to.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-09 19:49:17 +00:00
Sami Kerola
7d9a5b5561
output: add mustach templating support
Based on José Bollo's mustache C implementation.  This adaptation uses
project specific data structures to avoid overhead with json parsing.

Reference: https://gitlab.com/jobol/mustach.git
Commit: d84608a69033d38c81b8fcff0cb272e225dd5428
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-09 19:49:13 +00:00
Sami Kerola
fe847bb9b1
output: use range_output_helper() value in output_xml()
Earlier commit started to use range_output_helper() in output_xml() so
remove the unnecessary calls to get_range_size().

Reference: c55c823753
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-08 23:04:28 +00:00
Sami Kerola
1182ec4cc9
include: use project specific header guard
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-07 13:45:17 +00:00
Sami Kerola
e9736f74e7
getdata: do not use 'else' after 'continue'
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-07 13:44:50 +00:00
Sami Kerola
e5cd46e4e9
other: do not use 'else' after 'return'
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-07 13:12:37 +00:00
Sami Kerola
eb7547c742
output: json nan values need quoting
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-07 10:41:53 +00:00
Sami Kerola
8fe7dc2c03
other: add --skip-ok to usage() output
Forgot in previous commit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-06 22:34:06 +00:00
Sami Kerola
c55c823753
output: add --skip-ok option
Omit ranges and shared networks that do not exceed warning or critical
thresholds.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-06 22:11:47 +00:00
Sami Kerola
e079cc16e0
output: include earlier missing data to json output
This commit adds all the data that is in text output to json output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-06 21:39:15 +00:00
Sami Kerola
344ed2900d
output: add color support to text output
When --warning or --critical thresholds are defined with text output lines
that exceed threshold will be either yellow (warning) or red (critical).

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-06 21:31:57 +00:00
Sami Kerola
48962004b8
output: add output helper functions
There is too much repetative confusing maths near printouts.  Move that
stuff to a function.

This change also fixes --snet-alarms option counting issue in range that
were not part of any shared network were ignored.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-05 16:21:20 +00:00
Sami Kerola
05f8208518
getdata: fix typo
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-05 10:01:07 +00:00
Sami Kerola
abf5d04736
output: make output_analysis() to be regular function
This commit makes it possible to define alarming thresholds at the same time
with other output formats.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-05 09:51:35 +00:00
Sami Kerola
9deeae8c36
update sitemap
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-23 09:18:35 +01:00
Sami Kerola
548ce63963
release: update web page meta data
This should have been done before tag.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-23 08:53:18 +01:00
Sami Kerola
58a31513fe
release: 2.29
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-23 08:17:38 +01:00
Sami Kerola
804aa3236d
docs: update maintainer gpg key
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-17 09:50:55 +01:00
Sami Kerola
af1ae94112
docs: add build instruction link to the project web page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-17 09:17:15 +01:00
Sami Kerola
fefd8d26cf
docs: tell what needs to be done when releasing new version
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-17 09:00:25 +01:00
Sami Kerola
1d47eb9a1c
docs: update doxygen configuration file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-17 08:43:19 +01:00
Sami Kerola
0c32a67ff1
build-sys: update bootstrap from gnulib
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-17 08:41:41 +01:00
Sami Kerola
bb0fa9adae
getdata: add cidr range support
This makes 'range6 123::/45' style cidr notation to be understood as address
range.  Earlier ranges that used cidr failed to parse completely.

Reported-by: Jeff Bailey <jeffrey.bailey@bt.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-17 00:03:06 +01:00
Sami Kerola
48d0629881
lib: update .gitignore
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-09 10:29:04 +01:00
Sami Kerola
782f63c3ad
add --ip-version option to force either IPv4 or IPv6 analysis
Proposed-by: Jeff Balley <jeffrey.bailey@bt.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-09 10:28:27 +01:00
Boris Lytochkin
b9cff0d814
introduce -A arg: treat single subnets as shared-network with CIDR as their name
Current output makes some false-positives for situations when multiple
ranges are specified inside single network, for example:

subnet 10.0.0.0 netmask 255.255.254.0 {
	...
	range 10.0.0.1 10.0.0.254;
	range 10.0.1.1 10.0.1.253;
	...
}

An alert for range 10.0.0.1 - 10.0.0.254 will be raised even in situations
when range 10.0.1.1 - 10.0.1.253 is completely empty.  To cope with this
issue, an -A option is added to treat all single networks as shared-network.
This option changes output for both range and shared networks output if
specified.  Frankly saying, using network CIDR as network name is much more
sane for me than 'All Networks'.

Signed-off-by: Boris Lytochkin <lytboris@yandex-team.ru>
2017-07-15 17:26:15 +01:00
Sami Kerola
dff991666e
lib: update .gitignore
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-21 17:30:24 +01:00
Sami Kerola
242ef3109b
variable: add const to print_mac_addreses_tmp
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-21 17:21:57 +01:00
Sami Kerola
1c8b799799
fix typo
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-06 16:44:19 +01:00
Sami Kerola
e93fc5dba4
lib: update .gitignore
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-15 20:42:58 +01:00
Sami Kerola
c3c3fc6e40
getdata: fpos_t is not easy to print correctly
On some systems fpos_t may be a complex object, so printing it is not as
easy as ftell() position.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-15 20:42:07 +01:00
Sami Kerola
e9223a852c
contrib: Klaus Slott told about opensuse package
Add opensuse rpm as an example how to build one.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-10 13:12:34 +01:00
Sami Kerola
9a52619385
style: use same argument names in header and source file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-07 22:56:19 +01:00
Sami Kerola
2b75a0d78e
getdata: remove POSIX_FADV_NOREUSE
It is too difficult to know what users might want to do.  Maybe some run
this software all the time from a monitoring system, and in cases like that
it is best to have caches helping.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:11:43 +00:00
Sami Kerola
344e01c1f6
output: add include avoid referringt to undefined definition
Reference: c4a654a149
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 18:00:02 +00:00
Sami Kerola
c4a654a149
output: fix timestamp localization on html page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-01-12 22:40:33 +00:00