check_dummy.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. void print_help (const char *);
  40. void print_usage (const char *);
  41. int
  42. main (int argc, char **argv)
  43. {
  44. int result;
  45. if (argc != 2) {
  46. printf ("Incorrect number of arguments supplied\n");
  47. exit (STATE_UNKNOWN);
  48. }
  49. else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
  50. print_revision (argv[0], "$Revision$");
  51. exit (STATE_OK);
  52. }
  53. else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
  54. print_help (argv[0]);
  55. exit (STATE_OK);
  56. }
  57. else if (!is_integer (argv[1])) {
  58. print_usage (argv[0]);
  59. exit (STATE_UNKNOWN);
  60. }
  61. result = atoi (argv[1]);
  62. switch (result) {
  63. case STATE_OK:
  64. printf ("Status is OK\n");
  65. break;
  66. case STATE_WARNING:
  67. printf ("Status is at WARNING level\n");
  68. break;
  69. case STATE_CRITICAL:
  70. printf ("Status is CRITICAL\n");
  71. break;
  72. default:
  73. printf ("Status is UNKNOWN\n");
  74. result = STATE_UNKNOWN;
  75. }
  76. return result;
  77. }
  78. void
  79. print_help (const char *cmd)
  80. {
  81. print_revision (cmd, "$Revision$");
  82. printf ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"
  83. "License: GPL\n\n");
  84. print_usage (cmd);
  85. printf
  86. ("\nThis plugin will simply return the state corresponding to the numeric value\n"
  87. "of the <state> argument.\n");
  88. }
  89. void
  90. print_usage (const char *cmd)
  91. {
  92. printf ("Usage: %s <integer state>\n", cmd);
  93. }