Hi,
I have a central cacti server and have configured 20servers to monitor for my customers. But the customers are live in different locations and they need to change the timezone to view graph in their timezone. So I am not sure how to change the timezone for a particular user cacti account.
Can anyone let me know how to change this?
Thanks.
Change TimeZone for a specific suer
Moderators: Developers, Moderators
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
Re: Change TimeZone for a specific suer
Not currently supported...
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
Re: Change TimeZone for a specific suer
But will be supported starting with 1.0.0
R.
R.
Re: Change TimeZone for a specific suer
From interests, I've tried implementing user specific timezone when viewing graphs.
Graph settings (per user)
When selected another timezone
Patch file for Cacti 0.8.7g +official patch +PIA2.9 - To apply:
% patch -p1 -N < /tmp/user_timezone.patch
patching file include/global_settings.php
patching file include/global_arrays.php
patching file lib/time.php
patching file lib/rrd.php
- To revert:
% patch -p1 -N --reverse < /tmp/user_timezone.patch
Modification summary
- Borrowed basic idea from here: http://www.vandenbogaerdt.nl/rrdtool/timezone.php
- Timezone lists are created from PECL's timezonedb.h
- Define new function to change TZ environment in lib/time.php
NOTE: date_default_timezone_set() doesn't take effect because (maybe) that is only available in PHP session (not in HTML part)..
- Change timezone in functions referring to date/time in lib/time.php
- Also in lib/rrd.php
Known issue
Server's timezone is changed temporarily only when displaying graphs, so any logs (PHP error log, Cacti's web events, etc.) are recorded with timestamps of selected timezone at that moment.
// Sorry my English
Graph settings (per user)
When selected another timezone
Patch file for Cacti 0.8.7g +official patch +PIA2.9 - To apply:
% patch -p1 -N < /tmp/user_timezone.patch
patching file include/global_settings.php
patching file include/global_arrays.php
patching file lib/time.php
patching file lib/rrd.php
- To revert:
% patch -p1 -N --reverse < /tmp/user_timezone.patch
Modification summary
- Borrowed basic idea from here: http://www.vandenbogaerdt.nl/rrdtool/timezone.php
- Timezone lists are created from PECL's timezonedb.h
- Define new function to change TZ environment in lib/time.php
Code: Select all
/* set_user_timezone - set user specific timezone for displaying graphs
* @arg $timezone - timezone string
*/
function set_user_timezone($timezone = '') {
global $config;
include($config["include_path"] . "/global_arrays.php");
if (empty($timezone)) {
$tz_id = read_graph_config_option("default_user_timezone");
if (!isset($tz_id) || $tz_id == '0') {
return '';
}
$timezone = $graph_usertimezones[$tz_id];
}
putenv("TZ=" . $timezone);
return $timezone;
}
- Change timezone in functions referring to date/time in lib/time.php
Code: Select all
function get_timespan(&$span, $curr_time, $timespan_given, $first_weekdayid) {
set_user_timezone();
...
}
function check_month_boundaries(&$span) {
set_user_timezone();
...
}
function shift_right_boundary(&$span, $direction, $shift_size) {
set_user_timezone();
...
}
function shift_time(&$span, $direction, $shift_size) {
set_user_timezone();
...
}
Code: Select all
function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, &$rrdtool_pipe) {
...
/* set timezone */
include_once($config["library_path"] . "/time.php");
$tz_serv = getenv("TZ");
$tz_user = set_user_timezone();
/* setup date format */
...
...
/* show timezone if needed */
if (read_graph_config_option("display_timezone_in_graph") == "on") {
$txt_graph_items .= RRD_NL . "COMMENT:\" \\n\"";
$txt_graph_items .= RRD_NL . "COMMENT:\"Timezone for displaying = " . ($tz_user == '' ? "default(" . $tz_serv . ")" : $tz_user) . "\"";
}
$graph_array = api_plugin_hook_function('rrd_graph_graph_options', ...
Server's timezone is changed temporarily only when displaying graphs, so any logs (PHP error log, Cacti's web events, etc.) are recorded with timestamps of selected timezone at that moment.
// Sorry my English
Who is online
Users browsing this forum: No registered users and 3 guests