uptrends 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63e0d2b7ad081a62966062a0f10be4a37b1f2990
4
- data.tar.gz: a9680e84d9c634a9dfaacdc9935968b6f080b846
3
+ metadata.gz: 230b460fe57835d0f5e24d44f9f05376aad9490e
4
+ data.tar.gz: 9fb5efd271b67f20899b642f31f52e82d918efe8
5
5
  SHA512:
6
- metadata.gz: 9d871f61e0b342f7ceba9ccc91b2ba540000023d4acee35d761d8039ad4f6296aa1a959bc0839b73a6e0e0ba60a501b5dddba88ffaf8c7ad80c718919e22a917
7
- data.tar.gz: 275568a6050f301ce8113d843185a1313322dd16ac01082ce44b0f7c2fa1754f80e3aaace5696d32ee4aa8d20b00069c1e179c8da1e8033093182ec9748a94d6
6
+ metadata.gz: e4e36b3e967428080f4664ea8a2b11faf9d52bdee3a74c767c147b0d4461d95b7e8cae34f9b56a44e810a4ed0ec4b6473bed31c56be6a705f131ed2f78277748
7
+ data.tar.gz: 748c9ef2dbe28a4ab46a46b54c324a908c6835342562161c14e6e8562a85bf1c335e4faa2766598cc6629f3392ce252c7ffd670964822929cf74403cefe47ef6
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require 'uptrends/api_client'
3
+
4
+ (puts "You must set both the \"uptrends_username\" and \"uptrends_password\" environment variables, exiting..."; exit 1;) unless ENV['uptrends_username'] && ENV['uptrends_password']
5
+
6
+ u = Uptrends::ApiClient.new(username: ENV['uptrends_username'], password: ENV['uptrends_password'])
7
+
8
+ # select our probe group by name
9
+ linux_probe_group = u.probe_groups.select { |x| x.name =~ /Linux/}.first
10
+
11
+ # grab the current group members
12
+ linux_group_members = u.get_probe_group_members(group: linux_probe_group)
13
+
14
+ # build an array of current probe group members guid
15
+ member_guids = linux_group_members.inject([]) do |memo, x|
16
+ memo << x.guid
17
+ memo
18
+ end
19
+
20
+ # add any missing probes to our probe group
21
+ u.probes.each do |x|
22
+ next if member_guids.include?(x.guid)
23
+
24
+ puts "Adding \"#{x.name}\" to the \"#{linux_probe_group.name}\" group now... "
25
+ u.add_probe_to_group(probe: x, group: linux_probe_group)
26
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ require 'uptrends/api_client'
3
+
4
+ (puts "You must set both the \"uptrends_username\" and \"uptrends_password\" environment variables, exiting..."; exit 1;) unless ENV['uptrends_username'] && ENV['uptrends_password']
5
+
6
+ u = Uptrends::ApiClient.new(username: ENV['uptrends_username'], password: ENV['uptrends_password'])
7
+
8
+ u.probes.each do |x|
9
+ next if x.dnslookupmode == 'Local' && x.timeout == 20000 && x.tcpconnecttimeout == 5000
10
+
11
+ x.dnslookupmode = 'Local'
12
+ x.timeout = 20000
13
+ x.tcpconnecttimeout = 5000
14
+
15
+ puts "Updating the \"#{x.name}\" probe now... "
16
+ u.update_probe(x)
17
+ end
@@ -30,9 +30,10 @@ module Uptrends
30
30
  @probe_groups ||= get_probe_groups
31
31
  end
32
32
 
33
+ private
33
34
  def get_probes
34
35
  parsed_response = self.class.get('/probes').parsed_response
35
- @probes = parsed_response.inject([]) do |memo, x|
36
+ probes = parsed_response.inject([]) do |memo, x|
36
37
  memo << Uptrends::Probe.new(x)
37
38
  memo
38
39
  end
@@ -40,17 +41,30 @@ module Uptrends
40
41
 
41
42
  def get_probe_groups
42
43
  parsed_response = self.class.get('/probegroups').parsed_response
43
- @probes = parsed_response.inject([]) do |memo, x|
44
+ probe_groups = parsed_response.inject([]) do |memo, x|
44
45
  memo << Uptrends::ProbeGroup.new(x)
45
46
  memo
46
47
  end
47
48
  end
48
49
 
50
+ public
51
+ def get_probe_group_members(options = {})
52
+ group = options[:group]
53
+ fail("You must pass a probe group using group: option.") unless Uptrends::ProbeGroup === group
54
+ group_guid = options[:group].guid ? options[:group].guid : fail("The probe group you passed does not have a guid.")
55
+
56
+ parsed_response = self.class.get("/probegroups/#{group_guid}/members").parsed_response
57
+ probe_group_members = parsed_response.inject([]) do |memo, x|
58
+ memo << Uptrends::Probe.new(x)
59
+ memo
60
+ end
61
+ end
62
+
49
63
  def add_probe_to_group(options = {})
50
64
  probe = options[:probe]
51
65
  group = options[:group]
52
66
 
53
- fail("You must pass a probe and probe group using probe: and group: options") unless Uptrends::Probe === probe && Uptrends::ProbeGroup === group
67
+ fail("You must pass a probe and probe group using probe: and group: options.") unless Uptrends::Probe === probe && Uptrends::ProbeGroup === group
54
68
 
55
69
  probe_guid = options[:probe].guid ? options[:probe].guid : fail("The probe you passed does not have a guid.")
56
70
  group_guid = options[:group].guid ? options[:group].guid : fail("The probe group you passed does not have a guid.")
@@ -1,3 +1,3 @@
1
1
  module Uptrends
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uptrends
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Barnett
@@ -38,6 +38,8 @@ files:
38
38
  - LICENSE.txt
39
39
  - README.md
40
40
  - Rakefile
41
+ - examples/add_probes_to_probe_group.rb
42
+ - examples/update_all_probe_attributes.rb
41
43
  - lib/uptrends.rb
42
44
  - lib/uptrends/api_client.rb
43
45
  - lib/uptrends/probe.rb