sumo-check-sumo 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sumo-platform-audit.rb +80 -0
  3. metadata +75 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f41a9722d283582cef4d80e6ef439db8bd1587c1
4
- data.tar.gz: 40c04481cf45edb53a5d5d703bd7d36f32ef8465
3
+ metadata.gz: 1b0217a9f46e58bb273b301c6a7545b51157c426
4
+ data.tar.gz: 746a37e6e928a19ad6159aa45f23908c6b91e51d
5
5
  SHA512:
6
- metadata.gz: 81b017510972e226fb7706e6a066f76ff3a65132a63b5aae3d98b4f6601786cee517990a354d3b0421e3ede22983420f7f904988966feefaf79423eb23e2ae6c
7
- data.tar.gz: c9417aaa34aecd48e6971f8b185e81c0e538716257ed2e57c586965c5012110dedc3feea43c5546f038caad36e6db85c6ecc8359e793e7cfdaa2f4c78d6a5464
6
+ metadata.gz: a880093cb2eee81d7d44415f8a2c6f4a14756e7a5f3a3c5900d8bb151a211052f477c619f5f5ea4cffccdbfe33453a8d991a320996698852d9938699a3359003
7
+ data.tar.gz: 1662c08a70e82ce900bea1fffde4182eee097943f22f350d2b7287c21390b6b80d3ff3ef6059054d9a4f5d17b0f318930bc567f1a4ee87fcb569762ad9444874
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sensu-plugin/metric/cli'
4
+ require 'mysql'
5
+ require 'inifile'
6
+
7
+ class SumoPlatformAudit < Sensu::Plugin::Metric::CLI::Graphite
8
+ option :host,
9
+ short: '-h HOST',
10
+ long: '--host HOST',
11
+ description: 'MySQL Host to connect to',
12
+ required: true,
13
+ default: "127.0.0.1"
14
+
15
+ option :port,
16
+ short: '-P PORT',
17
+ long: '--port PORT',
18
+ description: 'MySQL Port to connect to',
19
+ proc: proc(&:to_i),
20
+ default: 3306
21
+
22
+ option :database,
23
+ short: '-d DATABASE',
24
+ long: '--database DATABASE',
25
+ description: 'MySQL database',
26
+ default: 'sumome'
27
+
28
+ option :ini,
29
+ short: '-i',
30
+ long: '--ini VALUE',
31
+ description: 'My.cnf ini file',
32
+ default: '/root/.my.cnf'
33
+
34
+
35
+ def run
36
+ # ini = IniFile.load(config[:ini])
37
+ ini = IniFile.load('/root/.my.cnf')
38
+ check_prefix_name="platform_audit"
39
+ section = ini['client']
40
+ db_user = section['user']
41
+ db_pass = section['password']
42
+ # db = Mysql.real_connect(config[:host], db_user, db_pass, config[:database], config[:port].to_i)
43
+
44
+ db = Mysql.real_connect('127.0.0.1', db_user, db_pass, 'sumome', 3306)
45
+ query="
46
+ SELECT
47
+ IF(LENGTH(IFNULL(all_platforms.platform, 'NULL')) = 0, 'BLANK', IFNULL(all_platforms.platform, 'NULL')) AS platform,
48
+ IFNULL(site_query.site_count, 0) AS site_count,
49
+ IFNULL(crawler_query.crawler_count, 0) AS crawler_count
50
+ FROM
51
+ (
52
+ select platform from Site group by platform union select platform from SiteCrawlerMeta group by platform
53
+ ) AS all_platforms
54
+ LEFT JOIN
55
+ (
56
+ SELECT platform AS site_platform, COUNT(*) AS site_count FROM Site GROUP BY platform
57
+ ) AS site_query ON all_platforms.platform = site_query.site_platform
58
+ LEFT JOIN
59
+ (
60
+ SELECT platform AS crawler_platform, COUNT(*) AS crawler_count FROM SiteCrawlerMeta GROUP BY platform
61
+ ) AS crawler_query ON all_platforms.platform = crawler_query.crawler_platform;"
62
+
63
+ result = db.query(query)
64
+ timestamp = Time.now.to_i
65
+
66
+ result.each_hash do |row|
67
+ output "#{check_prefix_name}.#{row["platform"]}.site_count",row["site_count"].to_i,timestamp
68
+ output "#{check_prefix_name}.#{row["platform"]}.crawler_count",row["crawler_count"].to_i,timestamp
69
+ end
70
+
71
+ ok
72
+ rescue Mysql::Error => e
73
+ errstr = "Error code: #{e.errno} Error message: #{e.error}"
74
+ critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
75
+ rescue => e
76
+ critical e
77
+ ensure
78
+ db.close if db
79
+ end
80
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumo-check-sumo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr. Ogg
@@ -29,6 +29,9 @@ dependencies:
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.11'
34
+ - - ">="
32
35
  - !ruby/object:Gem::Version
33
36
  version: 3.11.0
34
37
  type: :runtime
@@ -36,6 +39,9 @@ dependencies:
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.11'
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: 3.11.0
41
47
  - !ruby/object:Gem::Dependency
@@ -57,6 +63,9 @@ dependencies:
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '6.10'
68
+ - - ">="
60
69
  - !ruby/object:Gem::Version
61
70
  version: 6.10.3
62
71
  type: :runtime
@@ -64,6 +73,9 @@ dependencies:
64
73
  version_requirements: !ruby/object:Gem::Requirement
65
74
  requirements:
66
75
  - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '6.10'
78
+ - - ">="
67
79
  - !ruby/object:Gem::Version
68
80
  version: 6.10.3
69
81
  - !ruby/object:Gem::Dependency
@@ -71,6 +83,9 @@ dependencies:
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
85
  - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.34'
88
+ - - ">="
74
89
  - !ruby/object:Gem::Version
75
90
  version: 1.34.2
76
91
  type: :runtime
@@ -78,8 +93,65 @@ dependencies:
78
93
  version_requirements: !ruby/object:Gem::Requirement
79
94
  requirements:
80
95
  - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.34'
98
+ - - ">="
81
99
  - !ruby/object:Gem::Version
82
100
  version: 1.34.2
101
+ - !ruby/object:Gem::Dependency
102
+ name: mysql2
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: 0.4.8
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: 0.4.8
115
+ - !ruby/object:Gem::Dependency
116
+ name: ruby-mysql
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '2.9'
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.9.14
125
+ type: :runtime
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.9'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 2.9.14
135
+ - !ruby/object:Gem::Dependency
136
+ name: sensu-plugins-mysql
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '2.1'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 2.1.2
145
+ type: :runtime
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '2.1'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 2.1.2
83
155
  description:
84
156
  email:
85
157
  executables:
@@ -87,6 +159,7 @@ executables:
87
159
  - sumo-check-sumo_main_site_login_logout.rb
88
160
  - sumo-check-new-relic-apdex.rb
89
161
  - sumo-check-docker.rb
162
+ - sumo-platform-audit.rb
90
163
  extensions: []
91
164
  extra_rdoc_files: []
92
165
  files:
@@ -94,6 +167,7 @@ files:
94
167
  - bin/sumo-check-new-relic-apdex.rb
95
168
  - bin/sumo-check-sumo_basic_contact_us_form.rb
96
169
  - bin/sumo-check-sumo_main_site_login_logout.rb
170
+ - bin/sumo-platform-audit.rb
97
171
  homepage:
98
172
  licenses: []
99
173
  metadata: {}