diff options
Diffstat (limited to 'plugins/check_pgsql.c')
| -rw-r--r-- | plugins/check_pgsql.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 07abd9c0..53ba2950 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 16 | 16 | ||
| 17 | $Id$ | ||
| 18 | |||
| 17 | *****************************************************************************/ | 19 | *****************************************************************************/ |
| 18 | 20 | ||
| 19 | #define DEFAULT_DB "template1" | 21 | #define DEFAULT_DB "template1" |
| @@ -55,7 +57,7 @@ const char *progname = "check_pgsql"; | |||
| 55 | const char *revision = "$Revision$"; | 57 | const char *revision = "$Revision$"; |
| 56 | const char *copyright = "1999-2003"; | 58 | const char *copyright = "1999-2003"; |
| 57 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 59 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
| 58 | 60 | ||
| 59 | 61 | ||
| 60 | /****************************************************************************** | 62 | /****************************************************************************** |
| 61 | 63 | ||
| @@ -110,8 +112,6 @@ Please note that all tags must be lowercase to use the DocBook XML DTD. | |||
| 110 | <title>Functions</title> | 112 | <title>Functions</title> |
| 111 | -@@ | 113 | -@@ |
| 112 | ******************************************************************************/ | 114 | ******************************************************************************/ |
| 113 | |||
| 114 | |||
| 115 | 115 | ||
| 116 | 116 | ||
| 117 | 117 | ||
| @@ -133,7 +133,7 @@ main (int argc, char **argv) | |||
| 133 | textdomain (PACKAGE); | 133 | textdomain (PACKAGE); |
| 134 | 134 | ||
| 135 | if (process_arguments (argc, argv) == ERROR) | 135 | if (process_arguments (argc, argv) == ERROR) |
| 136 | usage ("Could not parse arguments"); | 136 | usage (_("check_pgsql: could not parse arguments\n")); |
| 137 | 137 | ||
| 138 | /* Set signal handling and alarm */ | 138 | /* Set signal handling and alarm */ |
| 139 | if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { | 139 | if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { |
| @@ -151,7 +151,7 @@ main (int argc, char **argv) | |||
| 151 | 151 | ||
| 152 | /* check to see that the backend connection was successfully made */ | 152 | /* check to see that the backend connection was successfully made */ |
| 153 | if (PQstatus (conn) == CONNECTION_BAD) { | 153 | if (PQstatus (conn) == CONNECTION_BAD) { |
| 154 | printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"), | 154 | printf (_("CRITICAL - no connection to '%s' (%s).\n"), |
| 155 | dbName, PQerrorMessage (conn)); | 155 | dbName, PQerrorMessage (conn)); |
| 156 | PQfinish (conn); | 156 | PQfinish (conn); |
| 157 | return STATE_CRITICAL; | 157 | return STATE_CRITICAL; |
| @@ -166,13 +166,13 @@ main (int argc, char **argv) | |||
| 166 | status = STATE_OK; | 166 | status = STATE_OK; |
| 167 | } | 167 | } |
| 168 | PQfinish (conn); | 168 | PQfinish (conn); |
| 169 | printf (_("PGSQL: %s - database %s (%d sec.)|%s\n"), | 169 | printf (_(" %s - database %s (%d sec.)|%s\n"), |
| 170 | state_text(status), dbName, elapsed_time, | 170 | state_text(status), dbName, elapsed_time, |
| 171 | fperfdata("time", elapsed_time, "s", | 171 | fperfdata("time", elapsed_time, "s", |
| 172 | (int)twarn, twarn, (int)tcrit, tcrit, TRUE, 0, FALSE,0)); | 172 | (int)twarn, twarn, (int)tcrit, tcrit, TRUE, 0, FALSE,0)); |
| 173 | return status; | 173 | return status; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | 177 | ||
| 178 | /* process command-line arguments */ | 178 | /* process command-line arguments */ |
| @@ -206,8 +206,9 @@ process_arguments (int argc, char **argv) | |||
| 206 | 206 | ||
| 207 | switch (c) { | 207 | switch (c) { |
| 208 | case '?': /* usage */ | 208 | case '?': /* usage */ |
| 209 | usage3 (_("Unknown argument"), optopt); | 209 | printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); |
| 210 | break; | 210 | print_usage (); |
| 211 | exit (STATE_UNKNOWN); | ||
| 211 | case 'h': /* help */ | 212 | case 'h': /* help */ |
| 212 | print_help (); | 213 | print_help (); |
| 213 | exit (STATE_OK); | 214 | exit (STATE_OK); |
| @@ -222,25 +223,25 @@ process_arguments (int argc, char **argv) | |||
| 222 | break; | 223 | break; |
| 223 | case 'c': /* critical time threshold */ | 224 | case 'c': /* critical time threshold */ |
| 224 | if (!is_nonnegative (optarg)) | 225 | if (!is_nonnegative (optarg)) |
| 225 | usage2 (_("Invalid critical threshold"), optarg); | 226 | usage2 (_("Critical threshold must be a positive integer"), optarg); |
| 226 | else | 227 | else |
| 227 | tcrit = strtod (optarg, NULL); | 228 | tcrit = strtod (optarg, NULL); |
| 228 | break; | 229 | break; |
| 229 | case 'w': /* warning time threshold */ | 230 | case 'w': /* warning time threshold */ |
| 230 | if (!is_nonnegative (optarg)) | 231 | if (!is_nonnegative (optarg)) |
| 231 | usage2 (_("Invalid critical threshold"), optarg); | 232 | usage2 (_("Critical threshold must be a positive integer"), optarg); |
| 232 | else | 233 | else |
| 233 | twarn = strtod (optarg, NULL); | 234 | twarn = strtod (optarg, NULL); |
| 234 | break; | 235 | break; |
| 235 | case 'H': /* host */ | 236 | case 'H': /* host */ |
| 236 | if (!is_host (optarg)) | 237 | if (!is_host (optarg)) |
| 237 | usage2 (_("Invalid host name"), optarg); | 238 | usage2 (_("Invalid hostname/address"), optarg); |
| 238 | else | 239 | else |
| 239 | pghost = optarg; | 240 | pghost = optarg; |
| 240 | break; | 241 | break; |
| 241 | case 'P': /* port */ | 242 | case 'P': /* port */ |
| 242 | if (!is_integer (optarg)) | 243 | if (!is_integer (optarg)) |
| 243 | usage2 (_("Port must be an integer"), optarg); | 244 | usage2 (_("Port must be a positive integer"), optarg); |
| 244 | else | 245 | else |
| 245 | pgport = optarg; | 246 | pgport = optarg; |
| 246 | break; | 247 | break; |
| @@ -287,12 +288,13 @@ first character cannot be a number, however.</para> | |||
| 287 | -@@ | 288 | -@@ |
| 288 | ******************************************************************************/ | 289 | ******************************************************************************/ |
| 289 | 290 | ||
| 291 | |||
| 292 | |||
| 290 | int | 293 | int |
| 291 | validate_arguments () | 294 | validate_arguments () |
| 292 | { | 295 | { |
| 293 | return OK; | 296 | return OK; |
| 294 | } | 297 | } |
| 295 | |||
| 296 | 298 | ||
| 297 | 299 | ||
| 298 | /****************************************************************************** | 300 | /****************************************************************************** |
| @@ -315,6 +317,8 @@ first character cannot be a number, however.</para> | |||
| 315 | -@@ | 317 | -@@ |
| 316 | ******************************************************************************/ | 318 | ******************************************************************************/ |
| 317 | 319 | ||
| 320 | |||
| 321 | |||
| 318 | int | 322 | int |
| 319 | is_pg_dbname (char *dbname) | 323 | is_pg_dbname (char *dbname) |
| 320 | { | 324 | { |
| @@ -355,6 +359,8 @@ should be added.</para> | |||
| 355 | -@@ | 359 | -@@ |
| 356 | ******************************************************************************/ | 360 | ******************************************************************************/ |
| 357 | 361 | ||
| 362 | |||
| 363 | |||
| 358 | int | 364 | int |
| 359 | is_pg_logname (char *username) | 365 | is_pg_logname (char *username) |
| 360 | { | 366 | { |
| @@ -370,8 +376,6 @@ is_pg_logname (char *username) | |||
| 370 | </article> | 376 | </article> |
| 371 | -@@ | 377 | -@@ |
| 372 | ******************************************************************************/ | 378 | ******************************************************************************/ |
| 373 | |||
| 374 | |||
| 375 | 379 | ||
| 376 | 380 | ||
| 377 | 381 | ||
| @@ -386,7 +390,7 @@ print_help (void) | |||
| 386 | 390 | ||
| 387 | printf (_(COPYRIGHT), copyright, email); | 391 | printf (_(COPYRIGHT), copyright, email); |
| 388 | 392 | ||
| 389 | printf (_("Test whether a PostgreSQL DBMS is accepting connections.\n\n")); | 393 | printf (_("Test whether a PostgreSQL Database is accepting connections.\n\n")); |
| 390 | 394 | ||
| 391 | print_usage (); | 395 | print_usage (); |
| 392 | 396 | ||
| @@ -431,7 +435,6 @@ a password, but no effort is made to obsure or encrypt the password.\n")); | |||
| 431 | 435 | ||
| 432 | 436 | ||
| 433 | 437 | ||
| 434 | |||
| 435 | void | 438 | void |
| 436 | print_usage (void) | 439 | print_usage (void) |
| 437 | { | 440 | { |
| @@ -444,4 +447,3 @@ Usage:\n %s [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]\n\ | |||
| 444 | %s (-V | --version) for version information\n"), | 447 | %s (-V | --version) for version information\n"), |
| 445 | progname, progname); | 448 | progname, progname); |
| 446 | } | 449 | } |
| 447 | |||
