Merge branch 'master' into check_curl_features

This commit is contained in:
Sven Nierlein 2024-07-23 21:09:21 +02:00 committed by GitHub
commit 562deb749a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 622 additions and 570 deletions

View file

@ -64,13 +64,9 @@ apt-get -y install perl \
iproute2
# remove ipv6 interface from hosts
if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then
sed '/^::1/d' /etc/hosts > /tmp/hosts
cp -f /tmp/hosts /etc/hosts
fi
sed '/^::1/d' /etc/hosts > /tmp/hosts
cp -f /tmp/hosts /etc/hosts
ip addr show
cat /etc/hosts
# apache

View file

@ -2,7 +2,7 @@ Releasing a New Monitoring Plugins Version
==========================================
Throughout this document, it is assumed that the current Monitoring
Plugins version is 2.3.4, and that we're about to publish version 2.4.
Plugins version is 2.3.5, and that we're about to publish version 2.4.
It is also assumed that the official repository on GitHub is tracked
using the remote name `monitoring-plugins` (rather than `origin`).
@ -11,14 +11,14 @@ Before you start
- Check Github Actions status.
- Update local Git repository to the current `master` tip. For a
maintenance release (e.g., version 2.3.4), update to the current
maintenance release (e.g., version 2.3.6), update to the current
`maint-2.3` tip, instead.
Prepare and commit files
------------------------
- Update `configure.ac` and `NP-VERSION-GEN` with new version.
- Update `NEWS` from `git log --reverse v2.3.4..` output, and specify
- Update `NEWS` from `git log --reverse v2.3.5..` output, and specify
the release version/date.
- Update `AUTHORS` if there are new team members.
- Update `THANKS.in` using `tools/update-thanks`.
@ -93,6 +93,6 @@ Announce new release
If you want to mention the number of contributors in the announcement:
git shortlog -s v2.3.4..v2.4 | wc -l
git shortlog -s v2.3.5..v2.4 | wc -l
<!-- vim:set filetype=markdown textwidth=72: -->

View file

@ -399,28 +399,30 @@ check_swap(float free_swap_mb, float total_swap_mb)
if (!total_swap_mb) return no_swap_state;
uint64_t free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
if (crit.is_percentage &&
crit.value != 0 &&
usage_percentage >= (100 - crit.value))
{
return STATE_CRITICAL;
}
if (warn.value || crit.value) { /* Thresholds defined */
if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
if (warn.is_percentage &&
warn.value != 0 &&
usage_percentage >= (100 - warn.value))
{
return STATE_WARNING;
}
if (crit.is_percentage &&
crit.value != 0 &&
usage_percentage >= (100 - crit.value))
{
return STATE_CRITICAL;
}
return STATE_OK;
if (warn.is_percentage &&
warn.value != 0 &&
usage_percentage >= (100 - warn.value))
{
return STATE_WARNING;
}
return STATE_OK;
} else { /* Without thresholds */
return STATE_OK;
}
}
@ -443,9 +445,6 @@ process_arguments (int argc, char **argv)
{0, 0, 0, 0}
};
if (argc < 2)
return ERROR;
while (1) {
c = getopt_long (argc, argv, "+?Vvhac:w:n:", longopts, &option);
@ -547,10 +546,7 @@ process_arguments (int argc, char **argv)
int
validate_arguments (void)
{
if (warn.value == 0 && crit.value == 0) {
return ERROR;
}
else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
/* This is NOT triggered if warn and crit are different units, e.g warn is percentage
* and crit is absolute. We cannot determine the condition at this point since we
* dont know the value of total swap yet
@ -595,6 +591,7 @@ print_help (void)
printf ("\n");
printf ("%s\n", _("Notes:"));
printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
printf (" %s\n", _("Without thresholds, the plugin shows free swap space and performance data, but always returns OK."));
printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
printf (UT_SUPPORT);
@ -605,6 +602,6 @@ void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
printf (" %s [-av] [-w <percent_free>%%] [-c <percent_free>%%]\n",progname);
printf (" [-w <bytes_free>] [-c <bytes_free>] [-n <state>]\n");
}

File diff suppressed because it is too large Load diff

View file

@ -205,9 +205,9 @@ SKIP: {
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
is( $res->return_code, 0, "Redirection based on location is okay");
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
}

View file

@ -166,10 +166,10 @@ SKIP: {
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
is( $res->return_code, 0, "Redirection based on location is okay");
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
}

View file

@ -5,7 +5,7 @@
#
use strict;
use Test::More tests => 8;
use Test::More tests => 14;
use NPTest;
my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
@ -14,6 +14,10 @@ my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)
my $result;
$result = NPTest->testCmd( "./check_swap" ); # Always OK
cmp_ok( $result->return_code, "==", 0, "Always OK" );
like( $result->output, $successOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free
cmp_ok( $result->return_code, "==", 0, "At least 1MB free" );
like( $result->output, $successOutput, "Right output" );
@ -29,3 +33,11 @@ like( $result->output, $failureOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn)
cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
like( $result->output, $warnOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -w 100%" ); # 100% (single threshold, always warn)
cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
like( $result->output, $warnOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical)
cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
like( $result->output, $failureOutput, "Right output" );