Class: Mysqlcollector::Cli
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize ⇒ Cli
constructor
A new instance of Cli.
- #options ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ Cli
Returns a new instance of Cli.
17 18 19 |
# File 'lib/mysqlcollector/cli.rb', line 17 def initialize end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/mysqlcollector/cli.rb', line 5 def config @config end |
Instance Method Details
#options ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mysqlcollector/cli.rb', line 21 def ARGV. do |opt| begin opt.on('--alias ALIAS', String, 'Alias for instance') do |v| $config[:influx_database] = v end opt.on('--mysql-host HOST', String, 'MySQL Host') do |v| $config[:mysql_host] = v end opt.on('--mysql-port PORT', Integer, 'MySQL Port') do |v| $config[:mysql_host] = v end opt.on('--mysql-username USER', String, 'MySQL User name') do |v| $config[:mysql_username] = v end opt.on('--mysql-password PASSWORD', String, 'MySQL User password') do |v| $config[:mysql_password] = v end opt.on('--influx-host HOST', String, 'InfluxDB Host') do |v| $config[:influx_host] = v end opt.on('--influx-username USER', String, 'InfluxDB User') do |v| $config[:influx_user] = v end opt.on('--influx-password PASSWORD', String, 'InfluxDB User password') do |v| $config[:influx_password] = v end opt.on('--influx-database DATABASE', String, 'InfluxDB Database') do |v| $config[:influx_database] = v end opt.on('--daemonize', 'Run this every 30 seconds') do |v| $config[:daemonize] = v end opt.on('--template', 'Export JSON template for Grafana') do |v| $config[:template] = v end opt.on('--debug', 'Debug this tool') do |v| $config[:debug] = v end opt.on('-v', '--version', 'Show version') do puts "MySQL Collector V-#{Mysqlcollector::VERSION}" end opt.on('-?', '--help', 'Show this help') { puts opt.help; } opt.parse! if $config.empty? puts opt.help exit 1 end rescue => e puts e exit 1 end end end |