diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 16b9a96e1b1f2306242c54a0dd4160e08a1dd9be..22a5b8119a98ba63855e140c9cf9163bcb02daa9 100644 (file)
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
char dbName[NAMEDATALEN] = DEFAULT_DB;
char *pguser = NULL;
char *pgpasswd = NULL;
-int twarn = DEFAULT_WARN;
-int tcrit = DEFAULT_CRIT;
+double twarn = (double)DEFAULT_WARN;
+double tcrit = (double)DEFAULT_CRIT;
PGconn *conn;
/*PGresult *res;*/
int
main (int argc, char **argv)
{
- int elapsed_time;
+ int elapsed_time, status;
/* begin, by setting the parameters for a backend connection if the
* parameters are null, then the system will try to use reasonable
/* check to see that the backend connection was successfully made */
if (PQstatus (conn) == CONNECTION_BAD) {
- printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"), dbName,
- PQerrorMessage (conn));
+ printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"),
+ dbName, PQerrorMessage (conn));
PQfinish (conn);
return STATE_CRITICAL;
}
else if (elapsed_time > tcrit) {
- PQfinish (conn);
- printf (_("PGSQL: CRITICAL - database %s (%d sec.)\n"), dbName,
- elapsed_time);
- return STATE_CRITICAL;
+ status = STATE_CRITICAL;
}
else if (elapsed_time > twarn) {
- PQfinish (conn);
- printf (_("PGSQL: WARNING - database %s (%d sec.)\n"), dbName, elapsed_time);
- return STATE_WARNING;
+ status = STATE_WARNING;
}
else {
- PQfinish (conn);
- printf (_("PGSQL: ok - database %s (%d sec.)\n"), dbName, elapsed_time);
- return STATE_OK;
+ status = STATE_OK;
}
+ PQfinish (conn);
+ printf (_("PGSQL: %s - database %s (%d sec.)|%s\n"),
+ state_text(status), dbName, elapsed_time,
+ fperfdata("time", elapsed_time, "s",
+ (int)twarn, twarn, (int)tcrit, tcrit, TRUE, 0, FALSE,0));
+ return status;
}
\f
timeout_interval = atoi (optarg);
break;
case 'c': /* critical time threshold */
- if (!is_integer (optarg))
+ if (!is_nonnegative (optarg))
usage2 (_("Invalid critical threshold"), optarg);
else
- tcrit = atoi (optarg);
+ tcrit = strtod (optarg, NULL);
break;
case 'w': /* warning time threshold */
- if (!is_integer (optarg))
+ if (!is_nonnegative (optarg))
usage2 (_("Invalid critical threshold"), optarg);
else
- twarn = atoi (optarg);
+ twarn = strtod (optarg, NULL);
break;
case 'H': /* host */
if (!is_host (optarg))