check_dummy.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. $Id$
  14. ******************************************************************************/
  15. const char *progname = "check_dummy";
  16. const char *revision = "$Revision$";
  17. const char *copyright = "1999-2005";
  18. const char *email = "nagiosplug-devel@lists.sourceforge.net";
  19. #include "common.h"
  20. #include "utils.h"
  21. void print_help (void);
  22. void print_usage (void);
  23. int
  24. main (int argc, char **argv)
  25. {
  26. int result = STATE_UNKNOWN;
  27. setlocale (LC_ALL, "");
  28. bindtextdomain (PACKAGE, LOCALEDIR);
  29. textdomain (PACKAGE);
  30. if (argc < 2)
  31. usage4 (_("Could not parse arguments"));
  32. else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
  33. print_revision (progname, revision);
  34. exit (STATE_OK);
  35. }
  36. else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
  37. print_help ();
  38. exit (STATE_OK);
  39. }
  40. else if (!is_integer (argv[1]))
  41. usage4 (_("Arguments to check_dummy must be an integer"));
  42. else
  43. result = atoi (argv[1]);
  44. switch (result) {
  45. case STATE_OK:
  46. printf (_("OK"));
  47. break;
  48. case STATE_WARNING:
  49. printf (_("WARNING"));
  50. break;
  51. case STATE_CRITICAL:
  52. printf (_("CRITICAL"));
  53. break;
  54. case STATE_UNKNOWN:
  55. printf (_("UNKNOWN"));
  56. break;
  57. default:
  58. printf (_("Status %d is not a supported error state\n"), result);
  59. break;
  60. }
  61. if (argc >= 3)
  62. printf (": %s", argv[2]);
  63. printf("\n");
  64. return result;
  65. }
  66. void
  67. print_help (void)
  68. {
  69. print_revision (progname, revision);
  70. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  71. printf (COPYRIGHT, copyright, email);
  72. printf (_("This plugin will simply return the state corresponding to the numeric value"));
  73. printf ("\n");
  74. printf (_("of the <state> argument with optional text"));
  75. printf ("\n\n");
  76. print_usage ();
  77. printf (_(UT_HELP_VRSN));
  78. printf (_(UT_SUPPORT));
  79. }
  80. void
  81. print_usage (void)
  82. {
  83. printf (_("Usage:"));
  84. printf (" %s <integer state> [optional text]\n", progname);
  85. }