Commit graph

205 commits

Author SHA1 Message Date
Lorenz Kästle
f5f60f5717
check_disk: compare inode thresholds against the correct value (#2223)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Spellcheck / codespell (push) Has been cancelled
Tests / Running unit and integrationt tests (push) Has been cancelled
Tests / Running rpm build test on almalinux:9 (push) Has been cancelled
Tests / Running rpm build test on fedora:latest (push) Has been cancelled
Tests / Running rpm build test on rockylinux:8 (push) Has been cancelled
* check_disk: compare inode thresholds against the correct value

* check_disk: Detect free inode number correctly in tests

---------

Co-authored-by: Lorenz Kästle <lorenz.kaestle@netways.de>
2026-01-16 12:16:45 +01:00
Lorenz Kästle
802e46f8ea Run clang-format again 2025-09-15 12:59:37 +02:00
Lorenz Kästle
1b0085c2e7 Fixes problems after a4cf2e79f7 2025-03-31 00:46:10 +02:00
Lorenz Kästle
d6d394fb0e Fix some typos with units 2025-03-31 00:10:56 +02:00
Lorenz Kästle
a4cf2e79f7 Remove cool, comfy c23 functionality for some dirty old hacks 2025-03-30 23:30:51 +02:00
Lorenz Kästle
c4fd34ed79 Codespell fixes 2025-03-30 22:46:09 +02:00
Lorenz Kästle
908aed4e6f Refactor check_disk and library functions 2025-03-30 22:37:48 +02:00
Lorenz Kästle
a0710dbd72 check_disk: Remove unnecessary NULL checks 2025-03-18 16:26:14 +01:00
Lorenz Kästle
75cf0d3072 Remove some unused code 2025-03-18 16:23:06 +01:00
Lorenz Kästle
29d946b9b5 Refactor check_disk, no more global variables 2025-03-18 14:37:49 +01:00
Lorenz Kästle
096afc90a7 check_disk: reset single file system result in between checks 2025-03-17 20:37:28 +01:00
Lorenz Kästle
7b53cbbd26 check_disk: Little fixes and improvements 2025-03-17 20:21:58 +01:00
Lorenz Kästle
4fb7fb05b6 check_disk: General refactoring 2025-03-17 19:36:11 +01:00
Lorenz Kästle
969f40c2a0 check_disk: boolean type and linter fixes 2025-03-17 17:44:28 +01:00
Lorenz Kästle
d24316a6b4 check_disk: clang-format 2025-03-17 17:40:29 +01:00
Lorenz Kästle
c0bcad7feb check_disk: Initialize most variables 2024-11-04 23:12:18 +01:00
RincewindsHat
08526fd07f check_disk: Linter fixes 2024-10-31 03:28:27 +01:00
RincewindsHat
78aa691505 check_disk: Update copyright 2024-10-31 03:25:04 +01:00
RincewindsHat
25e0c67b09 check_disk: clang-format 2024-10-31 03:24:02 +01:00
Lorenz Kästle
fb5175aed6 check_disk: remove unused variables and functions 2024-09-27 13:53:24 +02:00
Lorenz Kästle
7ca72ecace check_disk: Declare global variables static
Variables only used in that specific translation unit should be static
to actually communicate that fact.
Also allows the compiler to detect unused (global) variables.
2024-09-27 13:51:21 +02:00
Lorenz Kästle
d3faf13961
check_disk: Fail on missing arguments for --warning and --critical and fix a test case (#1935)
* check_disk: Fail on missing arguments for --warning and --critical
* Add new test function for percentage expressions and use it in check_disk
* Add error abort in tests if they fail to parse output
* Fix typo in test which probably broke the test since forever :-(
2024-03-27 00:36:41 +01:00
Sven Nierlein
117cd8e4b8
check_disk increase alert precision (#1989)
* check_disk increase alert precision

Free disk percentage value was rounded to a full integer meaning it alerted about ~1% percent too early. This is about 10GB on a 1TB disk.
The warning and critical thresholds already support float values, so just the percentage calculation needs to be improved.

old:

    ./check_disk -w 35% -c 20% -p / -f -vvv
    Thresholds(pct) for / warn: 35.000000 crit 20.000000
    calling stat on /
    For /, used_pct=65 free_pct=35 used_units=286451 free_units=156651 total_units=443102 used_inodes_pct=11 free_inodes_pct=89 fsp.fsu_blocksize=4096 mult=1048576
    Freespace_units result=0
    Freespace% result=1
    Usedspace_units result=0
    Usedspace_percent result=0
    Usedinodes_percent result=0
    Freeinodes_percent result=0
    DISK WARNING - free space: WARNING [ / 156651MiB (35% inode=89%)];| /=300365643776B;302006979788;371700898201;0;464626122752

new:

    ./check_disk -w 35% -c 20% -p / -f -vvv
    Thresholds(pct) for / warn: 35.000000 crit 20.000000
    calling stat on /
    For /, used_pct=64.649722 free_pct=35.350278 used_units=286464 free_units=156637 total_units=443102 used_inodes_pct=10.016183 free_inodes_pct=89.983817 fsp.fsu_blocksize=4096 mult=1048576
    Freespace_units result=0
    Freespace% result=0
    Usedspace_units result=0
    Usedspace_percent result=0
    Usedinodes_percent result=0
    Freeinodes_percent result=0
    DISK OK - free space: / 156637MiB (35.4% inode=90%);| /=300379275264B;302006979788;371700898201;0;464626122752

* check_disk: adjust test case to support float precision
2024-02-23 18:24:28 +01:00
Sven Nierlein
579db5a930 check_disk: fix ignore-missing in combination with includes (fixes #1963)
Using --ignore-missing together with regex matching and ignore option lead
to a wrong error message.

    ./check_disk -n -w 10% -c 5% -W 10% -r /dummy -i /dummy2
    DISK UNKNOWN: Paths need to be selected before using -i/-I. Use -A to select all paths explicitly

The use case here is a cluster with fail-over mounts. So it is a valid situation that
the regex match does not find anything in addtition with a ignore which also does not exist.

After this patch:

    ./check_disk -n -w 10% -c 5% -W 10% -r /dummy -i /dummy2
    DISK OK - No disks were found for provided parameters|
2023-11-27 13:04:10 +01:00
Sven Nierlein
f59c516011 check_disk: add -n short option for --ignore-missing
Signed-off-by: Sven Nierlein <sven@consol.de>
2023-11-27 13:04:10 +01:00
RincewindsHat
b6796d9172 check_disk: Use C99 booleans 2023-10-18 16:16:44 +02:00
Lorenz Kästle
819f90b726 check_disk: Change usage for --include-type to indicated regexes are now possible 2023-10-01 00:41:55 +02:00
Lorenz Kästle
6947a8cea9 check_disk: Use regex also to include fs types 2023-09-30 12:54:21 +02:00
Alexander A. Klimov
4bb444f335 check_disk: make -X a regex list 2023-09-28 13:20:24 +02:00
Lorenz Kästle
2ef36843ab Add -C to general usage hints 2023-09-21 12:09:10 +02:00
RincewindsHat
8faf7afad3 check_disk: Add some general usage hints 2023-09-21 12:09:10 +02:00
RincewindsHat
b01aa8c433 check_disk: More spacing to separate examples 2023-09-21 12:09:10 +02:00
RincewindsHat
2f916675b3 check_disk: Mention -A and long options in error message about missing thresholds 2023-09-21 12:09:10 +02:00
RincewindsHat
3e8fdf9b35 check_disk: Fix printf format string 2023-09-21 12:09:10 +02:00
RincewindsHat
53ea2304aa check_disk: Remove some dead variables 2023-09-12 00:50:55 +02:00
RincewindsHat
bf8eb6dcc7 check_disk: Display SI units correctly 2023-05-26 08:45:00 +02:00
Jan Wagner
0f3703e641 Fix a lot of typos reported by codespell 2023-04-14 18:35:00 +00:00
Kristian Schuster
3e7da5f970
check_disk: use cleaner code for ignore-missing option
- use datatype bool for new vars ignore_missing and path_ignored instead of int
- directly initialize preamble and ignored_preamble with their strings
2023-03-06 14:03:10 +01:00
Kristian Schuster
e102b8a49e
check_disk: fix ugly output with -e option and adapt tests accordingly 2023-02-20 02:03:01 +01:00
Kristian Schuster
a0d4277721
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option 2023-02-19 23:49:18 +01:00
Kristian Schuster
ba78c32018
check_disk: still allow check of available disks with ignore-missing param used
Also add reporting of ignored paths. When paths are provided by -p and/ or -r and
one path does not match a mounted disk, checking available disks is still
possible. Paths provided by -p are reported as ignored, when not available. Due
to code structure, this is not possible for -r unfortunately.
2023-02-19 22:49:30 +01:00
Lorenz Kästle
05ab60f808 check_disk: Remove weird code (workaround?) which broke with gnulib update 2023-02-01 00:56:44 +01:00
Lorenz
67b472f9d1
check_disk: Clarify usage possibilites (#1745)
* Clarify usage possibilites of check_disk

* Remove superfluous newlines

Co-authored-by: waja <waja@users.noreply.github.com>
2023-01-20 12:08:15 +01:00
Kristian Schuster
8cf31437e9
check_disk: add ignore-missing option to return OK for missing fs
There a situations where UNKNOWN or CRITICAL services are not
wanted when a filesystem is missing, a regex does not match or the
filesystem is inaccessible on a system.
This new option helps to have the service in state OK.
2022-10-24 17:29:53 +02:00
Lorenz
ef57962552
Check disk compiler warnings (#1758)
* Use unused variable

* Proper format strings for printf

* Use proper functions for absolute values

* Remove and add comments at some places
2022-09-11 06:29:58 +02:00
Lorenz
d485b64ef0
Description for -M was the wrong way around (#1746)
Using -M should show the mountpoint instead of the device the
file system originated from.
Seems like this was not the case for a long time and now
the default is to show the mount point. Using `-M` reverts
to showing the (block) device instead.
The usage Description was adjusted with this commit.
2022-01-30 19:41:36 +01:00
Lorenz
cf669f5ff5
Trivial printf fix and a little bit of code style (#1695)
* Fix several warnings (and some downright bugs probably) with formating in check_disk

Update to master

* Fix merge error, I forgot the last time

* Fix indentation

Co-authored-by: rincewind <rincewind@vulgrim.de>
2022-01-22 22:23:13 +01:00
RincewindsHat
d28bab4dbd More wrong printf formatting 2021-11-24 19:02:17 +01:00
RincewindsHat
e2f24a5af3 Fix CodeQL checks 2021-11-24 14:25:42 +01:00
RincewindsHat
884327ee21 Replace tabs with spaces and do some formatting 2021-10-27 12:53:13 +02:00