root / plugins / php / php-fcgi @ dd4afac8
Historique | Voir | Annoter | Télécharger (2,7 ko)
| 1 | d3b1fb3e | perusio | #!/usr/bin/perl -w |
|---|---|---|---|
| 2 | # -*- mode: cperl; mode: autopair -*- |
||
| 3 | # Magic markers: |
||
| 4 | #%# family=auto |
||
| 5 | #%# capabilities=autoconf |
||
| 6 | # php_fcgi --- Munin plugin for determining the memory usage and |
||
| 7 | # number of PHP FastCGI processes. |
||
| 8 | |||
| 9 | # Copyright (C) 2010 António P. P. Almeida <appa@perusio.net> |
||
| 10 | |||
| 11 | # Author: António P. P. Almeida <appa@perusio.net> |
||
| 12 | |||
| 13 | # Permission is hereby granted, free of charge, to any person obtaining a |
||
| 14 | # copy of this software and associated documentation files (the "Software"), |
||
| 15 | # to deal in the Software without restriction, including without limitation |
||
| 16 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
| 17 | # and/or sell copies of the Software, and to permit persons to whom the |
||
| 18 | # Software is furnished to do so, subject to the following conditions: |
||
| 19 | |||
| 20 | # The above copyright notice and this permission notice shall be included in |
||
| 21 | # all copies or substantial portions of the Software. |
||
| 22 | |||
| 23 | # Except as contained in this notice, the name(s) of the above copyright |
||
| 24 | # holders shall not be used in advertising or otherwise to promote the sale, |
||
| 25 | # use or other dealings in this Software without prior written authorization. |
||
| 26 | |||
| 27 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
| 28 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
| 29 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
| 30 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
| 31 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||
| 32 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
| 33 | # DEALINGS IN THE SOFTWARE. |
||
| 34 | |||
| 35 | =head1 NAME |
||
| 36 | |||
| 37 | php_fcgi - Munin plugin to show the Memory anf number of processes used by PHP FastCGI. |
||
| 38 | |||
| 39 | =encoding utf8 |
||
| 40 | |||
| 41 | =head1 APPLICABLE SYSTEMS |
||
| 42 | |||
| 43 | Any host running PHP FastCGI. |
||
| 44 | |||
| 45 | =head1 MAGIC MARKERS |
||
| 46 | |||
| 47 | #%# family=auto |
||
| 48 | #%# capabilities=autoconf |
||
| 49 | |||
| 50 | =head1 VERSION |
||
| 51 | |||
| 52 | 1.0 |
||
| 53 | |||
| 54 | =head1 BUGS |
||
| 55 | |||
| 56 | None known |
||
| 57 | |||
| 58 | =head1 AUTHOR |
||
| 59 | |||
| 60 | António Almeida <appa@perusio.net> |
||
| 61 | |||
| 62 | =head1 REPOSITORY |
||
| 63 | |||
| 64 | Source code at http://github.com/perusio/munin-php-cgi |
||
| 65 | |||
| 66 | =head1 LICENSE |
||
| 67 | |||
| 68 | MIT |
||
| 69 | |||
| 70 | =cut |
||
| 71 | |||
| 72 | ## Support for rounding functions. |
||
| 73 | use POSIX; |
||
| 74 | |||
| 75 | ## Munin config method. |
||
| 76 | if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
||
| 77 | |||
| 78 | print "graph_title PHP CGI [MB]\n"; |
||
| 79 | print "graph_vlabel PHP CGI Memory usage\n"; |
||
| 80 | print "graph_category php-cgi\n"; |
||
| 81 | print "graph_args -l 0\n"; |
||
| 82 | print "php_cgi_ram.label PHP CGI Used RAM\n"; |
||
| 83 | print "php_cgi_ram.draw LINE2\n"; |
||
| 84 | print "php_cgi_processes.info Number of PHP CGI processes\n"; |
||
| 85 | print "php_cgi_processes.label processes\n"; |
||
| 86 | |||
| 87 | exit 0; |
||
| 88 | } else {
|
||
| 89 | my ($pp, $pm) = eval(`ps u -p \$(pidof php-cgi) | awk 'NR > 1 {pm += \$5} END {print "("NR-1","pm/1024")"}'`);
|
||
| 90 | printf("php_cgi_ram.value %d\n", ceil($pm));
|
||
| 91 | print "php_cgi_processes.value $pp\n"; |
||
| 92 | } |
