sumo-check-sumo 0.0.22 → 0.0.23
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 +4 -4
- data/bin/sumo-SumoMailEmail-metrics.rb +94 -0
- data/bin/sumo-check-SumoMailEmail.rb +49 -0
- data/bin/sumo-check-message-center.rb +2 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a0f870e07ebe0ce302e00a2326d711f2cf31c8e
|
4
|
+
data.tar.gz: 932ff67a0ba0fa312fff471c8e7964cb30d92257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4e8ac285e10db628a6339f6e33f6ad17c94a1898862acd858feecb8e7c2f91c9646bc344a964d454c8b89a8bc2c838696e526a7817b20651de13efec0f8c8c3
|
7
|
+
data.tar.gz: e16d1ae8b8ee33668b461a30cf4cfeb6596f59ea61bd2b74fbc91b3aca557a7042a20258c197292a76e1dc171eac5a5afe01354a4363d54db8335710b9ddc568
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
require 'sensu-plugin/metric/cli'
|
5
|
+
require 'mysql2'
|
6
|
+
require 'inifile'
|
7
|
+
|
8
|
+
class SumoMessageCenterMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
9
|
+
|
10
|
+
def run
|
11
|
+
ini = IniFile.load('/root/.my.cnf')
|
12
|
+
check_prefix_name="SumoMailMetrics"
|
13
|
+
section = ini['client']
|
14
|
+
db = Mysql2::Client.new(:host => "127.0.0.1", :username => section['user'], :database => "sumome", :password => section['password'])
|
15
|
+
metrics = ['errorsending','timedout','optedout','excluded','pending','inprogress','delivered']
|
16
|
+
|
17
|
+
list_types = db.query("select DISTINCT email_list_type from SumoMailEmail;",:as => :array).to_a.flatten
|
18
|
+
list_types.each do |type|
|
19
|
+
metrics.each do |m|
|
20
|
+
result = db.query("SELECT count(id) FROM SumoMailEmail where state='#{m}' and email_list_type='#{type}';")
|
21
|
+
if result.count > 0
|
22
|
+
output "#{check_prefix_name}.#{type}.#{m}.count".tr(' ', '_'),result.first["count(id)"].to_i,Time.now.to_i
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
ok
|
28
|
+
rescue Mysql2::Error => e
|
29
|
+
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
30
|
+
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
31
|
+
rescue => e
|
32
|
+
critical e
|
33
|
+
ensure
|
34
|
+
db.close if db
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# mysql> select DISTINCT email_list_type from SumoMailEmail;
|
40
|
+
# +-------------------------+
|
41
|
+
# | email_list_type |
|
42
|
+
# +-------------------------+
|
43
|
+
# | auto-response-email |
|
44
|
+
# | automation-email |
|
45
|
+
# | customer-outreach-email |
|
46
|
+
# | customer-outreach-test |
|
47
|
+
# | customer-outreach-type |
|
48
|
+
# | sumo-chat-email |
|
49
|
+
# +-------------------------+
|
50
|
+
# 6 rows in set (0.00 sec)
|
51
|
+
|
52
|
+
|
53
|
+
# mysql> show columns from SumoMailEmail;
|
54
|
+
# +--------------------------------+------------------------------------------------------------------------------------------+------+-----+---------+-------+
|
55
|
+
# | Field | Type | Null | Key | Default | Extra |
|
56
|
+
# +--------------------------------+------------------------------------------------------------------------------------------+------+-----+---------+-------+
|
57
|
+
# | id | varchar(36) | NO | PRI | NULL | |
|
58
|
+
# | email | varchar(255) | YES | MUL | NULL | |
|
59
|
+
# | site_id | varchar(64) | YES | MUL | NULL | |
|
60
|
+
# | sender | varchar(255) | YES | | NULL | |
|
61
|
+
# | app_id | varchar(36) | YES | MUL | NULL | |
|
62
|
+
# | rule_id | varchar(36) | YES | MUL | NULL | |
|
63
|
+
# | email_id | varchar(36) | YES | MUL | NULL | |
|
64
|
+
# | sendgrid_id | text | YES | | NULL | |
|
65
|
+
# | campaign_rule_id | varchar(36) | YES | MUL | NULL | |
|
66
|
+
# | template | text | NO | | NULL | |
|
67
|
+
# | header | text | YES | | NULL | |
|
68
|
+
# | subheader | text | YES | | NULL | |
|
69
|
+
# | html_body | text | YES | | NULL | |
|
70
|
+
# | markdown_body | text | YES | | NULL | |
|
71
|
+
# | label | varchar(255) | NO | MUL | NULL | |
|
72
|
+
# | state | enum('errorsending','timedout','optedout','excluded','pending','inprogress','delivered') | NO | MUL | pending | |
|
73
|
+
# | dont_send_if_has_same_label | tinyint(1) | NO | | 0 | |
|
74
|
+
# | same_label_timeout | int(11) unsigned | YES | | NULL | |
|
75
|
+
# | dont_send_if_has_same_email_id | tinyint(1) | NO | | 0 | |
|
76
|
+
# | same_email_id_timeout | int(11) unsigned | YES | | NULL | |
|
77
|
+
# | context | text | YES | | NULL | |
|
78
|
+
# | scheduled_for | datetime | NO | MUL | NULL | |
|
79
|
+
# | email_task_id | varchar(36) | YES | MUL | NULL | |
|
80
|
+
# | email_task_at | datetime | YES | | NULL | |
|
81
|
+
# | email_sent_at | datetime | YES | MUL | NULL | |
|
82
|
+
# | email_open_at | datetime | YES | MUL | NULL | |
|
83
|
+
# | email_unsubbed_at | datetime | YES | MUL | NULL | |
|
84
|
+
# | email_bounced_at | datetime | YES | | NULL | |
|
85
|
+
# | email_complained_at | datetime | YES | | NULL | |
|
86
|
+
# | email_clicked_at | datetime | YES | MUL | NULL | |
|
87
|
+
# | email_list_type | varchar(100) | YES | MUL | NULL | |
|
88
|
+
# | created_at | datetime | NO | MUL | NULL | |
|
89
|
+
# | updated_at | datetime | NO | MUL | NULL | |
|
90
|
+
# | reply_to | varchar(255) | YES | | NULL | |
|
91
|
+
# | is_test | tinyint(1) | YES | MUL | NULL | |
|
92
|
+
# | json_body | text | YES | | NULL | |
|
93
|
+
# | tokens | text | YES | | NULL | |
|
94
|
+
# +--------------------------------+------------------------------------------------------------------------------------------+------+-----+---------+-------+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'sensu-plugin/check/cli'
|
3
|
+
require 'mysql2'
|
4
|
+
require 'inifile'
|
5
|
+
|
6
|
+
class SumoSumoMailEmailCheck < Sensu::Plugin::Check::CLI
|
7
|
+
|
8
|
+
option :warn_value,
|
9
|
+
short: '-W VALUE',
|
10
|
+
long: '--warn_value VALUE',
|
11
|
+
description: 'Warning for Pending Messages',
|
12
|
+
required: false,
|
13
|
+
default: 1000
|
14
|
+
|
15
|
+
option :critical_value,
|
16
|
+
short: '-c VALUE',
|
17
|
+
long: '--critical_value VALUE',
|
18
|
+
description: 'critical for Pending Messages',
|
19
|
+
required: false,
|
20
|
+
default: 1500
|
21
|
+
|
22
|
+
option :interval_value,
|
23
|
+
short: '-i VALUE',
|
24
|
+
long: '--interval VALUE',
|
25
|
+
description: 'interval window in minutes',
|
26
|
+
required: false,
|
27
|
+
default: 10
|
28
|
+
|
29
|
+
def run
|
30
|
+
ini = IniFile.load('/root/.my.cnf')
|
31
|
+
section = ini['client']
|
32
|
+
db = Mysql2::Client.new(:host => "127.0.0.1", :username => section['user'], :database => "sumome", :password => section['password'])
|
33
|
+
# pending_count = db.query("SELECT count(id) FROM SumoMailEmail where state='pending' and scheduled_for <= NOW() - INTERVAL #{config[:interval_value].to_i} MINUTE;").first["count(id)"].to_i
|
34
|
+
pending_count = db.query("SELECT count(id) FROM SumoMailEmail where state='pending').first["count(id)"].to_i
|
35
|
+
|
36
|
+
case
|
37
|
+
when pending_count == 0
|
38
|
+
ok "SumoMailEmail Pending Count is: #{pending_count} "
|
39
|
+
when pending_count >config[:critical_value].to_i
|
40
|
+
critical "SumoMailEmail Pending Count is: #{pending_count} "
|
41
|
+
when pending_count >config[:warn_value].to_i
|
42
|
+
warning "SumoMailEmailPending Count is: #{pending_count} "
|
43
|
+
else
|
44
|
+
warning "ODD: we did not match any cases for alerts, this should not happen, SumoMailEmail Pending Count is: #{pending_count} "
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -30,7 +30,8 @@ class SumoMessageCenterCheck < Sensu::Plugin::Check::CLI
|
|
30
30
|
ini = IniFile.load('/root/.my.cnf')
|
31
31
|
section = ini['client']
|
32
32
|
db = Mysql2::Client.new(:host => "127.0.0.1", :username => section['user'], :database => "sumome", :password => section['password'])
|
33
|
-
pending_count = db.query("SELECT count(id) FROM
|
33
|
+
# pending_count = db.query("SELECT count(id) FROM MessageCenterEmail where state='pending' and scheduled_for <= NOW() - INTERVAL #{config[:interval_value].to_i} MINUTE;").first["count(id)"].to_i
|
34
|
+
pending_count = db.query("SELECT count(id) FROM MessageCenterEmail where state='pending').first["count(id)"].to_i
|
34
35
|
|
35
36
|
case
|
36
37
|
when pending_count == 0
|
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.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr. Ogg
|
@@ -108,9 +108,13 @@ executables:
|
|
108
108
|
- sumo-platform-audit.rb
|
109
109
|
- sumo-message-center-metrics.rb
|
110
110
|
- sumo-check-message-center.rb
|
111
|
+
- sumo-check-SumoMailEmail.rb
|
112
|
+
- sumo-SumoMailEmail-metrics.rb
|
111
113
|
extensions: []
|
112
114
|
extra_rdoc_files: []
|
113
115
|
files:
|
116
|
+
- bin/sumo-SumoMailEmail-metrics.rb
|
117
|
+
- bin/sumo-check-SumoMailEmail.rb
|
114
118
|
- bin/sumo-check-docker.rb
|
115
119
|
- bin/sumo-check-message-center.rb
|
116
120
|
- bin/sumo-check-new-relic-apdex.rb
|