From 63d9e1303987edb5b0adb8d92f54f015a3f33238 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 24 Apr 2012 10:48:07 +0000 Subject: [PATCH] fixes to mysql agent script. fixes to links on apps overview. git-svn-id: http://www.observium.org/svn/observer/trunk@3082 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/apps/overview.inc.php | 2 +- scripts/agent-local/mysql | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/html/pages/apps/overview.inc.php b/html/pages/apps/overview.inc.php index 3ed942ba0e..1ff1c48c73 100644 --- a/html/pages/apps/overview.inc.php +++ b/html/pages/apps/overview.inc.php @@ -36,7 +36,7 @@ foreach ($app_list as $app) unset($link_array['height'], $link_array['width']); $link = generate_url($link_array); - $overlib_link = generate_device_link($device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$app['app_type']))."
"; + $overlib_link = generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$app['app_type']))."
"; $overlib_link .= generate_graph_tag($graph_array); $overlib_content = generate_overlib_content($graph_array, $port['hostname'] . " - " . $port['label']); diff --git a/scripts/agent-local/mysql b/scripts/agent-local/mysql index ee1e26ebc8..72297c2390 100755 --- a/scripts/agent-local/mysql +++ b/scripts/agent-local/mysql @@ -48,9 +48,10 @@ $mysql_host = 'localhost'; $mysql_port = 3306; $mysql_ssl = FALSE; # Whether to use SSL to connect to MySQL. -$heartbeat = ''; # db.tbl in case you use mk-heartbeat from Maatkit. -$cache_dir = '/tmp'; # If set, this uses caching to avoid multiple calls. -$poll_time = 300; # Adjust to match your polling interval. +$heartbeat = ''; # db.tbl in case you use mk-heartbeat from Maatkit. +$cache_dir = '/tmp'; # If set, this uses caching to avoid multiple calls. +$cache_time = 30; # How long to cache data. + $chk_options = array ( 'innodb' => true, # Do you want to check InnoDB statistics? 'master' => true, # Do you want to check binary logging? @@ -252,7 +253,7 @@ function parse_cmdline( $args ) { # ============================================================================ function ss_get_mysql_stats( $options ) { # Process connection options and connect to MySQL. - global $debug, $mysql_user, $mysql_pass, $heartbeat, $cache_dir, $poll_time, + global $debug, $mysql_user, $mysql_pass, $heartbeat, $cache_dir, $cache_time, $chk_options, $mysql_host, $mysql_port, $mysql_ssl; # Connect to MySQL. @@ -282,8 +283,7 @@ function ss_get_mysql_stats( $options ) { } $sanitized_host = str_replace(array(":", "/"), array("", "_"), $host); - $cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" - . $port != 3306 ? ":$port" : ''; + $cache_file = "$cache_dir/mysql_stats.txt"; debug("Cache file is $cache_file"); # First, check the cache. @@ -293,7 +293,7 @@ function ss_get_mysql_stats( $options ) { $locked = flock($fp, 1); # LOCK_SH if ($locked ) { if (filesize($cache_file) > 0 - && filectime($cache_file) + ($poll_time/2) > time() + && filectime($cache_file) + ($cache_time) > time() && ($arr = file($cache_file)) ) {# The cache file is good to use. debug("Using the cache file"); @@ -308,7 +308,7 @@ function ss_get_mysql_stats( $options ) { # another process ran and updated it. Let's see if we can just # return the data now: if (filesize($cache_file) > 0 - && filectime($cache_file) + ($poll_time/2) > time() + && filectime($cache_file) + ($cache_time) > time() && ($arr = file($cache_file)) ) {# The cache file is good to use. debug("Using the cache file");