From 77a77bb593cbfabed569b54c8db0ad11e2011fd6 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Wed, 3 Apr 2019 18:57:09 +0200 Subject: [PATCH] added a complete graph to support PHP-FPM statistics ('phpfpm.pm'). #167 --- Changes | 1 + lib/phpfpm.pm | 1034 ++++++++++++++++++++++++++++++++++++++++++++++++ monitorix.conf | 31 +- 3 files changed, 1065 insertions(+), 1 deletion(-) create mode 100644 lib/phpfpm.pm diff --git a/Changes b/Changes index d8c6379..d920352 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ 3.NN.N - DD-MMM-2019 ==================== +- Added a complete graph to support PHP-FPM statistics ('phpfpm.pm'). [#167] - Fixed the copyright year in 'monitorix.cgi'. - Fixed in 'mail.pm to use the option 'mail_log' instead the hard coded path I forgot to remove when adding the Exim support. diff --git a/lib/phpfpm.pm b/lib/phpfpm.pm new file mode 100644 index 0000000..6e88718 --- /dev/null +++ b/lib/phpfpm.pm @@ -0,0 +1,1034 @@ +# +# Monitorix - A lightweight system monitoring tool. +# +# Copyright (C) 2005-2019 by Jordi Sanfeliu +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +package phpfpm; + +use strict; +use warnings; +use Monitorix; +use RRDs; +use LWP::UserAgent; +use Exporter 'import'; +our @EXPORT = qw(phpfpm_init phpfpm_update phpfpm_cgi); + +sub phpfpm_init { + my $myself = (caller(0))[3]; + my ($package, $config, $debug) = @_; + my $rrd = $config->{base_lib} . $package . ".rrd"; + my $phpfpm = $config->{phpfpm}; + + my $info; + my @ds; + my @rra; + my @tmp; + my $n; + + my @average; + my @min; + my @max; + my @last; + + if(-e $rrd) { + $info = RRDs::info($rrd); + for my $key (keys %$info) { + if(index($key, 'ds[') == 0) { + if(index($key, '.type') != -1) { + push(@ds, substr($key, 3, index($key, ']') - 3)); + } + } + if(index($key, 'rra[') == 0) { + if(index($key, '.rows') != -1) { + push(@rra, substr($key, 4, index($key, ']') - 4)); + } + } + } + if(scalar(@ds) / 144 != keys(%{$phpfpm->{list}})) { + logger("$myself: Detected size mismatch between ... (" . keys(%{$phpfpm->{list}}) . ") and $rrd (" . scalar(@ds) / 144 . "). Resizing it accordingly. All historical data will be lost. Backup file created."); + rename($rrd, "$rrd.bak"); + } + if(scalar(@rra) < 12 + (4 * $config->{max_historic_years})) { + logger("$myself: Detected size mismatch between 'max_historic_years' (" . $config->{max_historic_years} . ") and $rrd (" . ((scalar(@rra) -12) / 4) . "). Resizing it accordingly. All historical data will be lost. Backup file created."); + rename($rrd, "$rrd.bak"); + } + } + + if(!(-e $rrd)) { + logger("Creating '$rrd' file."); + for($n = 1; $n <= $config->{max_historic_years}; $n++) { + push(@average, "RRA:AVERAGE:0.5:1440:" . (365 * $n)); + push(@min, "RRA:MIN:0.5:1440:" . (365 * $n)); + push(@max, "RRA:MAX:0.5:1440:" . (365 * $n)); + push(@last, "RRA:LAST:0.5:1440:" . (365 * $n)); + } + for($n = 0; $n < keys(%{$phpfpm->{list}}); $n++) { + my $n2; + for($n2 = 0; $n2 < 8; $n2++) { + push(@tmp, "DS:phpfpm" . $n . "_uptim" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_aconn" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_lqueu" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_mlque" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_iproc" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_aproc" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_mapro" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_mchil" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_slreq" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val1" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val2" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val3" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val4" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val5" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val6" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val7" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val8" . $n2 . ":GAUGE:120:0:U"); + push(@tmp, "DS:phpfpm" . $n . "_val9" . $n2 . ":GAUGE:120:0:U"); + } + } + eval { + RRDs::create($rrd, + "--step=60", + @tmp, + "RRA:AVERAGE:0.5:1:1440", + "RRA:AVERAGE:0.5:30:336", + "RRA:AVERAGE:0.5:60:744", + @average, + "RRA:MIN:0.5:1:1440", + "RRA:MIN:0.5:30:336", + "RRA:MIN:0.5:60:744", + @min, + "RRA:MAX:0.5:1:1440", + "RRA:MAX:0.5:30:336", + "RRA:MAX:0.5:60:744", + @max, + "RRA:LAST:0.5:1:1440", + "RRA:LAST:0.5:30:336", + "RRA:LAST:0.5:60:744", + @last, + ); + }; + my $err = RRDs::error; + if($@ || $err) { + logger("$@") unless !$@; + if($err) { + logger("ERROR: while creating $rrd: $err"); + if($err eq "RRDs::error") { + logger("... is the RRDtool Perl package installed?"); + } + } + return; + } + } + + $config->{phpfpm_hist} = (); + push(@{$config->{func_update}}, $package); + logger("$myself: Ok") if $debug; +} + +sub phpfpm_update { + my $myself = (caller(0))[3]; + my ($package, $config, $debug) = @_; + my $rrd = $config->{base_lib} . $package . ".rrd"; + my $phpfpm = $config->{phpfpm}; + + my @sens; + + my $n; + my $str; + my $rrdata = "N"; + + foreach my $pfg (sort keys %{$phpfpm->{group}}) { + my @pfl = split(',', $phpfpm->{list}->{$pfg}); + for($n = 0; $n < 8; $n++) { + my $uptim = 0; + my $aconn = 0; + my $lqueu = 0; + my $mlque = 0; + my $iproc = 0; + my $aproc = 0; + my $mapro = 0; + my $mchil = 0; + my $slreq = 0; + my $ssl = ""; + + my $pool = trim($pfl[$n] || ""); + if(!$pool) { + $rrdata .= ":0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0"; + next; + } + + my $url = $phpfpm->{desc}->{$pool} || ""; + if(!$url) { + logger("$myself: ERROR: the pool '$pool' don't has an associated URL."); + $rrdata .= ":0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0"; + next; + } + + $ssl = "ssl_opts => {verify_hostname => 0}" + if lc($config->{accept_selfsigned_certs}) eq "y"; + my $ua = LWP::UserAgent->new(timeout => 30, $ssl); + $ua->agent($config->{user_agent_id}) if $config->{user_agent_id} || ""; + my $response = $ua->request(HTTP::Request->new('GET', $url)); + if(!$response->is_success) { + logger("$myself: ERROR: in pool '$pool', unable to connect to '$url'."); + } else { + foreach(split('\n', $response->content)) { + if(/^start since:\s+(\d+)$/) { + $uptim = $1; + } + if(/^accepted conn:\s+(\d+)$/) { + $str = $pfg . $n . "aconn"; + $aconn = $1 - ($config->{phpfpm_hist}->{$str} || 0); + $aconn = 0 unless $aconn != $1; + $aconn /= 60; + $config->{phpfpm_hist}->{$str} = $1; + } + if(/^listen queue:\s+(\d+)$/) { + $lqueu = $1; + } + if(/^max listen queue:\s+(\d+)$/) { + $mlque = $1; + } + if(/^idle processes:\s+(\d+)$/) { + $iproc = $1; + } + if(/^active processes:\s+(\d+)$/) { + $aproc = $1; + } + if(/^max active processes:\s+(\d+)$/) { + $mapro = $1; + } + if(/^max children reached:\s+(\d+)$/) { + $mchil = $1; + } + if(/^slow requests:\s+(\d+)$/) { + $slreq = $1; + } + } + } + $rrdata .= ":$uptim:$aconn:$lqueu:$mlque:$iproc:$aproc:$mapro:$mchil:$slreq:0:0:0:0:0:0:0:0:0"; + } + } + + RRDs::update($rrd, $rrdata); + logger("$myself: $rrdata") if $debug; + my $err = RRDs::error; + logger("ERROR: while updating $rrd: $err") if $err; +} + +sub phpfpm_cgi { + my ($package, $config, $cgi) = @_; + my @output; + + my $phpfpm = $config->{phpfpm}; + my @rigid = split(',', ($phpfpm->{rigid} || "")); + my @limit = split(',', ($phpfpm->{limit} || "")); + my $tf = $cgi->{tf}; + my $colors = $cgi->{colors}; + my $graph = $cgi->{graph}; + my $silent = $cgi->{silent}; + my $zoom = "--zoom=" . $config->{global_zoom}; + my %rrd = ( + 'new' => \&RRDs::graphv, + 'old' => \&RRDs::graph, + ); + my $version = "new"; + my $pic; + my $picz; + my $picz_width; + my $picz_height; + + my $u = ""; + my $width; + my $height; + my @riglim; + my @IMG; + my @IMGz; + my @tmp; + my @tmpz; + my @CDEF; + my $e; + my $e2; + my $n; + my $n2; + my $str; + my $err; + my @LC = ( + "#4444EE", + "#EEEE44", + "#44EEEE", + "#EE44EE", + "#888888", + "#E29136", + "#44EE44", + "#448844", + "#EE4444", + ); + + $version = "old" if $RRDs::VERSION < 1.3; + my $rrd = $config->{base_lib} . $package . ".rrd"; + my $title = $config->{graph_title}->{$package}; + my $IMG_DIR = $config->{base_dir} . "/" . $config->{imgs_dir}; + my $imgfmt_uc = uc($config->{image_format}); + my $imgfmt_lc = lc($config->{image_format}); + + $title = !$silent ? $title : ""; + + # text mode + # + if(lc($config->{iface_mode}) eq "text") { + if($title) { + push(@output, main::graph_header($title, 2)); + push(@output, " \n"); + push(@output, " \n"); + } + my (undef, undef, undef, $data) = RRDs::fetch("$rrd", + "--start=-$tf->{nwhen}$tf->{twhen}", + "AVERAGE", + "-r $tf->{res}"); + $err = RRDs::error; + push(@output, "ERROR: while fetching $rrd: $err\n") if $err; + my $line1; + my $line2; + my $line3; + my $line4; + push(@output, "
\n");
+		push(@output, "    ");
+		foreach my $pfg (sort keys %{$phpfpm->{group}}) {
+			$line1 = " ";
+			$line2 .= " ";
+			$line3 .= " ";
+			$line4 .= "-";
+			for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) {
+				my $dl = trim($pfl[$n]);
+				$str = $phpfpm->{map}->{$dl} || $dl;
+				$line1 .= "                                                               ";
+				$line2 .= sprintf(" %62s", $str);
+				$line3 .= "  aconn  lqueue  mlqueu  idproc  acproc  macpro  mchild  slwreq";
+				$line4 .= "---------------------------------------------------------------";
+			}
+			if($line1) {
+				my $i = length($line1);
+				push(@output, sprintf(sprintf("%${i}s", sprintf("%s", trim($phpfpm->{group}->{$pfg})))));
+			}
+		}
+		push(@output, "\n");
+		push(@output, "    $line2\n");
+		push(@output, "Time$line3\n");
+		push(@output, "----$line4 \n");
+		my $line;
+		my @row;
+		my $time;
+		my $n2;
+		my $n3;
+		my $from;
+		my $to;
+		for($n = 0, $time = $tf->{tb}; $n < ($tf->{tb} * $tf->{ts}); $n++) {
+			$line = @$data[$n];
+			$time = $time - (1 / $tf->{ts});
+			push(@output, sprintf(" %2d$tf->{tc} ", $time));
+			$n3 = 0;
+			foreach my $pfg (sort keys %{$phpfpm->{group}}) {
+				for($n2 = 0; $n2 < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n2++) {
+					$from = $n2 * 18 + ($n3 * 144);
+					$to = $from + 18;
+					my (undef, $aconn, $lqueue, $mlqueu, $idproc, $acproc, $macpro, $mchild, $slwreq) = @$line[$from..$to];
+					@row = ($aconn, $lqueue, $mlqueu, $idproc, $acproc, $macpro, $mchild, $slwreq);
+					push(@output, sprintf(" %6d  %6d  %6d  %6d  %6d  %6d  %6d  %6d", @row));
+				}
+				push(@output, sprintf(" "));
+				$n3++;
+			}
+			push(@output, "\n");
+		}
+		push(@output, "    
\n"); + if($title) { + push(@output, " \n"); + push(@output, " \n"); + push(@output, main::graph_footer()); + } + push(@output, "
\n"); + return @output; + } + + + # graph mode + # + if($silent eq "yes" || $silent eq "imagetag") { + $colors->{fg_color} = "#000000"; # visible color for text mode + $u = "_"; + } + if($silent eq "imagetagbig") { + $colors->{fg_color} = "#000000"; # visible color for text mode + $u = ""; + } + + $n = 0; + foreach my $pfg (sort keys %{$phpfpm->{group}}) { + for($n2 = 1; $n2 <= 6; $n2++) { + $str = $u . $package . $n . $n2 . "." . $tf->{when} . ".$imgfmt_lc"; + push(@IMG, $str); + unlink("$IMG_DIR" . $str); + if(lc($config->{enable_zoom}) eq "y") { + $str = $u . $package . $n . $n2 . "z." . $tf->{when} . ".$imgfmt_lc"; + push(@IMGz, $str); + unlink("$IMG_DIR" . $str); + } + } + $n++; + } + + $e = 0; + foreach my $pfg (sort keys %{$phpfpm->{group}}) { + if($e) { + push(@output, "
\n"); + } + if($title) { + push(@output, main::graph_header($title, 2)); + } + + @riglim = @{setup_riglim($rigid[0], $limit[0])}; + my (undef, undef, undef, $data) = RRDs::fetch("$rrd", + "--start=-1min", + "AVERAGE", + "-r 60"); + my $line = @$data[0]; + my ($uptime) = @$line[$e * 144]; + my $uptimeline; + if($RRDs::VERSION > 1.2) { + $uptimeline = "COMMENT:uptime\\: " . uptime2str($uptime) . "\\c"; + } else { + $uptimeline = "COMMENT:uptime: " . uptime2str($uptime) . "\\c"; + } + + undef(@tmp); + undef(@tmpz); + undef(@CDEF); + my $comments; + for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) { + $str = trim($pfl[$n]); + $str = $phpfpm->{map}->{$str} ? $phpfpm->{map}->{$str} : $str; + my $dstr = sprintf("%-25s", substr($str, 0, 25)); + push(@tmp, "LINE2:acon" . $e . "_$n" . $LC[$n] . ":$dstr"); + push(@tmpz, "LINE2:acon" . $e . "_$n" . $LC[$n] . ":$str"); + push(@tmp, "GPRINT:acon" . $e . "_$n" . ":LAST: Cur\\:%5.2lf"); + push(@tmp, "GPRINT:acon" . $e . "_$n" . ":AVERAGE: Avg\\:%5.2lf"); + push(@tmp, "GPRINT:acon" . $e . "_$n" . ":MIN: Min\\:%5.2lf"); + push(@tmp, "GPRINT:acon" . $e . "_$n" . ":MAX: Max\\:%5.2lf\\n"); + $comments = 8 - scalar(@pfl); + } + + if($title) { + push(@output, " \n"); + push(@output, " \n"); + } + if(lc($config->{show_gaps}) eq "y") { + push(@tmp, "AREA:wrongdata#$colors->{gap}:"); + push(@tmpz, "AREA:wrongdata#$colors->{gap}:"); + push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF"); + } + for($n = 0; $n < $comments / 2; $n++) { + push(@tmp, "COMMENT: \\n"); + } + ($width, $height) = split('x', $config->{graph_size}->{main}); + $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6]", + "--title=$config->{graphs}->{_phpfpm1} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Connections/s", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$colors->{graph_colors}}, + "DEF:acon" . $e . "_0=$rrd:phpfpm" . $e . "_aconn0:AVERAGE", + "DEF:acon" . $e . "_1=$rrd:phpfpm" . $e . "_aconn1:AVERAGE", + "DEF:acon" . $e . "_2=$rrd:phpfpm" . $e . "_aconn2:AVERAGE", + "DEF:acon" . $e . "_3=$rrd:phpfpm" . $e . "_aconn3:AVERAGE", + "DEF:acon" . $e . "_4=$rrd:phpfpm" . $e . "_aconn4:AVERAGE", + "DEF:acon" . $e . "_5=$rrd:phpfpm" . $e . "_aconn5:AVERAGE", + "DEF:acon" . $e . "_6=$rrd:phpfpm" . $e . "_aconn6:AVERAGE", + "DEF:acon" . $e . "_7=$rrd:phpfpm" . $e . "_aconn7:AVERAGE", + "CDEF:allvalues=acon" . $e . "_0,acon" . $e . "_1,acon" . $e . "_2,acon" . $e . "_3,acon" . $e . "_4,acon" . $e . "_5,acon" . $e . "_6,acon" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmp, + $uptimeline); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6]: $err\n") if $err; + if(lc($config->{enable_zoom}) eq "y") { + ($width, $height) = split('x', $config->{graph_size}->{zoom}); + $picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$e * 6]", + "--title=$config->{graphs}->{_phpfpm1} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Connections/s", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$colors->{graph_colors}}, + "DEF:acon" . $e . "_0=$rrd:phpfpm" . $e . "_aconn0:AVERAGE", + "DEF:acon" . $e . "_1=$rrd:phpfpm" . $e . "_aconn1:AVERAGE", + "DEF:acon" . $e . "_2=$rrd:phpfpm" . $e . "_aconn2:AVERAGE", + "DEF:acon" . $e . "_3=$rrd:phpfpm" . $e . "_aconn3:AVERAGE", + "DEF:acon" . $e . "_4=$rrd:phpfpm" . $e . "_aconn4:AVERAGE", + "DEF:acon" . $e . "_5=$rrd:phpfpm" . $e . "_aconn5:AVERAGE", + "DEF:acon" . $e . "_6=$rrd:phpfpm" . $e . "_aconn6:AVERAGE", + "DEF:acon" . $e . "_7=$rrd:phpfpm" . $e . "_aconn7:AVERAGE", + "CDEF:allvalues=acon" . $e . "_0,acon" . $e . "_1,acon" . $e . "_2,acon" . $e . "_3,acon" . $e . "_4,acon" . $e . "_5,acon" . $e . "_6,acon" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmpz); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6]: $err\n") if $err; + } + $e2 = $e + 1; + if($title || ($silent =~ /imagetag/ && $graph =~ /phpfpm$e2/)) { + if(lc($config->{enable_zoom}) eq "y") { + if(lc($config->{disable_javascript_void}) eq "y") { + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6] . "\">\n"); + } else { + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); + } + } else { + push(@output, " \n"); + } + } + + @riglim = @{setup_riglim($rigid[1], $limit[1])}; + undef(@tmp); + undef(@tmpz); + undef(@CDEF); + for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) { + $str = trim($pfl[$n]); + $str = $phpfpm->{map}->{$str} ? $phpfpm->{map}->{$str} : $str; + my $dstr = sprintf("%-25s", substr($str, 0, 25)); + push(@tmp, "LINE2:aproc" . $e . "_$n" . $LC[$n] . ":$dstr"); + push(@tmpz, "LINE2:aproc" . $e . "_$n" . $LC[$n] . ":$str"); + push(@tmp, "GPRINT:aproc" . $e . "_$n" . ":LAST: Cur\\:%5.2lf"); + push(@tmp, "GPRINT:aproc" . $e . "_$n" . ":AVERAGE: Avg\\:%5.2lf"); + push(@tmp, "GPRINT:aproc" . $e . "_$n" . ":MIN: Min\\:%5.2lf"); + push(@tmp, "GPRINT:aproc" . $e . "_$n" . ":MAX: Max\\:%5.2lf\\n"); + $comments = 8 - scalar(@pfl); + } + if(lc($config->{show_gaps}) eq "y") { + push(@tmp, "AREA:wrongdata#$colors->{gap}:"); + push(@tmpz, "AREA:wrongdata#$colors->{gap}:"); + push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF"); + } + for($n = 0; $n < $comments / 2; $n++) { + push(@tmp, "COMMENT: \\n"); + } + ($width, $height) = split('x', $config->{graph_size}->{main}); + $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 1]", + "--title=$config->{graphs}->{_phpfpm2} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Processes", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$colors->{graph_colors}}, + "DEF:aproc" . $e . "_0=$rrd:phpfpm" . $e . "_aproc0:AVERAGE", + "DEF:aproc" . $e . "_1=$rrd:phpfpm" . $e . "_aproc1:AVERAGE", + "DEF:aproc" . $e . "_2=$rrd:phpfpm" . $e . "_aproc2:AVERAGE", + "DEF:aproc" . $e . "_3=$rrd:phpfpm" . $e . "_aproc3:AVERAGE", + "DEF:aproc" . $e . "_4=$rrd:phpfpm" . $e . "_aproc4:AVERAGE", + "DEF:aproc" . $e . "_5=$rrd:phpfpm" . $e . "_aproc5:AVERAGE", + "DEF:aproc" . $e . "_6=$rrd:phpfpm" . $e . "_aproc6:AVERAGE", + "DEF:aproc" . $e . "_7=$rrd:phpfpm" . $e . "_aproc7:AVERAGE", + "CDEF:allvalues=aproc" . $e . "_0,aproc" . $e . "_1,aproc" . $e . "_2,aproc" . $e . "_3,aproc" . $e . "_4,aproc" . $e . "_5,aproc" . $e . "_6,aproc" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmp); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 1]: $err\n") if $err; + if(lc($config->{enable_zoom}) eq "y") { + ($width, $height) = split('x', $config->{graph_size}->{zoom}); + $picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$e * 6 + 1]", + "--title=$config->{graphs}->{_phpfpm2} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Processes", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$colors->{graph_colors}}, + "DEF:aproc" . $e . "_0=$rrd:phpfpm" . $e . "_aproc0:AVERAGE", + "DEF:aproc" . $e . "_1=$rrd:phpfpm" . $e . "_aproc1:AVERAGE", + "DEF:aproc" . $e . "_2=$rrd:phpfpm" . $e . "_aproc2:AVERAGE", + "DEF:aproc" . $e . "_3=$rrd:phpfpm" . $e . "_aproc3:AVERAGE", + "DEF:aproc" . $e . "_4=$rrd:phpfpm" . $e . "_aproc4:AVERAGE", + "DEF:aproc" . $e . "_5=$rrd:phpfpm" . $e . "_aproc5:AVERAGE", + "DEF:aproc" . $e . "_6=$rrd:phpfpm" . $e . "_aproc6:AVERAGE", + "DEF:aproc" . $e . "_7=$rrd:phpfpm" . $e . "_aproc7:AVERAGE", + "CDEF:allvalues=aproc" . $e . "_0,aproc" . $e . "_1,aproc" . $e . "_2,aproc" . $e . "_3,aproc" . $e . "_4,aproc" . $e . "_5,aproc" . $e . "_6,aproc" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmpz); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 1]: $err\n") if $err; + } + $e2 = $e + 2; + if($title || ($silent =~ /imagetag/ && $graph =~ /phpfpm$e2/)) { + if(lc($config->{enable_zoom}) eq "y") { + if(lc($config->{disable_javascript_void}) eq "y") { + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 1] . "\">\n"); + } else { + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 1] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); + } + } else { + push(@output, " \n"); + } + } + + if($title) { + push(@output, " \n"); + push(@output, " \n"); + } + + @riglim = @{setup_riglim($rigid[2], $limit[2])}; + undef(@tmp); + undef(@tmpz); + undef(@CDEF); + for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) { + $str = trim($pfl[$n]); + $str = $phpfpm->{map}->{$str} ? $phpfpm->{map}->{$str} : $str; + my $dstr = substr($str, 0, 25); + push(@tmp, "LINE2:lqueue" . $e . "_$n" . $LC[$n] . ":$dstr"); + push(@tmpz, "LINE2:lqueue" . $e . "_$n" . $LC[$n] . ":$str\\g"); + } + if(lc($config->{show_gaps}) eq "y") { + push(@tmp, "AREA:wrongdata#$colors->{gap}:"); + push(@tmpz, "AREA:wrongdata#$colors->{gap}:"); + push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF"); + } + ($width, $height) = split('x', $config->{graph_size}->{small}); + $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 2]", + "--title=$config->{graphs}->{_phpfpm3} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Listening", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:lqueue" . $e . "_0=$rrd:phpfpm" . $e . "_lqueu0:AVERAGE", + "DEF:lqueue" . $e . "_1=$rrd:phpfpm" . $e . "_lqueu1:AVERAGE", + "DEF:lqueue" . $e . "_2=$rrd:phpfpm" . $e . "_lqueu2:AVERAGE", + "DEF:lqueue" . $e . "_3=$rrd:phpfpm" . $e . "_lqueu3:AVERAGE", + "DEF:lqueue" . $e . "_4=$rrd:phpfpm" . $e . "_lqueu4:AVERAGE", + "DEF:lqueue" . $e . "_5=$rrd:phpfpm" . $e . "_lqueu5:AVERAGE", + "DEF:lqueue" . $e . "_6=$rrd:phpfpm" . $e . "_lqueu6:AVERAGE", + "DEF:lqueue" . $e . "_7=$rrd:phpfpm" . $e . "_lqueu7:AVERAGE", + "CDEF:allvalues=lqueue" . $e . "_0,lqueue" . $e . "_1,lqueue" . $e . "_2,lqueue" . $e . "_3,lqueue" . $e . "_4,lqueue" . $e . "_5,lqueue" . $e . "_6,lqueue" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmp); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 2]: $err\n") if $err; + if(lc($config->{enable_zoom}) eq "y") { + ($width, $height) = split('x', $config->{graph_size}->{zoom}); + $picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$e * 6 + 2]", + "--title=$config->{graphs}->{_phpfpm3} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Listening", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:lqueue" . $e . "_0=$rrd:phpfpm" . $e . "_lqueu0:AVERAGE", + "DEF:lqueue" . $e . "_1=$rrd:phpfpm" . $e . "_lqueu1:AVERAGE", + "DEF:lqueue" . $e . "_2=$rrd:phpfpm" . $e . "_lqueu2:AVERAGE", + "DEF:lqueue" . $e . "_3=$rrd:phpfpm" . $e . "_lqueu3:AVERAGE", + "DEF:lqueue" . $e . "_4=$rrd:phpfpm" . $e . "_lqueu4:AVERAGE", + "DEF:lqueue" . $e . "_5=$rrd:phpfpm" . $e . "_lqueu5:AVERAGE", + "DEF:lqueue" . $e . "_6=$rrd:phpfpm" . $e . "_lqueu6:AVERAGE", + "DEF:lqueue" . $e . "_7=$rrd:phpfpm" . $e . "_lqueu7:AVERAGE", + "CDEF:allvalues=lqueue" . $e . "_0,lqueue" . $e . "_1,lqueue" . $e . "_2,lqueue" . $e . "_3,lqueue" . $e . "_4,lqueue" . $e . "_5,lqueue" . $e . "_6,lqueue" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmpz); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 2]: $err\n") if $err; + } + $e2 = $e + 3; + if($title || ($silent =~ /imagetag/ && $graph =~ /phpfpm$e2/)) { + if(lc($config->{enable_zoom}) eq "y") { + if(lc($config->{disable_javascript_void}) eq "y") { + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 2] . "\">\n"); + } else { + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 2] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); + } + } else { + push(@output, " \n"); + } + } + + @riglim = @{setup_riglim($rigid[3], $limit[3])}; + undef(@tmp); + undef(@tmpz); + undef(@CDEF); + for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) { + $str = trim($pfl[$n]); + $str = $phpfpm->{map}->{$str} ? $phpfpm->{map}->{$str} : $str; + my $dstr = substr($str, 0, 25); + push(@tmp, "LINE2:tproc" . $n . $LC[$n] . ":$dstr"); + push(@tmpz, "LINE2:tproc" . $n . $LC[$n] . ":$str\\g"); + } + if(lc($config->{show_gaps}) eq "y") { + push(@tmp, "AREA:wrongdata#$colors->{gap}:"); + push(@tmpz, "AREA:wrongdata#$colors->{gap}:"); + push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF"); + } + ($width, $height) = split('x', $config->{graph_size}->{small}); + $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 3]", + "--title=$config->{graphs}->{_phpfpm4} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Processes", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:iproc" . $e . "_0=$rrd:phpfpm" . $e . "_iproc0:AVERAGE", + "DEF:iproc" . $e . "_1=$rrd:phpfpm" . $e . "_iproc1:AVERAGE", + "DEF:iproc" . $e . "_2=$rrd:phpfpm" . $e . "_iproc2:AVERAGE", + "DEF:iproc" . $e . "_3=$rrd:phpfpm" . $e . "_iproc3:AVERAGE", + "DEF:iproc" . $e . "_4=$rrd:phpfpm" . $e . "_iproc4:AVERAGE", + "DEF:iproc" . $e . "_5=$rrd:phpfpm" . $e . "_iproc5:AVERAGE", + "DEF:iproc" . $e . "_6=$rrd:phpfpm" . $e . "_iproc6:AVERAGE", + "DEF:iproc" . $e . "_7=$rrd:phpfpm" . $e . "_iproc7:AVERAGE", + "DEF:aproc" . $e . "_0=$rrd:phpfpm" . $e . "_aproc0:AVERAGE", + "DEF:aproc" . $e . "_1=$rrd:phpfpm" . $e . "_aproc1:AVERAGE", + "DEF:aproc" . $e . "_2=$rrd:phpfpm" . $e . "_aproc2:AVERAGE", + "DEF:aproc" . $e . "_3=$rrd:phpfpm" . $e . "_aproc3:AVERAGE", + "DEF:aproc" . $e . "_4=$rrd:phpfpm" . $e . "_aproc4:AVERAGE", + "DEF:aproc" . $e . "_5=$rrd:phpfpm" . $e . "_aproc5:AVERAGE", + "DEF:aproc" . $e . "_6=$rrd:phpfpm" . $e . "_aproc6:AVERAGE", + "DEF:aproc" . $e . "_7=$rrd:phpfpm" . $e . "_aproc7:AVERAGE", + "CDEF:tproc0=iproc" . $e . "_0,aproc" . $e . "_0,+", + "CDEF:tproc1=iproc" . $e . "_1,aproc" . $e . "_1,+", + "CDEF:tproc2=iproc" . $e . "_2,aproc" . $e . "_2,+", + "CDEF:tproc3=iproc" . $e . "_3,aproc" . $e . "_3,+", + "CDEF:tproc4=iproc" . $e . "_4,aproc" . $e . "_4,+", + "CDEF:tproc5=iproc" . $e . "_5,aproc" . $e . "_5,+", + "CDEF:tproc6=iproc" . $e . "_6,aproc" . $e . "_6,+", + "CDEF:tproc7=iproc" . $e . "_7,aproc" . $e . "_6,+", + "CDEF:allvalues=tproc0,tproc1,tproc2,tproc3,tproc4,tproc5,tproc6,tproc7,+,+,+,+,+,+,+", + @CDEF, + @tmp); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 3]: $err\n") if $err; + if(lc($config->{enable_zoom}) eq "y") { + ($width, $height) = split('x', $config->{graph_size}->{zoom}); + $picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$e * 6 + 3]", + "--title=$config->{graphs}->{_phpfpm4} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Processes", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:iproc" . $e . "_0=$rrd:phpfpm" . $e . "_iproc0:AVERAGE", + "DEF:iproc" . $e . "_1=$rrd:phpfpm" . $e . "_iproc1:AVERAGE", + "DEF:iproc" . $e . "_2=$rrd:phpfpm" . $e . "_iproc2:AVERAGE", + "DEF:iproc" . $e . "_3=$rrd:phpfpm" . $e . "_iproc3:AVERAGE", + "DEF:iproc" . $e . "_4=$rrd:phpfpm" . $e . "_iproc4:AVERAGE", + "DEF:iproc" . $e . "_5=$rrd:phpfpm" . $e . "_iproc5:AVERAGE", + "DEF:iproc" . $e . "_6=$rrd:phpfpm" . $e . "_iproc6:AVERAGE", + "DEF:iproc" . $e . "_7=$rrd:phpfpm" . $e . "_iproc7:AVERAGE", + "DEF:aproc" . $e . "_0=$rrd:phpfpm" . $e . "_aproc0:AVERAGE", + "DEF:aproc" . $e . "_1=$rrd:phpfpm" . $e . "_aproc1:AVERAGE", + "DEF:aproc" . $e . "_2=$rrd:phpfpm" . $e . "_aproc2:AVERAGE", + "DEF:aproc" . $e . "_3=$rrd:phpfpm" . $e . "_aproc3:AVERAGE", + "DEF:aproc" . $e . "_4=$rrd:phpfpm" . $e . "_aproc4:AVERAGE", + "DEF:aproc" . $e . "_5=$rrd:phpfpm" . $e . "_aproc5:AVERAGE", + "DEF:aproc" . $e . "_6=$rrd:phpfpm" . $e . "_aproc6:AVERAGE", + "DEF:aproc" . $e . "_7=$rrd:phpfpm" . $e . "_aproc7:AVERAGE", + "CDEF:tproc0=iproc" . $e . "_0,aproc" . $e . "_0,+", + "CDEF:tproc1=iproc" . $e . "_1,aproc" . $e . "_1,+", + "CDEF:tproc2=iproc" . $e . "_2,aproc" . $e . "_2,+", + "CDEF:tproc3=iproc" . $e . "_3,aproc" . $e . "_3,+", + "CDEF:tproc4=iproc" . $e . "_4,aproc" . $e . "_4,+", + "CDEF:tproc5=iproc" . $e . "_5,aproc" . $e . "_5,+", + "CDEF:tproc6=iproc" . $e . "_6,aproc" . $e . "_6,+", + "CDEF:tproc7=iproc" . $e . "_7,aproc" . $e . "_6,+", + "CDEF:allvalues=tproc0,tproc1,tproc2,tproc3,tproc4,tproc5,tproc6,tproc7,+,+,+,+,+,+,+", + @CDEF, + @tmpz); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 3]: $err\n") if $err; + } + $e2 = $e + 4; + if($title || ($silent =~ /imagetag/ && $graph =~ /phpfpm$e2/)) { + if(lc($config->{enable_zoom}) eq "y") { + if(lc($config->{disable_javascript_void}) eq "y") { + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 3] . "\">\n"); + } else { + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 3] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); + } + } else { + push(@output, " \n"); + } + } + + @riglim = @{setup_riglim($rigid[4], $limit[4])}; + undef(@tmp); + undef(@tmpz); + undef(@CDEF); + for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) { + $str = trim($pfl[$n]); + $str = $phpfpm->{map}->{$str} ? $phpfpm->{map}->{$str} : $str; + my $dstr = substr($str, 0, 25); + push(@tmp, "LINE2:mchild" . $e . "_$n" . $LC[$n] . ":$dstr"); + push(@tmpz, "LINE2:mchild" . $e . "_$n" . $LC[$n] . ":$str\\g"); + } + if(lc($config->{show_gaps}) eq "y") { + push(@tmp, "AREA:wrongdata#$colors->{gap}:"); + push(@tmpz, "AREA:wrongdata#$colors->{gap}:"); + push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF"); + } + ($width, $height) = split('x', $config->{graph_size}->{small}); + $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 4]", + "--title=$config->{graphs}->{_phpfpm5} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Children", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:mchild" . $e . "_0=$rrd:phpfpm" . $e . "_mchil0:AVERAGE", + "DEF:mchild" . $e . "_1=$rrd:phpfpm" . $e . "_mchil1:AVERAGE", + "DEF:mchild" . $e . "_2=$rrd:phpfpm" . $e . "_mchil2:AVERAGE", + "DEF:mchild" . $e . "_3=$rrd:phpfpm" . $e . "_mchil3:AVERAGE", + "DEF:mchild" . $e . "_4=$rrd:phpfpm" . $e . "_mchil4:AVERAGE", + "DEF:mchild" . $e . "_5=$rrd:phpfpm" . $e . "_mchil5:AVERAGE", + "DEF:mchild" . $e . "_6=$rrd:phpfpm" . $e . "_mchil6:AVERAGE", + "DEF:mchild" . $e . "_7=$rrd:phpfpm" . $e . "_mchil7:AVERAGE", + "CDEF:allvalues=mchild" . $e . "_0,mchild" . $e . "_1,mchild" . $e . "_2,mchild" . $e . "_3,mchild" . $e . "_4,mchild" . $e . "_5,mchild" . $e . "_6,mchild" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmp); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 4]: $err\n") if $err; + if(lc($config->{enable_zoom}) eq "y") { + ($width, $height) = split('x', $config->{graph_size}->{zoom}); + $picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$e * 6 + 4]", + "--title=$config->{graphs}->{_phpfpm5} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Children", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:mchild" . $e . "_0=$rrd:phpfpm" . $e . "_mchil0:AVERAGE", + "DEF:mchild" . $e . "_1=$rrd:phpfpm" . $e . "_mchil1:AVERAGE", + "DEF:mchild" . $e . "_2=$rrd:phpfpm" . $e . "_mchil2:AVERAGE", + "DEF:mchild" . $e . "_3=$rrd:phpfpm" . $e . "_mchil3:AVERAGE", + "DEF:mchild" . $e . "_4=$rrd:phpfpm" . $e . "_mchil4:AVERAGE", + "DEF:mchild" . $e . "_5=$rrd:phpfpm" . $e . "_mchil5:AVERAGE", + "DEF:mchild" . $e . "_6=$rrd:phpfpm" . $e . "_mchil6:AVERAGE", + "DEF:mchild" . $e . "_7=$rrd:phpfpm" . $e . "_mchil7:AVERAGE", + "CDEF:allvalues=mchild" . $e . "_0,mchild" . $e . "_1,mchild" . $e . "_2,mchild" . $e . "_3,mchild" . $e . "_4,mchild" . $e . "_5,mchild" . $e . "_6,mchild" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmpz); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 4]: $err\n") if $err; + } + $e2 = $e + 5; + if($title || ($silent =~ /imagetag/ && $graph =~ /phpfpm$e2/)) { + if(lc($config->{enable_zoom}) eq "y") { + if(lc($config->{disable_javascript_void}) eq "y") { + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 4] . "\">\n"); + } else { + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 4] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); + } + } else { + push(@output, " \n"); + } + } + + @riglim = @{setup_riglim($rigid[5], $limit[5])}; + undef(@tmp); + undef(@tmpz); + undef(@CDEF); + for($n = 0; $n < scalar(my @pfl = split(',', $phpfpm->{list}->{$pfg})); $n++) { + $str = trim($pfl[$n]); + $str = $phpfpm->{map}->{$str} ? $phpfpm->{map}->{$str} : $str; + my $dstr = substr($str, 0, 25); + push(@tmp, "LINE2:slwreq" . $e . "_$n" . $LC[$n] . ":$dstr"); + push(@tmpz, "LINE2:slwreq" . $e . "_$n" . $LC[$n] . ":$str\\g"); + } + if(lc($config->{show_gaps}) eq "y") { + push(@tmp, "AREA:wrongdata#$colors->{gap}:"); + push(@tmpz, "AREA:wrongdata#$colors->{gap}:"); + push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF"); + } + ($width, $height) = split('x', $config->{graph_size}->{small}); + $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 5]", + "--title=$config->{graphs}->{_phpfpm6} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Requests", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:slwreq" . $e . "_0=$rrd:phpfpm" . $e . "_slreq0:AVERAGE", + "DEF:slwreq" . $e . "_1=$rrd:phpfpm" . $e . "_slreq1:AVERAGE", + "DEF:slwreq" . $e . "_2=$rrd:phpfpm" . $e . "_slreq2:AVERAGE", + "DEF:slwreq" . $e . "_3=$rrd:phpfpm" . $e . "_slreq3:AVERAGE", + "DEF:slwreq" . $e . "_4=$rrd:phpfpm" . $e . "_slreq4:AVERAGE", + "DEF:slwreq" . $e . "_5=$rrd:phpfpm" . $e . "_slreq5:AVERAGE", + "DEF:slwreq" . $e . "_6=$rrd:phpfpm" . $e . "_slreq6:AVERAGE", + "DEF:slwreq" . $e . "_7=$rrd:phpfpm" . $e . "_slreq7:AVERAGE", + "CDEF:allvalues=slwreq" . $e . "_0,slwreq" . $e . "_1,slwreq" . $e . "_2,slwreq" . $e . "_3,slwreq" . $e . "_4,slwreq" . $e . "_5,slwreq" . $e . "_6,slwreq" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmp); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 5]: $err\n") if $err; + if(lc($config->{enable_zoom}) eq "y") { + ($width, $height) = split('x', $config->{graph_size}->{zoom}); + $picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$e * 6 + 5]", + "--title=$config->{graphs}->{_phpfpm6} ($tf->{nwhen}$tf->{twhen})", + "--start=-$tf->{nwhen}$tf->{twhen}", + "--imgformat=$imgfmt_uc", + "--vertical-label=Requests", + "--width=$width", + "--height=$height", + @riglim, + $zoom, + @{$cgi->{version12}}, + @{$cgi->{version12_small}}, + @{$colors->{graph_colors}}, + "DEF:slwreq" . $e . "_0=$rrd:phpfpm" . $e . "_slreq0:AVERAGE", + "DEF:slwreq" . $e . "_1=$rrd:phpfpm" . $e . "_slreq1:AVERAGE", + "DEF:slwreq" . $e . "_2=$rrd:phpfpm" . $e . "_slreq2:AVERAGE", + "DEF:slwreq" . $e . "_3=$rrd:phpfpm" . $e . "_slreq3:AVERAGE", + "DEF:slwreq" . $e . "_4=$rrd:phpfpm" . $e . "_slreq4:AVERAGE", + "DEF:slwreq" . $e . "_5=$rrd:phpfpm" . $e . "_slreq5:AVERAGE", + "DEF:slwreq" . $e . "_6=$rrd:phpfpm" . $e . "_slreq6:AVERAGE", + "DEF:slwreq" . $e . "_7=$rrd:phpfpm" . $e . "_slreq7:AVERAGE", + "CDEF:allvalues=slwreq" . $e . "_0,slwreq" . $e . "_1,slwreq" . $e . "_2,slwreq" . $e . "_3,slwreq" . $e . "_4,slwreq" . $e . "_5,slwreq" . $e . "_6,slwreq" . $e . "_7,+,+,+,+,+,+,+", + @CDEF, + @tmpz); + $err = RRDs::error; + push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 5]: $err\n") if $err; + } + $e2 = $e + 6; + if($title || ($silent =~ /imagetag/ && $graph =~ /phpfpm$e2/)) { + if(lc($config->{enable_zoom}) eq "y") { + if(lc($config->{disable_javascript_void}) eq "y") { + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 5] . "\">\n"); + } else { + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + push(@output, " {url} . "/" . $config->{imgs_dir} . $IMGz[$e * 6 + 5] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); + } + } else { + push(@output, " \n"); + } + } + + if($title) { + push(@output, " \n"); + push(@output, " \n"); + + push(@output, " \n"); + push(@output, " \n"); + push(@output, " \n"); + push(@output, " \n"); + push(@output, "   $phpfpm->{group}->{$pfg}\n"); + push(@output, " \n"); + push(@output, " \n"); + push(@output, " \n"); + push(@output, main::graph_footer()); + } + $e++; + } + push(@output, "
\n"); + return @output; +} + +1; diff --git a/monitorix.conf b/monitorix.conf index 05b60dc..36c5a57 100644 --- a/monitorix.conf +++ b/monitorix.conf @@ -115,6 +115,7 @@ secure_log_date_format = %b %e raspberrypi = n phpapc = n memcached = n + phpfpm = n apcupsd = n nut = n wowza = n @@ -712,6 +713,27 @@ secure_log_date_format = %b %e +# PHP-FPM graph +# ----------------------------------------------------------------------------- + + + 0 = First group of domains + + + 0 = example1.com, example2.com, example3.com + + + example1.com = http://www.example1.com/php_fpm_status + example2.com = http://www.example2.com/php_fpm_status + example3.com = http://www.example3.com/php_fpm_status + + + + rigid = 0, 0, 2, 0, 0, 0 + limit = 100, 100, 100, 100, 100, 100 + + + # APCUPSD graph # ----------------------------------------------------------------------------- @@ -897,7 +919,7 @@ logo_bottom = logo_bot.png remote = 300x100 -graph_name = system, kern, proc, hptemp, lmsens, gensens, ipmi, ambsens, nvidia, disk, fs, zfs, du, net, netstat, tc, libvirt, process, serv, mail, port, user, ftp, apache, nginx, lighttpd, mysql, mongodb, varnish, pagespeed, squid, nfss, nfsc, bind, ntp, chrony, fail2ban, icecast, raspberrypi, phpapc, memcached, apcupsd, nut, wowza, int, verlihub +graph_name = system, kern, proc, hptemp, lmsens, gensens, ipmi, ambsens, nvidia, disk, fs, zfs, du, net, netstat, tc, libvirt, process, serv, mail, port, user, ftp, apache, nginx, lighttpd, mysql, mongodb, varnish, pagespeed, squid, nfss, nfsc, bind, ntp, chrony, fail2ban, icecast, raspberrypi, phpapc, memcached, phpfpm, apcupsd, nut, wowza, int, verlihub system = System load average and usage @@ -941,6 +963,7 @@ graph_name = system, kern, proc, hptemp, lmsens, gensens, ipmi, ambsens, nvidia, raspberrypi = Raspberry Pi sensor statistics phpapc = Alternative PHP Cache statistics memcached = Memcached statistics + phpfpm = PHP-FPM statistics apcupsd = APC UPS statistics nut = Network UPS Tools statistics wowza = Wowza Media Server @@ -1122,6 +1145,12 @@ graph_name = system, kern, proc, hptemp, lmsens, gensens, ipmi, ambsens, nvidia, _memcached5 = Objects I/O _memcached6 = Connections _memcached7 = Memcached traffic + _phpfpm1 = Accepted connections + _phpfpm2 = Active processes + _phpfpm3 = Listen queue + _phpfpm4 = Total processes + _phpfpm5 = Max. children reached + _phpfpm6 = Slow requests _apcupsd1 = Line voltage _apcupsd2 = Battery charge _apcupsd3 = Temperatures