summaryrefslogtreecommitdiffstats
path: root/plugins/check_ups.c
diff options
context:
space:
mode:
authorBenoit Mortier <opensides@users.sourceforge.net>2006-06-18 19:36:48 (GMT)
committerBenoit Mortier <opensides@users.sourceforge.net>2006-06-18 19:36:48 (GMT)
commitf9394308c9c372bcf419a311c61ba420247ae613 (patch)
tree616e0bebcbe821703dff207f7f1b704c2deae349 /plugins/check_ups.c
parentcbbfed30eb01a702b2e61c0abcb64c834e73d654 (diff)
downloadmonitoring-plugins-f9394308c9c372bcf419a311c61ba420247ae613.tar.gz
updating help and usage and license
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1434 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r--plugins/check_ups.c129
1 files changed, 66 insertions, 63 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 786cedc..110ea0a 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -1,35 +1,42 @@
1/****************************************************************************** 1/******************************************************************************
2 2*
3 check_ups 3* Nagios check_ups plugin
4 4*
5 Program: Network UPS Tools plugin for Nagios 5* License: GPL
6 License: GPL 6* Copyright (c) 2000 Tom Shields
7 Copyright (c) 2000 Tom Shields 7* 2004 Alain Richard <alain.richard@equation.fr>
8 2004 Alain Richard <alain.richard@equation.fr> 8* 2004 Arnaud Quette <arnaud.quette@mgeups.com>
9 2004 Arnaud Quette <arnaud.quette@mgeups.com> 9* Copyright (c) 2002-2006 nagios-plugins team
10 10*
11 11* Last Modified: $Date$
12 This program is free software; you can redistribute it and/or modify 12*
13 it under the terms of the GNU General Public License as published by 13* Description:
14 the Free Software Foundation; either version 2 of the License, or (at 14*
15 your option) any later version. 15* This file contains Network UPS Tools plugin for Nagios
16 16*
17 This program is distributed in the hope that it will be useful, but 17* License Information:
18 WITHOUT ANY WARRANTY; without even the implied warranty of 18*
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19* This program is free software; you can redistribute it and/or modify
20 General Public License for more details. 20* it under the terms of the GNU General Public License as published by
21 21* the Free Software Foundation; either version 2 of the License, or
22 You should have received a copy of the GNU General Public License 22* (at your option) any later version.
23 along with this program; if not, write to the Free Software 23*
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24* This program is distributed in the hope that it will be useful,
25 25* but WITHOUT ANY WARRANTY; without even the implied warranty of
26 $Id$ 26* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 27* GNU General Public License for more details.
28*
29* You should have received a copy of the GNU General Public License
30* along with this program; if not, write to the Free Software
31* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32*
33* $Id$
34*
28******************************************************************************/ 35******************************************************************************/
29 36
30const char *progname = "check_ups"; 37const char *progname = "check_ups";
31const char *revision = "$Revision$"; 38const char *revision = "$Revision$";
32const char *copyright = "2000-2004"; 39const char *copyright = "2000-2006";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 40const char *email = "nagiosplug-devel@lists.sourceforge.net";
34 41
35#include "common.h" 42#include "common.h"
@@ -338,7 +345,7 @@ determine_status (void)
338 res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); 345 res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
339 if (res == NOSUCHVAR) return OK; 346 if (res == NOSUCHVAR) return OK;
340 if (res != STATE_OK) { 347 if (res != STATE_OK) {
341 printf (_("Invalid response received from host\n")); 348 printf ("%s\n", _("Invalid response received from host"));
342 return ERROR; 349 return ERROR;
343 } 350 }
344 351
@@ -398,7 +405,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
398 if (process_tcp_request 405 if (process_tcp_request
399 (server_address, server_port, send_buffer, temp_buffer, 406 (server_address, server_port, send_buffer, temp_buffer,
400 sizeof (temp_buffer)) != STATE_OK) { 407 sizeof (temp_buffer)) != STATE_OK) {
401 printf (_("Invalid response received from host\n")); 408 printf ("%s\n", _("Invalid response received from host"));
402 return ERROR; 409 return ERROR;
403 } 410 }
404 411
@@ -416,7 +423,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
416 } 423 }
417 424
418 if (strcmp (ptr, "ERR DATA-STALE") == 0) { 425 if (strcmp (ptr, "ERR DATA-STALE") == 0) {
419 printf (_("CRITICAL - UPS data is stale\n")); 426 printf ("%s\n", _("CRITICAL - UPS data is stale"));
420 return ERROR; 427 return ERROR;
421 } 428 }
422 429
@@ -428,7 +435,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
428 ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; 435 ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6;
429 len = strlen(ptr); 436 len = strlen(ptr);
430 if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { 437 if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') {
431 printf (_("Error: unable to parse variable\n")); 438 printf ("%s\n", _("Error: unable to parse variable"));
432 return ERROR; 439 return ERROR;
433 } 440 }
434 strncpy (buf, ptr+1, len - 2); 441 strncpy (buf, ptr+1, len - 2);
@@ -573,7 +580,7 @@ int
573validate_arguments (void) 580validate_arguments (void)
574{ 581{
575 if (! ups_name) { 582 if (! ups_name) {
576 printf (_("Error : no ups indicated\n")); 583 printf ("%s\n", _("Error : no ups indicated"));
577 return ERROR; 584 return ERROR;
578 } 585 }
579 return OK; 586 return OK;
@@ -593,9 +600,10 @@ print_help (void)
593 printf ("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n"); 600 printf ("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n");
594 printf (COPYRIGHT, copyright, email); 601 printf (COPYRIGHT, copyright, email);
595 602
596 printf (_("This plugin tests the UPS service on the specified host.\n\ 603 printf ("%s\n", _("This plugin tests the UPS service on the specified host.Network UPS Tools "));
597Network UPS Tools from www.networkupstools.org must be running for this\n\ 604 printf ("%s\n", _("from www.networkupstools.org must be running for thisplugin to work."));
598plugin to work.\n\n")); 605
606 printf ("\n\n");
599 607
600 print_usage (); 608 print_usage ();
601 609
@@ -603,13 +611,10 @@ plugin to work.\n\n"));
603 611
604 printf (_(UT_HOST_PORT), 'p', myport); 612 printf (_(UT_HOST_PORT), 'p', myport);
605 613
606 printf (_("\ 614 printf (" %s\n", "-u, --ups=STRING");
607 -u, --ups=STRING\n\ 615 printf (" %s\n", _("Name of UPS"));
608 Name of UPS\n")); 616 printf (" %s\n", "-T, --temperature");
609 617 printf (" %s\n", _("Output of temperatures in Celsius"));
610 printf (_("\
611 -T, --temperature\n\
612 Output of temperatures in Celsius\n"));
613 618
614 printf (_(UT_WARN_CRIT)); 619 printf (_(UT_WARN_CRIT));
615 620
@@ -617,24 +622,23 @@ plugin to work.\n\n"));
617 622
618 printf (_(UT_VERBOSE)); 623 printf (_(UT_VERBOSE));
619 624
620 printf (_("\ 625 printf ("\n");
621This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\ 626 printf ("%s\n", _("Notes:"));
622Supply) on a local or remote host. If the UPS is online or calibrating, the\n\ 627
623plugin will return an OK state. If the battery is on it will return a WARNING\n\ 628 printf ("%s\n", _("This plugin attempts to determine the status of a UPS (Uninterruptible Power"));
624state. If the UPS is off or has a low battery the plugin will return a CRITICAL\n\ 629 printf ("%s\n", _("Supply) on a local or remote host. If the UPS is online or calibrating, the"));
625state.\n\n")); 630 printf ("%s\n", _("plugin will return an OK state. If the battery is on it will return a WARNING"));
626 631 printf ("%s\n", _("state.If the UPS is off or has a low battery the plugin will return a CRITICAL"));
627 printf (_("\ 632 printf ("%s\n\n", _("state."));
628You may also specify a variable to check [such as temperature, utility voltage,\n\ 633
629battery load, etc.] as well as warning and critical thresholds for the value of\n\ 634 printf ("%s\n", _("You may also specify a variable to check [such as temperature, utility voltage,"));
630that variable. If the remote host has multiple UPS that are being monitored you\n\ 635 printf ("%s\n", _("battery load, etc.] as well as warning and critical thresholds for the value of"));
631will have to use the [ups] option to specify which UPS to check.\n\n")); 636 printf ("%s\n", _("that variable. If the remote host has multiple UPS that are being monitored you"));
632 637 printf ("%s\n", _("will have to use the [ups] option to specify which UPS to check."));
633 printf (_("Notes:\n\n\ 638
634This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ 639 printf ("%s\n", _("This plugin requires that the UPSD daemon distributed with Russel Kroll's"));
635Smart UPS Tools be installed on the remote host. If you do not have the\n\ 640 printf ("%s\n", _("Smart UPS Tools be installed on the remote host. If you do not have the"));
636package installed on your system, you can download it from\n\ 641 printf ("%s\n", _("package installed on your system, you can download it from http://www.networkupstools.org"));
637http://www.networkupstools.org\n\n"));
638 642
639 printf (_(UT_SUPPORT)); 643 printf (_(UT_SUPPORT));
640} 644}
@@ -643,7 +647,6 @@ http://www.networkupstools.org\n\n"));
643void 647void
644print_usage (void) 648print_usage (void)
645{ 649{
646 printf ("\ 650 printf (_("Usage:"));
647Usage: %s -H host -u ups [-p port] [-v variable]\n\ 651 printf ("%s -H host -u ups [-p port] [-v variable] [-w warn_value] [-c crit_value] [-to to_sec] [-T]\n", progname);
648 [-wv warn_value] [-cv crit_value] [-to to_sec] [-T]\n", progname);
649} 652}