Installing by patch
Save your files!
./include/html/inc_timespan_settings.php
./include/html/inc_timespan_selector.php
./include/config_constants.php
./include/config_arrays.php
./include/config_settings.php
will be changed. You may need them as a backup!
This approach only works with unpatched cacti. If you already installed the fist Time Shifter version, please use the tar.gz approach.
Copy attached patch file to your current cacti directory.
Code: Select all
patch -p1 < cacti_patch_time_shifter2.patch
Code: Select all
patching file images/move_left.gif
patching file images/move_right.gif
patching file include/config_arrays.php
patching file include/config_constants.php
patching file include/config_settings.php
patching file include/html/inc_timespan_selector.php
patching file include/html/inc_timespan_settings.php
patching file lib/time.php
Installing by overwriting
Save your files!
./include/html/inc_timespan_settings.php
./include/html/inc_timespan_selector.php
./include/config_constants.php
./include/config_arrays.php
./include/config_settings.php
will be changed. You may need them as a backup!
This approach works with already patched cacti. But be careful. It OVERWRITES some existing files. Perhaps it would be better to extract the changes from the tar.gz files
- include/config_settings.php
- include/config_constants.php
- include/config_arrays.php
- include/html/inc_timespan_selector.php
- include/html/inc_timespan_settings.php
manually and apply them to your files.
Code: Select all
tar -zxvf cacti_patch_time_shifter2.tar.gz
Code: Select all
./
./images/
./images/move_right.gif
./images/move_left.gif
./include/
./include/html/
./include/html/inc_timespan_settings.php
./include/html/inc_timespan_selector.php
./include/config_constants.php
./include/config_arrays.php
./include/config_settings.php
./lib/
./lib/time.php
User Management settings for each user are extended by this patch. Select the Graph Settings Tab to find three new entries that control Graph Generation. The following picture shows the default settings:
Default Graph View Timeshift
Select the amount of time for shifting actions. This defaults to 1 Day. Special attention must be given to monthly shifting. But this will be explained later.
Allow Graph to extend to Future
Due to some extension of Preset, it is possible to preselect a timespan, that extends to the future (e.g. to end of current month). This checkbox allows for suppression of that, so that no graph may show times in the future. Excuse my lack of english knowledge, I can't explain this better.
For displaying graphs representing special timespans (weekly, monthly, yearly) and shifting them it is useful to have this checked.
First Day of the Week
For weekly timespans, this dropdown allows specifying the first weekday of a week. I know there are lots of people out there that use other calendars (different year definitions and the like); but I don't know much about that. So I did not implement these specialties.
Please change these values first if there is any need for this. They are stored on a "per user" basis in cacti's MySQL tables without need for table schema change.
Using: General
This patch extends the time selection bar as shown below. I had fun to provide a tooltip help using html title tags for each item on the bar.
Using: new Presets
Some requests were made on the forum to allow for calendaric display, e.g. not only last week but current week (from e.g. monday to sunday) or month (from first day to last day of month). So I extended the Preset dropdown by:
- This Day
- This Week
- This Month
- This Year
- Previous Day
- Previous Week
- Previous Month
- Previous Year
And now for Previous Month:
Using: new Shift Amounts
The first solution published tried to deduce the shift amount by guessing this from the timespan between current graph begin and end time. This could turn out be be way too complicated for quickly work. So I introduced a new dropdown to define the shift amount seperately. This amount is initialized to 1 Day and may be changed for each user individually (see above). So please select the appropriate Shift Amount before using the "Shift Left" or "Shift Right" arrows.
The calendar magic is pure php builtin functions (strtotime, date) and confirmed to work at least with php 4.3.9. As to the PHP Site, there may be some change for php version 5; but I did not have the opportunity to check this out.
Using: true Monthly Shifting
I'm very proud to present this feature. And yes, it took me quite some time. Of course, this is not hard to understand, but let me show you some examples:
Shifting 1 Month using arbitrary begin/end times
Lets assume, Graph start at Feb, 24 at 15:00 and end at Feb, 25, 15:00. Shifting "1 Month" left will of course result in the new Graph spanning the time from Jan, 24 at 15:00 to Jan, 25 at 15:00. No magic, so far.
Shifting 1 Month using "This Month" Preset
Now lets start the Graph at Feb, 01 at 00:00 and end it at Feb, 28 at 23:59. If current time is somewhere within February, this is easily done using "This Month" Preset.
What would you assume shifting "1 Month" left would result in? Wrong!
Shifting Feb, 01 at 00:00 "1 Month" left results in: Jan, 01 at 00:00.
Shifting Feb, 28 at 23:59 "1 Month" left results in: Jan, 31 at 23:59!
So Monthly Shifting takes different numbers of days for the months into account. The code was made such, that begin time is checked for "begin of any month" and end time is checked for "end of any month". Begin and end need not to be related to the same month. So you may span e.g. two months manually.
Shifting "1 Month" left will result in a 2 Months spanning Graph as expected.
Time Shifter will not only work in Tree Mode but also in Preview Mode
As always Use this at your own risk
happy cactiing
Reinhard