check_dummy.c 2.6 KB

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