root / plugins / php / php-fastcgi @ 72e4561a
Historique | Voir | Annoter | Télécharger (3,03 ko)
| 1 | 8b5ee604 | 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 | 0b18f278 | Andrey Dudin | # Copyright (C) 2010 Antonio P. P. Almeida <appa@perusio.net> |
| 10 | 8b5ee604 | perusio | |
| 11 | 0b18f278 | Andrey Dudin | # Author: Antonio P. P. Almeida <appa@perusio.net> |
| 12 | 8b5ee604 | perusio | |
| 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 | 0b18f278 | Andrey Dudin | =head1 CONFIGURATION |
| 55 | |||
| 56 | This shows the default configuration of this plugin. You can override |
||
| 57 | the process name of php-fcgi. |
||
| 58 | |||
| 59 | [php-fcgi] |
||
| 60 | env.pname php-cgi |
||
| 61 | |||
| 62 | 8b5ee604 | perusio | =head1 BUGS |
| 63 | |||
| 64 | None known |
||
| 65 | |||
| 66 | =head1 AUTHOR |
||
| 67 | |||
| 68 | 0b18f278 | Andrey Dudin | Antonio Almeida <appa@perusio.net> |
| 69 | 8b5ee604 | perusio | |
| 70 | =head1 REPOSITORY |
||
| 71 | |||
| 72 | Source code at http://github.com/perusio/munin-php-cgi |
||
| 73 | |||
| 74 | =head1 LICENSE |
||
| 75 | |||
| 76 | MIT |
||
| 77 | |||
| 78 | =cut |
||
| 79 | |||
| 80 | ## Support for rounding functions. |
||
| 81 | use POSIX; |
||
| 82 | |||
| 83 | 0b18f278 | Andrey Dudin | ## Environment defined variables. |
| 84 | ## The default process name if different set it in the environment. |
||
| 85 | |||
| 86 | my $PROCESS_NAME = exists $ENV{'pname'} ? $ENV{'pname'} : "php-cgi";
|
||
| 87 | |||
| 88 | 8b5ee604 | perusio | ## Munin config method. |
| 89 | if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
||
| 90 | |||
| 91 | print "graph_title PHP CGI [MB]\n"; |
||
| 92 | print "graph_vlabel PHP CGI Memory usage\n"; |
||
| 93 | print "graph_category php-cgi\n"; |
||
| 94 | print "graph_args -l 0\n"; |
||
| 95 | print "php_cgi_ram.label PHP CGI Used RAM\n"; |
||
| 96 | print "php_cgi_ram.draw LINE2\n"; |
||
| 97 | print "php_cgi_processes.info Number of PHP CGI processes\n"; |
||
| 98 | print "php_cgi_processes.label processes\n"; |
||
| 99 | |||
| 100 | exit 0; |
||
| 101 | } else {
|
||
| 102 | 0b18f278 | Andrey Dudin | my ($pp, $pm) = eval(`ps u -p \$(pidof $PROCESS_NAME) | awk 'NR > 1 {pm += \$5} END {print "("NR-1","pm/1024")"}'`);
|
| 103 | 8b5ee604 | perusio | printf("php_cgi_ram.value %d\n", ceil($pm));
|
| 104 | print "php_cgi_processes.value $pp\n"; |
||
| 105 | 0b18f278 | Andrey Dudin | } |
