Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix freebsd graphes #12

Merged
merged 2 commits into from
May 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions html/nfsenutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ function nfsend_query ( $command, $cmd_opts ) {
$error_occured = 0;
while ( !$done ) {
if ( $is_binary )
$line = @socket_read($nfsend, 1024, PHP_BINARY_READ);
$line = @socket_read($nfsend, 65534, PHP_BINARY_READ);
else
$line = @socket_read($nfsend, 1024, PHP_NORMAL_READ);
$line = @socket_read($nfsend, 65534, PHP_NORMAL_READ);

if ( $line == FALSE ) {
$errno = socket_last_error($nfsend);
Expand Down
15 changes: 12 additions & 3 deletions libexec/NfSenRRD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ package NfSenRRD;
use RRDs;
use Log;
use NfSen;
use File::Temp qw/tempfile/;
use strict;
use warnings;

Expand Down Expand Up @@ -280,7 +281,7 @@ sub GenGraph {
}

my $graph_filename = "$NfConf::PROFILESTATDIR/$profiledir/${what}${extension}.png";
my ($averages,$xsize,$ysize) = RRDs::graph $graph_filename,
my $res = RRDs::graphv $graph_filename,
@DEFS,
"--imgformat", "PNG",
"--title", "$title" ,
Expand Down Expand Up @@ -447,7 +448,9 @@ sub GenDetailsGraph {
}

my @rrdargs = ();
push @rrdargs, "-"; # output graphics to stdout
#push @rrdargs, "-"; # output graphics to stdout
my (undef,$tmpng) = tempfile('/tmp/NfProfilePNGXXXX',OPEN => 0) or die "Unable to create tempfile";
push @rrdargs, $tmpng; # output graphics to temp file

foreach my $def ( @DEFS ) {
$$profileinfo{'channel'}{$def}{'scale'} = $$profileinfo{'channel'}{$def}{'sign'} eq "-" ? -1 : 1;
Expand Down Expand Up @@ -523,6 +526,8 @@ sub GenDetailsGraph {
SendFile("$NfConf::HTMLDIR/icons/ErrorGraph.png");
return "$ERROR: Arg: '$profile', '$sources', '$proto', '$type', '$pstart', '$tstart', '$tend', '$tleft', '$tright', '$width', '$heigh', '$light', '$logscale', '$linegraph'";
} else {
SendFile($tmpng);
unlink($tmpng);
return "ok";
}

Expand Down Expand Up @@ -563,7 +568,9 @@ sub GenAlertGraph {
my @DEFS = split ':', $sources;

my @rrdargs = ();
push @rrdargs, "-"; # output graphics to stdout
#push @rrdargs, "-"; # output graphics to stdout
my (undef,$tmpng) = tempfile('/tmp/NfProfilePNGXXXX',OPEN => 0) or die "Unable to create tempfile";
push @rrdargs, $tmpng; # output graphics to temp file

foreach my $def ( @DEFS ) {
push @rrdargs, "DEF:data${def}=$NfConf::PROFILESTATDIR/~$alertname/avg-$type.rrd:${def}:AVERAGE";
Expand Down Expand Up @@ -600,6 +607,8 @@ sub GenAlertGraph {
SendFile("$NfConf::HTMLDIR/icons/ErrorGraph.png");
return "ERR failed $ERROR";
} else {
SendFile($tmpng);
unlink($tmpng);
return "ok";
}

Expand Down