Skip to content

Commit

Permalink
fixed timezone issue when no php default is present
Browse files Browse the repository at this point in the history
also fixed some permissions issues with the
vagrant boostrap.sh setup process.  I moved the cron
job from root to vagrant user, but forgot about file
permissions on the slow log file.  Moved it back to root.
  • Loading branch information
gtowey committed May 16, 2014
1 parent bae7a98 commit abed86c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions conf/sample.config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
$conn['port'] = $parts[1];
}

$conn['db'] = 'mysql';
if ($sample['db_max'] != '')
{
$conn['db'] = $sample['db_max'];
Expand Down
12 changes: 10 additions & 2 deletions lib/Anemometer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Anemometer {
private $report_obj;
private $header_printed = false;
private $exception_select_fields = array('checksum','sample','DIGEST'); // column names which appear in both fact and dimension tables
private $timezone_offset;

/**
* Constructor. Pass in the global configuration object
Expand All @@ -39,6 +40,13 @@ function __construct($conf)
return;
}

$timezone = ini_get('date.timezone');
if (!$timezone)
{
date_default_timezone_set('America/Los_Angeles');
$timezone = date_default_timezone_get();
}
$this->timezone_offset = timezone_offset_get( new DateTimeZone( $timezone ), new DateTime());

$this->conf = $conf;
$this->data_model = new AnemometerModel($conf);
Expand Down Expand Up @@ -199,7 +207,7 @@ private function setup_data_for_graph_search($data=null)
$data['ajax_table_request_url_base'] = site_url() . '?action=api&output=table&noheader=1&datasource=' . $data['datasource']. '&' . $this->report_obj->get_search_uri(array( 'dimension-'.$data['time_field_name'], 'dimension-ts_min'));
$data['table_url_time_start_param'] = 'dimension-'.$data['time_field_name'].'_start';
$data['table_url_time_end_param'] = 'dimension-'.$data['time_field_name'].'_end';
$data['timezone_offset'] = timezone_offset_get( new DateTimeZone( ini_get('date.timezone' )), new DateTime());
$data['timezone_offset'] = $this->timezone_offset;

return $data;
}
Expand Down Expand Up @@ -437,7 +445,7 @@ public function show_query() {
$data['hostname_field_name'] = $this->data_model->get_field_name('hostname');
$data['checksum_field_name'] = $this->data_model->get_field_name('checksum');

$data['timezone_offset'] = timezone_offset_get( new DateTimeZone( ini_get('date.timezone' )), new DateTime());
$data['timezone_offset'] = $this->timezone_offset;

$data['tables'] = $this->report_obj->get_tables();
if ($source_type == 'slow_query_log')
Expand Down
4 changes: 2 additions & 2 deletions vagrant/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ EOF

# add cron for collection script
cat << EOF > /home/vagrant/crontab
*/5 * * * * /vagrant/anemometer/scripts/anemometer_collect.sh --interval 15 --history-db-host localhost
*/5 * * * * /vagrant/anemometer/scripts/anemometer_collect.sh --interval 15 --history-db-host localhost --defaults-file /home/vagrant/.my.cnf --history-defaults-file /home/vagrant/.my.cnf
EOF
crontab -u vagrant /home/vagrant/crontab
crontab -u root /home/vagrant/crontab

0 comments on commit abed86c

Please sign in to comment.