summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-07-26 12:15:06 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-07-26 12:15:06 +0000
commit32a023896b5e0ee721b9b43a7b4ba222abeb8186 (patch)
treed504bb986599296ea6e21a3b0ef7342d64ba7764
parent22c75b6d3cd0482499bd5dbe6e7a6a068d3951d6 (diff)
downloadmonitoring-plugins-32a023896b5e0ee721b9b43a7b4ba222abeb8186.tar.gz
mark for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@607 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_pgsql.c166
1 files changed, 90 insertions, 76 deletions
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index e1484566..dea39cf9 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -30,45 +30,9 @@ const char *progname = "check_pgsql";
30#define EMAIL "kdebisschop@users.sourceforge.net" 30#define EMAIL "kdebisschop@users.sourceforge.net"
31#define SUMMARY "Tests to see if a PostgreSQL DBMS is accepting connections.\n" 31#define SUMMARY "Tests to see if a PostgreSQL DBMS is accepting connections.\n"
32 32
33#define OPTIONS "[-c critical_time] [-w warning_time] [-t timeout] [-H host]\n\
34 [-P port] [-d database] [-l logname] [-p password]"
35
36#define LONGOPTIONS "\
37 -c, --critical=INTEGER\n\
38 Exit STATE_CRITICAL if connection time exceeds threshold (default: %d)\n\
39 -w, --warning=INTEGER\n\
40 Exit STATE_WARNING if connection time exceeds threshold (default: %d)\n\
41 -t, --timeout=INTEGER\n\
42 Terminate test if timeout limit is exceeded (default: %d)\n\
43 -H, --hostname=STRING\n\
44 Name or numeric IP address of machine running backend\n\
45 -P, --port=INTEGER\n\
46 Port running backend (default: %d)\n\
47 -d, --database=STRING\n\
48 Database to check (default: %s)\n\
49 -l, --logname = STRING\n\
50 Login name of user\n\
51 -p, --password = STRING\n\
52 Password (BIG SECURITY ISSUE)\n"
53
54#define DESCRIPTION "All parameters are optional.\n\
55\n\
56This plugin tests a PostgreSQL DBMS to determine whether it is active and\n\
57accepting queries. In its current operation, it simply connects to the\n\
58specified database, and then disconnects. If no database is specified, it\n\
59connects to the template1 database, which is present in every functioning \n\
60PostgreSQL DBMS.\n\
61\n\
62The plugin will connect to a local postmaster if no host is specified. To\n\
63connect to a remote host, be sure that the remote postmaster accepts TCP/IP\n\
64connections (start the postmaster with the -i option).\n\
65\n\
66Typically, the nagios user (unless the --logname option is used) should be\n\
67able to connect to the database without a password. The plugin can also send\n\
68a password, but no effort is made to obsure or encrypt the password.\n"
69
70#define DEFAULT_DB "template1" 33#define DEFAULT_DB "template1"
71#define DEFAULT_HOST "127.0.0.1" 34#define DEFAULT_HOST "127.0.0.1"
35
72enum { 36enum {
73 DEFAULT_PORT = 5432, 37 DEFAULT_PORT = 5432,
74 DEFAULT_WARN = 2, 38 DEFAULT_WARN = 2,
@@ -156,6 +120,82 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
156<title>Functions</title> 120<title>Functions</title>
157-@@ 121-@@
158******************************************************************************/ 122******************************************************************************/
123
124
125
126
127void
128print_help (void)
129{
130 print_revision (progname, REVISION);
131 printf
132 ("Copyright (c) %s %s <%s>\n\n%s\n",
133 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
134 print_usage ();
135 printf (_("\
136\nOptions:\n\
137 -H, --hostname=ADDRESS\n\
138 Host name argument for servers using host headers (use numeric\n\
139 address if possible to bypass DNS lookup).\n\
140 -P, --port=INTEGER\n\
141 Port number (default: %d)\n\
142 -4, --use-ipv4\n\
143 Use IPv4 connection\n\
144 -6, --use-ipv6\n\
145 Use IPv6 connection\n"), DEFAULT_PORT);
146 printf (S_("\
147 -d, --database=STRING\n\
148 Database to check (default: %s)\n\
149 -l, --logname = STRING\n\
150 Login name of user\n\
151 -p, --password = STRING\n\
152 Password (BIG SECURITY ISSUE)\n\n"), DEFAULT_DB);
153 printf (S_("\nOptions:\n\
154 -c, --critical=INTEGER\n\
155 Exit STATE_CRITICAL if connection time exceeds threshold (default: %d)\n\
156 -w, --warning=INTEGER\n\
157 Exit STATE_WARNING if connection time exceeds threshold (default: %d)\n\
158 -t, --timeout=INTEGER\n\
159 Terminate test if timeout limit is exceeded (default: %d)\n"),
160 DEFAULT_WARN, DEFAULT_CRIT, DEFAULT_TIMEOUT);
161 printf (_("\
162 -v, --verbose\n\
163 Show details for command-line debugging (Nagios may truncate output)\n\
164 -h, --help\n\
165 Print detailed help screen\n\
166 -V, --version\n\
167 Print version information\n\n"));
168 printf (S_("All parameters are optional.\n\
169\n\
170This plugin tests a PostgreSQL DBMS to determine whether it is active and\n\
171accepting queries. In its current operation, it simply connects to the\n\
172specified database, and then disconnects. If no database is specified, it\n\
173connects to the template1 database, which is present in every functioning \n\
174PostgreSQL DBMS.\n"));
175 printf (S_("\n\
176The plugin will connect to a local postmaster if no host is specified. To\n\
177connect to a remote host, be sure that the remote postmaster accepts TCP/IP\n\
178connections (start the postmaster with the -i option).\n"));
179 printf (S_("\n\
180Typically, the nagios user (unless the --logname option is used) should be\n\
181able to connect to the database without a password. The plugin can also send\n\
182a password, but no effort is made to obsure or encrypt the password.\n"));
183
184 support ();
185}
186
187void
188print_usage (void)
189{
190 printf (S_("\
191Usage:\n %s [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]\n\
192 [-t <timeout>]"), progname);
193 printf (S_("[-d <database>] [-l <logname>] [-p <password>]\n"));
194 printf (S_("\
195 %s (-h | --help) for detailed help\n\
196 %s (-V | --version) for version information\n"),
197 progname, progname);
198}
159 199
160int 200int
161main (int argc, char **argv) 201main (int argc, char **argv)
@@ -175,7 +215,7 @@ main (int argc, char **argv)
175 215
176 /* Set signal handling and alarm */ 216 /* Set signal handling and alarm */
177 if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { 217 if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
178 printf ("Cannot catch SIGALRM"); 218 printf (_("Cannot catch SIGALRM"));
179 return STATE_UNKNOWN; 219 return STATE_UNKNOWN;
180 } 220 }
181 alarm (timeout_interval); 221 alarm (timeout_interval);
@@ -189,57 +229,31 @@ main (int argc, char **argv)
189 229
190 /* check to see that the backend connection was successfully made */ 230 /* check to see that the backend connection was successfully made */
191 if (PQstatus (conn) == CONNECTION_BAD) { 231 if (PQstatus (conn) == CONNECTION_BAD) {
192 printf ("PGSQL: CRITICAL - no connection to '%s' (%s).\n", dbName, 232 printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"), dbName,
193 PQerrorMessage (conn)); 233 PQerrorMessage (conn));
194 PQfinish (conn); 234 PQfinish (conn);
195 return STATE_CRITICAL; 235 return STATE_CRITICAL;
196 } 236 }
197 else if (elapsed_time > tcrit) { 237 else if (elapsed_time > tcrit) {
198 PQfinish (conn); 238 PQfinish (conn);
199 printf ("PGSQL: CRITICAL - database %s (%d sec.)\n", dbName, 239 printf (_("PGSQL: CRITICAL - database %s (%d sec.)\n"), dbName,
200 elapsed_time); 240 elapsed_time);
201 return STATE_CRITICAL; 241 return STATE_CRITICAL;
202 } 242 }
203 else if (elapsed_time > twarn) { 243 else if (elapsed_time > twarn) {
204 PQfinish (conn); 244 PQfinish (conn);
205 printf ("PGSQL: WARNING - database %s (%d sec.)\n", dbName, elapsed_time); 245 printf (_("PGSQL: WARNING - database %s (%d sec.)\n"), dbName, elapsed_time);
206 return STATE_WARNING; 246 return STATE_WARNING;
207 } 247 }
208 else { 248 else {
209 PQfinish (conn); 249 PQfinish (conn);
210 printf ("PGSQL: ok - database %s (%d sec.)\n", dbName, elapsed_time); 250 printf (_("PGSQL: ok - database %s (%d sec.)\n"), dbName, elapsed_time);
211 return STATE_OK; 251 return STATE_OK;
212 } 252 }
213} 253}
214 254
215 255
216 256
217
218void
219print_help (void)
220{
221 print_revision (progname, REVISION);
222 printf
223 ("Copyright (c) %s %s <%s>\n\n%s\n",
224 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
225 print_usage ();
226 printf
227 ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n",
228 DEFAULT_WARN, DEFAULT_CRIT, DEFAULT_TIMEOUT, DEFAULT_PORT, DEFAULT_DB);
229 support ();
230}
231
232void
233print_usage (void)
234{
235 printf ("Usage:\n" " %s %s\n"
236 " %s (-h | --help) for detailed help\n"
237 " %s (-V | --version) for version information\n",
238 progname, OPTIONS, progname, progname);
239}
240
241
242
243/* process command-line arguments */ 257/* process command-line arguments */
244int 258int
245process_arguments (int argc, char **argv) 259process_arguments (int argc, char **argv)
@@ -271,7 +285,7 @@ process_arguments (int argc, char **argv)
271 285
272 switch (c) { 286 switch (c) {
273 case '?': /* usage */ 287 case '?': /* usage */
274 usage3 ("Unknown argument", optopt); 288 usage3 (_("Unknown argument"), optopt);
275 case 'h': /* help */ 289 case 'h': /* help */
276 print_help (); 290 print_help ();
277 exit (STATE_OK); 291 exit (STATE_OK);
@@ -280,38 +294,38 @@ process_arguments (int argc, char **argv)
280 exit (STATE_OK); 294 exit (STATE_OK);
281 case 't': /* timeout period */ 295 case 't': /* timeout period */
282 if (!is_integer (optarg)) 296 if (!is_integer (optarg))
283 usage2 ("Timeout Interval must be an integer", optarg); 297 usage2 (_("Timeout Interval must be an integer"), optarg);
284 timeout_interval = atoi (optarg); 298 timeout_interval = atoi (optarg);
285 break; 299 break;
286 case 'c': /* critical time threshold */ 300 case 'c': /* critical time threshold */
287 if (!is_integer (optarg)) 301 if (!is_integer (optarg))
288 usage2 ("Invalid critical threshold", optarg); 302 usage2 (_("Invalid critical threshold"), optarg);
289 tcrit = atoi (optarg); 303 tcrit = atoi (optarg);
290 break; 304 break;
291 case 'w': /* warning time threshold */ 305 case 'w': /* warning time threshold */
292 if (!is_integer (optarg)) 306 if (!is_integer (optarg))
293 usage2 ("Invalid critical threshold", optarg); 307 usage2 (_("Invalid critical threshold"), optarg);
294 twarn = atoi (optarg); 308 twarn = atoi (optarg);
295 break; 309 break;
296 case 'H': /* host */ 310 case 'H': /* host */
297 if (!is_host (optarg)) 311 if (!is_host (optarg))
298 usage2 ("You gave an invalid host name", optarg); 312 usage2 (_("You gave an invalid host name"), optarg);
299 pghost = optarg; 313 pghost = optarg;
300 break; 314 break;
301 case 'P': /* port */ 315 case 'P': /* port */
302 if (!is_integer (optarg)) 316 if (!is_integer (optarg))
303 usage2 ("Port must be an integer", optarg); 317 usage2 (_("Port must be an integer"), optarg);
304 pgport = optarg; 318 pgport = optarg;
305 break; 319 break;
306 case 'd': /* database name */ 320 case 'd': /* database name */
307 if (!is_pg_dbname (optarg)) 321 if (!is_pg_dbname (optarg))
308 usage2 ("Database name is not valid", optarg); 322 usage2 (_("Database name is not valid"), optarg);
309 strncpy (dbName, optarg, NAMEDATALEN - 1); 323 strncpy (dbName, optarg, NAMEDATALEN - 1);
310 dbName[NAMEDATALEN - 1] = 0; 324 dbName[NAMEDATALEN - 1] = 0;
311 break; 325 break;
312 case 'l': /* login name */ 326 case 'l': /* login name */
313 if (!is_pg_logname (optarg)) 327 if (!is_pg_logname (optarg))
314 usage2 ("user name is not valid", optarg); 328 usage2 (_("user name is not valid"), optarg);
315 pguser = optarg; 329 pguser = optarg;
316 break; 330 break;
317 case 'p': /* authentication password */ 331 case 'p': /* authentication password */