check_dummy.c 2.5 KB

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