Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stats.h 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C) 2019 Weber Yann
  3. *
  4. * This file is part of PyFCGI.
  5. *
  6. * PyFCGI is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * PyFCGI is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PyFCGI. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**@file stats.h
  20. * @ingroup monitoring */
  21. #ifndef _STATS__H___
  22. #define _STATS__H___
  23. #include "config.h"
  24. #include <fcgiapp.h>
  25. #include <signal.h>
  26. #include <string.h>
  27. typedef struct pyfcgi_stats_s pyfcgi_stats_t;
  28. #include "conf.h"
  29. #include "logger.h"
  30. struct pyfcgi_stats_s
  31. {
  32. /**@brief Request per seconds on 15 minutes */
  33. int reqs[900];
  34. /**@brief Current request index */
  35. int cur_req;
  36. /**@brief Repeating 1s timer sending SIGALRM */
  37. timer_t timerid;
  38. /**@brief Old SIGALRM handler */
  39. struct sigaction oldact;
  40. };
  41. /**@brief Starts collecting statistics
  42. *
  43. * Set an handler for SIGALRM and set a repeating alarm each seconds
  44. * @warning designed to be called from monitor server process
  45. * @return -1 on error else 0
  46. */
  47. int pyfcgi_stats_init();
  48. /**@brief SIGALRM signal handler
  49. * @param int signum
  50. */
  51. void pyfcgi_stats_collector(int);
  52. #endif