From f1323455cfeb7885a8dea9ed9bb2f0d69af2ae95 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Thu, 19 Jun 2014 11:37:53 +0200 Subject: [PATCH] added new 'limit' functionality to 'nginx' graph --- lib/nginx.pm | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/lib/nginx.pm b/lib/nginx.pm index 789a9f4..62d69e0 100644 --- a/lib/nginx.pm +++ b/lib/nginx.pm @@ -244,8 +244,8 @@ sub nginx_cgi { my ($package, $config, $cgi) = @_; my $nginx = $config->{nginx}; - my @rigid = split(',', $nginx->{rigid}); - my @limit = split(',', $nginx->{limit}); + my @rigid = split(',', ($nginx->{rigid} || "")); + my @limit = split(',', ($nginx->{limit} || "")); my $tf = $cgi->{tf}; my $colors = $cgi->{colors}; my $graph = $cgi->{graph}; @@ -350,14 +350,7 @@ sub nginx_cgi { if($title) { main::graph_header($title, 2); } - if(trim($rigid[0]) eq 1) { - push(@riglim, "--upper-limit=" . trim($limit[0])); - } else { - if(trim($rigid[0]) eq 2) { - push(@riglim, "--upper-limit=" . trim($limit[0])); - push(@riglim, "--rigid"); - } - } + @riglim = @{setup_riglim($rigid[0], $limit[0])}; if($title) { print(" \n"); print(" \n"); @@ -415,7 +408,6 @@ sub nginx_cgi { "--width=$width", "--height=$height", @riglim, - "--lower-limit=0", $zoom, @{$cgi->{version12}}, @{$colors->{graph_colors}}, @@ -439,7 +431,6 @@ sub nginx_cgi { "--width=$width", "--height=$height", @riglim, - "--lower-limit=0", @{$cgi->{version12}}, @{$colors->{graph_colors}}, "DEF:total=$rrd:nginx_total:AVERAGE", @@ -469,15 +460,7 @@ sub nginx_cgi { print(" \n"); print(" \n"); } - undef(@riglim); - if(trim($rigid[1]) eq 1) { - push(@riglim, "--upper-limit=" . trim($limit[1])); - } else { - if(trim($rigid[1]) eq 2) { - push(@riglim, "--upper-limit=" . trim($limit[1])); - push(@riglim, "--rigid"); - } - } + @riglim = @{setup_riglim($rigid[1], $limit[1])}; undef(@tmp); undef(@tmpz); undef(@CDEF); @@ -508,7 +491,6 @@ sub nginx_cgi { "--width=$width", "--height=$height", @riglim, - "--lower-limit=0", $zoom, @{$cgi->{version12}}, @{$cgi->{version12_small}}, @@ -529,7 +511,6 @@ sub nginx_cgi { "--width=$width", "--height=$height", @riglim, - "--lower-limit=0", @{$cgi->{version12}}, @{$cgi->{version12_small}}, @{$colors->{graph_colors}}, @@ -588,15 +569,7 @@ sub nginx_cgi { push(@warning, $colors->{warning_color}); } - undef(@riglim); - if(trim($rigid[2]) eq 1) { - push(@riglim, "--upper-limit=" . trim($limit[2])); - } else { - if(trim($rigid[2]) eq 2) { - push(@riglim, "--upper-limit=" . trim($limit[2])); - push(@riglim, "--rigid"); - } - } + @riglim = @{setup_riglim($rigid[2], $limit[2])}; undef(@tmp); undef(@tmpz); undef(@CDEF); @@ -641,7 +614,6 @@ sub nginx_cgi { "--width=$width", "--height=$height", @riglim, - "--lower-limit=0", $zoom, @{$cgi->{version12}}, @{$cgi->{version12_small}}, @@ -664,7 +636,6 @@ sub nginx_cgi { "--width=$width", "--height=$height", @riglim, - "--lower-limit=0", @{$cgi->{version12}}, @{$cgi->{version12_small}}, @{$colors->{graph_colors}},