简体   繁体   中英

RRDTool - Get time range

I am using RRDTool to graph Data and a predicted Trend (LSL) in one Graph.
Therefore I am adjusting the corresponding template.
At the moment I set my end time like this:

--end start+7d

When looking at the resulting graphs via the website I can select different time ranges on the right side:
Custom time Range, Overview, 4 Hours, 25 Hours, One Week, One Month and One Year

What I want:
If I select a time range of 4 Hours, 7 days of forecasting makes no sense. I want to calculate the end time dependent on the time range selected. For example I want the time period displayed in the future being exact of the same size as the time range selected.
Basically I want to define my ending time like this:

--end start+(end-start)

This is not possible, because the end time can not be defined by itself.

Is there a way to extract the selected time-range before defining the end by hand? I could calculate start+(end-start) in my PHP Template and insert it when defining the ending time.

Every help appreciated.

EDIT: I forgot to mention, that I am using RRDTool via PNP4Nagios . When speaking of a website I meant the PNP4Nagios Standard Web Appearance. This is shipped by default when installing PNP4Nagios via Packages.

With PNP4Nagios, your custom template can be used to define all the graph definition -- with the exception of the time window, which is added to the parameter lists in $opt[] and $def[]. So, you cannot easily override the time window 'end' as it is already defined as 'now' by PNP4Nagios (and the 'start' is already defined relative to the end, based on the time range you selected in the web interface). In fact, RRDTool is fairly robust, so if it sees a start/end being redefined the last such definition usually takes precedence... but this doesn't solve your issue.

I think what you're trying to do is have the 1day graph (which normally starts at 'end-1day' and ends at 'now') to go from 'now-1day' to 'now+1day' so that your prediction line could fill the second part. This would need to be done by editing the PNP4Nagios code, which is a bit out of scope of this answer.

PNP4Nagios allows definition of the standard timeranges in the config.php; you can also define new timeranges when you call the graph. This means you can achieve the required time window like this:

pnp4nagios/graph?host=<hostname>&srv=<servicedesc>&start=-1day&end=+1day

... although this is just a one-off and does not override the defaults.

The current view config in PNP4Nagios does not allow the default views to specify an end offset, only a start offset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM