check_dummy.c 3.0 KB

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