diff options
Diffstat (limited to 'plugins/check_pgsql.c')
-rw-r--r-- | plugins/check_pgsql.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 16b9a96e..00b051be 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c | |||
@@ -118,7 +118,7 @@ Please note that all tags must be lowercase to use the DocBook XML DTD. | |||
118 | int | 118 | int |
119 | main (int argc, char **argv) | 119 | main (int argc, char **argv) |
120 | { | 120 | { |
121 | int elapsed_time; | 121 | int elapsed_time, status; |
122 | 122 | ||
123 | /* begin, by setting the parameters for a backend connection if the | 123 | /* begin, by setting the parameters for a backend connection if the |
124 | * parameters are null, then the system will try to use reasonable | 124 | * parameters are null, then the system will try to use reasonable |
@@ -151,27 +151,26 @@ 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"), dbName, | 154 | printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"), |
155 | PQerrorMessage (conn)); | 155 | dbName, PQerrorMessage (conn)); |
156 | PQfinish (conn); | 156 | PQfinish (conn); |
157 | return STATE_CRITICAL; | 157 | return STATE_CRITICAL; |
158 | } | 158 | } |
159 | else if (elapsed_time > tcrit) { | 159 | else if (elapsed_time > tcrit) { |
160 | PQfinish (conn); | 160 | status = STATE_CRITICAL; |
161 | printf (_("PGSQL: CRITICAL - database %s (%d sec.)\n"), dbName, | ||
162 | elapsed_time); | ||
163 | return STATE_CRITICAL; | ||
164 | } | 161 | } |
165 | else if (elapsed_time > twarn) { | 162 | else if (elapsed_time > twarn) { |
166 | PQfinish (conn); | 163 | status = STATE_WARNING; |
167 | printf (_("PGSQL: WARNING - database %s (%d sec.)\n"), dbName, elapsed_time); | ||
168 | return STATE_WARNING; | ||
169 | } | 164 | } |
170 | else { | 165 | else { |
171 | PQfinish (conn); | 166 | status = STATE_OK; |
172 | printf (_("PGSQL: ok - database %s (%d sec.)\n"), dbName, elapsed_time); | ||
173 | return STATE_OK; | ||
174 | } | 167 | } |
168 | PQfinish (conn); | ||
169 | printf (_("PGSQL: %s - database %s (%d sec.)|%s\n"), | ||
170 | state_text(status), dbName, elapsed_time, | ||
171 | perfdata("time", (long)elapsed_time, "s", | ||
172 | twarn, (long)twarn, tcrit, (long)tcrit, TRUE, 0, FALSE,0)); | ||
173 | return status; | ||
175 | } | 174 | } |
176 | 175 | ||
177 | 176 | ||