Commit graph

90 commits

Author SHA1 Message Date
Lorenz Kästle
36ac312e07 fix typos 2025-11-05 14:01:31 +01:00
Lorenz Kästle
8a71cf947f check_pgsql: implement cli params for output format 2025-11-05 14:01:17 +01:00
Lorenz Kästle
2f0fc05981 check_pgsql: cleanup leftover code 2025-11-05 13:58:48 +01:00
Lorenz Kästle
ba6f903733 check_pgsql: implement modern output 2025-11-05 13:54:04 +01:00
Lorenz Kästle
4191aa46a2 put includes before any declarations 2025-11-04 12:15:20 +01:00
Lorenz Kästle
b207ac3b0a remove cpp constant and localize that value instead 2025-11-04 12:14:36 +01:00
Lorenz Kästle
802e46f8ea Run clang-format again 2025-09-15 12:59:37 +02:00
Lorenz Kästle
de392a81ed Refactor check_pgsql 2025-03-12 02:16:41 +01:00
Lorenz Kästle
003b96741d check_pgsql: clang-format 2025-03-12 01:47:38 +01:00
RincewindsHat
f60f83a522 check_pgsql: print_usage must be exported 2024-10-31 13:35:48 +01:00
RincewindsHat
0a3fcf0d97 check_pgsql: diverse style fixes 2024-10-31 13:33:31 +01:00
RincewindsHat
daf37fbd67 check_pgsql: do not export local variables 2024-10-31 13:26:56 +01:00
RincewindsHat
cc63bc6699 check_pgsql: update copyright 2024-10-31 13:25:30 +01:00
RincewindsHat
835be77d74 check_pgsql: clang-format 2024-10-31 13:24:56 +01:00
RincewindsHat
9274b6db8b check_pgsql: Use C99 booleans 2023-10-18 17:26:43 +02:00
Lorenz
b3e066a82e
Merge pull request #1486 from philipowen/feature/pgsql-extra-info
check_pgsql: Add extra output
2023-05-10 14:04:15 +02:00
Jan Wagner
24e99301b4 Fix a psuedo typo 2023-04-17 08:23:28 +02:00
phowen
9f15dac8e7 add extra output to pgsql check 2023-02-03 16:37:19 +01:00
waja
2d9c6276d0
Removing is_pg_dbname alltogether,using postgres API. (Closes: #1660) (#1803)
The problem is that check_pgsql validates the Database name and has different assumptions
that postgres itself.

I fail to see a reason to validate the database name here. Postgres'es API should
do this - So i would suggest a fix like this by removing is_pg_dbname alltogether.

Co-authored-by: Florian Lohoff <f@zz.de>
2022-11-04 19:16:01 +01:00
datamuc
e2397167c7
add --queryname parameter to check_pgsql (#1741)
This is used in the long output instead of the actual query.
So instead of

    OK - 'select stuff from various, tables where some_stuff is null and other_stuff is not null' returned 42

one can use --queryname=check_greatest_basket and it will print

OK - check_greatest_basket returned 42

That's nicer for alerting purposes, at least in our use case.
2022-01-25 10:57:02 +01:00
Florian Lohoff
dae075e65a Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601)
As strcpy may overflow the resulting buffer:

flo@p5:~$ /tmp/f/usr/lib/nagios/plugins/check_pgsql -d "$(seq 1 10000)"
*** buffer overflow detected ***: terminated
Aborted

I would propose to change the code rather like this, using snprintf
which honors the buffers size and guarantees null termination.
2021-02-15 15:34:07 +01:00
Sven Nierlein
7cafb0e845 check_by_ssh: fix child process leak on timeouts
When check_by_ssh runs into a timeout it simply exits keeping all child processes running.
Simply adopting the kill loop from runcmd_timeout_alarm_handler() fixes this.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-02-15 10:36:28 +01:00
Jan Wagner
dbb92c347e Spelling fixes suggested by lintian 2016-12-01 12:49:40 +01:00
Sven Nierlein
edca257e20 use unknown exit code for help/version in plugins
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2015-10-04 19:24:30 +02:00
Holger Weiss
3f4419c07e check_pgsql: Add missing newline to --help output 2014-03-13 12:52:48 +01:00
Thomas Guyot-Sionnest
11cf54ca78 Merge branch 'rename' 2014-01-21 07:59:07 -05:00
Spenser Reinhardt
212575b858 plugins/*.c: Alterations for timeout messages.
.c file changes for misleading timeout messages in help functions. Solution to pull request #1209 tracker by awiddersheim.

Files: plugins/check_apt.c, plugins/check_by_ssh.c, plugins/check_dbi.c, plugins/check_dig.c, plugins/check_disk.c, plugins/check_dns.c, plugins/check_game.c, plugins/check_http.c, plugins/check_ldap.c, plugins/check_ntp.c, plugins/check_ntp_peer.c, plugins/check_ntp_time.c, plugins/check_nwstat.c, plugins/check_overcr.c, plugins/check_pgsql.c, plugins/check_ping.c, plugins/check_procs.c, plugins/check_radius.c, plugins/check_real.c, plugins/check_smtp.c, plugins/check_snmp.c, plugins/check_ssh.c, plugins/check_tcp.c, plugins/check_time.c, plugins/check_ups.c, plugins/negate.c
2014-01-21 11:33:45 +01:00
Holger Weiss
c3e756a855 Capitalize "Monitoring" when it's the first word 2014-01-20 03:12:50 +01:00
Monitoring Plugins Development Team
63734f52ab Project rename initial commit.
This is an initial take at renaming the project to Monitoring Plugins.
It's not expected to be fully complete, and it is expected to break
things (The perl module for instance). More testing will be required
before this goes mainline.
2014-01-19 14:18:47 -05:00
Holger Weiss
6f0366c8b8 check_pgsql: Don't exit UNKNOWN instead of OK
Since commit 912df3ef9b, check_pgsql
exited UNKNOWN instead of OK if the new --query option was *not*
specified.  This bug is fixed now.
2013-09-19 12:41:42 +02:00
Holger Weiss
b62f0fb444 check_pgsql: Add missing printf(3) argument 2013-08-17 23:06:16 +02:00
Holger Weiss
329f843ef6 check_pgsql: Remove -4/-6 flags from help output
The -4/-6 options are currently not supported.
2013-08-17 22:33:43 +02:00
Holger Weiss
e47a06f77d Merge remote-tracking branch 'github/tokkee/sh/check_pgsql'
* github/tokkee/sh/check_pgsql:
  check_pgsql: Determine connection time in µs-resolution.
  check_pgsql: Leave 'min' value in query perfdata empty.
  check_pgsql: Updated copyright.
  check_pgsql: Added support for the -o command line option.
  check_pgsql: Removed -4/-6 flags from help output.
  check_pgsql: Allow UNIX socket directories as hostname as well.
  check_pgsql: Use PQconnectdb() rather than PQsetdbLogin().
  check_pgsql: Fixed query perfdata output for empty warn/crit ranges.
  check_pgsql: Added support for executing queries.

Conflicts:
	plugins/check_pgsql.c
2013-08-17 22:28:38 +02:00
Sven Nierlein
24772e755e unified ipv4/6 usage and help text 2012-11-28 11:03:11 +01:00
Sebastian Harl
c0bef3da51 check_pgsql: Determine connection time in µs-resolution.
… thus, treat "elapsed time" and the thresholds as floating point values.
2012-07-05 11:36:58 +02:00
Sebastian Harl
c56a22cbbf check_pgsql: Leave 'min' value in query perfdata empty.
There is no reasonable default value for that.
2012-07-05 11:36:58 +02:00
Sebastian Harl
034f6b3699 check_pgsql: Updated copyright. 2012-07-05 11:36:58 +02:00
Sebastian Harl
c3f97e6180 check_pgsql: Added support for the -o command line option.
This option may be used to specify further connection parameters to be passed
to PQconnectdb(). For example, this may be used to specify a service name in
pg_service.conf to be used for additional connection parameters: -o
'service=<name>' or to specify the SSL mode: -o 'sslmode=require'.

See the chapter "libpq - C Library" in the PostgreSQL manual for details.
2012-07-05 11:36:58 +02:00
Sebastian Harl
b3773ae7e5 check_pgsql: Removed -4/-6 flags from help output.
These options are not currently supported.
2012-07-05 11:36:58 +02:00
Sebastian Harl
a241ab0b9d check_pgsql: Allow UNIX socket directories as hostname as well.
PostgreSQL accepts the directory name of its UNIX socket as hostname as well,
e.g. /var/run/postgresql/.
2012-07-05 11:36:57 +02:00
Sebastian Harl
f3e2ebd974 check_pgsql: Use PQconnectdb() rather than PQsetdbLogin().
This is more flexible and the recommended way to connect to a PostgreSQL
database.

Also, the verbose output now includes detailed information about the
connection.
2012-07-05 11:36:57 +02:00
Sebastian Harl
58ef38e2bb check_pgsql: Fixed query perfdata output for empty warn/crit ranges.
Previously, "(null)" was printed (when using GNU's libc). This has been
changed to print the empty string instead.
2012-07-05 11:36:57 +02:00
Sebastian Harl
912df3ef9b check_pgsql: Added support for executing queries.
The query result (the double value of the first column in the first row, to be
precise) will be checked against threshold ranges specified using the -C and
-W options.

Note that this also allows to query PostgreSQL internal values using the
information available from the database daemon's "statistics collector" -- see
the chapter "Monitoring Database Activity" in the PostgreSQL manual for
details.
2012-07-05 11:36:57 +02:00
Anders Kaseorg
028d50d6f9 Die when asprintf fails
Fixes many instances of
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-06-29 13:39:11 +02:00
Thomas Guyot-Sionnest
eaf3cb27f4 Add newline after "Usage:" in --help 2010-04-22 08:57:14 -04:00
Thomas Guyot-Sionnest
884aee0667 Standardize the extra-opts notes 2010-04-21 23:29:18 -04:00
Thomas Guyot-Sionnest
25d1ee331d Fix translations when extra-opts aren't enabled
Bug #2832884 reported problem with translations outputting pot file
headers. This is caused by "" matching the header of the translation
files.

This patch moves gettext macros inside utils macros and update some
french translations.
2010-04-14 08:33:06 -04:00
Matthias Eble
aff6140989 Whitespace indent fixes for check_pgsql 2009-06-01 22:47:34 +02:00
Matthias Eble
28e1b836b1 Added verbose output to check_pgsql (#2799281 - Jun Kuriyama)
check_pgsql displayed the -v flag in help output, but didn't
accept the verbosity argument. Added -v and basic verbose output.
2009-06-01 22:08:07 +02:00
Thomas Guyot-Sionnest
6fbd14fea5 Removing CVS/SVN tags and replacing with git-based versioning
For contrib/, full tags have been imported from subversion


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2091 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-23 05:38:47 +00:00