check_dummy.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. if (argc != 2)
  27. usage (_("Incorrect number of arguments supplied\n"));
  28. else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
  29. print_revision (progname, revision);
  30. exit (STATE_OK);
  31. }
  32. else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
  33. print_help ();
  34. exit (STATE_OK);
  35. }
  36. else if (!is_integer (argv[1]))
  37. usage (_("Arguments to check_dummy must be an integer\n"));
  38. else
  39. result = atoi (argv[1]);
  40. switch (result) {
  41. case STATE_OK:
  42. printf ("Status is OK\n");
  43. break;
  44. case STATE_WARNING:
  45. printf ("Status is at WARNING level\n");
  46. break;
  47. case STATE_CRITICAL:
  48. printf ("Status is CRITICAL\n");
  49. break;
  50. case STATE_UNKNOWN:
  51. printf ("Status is UNKNOWN\n");
  52. break;
  53. default:
  54. printf ("Status %d is not a supported error state\n", result);
  55. break;
  56. }
  57. return result;
  58. }
  59. void
  60. print_help (void)
  61. {
  62. print_revision (progname, revision);
  63. printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
  64. printf (_(COPYRIGHT), copyright, email);
  65. print_usage ();
  66. printf (_(UT_HELP_VRSN));
  67. printf (_("\n\
  68. This plugin will simply return the state corresponding to the numeric value\n\
  69. of the <state> argument.\n"));
  70. printf (_(UT_SUPPORT));
  71. }
  72. void
  73. print_usage (void)
  74. {
  75. printf (_("Usage: %s <integer state>\n"), progname);
  76. }