From a37a142199d11c786b8b9d99dc92bb241a15eddf Mon Sep 17 00:00:00 2001 From: Denis Corol Date: Wed, 24 May 2017 17:31:16 -0400 Subject: [PATCH 1/4] Check if the options are not empty if specified by cacti --- cacti/scripts/ss_get_mysql_stats.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cacti/scripts/ss_get_mysql_stats.php b/cacti/scripts/ss_get_mysql_stats.php index b042851..a825d4c 100644 --- a/cacti/scripts/ss_get_mysql_stats.php +++ b/cacti/scripts/ss_get_mysql_stats.php @@ -252,10 +252,10 @@ function ss_get_mysql_stats( $options ) { $mysql_connection_timeout, $heartbeat, $heartbeat_table, $heartbeat_server_id, $heartbeat_utc; - $user = isset($options['user']) ? $options['user'] : $mysql_user; - $pass = isset($options['pass']) ? $options['pass'] : $mysql_pass; + $user = isset($options['user']) && ($options['user'] != '') ? $options['user'] : $mysql_user; + $pass = isset($options['pass']) && ($options['pass'] != '') ? $options['pass'] : $mysql_pass; $host = $options['host']; - $port = isset($options['port']) ? $options['port'] : $mysql_port; + $port = isset($options['port']) && ($options['port'] != '')? $options['port'] : $mysql_port; $socket = isset($options['socket']) ? $options['socket'] : $mysql_socket; $flags = isset($options['flags']) ? $options['flags'] : $mysql_flags; $connection_timeout = isset($options['connection-timeout']) ? $options['connection-timeout'] : $mysql_connection_timeout; From 574a19b1dbab7e3f50295f8faec94c5de9d8e9d0 Mon Sep 17 00:00:00 2001 From: Denis Corol Date: Thu, 25 May 2017 11:14:36 -0400 Subject: [PATCH 2/4] check if server-id is empty then use `$heartbeat_server_id` --- cacti/scripts/ss_get_mysql_stats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cacti/scripts/ss_get_mysql_stats.php b/cacti/scripts/ss_get_mysql_stats.php index a825d4c..cb72e74 100644 --- a/cacti/scripts/ss_get_mysql_stats.php +++ b/cacti/scripts/ss_get_mysql_stats.php @@ -259,7 +259,7 @@ function ss_get_mysql_stats( $options ) { $socket = isset($options['socket']) ? $options['socket'] : $mysql_socket; $flags = isset($options['flags']) ? $options['flags'] : $mysql_flags; $connection_timeout = isset($options['connection-timeout']) ? $options['connection-timeout'] : $mysql_connection_timeout; - $heartbeat_server_id = isset($options['server-id']) ? $options['server-id'] : $heartbeat_server_id; + $heartbeat_server_id = isset($options['server-id']) && ($options['server-id'] != '') ? $options['server-id'] : $heartbeat_server_id; $sanitized_host = str_replace(array(":", "/"), array("", "_"), $host); $cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" . ($port != 3306 ? ":$port" : ''); From 84bd972adb75ef4f3f14bd024005a87e2e883d4a Mon Sep 17 00:00:00 2001 From: Denis Corol Date: Thu, 25 May 2017 11:23:49 -0400 Subject: [PATCH 3/4] use `empty()` instead --- cacti/scripts/ss_get_mysql_stats.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cacti/scripts/ss_get_mysql_stats.php b/cacti/scripts/ss_get_mysql_stats.php index cb72e74..b289938 100644 --- a/cacti/scripts/ss_get_mysql_stats.php +++ b/cacti/scripts/ss_get_mysql_stats.php @@ -252,14 +252,14 @@ function ss_get_mysql_stats( $options ) { $mysql_connection_timeout, $heartbeat, $heartbeat_table, $heartbeat_server_id, $heartbeat_utc; - $user = isset($options['user']) && ($options['user'] != '') ? $options['user'] : $mysql_user; - $pass = isset($options['pass']) && ($options['pass'] != '') ? $options['pass'] : $mysql_pass; + $user = isset($options['user']) && !empty($options['user']) ? $options['user'] : $mysql_user; + $pass = isset($options['pass']) && !empty($options['pass']) ? $options['pass'] : $mysql_pass; $host = $options['host']; $port = isset($options['port']) && ($options['port'] != '')? $options['port'] : $mysql_port; $socket = isset($options['socket']) ? $options['socket'] : $mysql_socket; $flags = isset($options['flags']) ? $options['flags'] : $mysql_flags; $connection_timeout = isset($options['connection-timeout']) ? $options['connection-timeout'] : $mysql_connection_timeout; - $heartbeat_server_id = isset($options['server-id']) && ($options['server-id'] != '') ? $options['server-id'] : $heartbeat_server_id; + $heartbeat_server_id = isset($options['server-id']) && !empty($options['server-id']) ? $options['server-id'] : $heartbeat_server_id; $sanitized_host = str_replace(array(":", "/"), array("", "_"), $host); $cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" . ($port != 3306 ? ":$port" : ''); From 4356147c43b150f0f64943818ee592794395c1ee Mon Sep 17 00:00:00 2001 From: Denis Corol Date: Thu, 25 May 2017 11:24:39 -0400 Subject: [PATCH 4/4] use `empty()` instead --- cacti/scripts/ss_get_mysql_stats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cacti/scripts/ss_get_mysql_stats.php b/cacti/scripts/ss_get_mysql_stats.php index b289938..126e080 100644 --- a/cacti/scripts/ss_get_mysql_stats.php +++ b/cacti/scripts/ss_get_mysql_stats.php @@ -255,7 +255,7 @@ function ss_get_mysql_stats( $options ) { $user = isset($options['user']) && !empty($options['user']) ? $options['user'] : $mysql_user; $pass = isset($options['pass']) && !empty($options['pass']) ? $options['pass'] : $mysql_pass; $host = $options['host']; - $port = isset($options['port']) && ($options['port'] != '')? $options['port'] : $mysql_port; + $port = isset($options['port']) && !empty($options['port']) ? $options['port'] : $mysql_port; $socket = isset($options['socket']) ? $options['socket'] : $mysql_socket; $flags = isset($options['flags']) ? $options['flags'] : $mysql_flags; $connection_timeout = isset($options['connection-timeout']) ? $options['connection-timeout'] : $mysql_connection_timeout;