diff options
author | Thomas Wiest <twiest@redhat.com> | 2014-10-28 14:43:15 -0400 |
---|---|---|
committer | Thomas Wiest <twiest@redhat.com> | 2014-10-29 12:00:06 -0400 |
commit | 525b741b6fbb178b11c6a2b3ccd4bf9ff9e98e0c (patch) | |
tree | 6b063a310bb71cae17f3b6a910dca5ac1584f829 /roles/docker_img_monitoring/files/monitoring_container/register-with-zabbix.rb | |
parent | fd788c250c1fbdc5cc188aa29812c65ebafecc59 (diff) | |
download | openshift-525b741b6fbb178b11c6a2b3ccd4bf9ff9e98e0c.tar.gz openshift-525b741b6fbb178b11c6a2b3ccd4bf9ff9e98e0c.tar.bz2 openshift-525b741b6fbb178b11c6a2b3ccd4bf9ff9e98e0c.tar.xz openshift-525b741b6fbb178b11c6a2b3ccd4bf9ff9e98e0c.zip |
Added Docker image build stuff
Diffstat (limited to 'roles/docker_img_monitoring/files/monitoring_container/register-with-zabbix.rb')
-rwxr-xr-x | roles/docker_img_monitoring/files/monitoring_container/register-with-zabbix.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/roles/docker_img_monitoring/files/monitoring_container/register-with-zabbix.rb b/roles/docker_img_monitoring/files/monitoring_container/register-with-zabbix.rb new file mode 100755 index 000000000..02659228f --- /dev/null +++ b/roles/docker_img_monitoring/files/monitoring_container/register-with-zabbix.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env oo-ruby + +require 'optparse' +require '/usr/local/lib/zabbix_helper' + + +if __FILE__ == $0 + $stdout.sync = true + $stderr.sync = true + + opt_name = nil + opt_hostgroup = [] + opt_template = [] + + optparse = OptionParser.new do |opts| + opts.banner = "\nUsage: #{File.basename $0}\n\n" + + opts.on('--name NAME', '[REQUIRED] The host name to register') { |value| opt_name = value } + opts.on('--hostgroup GROUP', '[REQUIRED] The hostgroup(s) with which to register') { |value| opt_hostgroup << value } + opts.on('--template TEMPLATE', '[REQUIRED] The template with which to register') { |value| opt_template << value } + end + + optparse.parse! + + abort optparse.help if opt_name.nil? || opt_hostgroup.empty? || opt_template.empty? + + puts "Adding host [#{opt_name}] to zabbix..." + + zh = ZabbixHelper.new() + result = zh.create_agentless_host(opt_name, opt_hostgroup, opt_template) + if result['hostids'].nil? + raise "failed to add #{opt_name}" + else + puts "Successfully registered host with hostid [#{result['hostids'].first}]" + end +end |