Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
system: improve RRD collector PID/service handling
  • Loading branch information
fichtner committed Jun 3, 2023
1 parent 038d5b9 commit fdf46f3
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/etc/inc/rrd.inc
Expand Up @@ -100,6 +100,9 @@ function rrd_configure($verbose = false, $bootup = false)
$downstream = 2500000000;
$upstream = 2500000000;

/* kill off traffic collectors */
killbypid('/var/run/updaterrd.pid');

if (isset($config['rrd']['enable'])) {
/* create directory if needed */
if (!is_dir($rrddbpath)) {
Expand All @@ -112,8 +115,6 @@ function rrd_configure($verbose = false, $bootup = false)
$rrdupdatesh .= "\n";
$rrdupdatesh .= "export TERM=dumb\n";
$rrdupdatesh .= "\n";
$rrdupdatesh .= 'echo $$ > /var/run/updaterrd.sh.pid';
$rrdupdatesh .= "\n";
$rrdupdatesh .= "counter=1\n";
$rrdupdatesh .= "while [ \"\$counter\" -ne 0 ]\n";
$rrdupdatesh .= "do\n";
Expand Down Expand Up @@ -560,17 +561,10 @@ EOD;
$fd = fopen("$updaterrdscript", "w");
fwrite($fd, "$rrdupdatesh");
fclose($fd);

unset($rrdupdatesh);

/* kill off traffic collectors */
rrd_stop();
chmod($updaterrdscrip, 0755);

/* start traffic collector */
mwexec_bg("/bin/sh $updaterrdscript");
} else {
/* kill off traffic collectors */
rrd_stop();
mwexecf('/usr/sbin/daemon -f -p %s %s', ['/var/run/updaterrd.pid', $updaterrdscript]);
}

$databases = glob("{$rrddbpath}/*.rrd");
Expand Down Expand Up @@ -609,11 +603,6 @@ function rrd_create_gateway_quality($rrd_file, $unknown = false)
}
}

function rrd_stop()
{
killbypid('/var/run/updaterrd.sh.pid');
}

function rrd_export()
{
$rrddbpath = '/var/db/rrd';
Expand Down

0 comments on commit fdf46f3

Please sign in to comment.