{"action":"created","issue":{"url":"https://api.github.com/repos/percona/percona-monitoring-plugins/issues/48","repository_url":"https://api.github.com/repos/percona/percona-monitoring-plugins","labels_url":"https://api.github.com/repos/percona/percona-monitoring-plugins/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/percona/percona-monitoring-plugins/issues/48/comments","events_url":"https://api.github.com/repos/percona/percona-monitoring-plugins/issues/48/events","html_url":"https://github.com/percona/percona-monitoring-plugins/pull/48","id":231178050,"number":48,"title":"Check if the options are not empty if specified by cacti","user":{"login":"deniskin82","id":386949,"avatar_url":"https://avatars0.githubusercontent.com/u/386949?v=3","gravatar_id":"","url":"https://api.github.com/users/deniskin82","html_url":"https://github.com/deniskin82","followers_url":"https://api.github.com/users/deniskin82/followers","following_url":"https://api.github.com/users/deniskin82/following{/other_user}","gists_url":"https://api.github.com/users/deniskin82/gists{/gist_id}","starred_url":"https://api.github.com/users/deniskin82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deniskin82/subscriptions","organizations_url":"https://api.github.com/users/deniskin82/orgs","repos_url":"https://api.github.com/users/deniskin82/repos","events_url":"https://api.github.com/users/deniskin82/events{/privacy}","received_events_url":"https://api.github.com/users/deniskin82/received_events","type":"User","site_admin":false},"labels":[{"id":198227723,"url":"https://api.github.com/repos/percona/percona-monitoring-plugins/labels/bug","name":"bug","color":"fc2929","default":true},{"id":294759563,"url":"https://api.github.com/repos/percona/percona-monitoring-plugins/labels/Cacti","name":"Cacti","color":"bfe5bf","default":false},{"id":640745075,"url":"https://api.github.com/repos/percona/percona-monitoring-plugins/labels/needs_review","name":"needs_review","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-05-24T21:33:55Z","updated_at":"2017-07-06T23:35:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/percona/percona-monitoring-plugins/pulls/48","html_url":"https://github.com/percona/percona-monitoring-plugins/pull/48","diff_url":"https://github.com/percona/percona-monitoring-plugins/pull/48.diff","patch_url":"https://github.com/percona/percona-monitoring-plugins/pull/48.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/percona/percona-monitoring-plugins/issues/comments/313547555","html_url":"https://github.com/percona/percona-monitoring-plugins/pull/48#issuecomment-313547555","issue_url":"https://api.github.com/repos/percona/percona-monitoring-plugins/issues/48","id":313547555,"user":{"login":"cezmunsta","id":6232753,"avatar_url":"https://avatars3.githubusercontent.com/u/6232753?v=3","gravatar_id":"","url":"https://api.github.com/users/cezmunsta","html_url":"https://github.com/cezmunsta","followers_url":"https://api.github.com/users/cezmunsta/followers","following_url":"https://api.github.com/users/cezmunsta/following{/other_user}","gists_url":"https://api.github.com/users/cezmunsta/gists{/gist_id}","starred_url":"https://api.github.com/users/cezmunsta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cezmunsta/subscriptions","organizations_url":"https://api.github.com/users/cezmunsta/orgs","repos_url":"https://api.github.com/users/cezmunsta/repos","events_url":"https://api.github.com/users/cezmunsta/events{/privacy}","received_events_url":"https://api.github.com/users/cezmunsta/received_events","type":"User","site_admin":false},"created_at":"2017-07-06T23:35:02Z","updated_at":"2017-07-06T23:35:02Z","body":"@deniskin82 @dbmiller validation of the input takes place in [`validate_options`](https://github.com/percona/percona-monitoring-plugins/blob/master/cacti/scripts/ss_get_mysql_stats.php#L173). \r\n\r\n@deniskin82 please apply the following patch to your branch and test: \r\n```\r\ndiff --git a/cacti/scripts/ss_get_mysql_stats.php b/cacti/scripts/ss_get_mysql_stats.php\r\nindex 126e080..983853f 100644\r\n--- a/cacti/scripts/ss_get_mysql_stats.php\r\n+++ b/cacti/scripts/ss_get_mysql_stats.php\r\n@@ -183,6 +183,14 @@ function validate_options($options) {\r\n          usage(\"Required option --$option is missing\");\r\n       }\r\n    }\r\n+\r\n+   # Safety-net for missing values\r\n+   foreach ( array('server-id', 'port', 'user') as $option ) {\r\n+      if ( array_key_exists($option, $options) && empty($options[$option]) ) {\r\n+         usage(\"Option --$option requires a value\");\r\n+      }\r\n+   }\r\n+\r\n    foreach ( $options as $key => $val ) {\r\n       if ( !in_array($key, $opts) ) {\r\n          usage(\"Unknown option --$key\");\r\n@@ -252,14 +260,14 @@ function ss_get_mysql_stats( $options ) {\r\n           $mysql_connection_timeout,\r\n           $heartbeat, $heartbeat_table, $heartbeat_server_id, $heartbeat_utc;\r\n \r\n-   $user = isset($options['user']) && !empty($options['user']) ? $options['user'] : $mysql_user;\r\n-   $pass = isset($options['pass']) && !empty($options['pass']) ? $options['pass'] : $mysql_pass;\r\n+   $user = isset($options['user']) ? $options['user'] : $mysql_user;\r\n+   $pass = isset($options['pass']) ? $options['pass'] : $mysql_pass;\r\n    $host = $options['host'];\r\n-   $port = isset($options['port']) && !empty($options['port']) ? $options['port'] : $mysql_port;\r\n+   $port = isset($options['port']) ? $options['port'] : $mysql_port;\r\n    $socket = isset($options['socket']) ? $options['socket'] : $mysql_socket;\r\n    $flags = isset($options['flags']) ? $options['flags'] : $mysql_flags;\r\n    $connection_timeout = isset($options['connection-timeout']) ? $options['connection-timeout'] : $mysql_connection_timeout;\r\n-   $heartbeat_server_id = isset($options['server-id']) && !empty($options['server-id']) ? $options['server-id'] : $heartbeat_server_id;\r\n+   $heartbeat_server_id = isset($options['server-id']) ? $options['server-id'] : $heartbeat_server_id;\r\n \r\n    $sanitized_host = str_replace(array(\":\", \"/\"), array(\"\", \"_\"), $host);\r\n    $cache_file = \"$cache_dir/$sanitized_host-mysql_cacti_stats.txt\" . ($port != 3306 ? \":$port\" : '');\r\n```\r\nThat will produce the following:\r\n```\r\n ⇒ php cacti/scripts/ss_get_mysql_stats.php --host x --items x --server-id | head -n1\r\nOption --server-id requires a value\r\n```"}}
{"actor":{"display_login":"cezmunsta"}}