Skip to content

Commit

Permalink
Don't use epoch ts in rrdtool fetch. Fixes #14418
Browse files Browse the repository at this point in the history
rrttool fetch has some issues with the way this package was using
epoch+<ts>s, so switch to using traditional dates instead.

Behavior should be the same or better in the end.
  • Loading branch information
jim-p committed May 25, 2023
1 parent d848b6d commit 0049587
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions sysutils/pfSense-pkg-RRD_Summary/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-RRD_Summary
PORTVERSION= 2.0
PORTREVISION= 2
PORTVERSION= 2.1
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
Expand Up @@ -86,11 +86,15 @@ function print_rrd_summary($rrd, $units, $startyear, $startday) {
if ($startyear > 0 && $startyear != $year) continue;
foreach (range(12, 1, -1) as $month) {
$start = strtotime(date("{$month}/{$startday}/{$year}"));
$end = strtotime("-1 second", strtotime("+1 month", $start));
$end = strtotime("+1 month", $start);
/* End time should be one second less than the start of the
* next month otherwise RRDtool will include the first day
* of the next month in the summary. */
$end = strtotime("-1 second", $end);
if ($start > $last || $end < $first) continue;
if ($start < $first) $start = $first;
if ($end > $last) $end = $last;
$data = fetch_rrd_summary($rrd, "epoch+{$start}s", "epoch+{$end}s", $units, 24*60*60);
/* Use at-time format as unix timestamps can be problematic in various ways. */
$data = fetch_rrd_summary($rrd, date('m/d/Y H:i', $start), date('m/d/Y H:i', $end), $units, 24*60*60);
?>
<tr>
<td><?=date("Y-m-d", $start); ?> to <?=date("Y-m-d", $end); ?></td>
Expand Down

0 comments on commit 0049587

Please sign in to comment.