check_dummy.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*****************************************************************************
  2. *
  3. * Nagios check_dummy plugin
  4. *
  5. * License: GPL
  6. * Copyright (c) 1999-2007 Nagios Plugins Development Team
  7. *
  8. * Last Modified: $Date$
  9. *
  10. * Description:
  11. *
  12. * This file contains the check_dummy plugin
  13. *
  14. * This plugin will simply return the state corresponding to the numeric value
  15. *
  16. *
  17. * This program is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. *
  30. * $Id$
  31. *
  32. *****************************************************************************/
  33. const char *progname = "check_dummy";
  34. const char *revision = "$Revision$";
  35. const char *copyright = "1999-2007";
  36. const char *email = "nagiosplug-devel@lists.sourceforge.net";
  37. #include "common.h"
  38. #include "utils.h"
  39. void print_help (void);
  40. void print_usage (void);
  41. int
  42. main (int argc, char **argv)
  43. {
  44. int result = STATE_UNKNOWN;
  45. setlocale (LC_ALL, "");
  46. bindtextdomain (PACKAGE, LOCALEDIR);
  47. textdomain (PACKAGE);
  48. if (argc < 2)
  49. usage4 (_("Could not parse arguments"));
  50. else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
  51. print_revision (progname, revision);
  52. exit (STATE_OK);
  53. }
  54. else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
  55. print_help ();
  56. exit (STATE_OK);
  57. }
  58. else if (!is_integer (argv[1]))
  59. usage4 (_("Arguments to check_dummy must be an integer"));
  60. else
  61. result = atoi (argv[1]);
  62. switch (result) {
  63. case STATE_OK:
  64. printf (_("OK"));
  65. break;
  66. case STATE_WARNING:
  67. printf (_("WARNING"));
  68. break;
  69. case STATE_CRITICAL:
  70. printf (_("CRITICAL"));
  71. break;
  72. case STATE_UNKNOWN:
  73. printf (_("UNKNOWN"));
  74. break;
  75. default:
  76. printf (_("UNKNOWN"));
  77. printf (": ");
  78. printf (_("Status %d is not a supported error state\n"), result);
  79. return STATE_UNKNOWN;
  80. }
  81. if (argc >= 3)
  82. printf (": %s", argv[2]);
  83. printf("\n");
  84. return result;
  85. }
  86. void
  87. print_help (void)
  88. {
  89. print_revision (progname, revision);
  90. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  91. printf (COPYRIGHT, copyright, email);
  92. printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
  93. printf ("%s\n", _("of the <state> argument with optional text"));
  94. printf ("\n\n");
  95. print_usage ();
  96. printf (_(UT_HELP_VRSN));
  97. printf (_(UT_SUPPORT));
  98. }
  99. void
  100. print_usage (void)
  101. {
  102. printf (_("Usage:"));
  103. printf (" %s <integer state> [optional text]\n", progname);
  104. }