Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


[revisitied] Time Shifter V0.2

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin General
Author Message
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12604
Location: Muenster, Germany

PostPosted: Sat Feb 25, 2006 7:39 am    Post subject: [revisitied] Time Shifter V0.2 Reply with quote

Some days ago I introduced a new feature, the Time Shifter. Due to some discussions on the forum and work with the current Time Shifter, I decided to implement some improved version based on current 0.8.6h svn branch. Unfortunately, this patch changes five files and generates two new files for the images (images/move_left.gif and images/move_right.gif, they already were provided by the last patch) and a new ./lib/time.php module.

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:
patch -p1 < cacti_patch_time_shifter2.patch
will patch existing files and create the new ones (the parameter is -pONE, it is a number, not the lowercase "L"). It would produce
Code:
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
That's all.

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:
tar -zxvf cacti_patch_time_shifter2.tar.gz
will expand all files to their correct directories. It should produce:
Code:
./
./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


Using: new Defaults
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
Some funny date calculations were needed for this. If interested, see ./lib/time.php. Pay attention to the date fields and the Graph Legend; see this in action for This Week:




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



cacti_patch_time_shifter2.patch
 Description:
Patch

Download
 Filename:  cacti_patch_time_shifter2.patch
 Filesize:  30.35 KB
 Downloaded:  355 Time(s)


cacti_patch_time_shifter2.tar.gz
 Description:
Whole files for overwriting as gzipped tar

Download
 Filename:  cacti_patch_time_shifter2.tar.gz
 Filesize:  15.5 KB
 Downloaded:  427 Time(s)

Back to top
fmangeant
Cacti Guru User


Joined: 19 Sep 2003
Posts: 2325
Location: Sophia-Antipolis, France

PostPosted: Mon Feb 27, 2006 3:19 am    Post subject: Reply with quote

Many many thanks, my users will be delighted to use the "true" presets...

IMHO it would be a good idea to incorporate this addon in a 0.8.6x release.
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12604
Location: Muenster, Germany

PostPosted: Mon Feb 27, 2006 5:46 am    Post subject: Reply with quote

fmangeant wrote:
IMHO it would be a good idea to incorporate this addon in a 0.8.6x release.
I suppose, this is not possible. The devs are working on 0.9.0 code and releasing another 0.8.6 version would cause unwanted delay, I suppose
Reinhard
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9736
Location: MI, USA

PostPosted: Mon Mar 06, 2006 7:33 pm    Post subject: Reply with quote

Make your case with Ian.

Larry
Back to top
davs



Joined: 31 Mar 2006
Posts: 28
Location: paris

PostPosted: Tue Apr 25, 2006 6:51 am    Post subject: Reply with quote

Hi Reinhard,

I've install your patch by overwriting the files... The time shifter works but all my plugins do not work anymore

Do you have any ideas to resolved that?

Thanks a lot...
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12604
Location: Muenster, Germany

PostPosted: Tue Apr 25, 2006 11:56 am    Post subject: Reply with quote

Sorry for that.
Please use patches only when plugin arch is installed (full files are based on pure cacti, not on plugin-modified-cacti). And please see the current version at http://forums.cacti.net/viewtopic.php?t=12429
Reinhard
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin General All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group