Welcome! Log In Create A New Profile

Advanced

RHEL 6.x to RHEL 8.x migration - rrdgraph no longer works from NGINX

Posted by rhelsysadmin 
RHEL 6.x to RHEL 8.x migration - rrdgraph no longer works from NGINX
September 11, 2023 11:34PM
Firstly, full disclosure, this is a long running problem and I have posted at github seeking assistance, apologies to those who have seen this already: https://github.com/oetiker/rrdtool-1.x/discussions/1229

As stated at github, I have narrowed down the problem to I what I believe is no longer supported calls to PCRE in a custom perl module and I am hoping to find some guidance with how change the perl subroutine so that it makes calls to ngx_regex_compile() as described here: https://trac.nginx.org/nginx/ticket/1403

I have web searched and search but, not being a developer, the information that I have found is proving useful without a lot of assumed knowledge.

The error.log show the following:
$VAR1 = [];
Error while graphing "/opt/mrtg/central/FILE_NAME.png": cannot compile regular expression: Error while compiling regular expression ^(?:[^%]+|%%)%[-+ 0#]?[0-9](?:[.][0-9]+)?leEfFgG(?:%s)?(?:[^%]+|%%)$ at char 86: failed to get memory (^(?:[^%]+|%%)%[-+ 0#]?[0-9](?:[.][0-9]+)?leEfFgG(?:%s)?(?:[^%]+|%%)$)
Failed to open file "/opt/mrtg/central/FILE_NAME.png": No such file or directory

The perl subroutine in question is as follows and any insights into how to fix it would be greatly appreciated:

#################### Subroutine Begin ###########################
sub main_screen_show_graph_img
{
my ( $self, $nodeId, $reference, $what, $period, $hidespikes ) = @;
my $sth = $self -> { dbh } -> prepare( "SELECT node,server FROM nodes,towns WHERE nodes.id=? and town=name" );
$sth -> execute( $nodeId );
my ( $node, $server ) = $sth -> fetchrow_array;
$sth -> finish;
my $file = "$path/$server/" . $nodeId . "" . lc($reference) . "_" . lc($what);
my @rrdArray = ();
warn Dumper @rrdArray;
my $time = time;
push( @rrdArray, "$file-$period-$time.png" );
if ( $hidespikes )
{
push( @rrdArray, "--logarithmic" );
push( @rrdArray, "--units" );
push( @rrdArray, "si" );
}
push( @rrdArray, "--x-grid" );

my $start = "end-";
my $periodSummary;
my $step;
if ( $period eq 'day' )
{
$periodSummary = "Day Summary";
$start .= "32h";
push( @rrdArray, "HOUR:1:DAY:1:HOUR:1:0:\%H" );
$step = 300;
}
elsif ( $period eq 'week' )
{
$periodSummary = "Week Summary";
$start .= "9d";
push( @rrdArray, "DAY:1:WEEK:1:DAY:1:86400:\%a" );
$step = 900;
}
elsif ( $period eq 'month' )
{
$periodSummary = "Month Summary";
$start .= "5w";
push( @rrdArray, "WEEK:1:MONTH:1:WEEK:1:604800:Week \%V" );
$step = 3600;
}
else
{
$periodSummary = "Year Summary";
$start .= "60w";
push( @rrdArray, "WEEK:1:MONTH:1:MONTH:1:2592000:\%b" );
$step = 43200;
}
push( @rrdArray, "--start" );
push( @rrdArray, $start );
push( @rrdArray, "--end" );
push( @rrdArray, "now - 300s" );
push( @rrdArray, "--step" );
push( @rrdArray, $step );
push( @rrdArray, "--imgformat" );
push( @rrdArray, "PNG" );
push( @rrdArray, "--width" );
push( @rrdArray, "768" );
push( @rrdArray, "--height" );
push( @rrdArray, "200" );
push( @rrdArray, "--slope-mode" );

my $title = $node . " ";
my $verticalLabel;
push( @rrdArray, "DEF:ds0avg=" . $file . ".rrd:ds0:AVERAGE" );
push( @rrdArray, "DEF:ds0max=" . $file . ".rrd:ds0:MAX" );
push( @rrdArray, "DEF:ds1avg=" . $file . ".rrd:ds1:AVERAGE" );
push( @rrdArray, "DEF:ds1max=" . $file . ".rrd:ds1:MAX" );
my $postDS0;
my $postDS1;
my $postDS2;
my $postDS3;
my $label0;
my $label1;
my $label2;
my $label3;
my $short0;
my $short1;
if ( ( $reference eq 'memory' ) || ( $reference eq 'cpu' ) )
{
if ( $reference eq 'memory' )
{
$title .= "Memory ";
$label0 = "Memory ";
$label1 = "IO ";
$label2 = "Maximal 5 Minute Memory Utilisation";
$label3 = "Maximal 5 Minute IO";
}
else
{
$title .= "CPU";
$label0 = "5m \% ";
$label1 = "1m \% ";
$label2 = "Maximal 5 Minute 5m CPU Utilisation";
$label3 = "Maximal 5 Minute 1m CPU Utilisation";
}
$title .= " Utilisation";
push( @rrdArray, "--lower-limit" );
if ( $hidespikes )
{
push( @rrdArray, "1" );
}
else
{
push( @rrdArray, "0" );
}
push( @rrdArray, "--upper-limit" );
push( @rrdArray, "100" );
push( @rrdArray, "--rigid" );
$verticalLabel = "Utilisation %";
$postDS0 = "ds0avg";
$postDS1 = "ds1avg";
$postDS2 = "ds0max";
$postDS3 = "ds1max";
}
else
{
$title .= "Interface " . $reference . " ";
$title .= "In/Out";
if ( $what eq 'InOutErrors' )
{
$title .= " Errors";
$verticalLabel = "Errors per second";
$label0 = "In Eps";
$label1 = "Out Eps";
$label2 = "Maximal 5 Minute Incoming Errors Per Second";
$label3 = "Maximal 5 Minute Outgoing Errors Per Second";
}
else
{
$verticalLabel = "Bits per second";
$label0 = "In bps";
$label1 = "Out bps";
$label2 = "Maximal 5 Minute Incoming Bits Per Second";
$label3 = "Maximal 5 Minute Outgoing Bits Per Second";
}
push( @rrdArray, "CDEF:ds0bitsavg=ds0avg,8,*" );
push( @rrdArray, "CDEF:ds1bitsavg=ds1avg,8,*" );
push( @rrdArray, "CDEF:ds0bitsmax=ds0max,8,*" );
push( @rrdArray, "CDEF:ds1bitsmax=ds1max,8,*" );
$postDS0 = "ds0bitsavg";
$postDS1 = "ds1bitsavg";
$postDS2 = "ds0bitsmax";
$postDS3 = "ds1bitsmax";
$short0 = "\%s";
$short1 = "\%s";
}
push( @rrdArray, "VDEF:vds0max=$postDS2,MAXIMUM" );
push( @rrdArray, "VDEF:vds1max=$postDS3,MAXIMUM" );
push( @rrdArray, "VDEF:vds0min=$postDS0,MINIMUM" );
push( @rrdArray, "VDEF:vds1min=$postDS1,MINIMUM" );
push( @rrdArray, "VDEF:vds0avg=$postDS0,AVERAGE" );
push( @rrdArray, "VDEF:vds1avg=$postDS1,AVERAGE" );
push( @rrdArray, "VDEF:vds0last=$postDS0,LAST" );
push( @rrdArray, "VDEF:vds1last=$postDS1,LAST" );
push( @rrdArray, "COMMENT: " );
push( @rrdArray, "COMMENT: Maximum" );
push( @rrdArray, "COMMENT: Minimum" );
push( @rrdArray, "COMMENT: Average" );
push( @rrdArray, "COMMENT: Current\\n" );
push( @rrdArray, "AREA:$postDS0#00ff00:$label0" );
push( @rrdArray, "GPRINT:vds0max:\%10.2lf$short0" );
push( @rrdArray, "GPRINT:vds0min:\%10.2lf$short0" );
push( @rrdArray, "GPRINT:vds0avg:\%10.2lf$short0" );
push( @rrdArray, "GPRINT:vds0last:\%10.2lf$short0\\n" );
push( @rrdArray, "LINE1:$postDS1#0000ff:$label1" );
push( @rrdArray, "GPRINT:vds1max:\%10.2lf$short1" );
push( @rrdArray, "GPRINT:vds1min:\%10.2lf$short1" );
push( @rrdArray, "GPRINT:vds1avg:\%10.2lf$short1" );
push( @rrdArray, "GPRINT:vds1last:\%10.2lf$short1\\n" );
if ( $period ne 'day' )
{
push( @rrdArray, "LINE1:$postDS2#006400:$label2" );
push( @rrdArray, "LINE1:$postDS3#ff00ff:$label3" );
}
$title .= " $periodSummary";
push( @rrdArray, "--title" );
push( @rrdArray, $title );
push( @rrdArray, "--vertical-label" );
push( @rrdArray, $verticalLabel );
push( @rrdArray, "--font" );
push( @rrdArray, "DEFAULT:0:/usr/share/fonts/bitstream-vera/VeraMono.ttf" );

RRDs::graph @rrdArray;
my $ERR=RRDs::error;
warn "Error while graphing \"$file-$period-$time.png\": $ERR\n" if $ERR;
open( FILE, "$file-$period-$time.png" ) or warn "Failed to open file \"$file-$period-$time.png\": $!\n\n";
binmode(FILE);
my ($buf, $data, $n);
while (($n = read FILE, $data, 4) != 0)
{
$buf .= $data;
}
close( FILE );
unlink( "$file-$period-$time.png" ) or warn "Failed to clean up temporary file \"$file-$period-$time.png\": $!\n\n";
return $buf;
}
#################### Subroutine End ###########################
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 243
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready