We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#!/opt/chefdk/embedded/bin/ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'site24x7client', git: 'https://github.com/danvideo/site24x7client' gem 'optimist' gem 'inifile' gem 'rest-client' end require 'pp' require 'site24x7client' require 'rest-client' require 'optimist' require 'inifile' require 'json' whoami = `whoami`.chomp # parse the command line options opts = Optimist.options do opt :token, 'Site 24x7 token value', type: :string, short: 't', required: false, default: ENV['SITE24X7_TOKEN'] opt :group, 'Monitor group to tag monitors into', type: :string, short: 'g', required: false, default: 'Concierge' opt :search, 'Search string for monitors to tag', type: :string, short: 's', required: true opt :verbose, 'Verbose', type: :boolean, default: true, short: 'v', required: false end begin # Establish connection to Site 24x7 API client = Site24x7client::Client.new(access_token: opts[:token]) mgroupid = 0 client.monitor_groups.all.each do |mgroup| next if mgroup.display_name.nil? if mgroup.display_name.include?(opts[:group]) mgroupid = mgroup.group_id puts "#{mgroup.display_name} id is #{mgroupid}" end end if mgroupid == 0 puts "Unable to find a monitor group matching '#{opts[:group]}'" exit 1 end client.monitors.all.each do |monitor| # <Site24x7client::Monitor {:@monitor_id=>"83611000025870031", :@display_name=>"NVA SSO Lobby API About Page", :@type=>"URL", :@website=>"https://lobby.gomoxie.solutions/master/about", :@check_frequency=>"5", :@timeout=>15, :@location_profile_id=>"83611000002423006", :@notification_profile_id=>"83611000021314001", :@threshold_profile_id=>"83611000002423008", :@user_group_ids=>["83611000000267003", "83611000025855097"], :@http_method=>"G", :@use_ipv6=>false, :@matching_keyword=>{"value"=>"Build number", "severity"=>2}, :@monitor_groups=>["83611000025870029"], :@up_status_codes=>nil}> next if monitor.display_name.nil? if monitor.display_name.include?(opts[:search]) mid = monitor.monitor_id puts "Adding monitor #{mid} to monitor group #{mgroupid}..." monitor.monitor_groups = [mgroupid] client.monitors.update(monitor, mid) pp monitor if opts[:verbose] puts "\n" end end rescue StandardError => e $stderr.puts "Error communicating with Site 24x7: #{e.message}" $stderr.puts e.backtrace exit 1 end
I'm getting the following output:
[nclemons@ryder site24x7 (DEVOPS-1797)]$ ./site24x7_tag_monitors -s ircon180event Concierge-Production id is 83611000002423001 Adding monitor 83611000026313085 to monitor group 83611000002423001... Error communicating with Site 24x7: 404: {"error_code":1009,"message":"Invalid URL."} /Users/nclemons/.chefdk/gem/ruby/2.4.0/bundler/gems/site24x7client-b45b2a92521b/lib/site24x7client/error_handling_resourcable.rb:8:in `block (2 levels) in included' /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/resource_kit-0.1.7/lib/resource_kit/action_invoker.rb:19:in `instance_exec' /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/resource_kit-0.1.7/lib/resource_kit/action_invoker.rb:19:in `handle_response' /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/resource_kit-0.1.7/lib/resource_kit/action_invoker.rb:14:in `call' /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/resource_kit-0.1.7/lib/resource_kit/method_factory.rb:16:in `block in method_for_action' ./site24x7_tag_monitors:54:in `block in <main>' ./site24x7_tag_monitors:47:in `each' ./site24x7_tag_monitors:47:in `<main>' [nclemons@ryder site24x7 (DEVOPS-1797)]$
Any advice as to what I'm doing wrong would be appreciated.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm getting the following output:
Any advice as to what I'm doing wrong would be appreciated.
The text was updated successfully, but these errors were encountered: