nagios-herald 0.0.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.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +9 -0
  4. data/CHANGELOG.md +11 -0
  5. data/CONTRIBUTING.md +28 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE +21 -0
  8. data/README.md +94 -0
  9. data/Rakefile +9 -0
  10. data/bin/draw_stack_bars +76 -0
  11. data/bin/dump_nagios_env.sh +25 -0
  12. data/bin/get_ganglia_graph +82 -0
  13. data/bin/get_graph +50 -0
  14. data/bin/get_graphite_graph +58 -0
  15. data/bin/nagios-herald +6 -0
  16. data/bin/splunk_alert_frequency +54 -0
  17. data/contrib/nrpe-plugins/check_cpu_stats.sh +186 -0
  18. data/contrib/nrpe-plugins/check_disk.sh +34 -0
  19. data/contrib/nrpe-plugins/check_mem.pl +181 -0
  20. data/contrib/nrpe-plugins/nrpe-plugin-examples.md +11 -0
  21. data/docs/config.md +62 -0
  22. data/docs/example_alerts.md +48 -0
  23. data/docs/formatters.md +180 -0
  24. data/docs/helpers.md +12 -0
  25. data/docs/images/cpu_no_context.png +0 -0
  26. data/docs/images/cpu_with_context.png +0 -0
  27. data/docs/images/disk_space_no_context.png +0 -0
  28. data/docs/images/disk_space_with_context.png +0 -0
  29. data/docs/images/memory_high_no_context.png +0 -0
  30. data/docs/images/memory_high_with_context.png +0 -0
  31. data/docs/images/nagios-herald-formatter-content-example.png +0 -0
  32. data/docs/images/nagios-herald.png +0 -0
  33. data/docs/images/stack-bars.png +0 -0
  34. data/docs/images/vanilla-nagios.png +0 -0
  35. data/docs/messages.md +16 -0
  36. data/docs/nagios-config.md +74 -0
  37. data/docs/tools.md +79 -0
  38. data/etc/config.yml.example +14 -0
  39. data/etc/readme.md +2 -0
  40. data/lib/nagios-herald/config.rb +25 -0
  41. data/lib/nagios-herald/executor.rb +265 -0
  42. data/lib/nagios-herald/formatter_loader.rb +82 -0
  43. data/lib/nagios-herald/formatters/base.rb +524 -0
  44. data/lib/nagios-herald/formatters/check_cpu.rb +71 -0
  45. data/lib/nagios-herald/formatters/check_disk.rb +143 -0
  46. data/lib/nagios-herald/formatters/check_logstash.rb +155 -0
  47. data/lib/nagios-herald/formatters/check_memory.rb +42 -0
  48. data/lib/nagios-herald/formatters/example.rb +19 -0
  49. data/lib/nagios-herald/formatters.rb +1 -0
  50. data/lib/nagios-herald/helpers/ganglia_graph.rb +99 -0
  51. data/lib/nagios-herald/helpers/graphite_graph.rb +85 -0
  52. data/lib/nagios-herald/helpers/logstash_query.rb +125 -0
  53. data/lib/nagios-herald/helpers/splunk_alert_frequency.rb +170 -0
  54. data/lib/nagios-herald/helpers/splunk_query.rb +119 -0
  55. data/lib/nagios-herald/helpers/url_image.rb +76 -0
  56. data/lib/nagios-herald/helpers.rb +5 -0
  57. data/lib/nagios-herald/logging.rb +48 -0
  58. data/lib/nagios-herald/message_loader.rb +40 -0
  59. data/lib/nagios-herald/messages/base.rb +56 -0
  60. data/lib/nagios-herald/messages/email.rb +150 -0
  61. data/lib/nagios-herald/messages/irc.rb +58 -0
  62. data/lib/nagios-herald/messages/pager.rb +75 -0
  63. data/lib/nagios-herald/messages.rb +3 -0
  64. data/lib/nagios-herald/test_helpers/base_test_case.rb +82 -0
  65. data/lib/nagios-herald/util.rb +45 -0
  66. data/lib/nagios-herald/version.rb +3 -0
  67. data/lib/nagios-herald.rb +7 -0
  68. data/lib/stackbars/__init__.py +0 -0
  69. data/lib/stackbars/chart_utils.py +25 -0
  70. data/lib/stackbars/grouped_stackbars.py +97 -0
  71. data/lib/stackbars/pilfonts/Tahoma.ttf +0 -0
  72. data/lib/stackbars/pilfonts/aerial.ttf +0 -0
  73. data/lib/stackbars/pilfonts/arial_black.ttf +0 -0
  74. data/lib/stackbars/stackbar.py +100 -0
  75. data/nagios-herald.gemspec +33 -0
  76. data/test/env_files/check_cpu_idle.CRITICAL +199 -0
  77. data/test/env_files/check_cpu_iowait.WARNING +199 -0
  78. data/test/env_files/check_disk.CRITICAL +197 -0
  79. data/test/env_files/check_disk.CRITICAL_ICINGA +197 -0
  80. data/test/env_files/check_disk.RECOVERY +197 -0
  81. data/test/env_files/check_memory.CRITICAL +197 -0
  82. data/test/env_files/nagios_vars.EXAMPLE +197 -0
  83. data/test/unit/test_config.rb +31 -0
  84. data/test/unit/test_executor.rb +65 -0
  85. data/test/unit/test_formatter_base.rb +131 -0
  86. data/test/unit/test_formatter_check_cpu_idle_critical.rb +135 -0
  87. data/test/unit/test_formatter_check_memory.rb +135 -0
  88. data/test/unit/test_icinga_variables.rb +31 -0
  89. data/test/unit/test_logging.rb +35 -0
  90. data/test/unit/test_message_email.rb +69 -0
  91. data/test/unit/test_message_pager.rb +69 -0
  92. metadata +204 -0
@@ -0,0 +1,135 @@
1
+ require 'minitest/autorun'
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
4
+ require 'nagios-herald'
5
+ require 'nagios-herald/config'
6
+ require 'nagios-herald/executor'
7
+ require 'nagios-herald/formatters/base'
8
+
9
+ # Test Formatter::Base.
10
+ class TestFormatterCheckMemory < MiniTest::Unit::TestCase
11
+
12
+ # TODO: We need a similar set of tests for RECOVERY emails.
13
+ # Initial setup before we execute tests
14
+ def setup
15
+ @options = {}
16
+ @options[:message_type] = 'EMAIL'
17
+ @options[:nagios_url] = "http://nagios.example.com"
18
+ @options[:formatter_name] = 'check_memory'
19
+ env_file = File.join(File.dirname(__FILE__), '..', 'env_files', 'check_memory.CRITICAL')
20
+ NagiosHerald::Executor.new.load_env_from_file(env_file) # load an env file for testing
21
+ NagiosHerald::Executor.new.load_formatters
22
+ NagiosHerald::Executor.new.load_messages
23
+ formatter_class = NagiosHerald::Formatter.formatters[@options[:formatter_name]]
24
+ @formatter = formatter_class.new(@options)
25
+ end
26
+
27
+ def teardown
28
+ # make certain we don't leave tons of empty temp dirs behind
29
+ @formatter.clean_sandbox
30
+ end
31
+
32
+ # Test that we have a new NagiosHerald::Formatter object.
33
+ def test_new_formatter
34
+ assert_instance_of NagiosHerald::Formatter::CheckMemory, @formatter
35
+ end
36
+
37
+ def test_add_content_basic
38
+ @formatter.add_text('test_add_content', 'This is test text')
39
+ assert_equal 'This is test text', @formatter.content[:text][:test_add_content]
40
+ @formatter.add_html('test_add_content', '<b>This is test HTML</b>')
41
+ assert_equal '<b>This is test HTML</b>', @formatter.content[:html][:test_add_content]
42
+ @formatter.generate_subject
43
+ assert_equal "PROBLEM Service web.example.com/Memory is CRITICAL", @formatter.content[:subject]
44
+ attachment_name = "#{@formatter.sandbox}/cat.gif"
45
+ @formatter.add_attachment(attachment_name)
46
+ assert @formatter.content[:attachments].include?(attachment_name), "Failed to attach #{attachment_name} to content hash."
47
+ end
48
+
49
+ def test_action_url
50
+ @formatter.action_url
51
+ assert_equal "<b>Action URL</b>: http://runbook.example.com/disk_space_alerts.html<br><br>", @formatter.content[:html][:action_url]
52
+ assert_equal "Action URL: http://runbook.example.com/disk_space_alerts.html\n\n", @formatter.content[:text][:action_url]
53
+ end
54
+
55
+ def test_host_info
56
+ @formatter.host_info
57
+ assert_equal "<br><b>Host</b>: web.example.com <b>Service</b>: Memory<br/><br>", @formatter.content[:html][:host_info]
58
+ assert_equal "Host: web.example.com Service: Memory\n\n", @formatter.content[:text][:host_info]
59
+ end
60
+
61
+ def test_state_info
62
+ @formatter.state_info
63
+ assert_equal "State is now: <b><font style='color:red'>CRITICAL</font></b> for <b>0d 0h 5m 3s</b> (was CRITICAL) after <b>3 / 3</b> checks<br/><br>", @formatter.content[:html][:state_info]
64
+ assert_equal "State is now: CRITICAL for 0d 0h 5m 3s (was CRITICAL) after 3 / 3 checks\n\n", @formatter.content[:text][:state_info]
65
+ end
66
+
67
+ def test_notification_info
68
+ @formatter.notification_info
69
+ assert_equal "Notification sent at: Thu May 14 21:06:38 UTC 2014 (notification number 1)<br><br>", @formatter.content[:html][:notification_info]
70
+ assert_equal "Notification sent at: Thu May 14 21:06:38 UTC 2014 (notification number 1)\n\n", @formatter.content[:text][:notification_info]
71
+ end
72
+
73
+ def test_additional_info
74
+ @formatter.additional_info
75
+ assert_equal "<b>Additional Info</b>: Memory CRITICAL - 98.1% used (22.986 GB total plus 0.171 GB cached, 0.098 GB reclaimable)<br><br>", @formatter.content[:html][:additional_info]
76
+ assert_equal "Additional Info: Memory CRITICAL - 98.1% used (22.986 GB total plus 0.171 GB cached, 0.098 GB reclaimable)\n\n", @formatter.content[:text][:additional_info]
77
+ end
78
+
79
+ def test_additional_details
80
+ @formatter.additional_details
81
+ puts
82
+ assert_equal "<b>Additional Details</b>:<pre><br>TOP 5 PROCESSES BY MEMORY USAGE:<br> %MEM RSS USER PID COMMAND<br><font color='red'> 2.4 1231696 larry 6658 tmux</font><br><font color='orange'> 1.5 777204 moe 32234 tmux/tmux -CC</font><br><font color='orange'> 0.8 399964 curly 12161 /usr/sbin/gmond</font><br><font color='orange'> 0.7 384772 shep 1945 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/web.example.com.err --pid-file=/var/lib/mysql/web.example.com.pid</font><br><font color='orange'> 0.7 355148 root 1245 SCREEN</font><br></pre><br>", @formatter.content[:html][:additional_details]
83
+ assert_equal "Additional Details:\n#TOP 5 PROCESSES BY MEMORY USAGE:\n %MEM RSS USER PID COMMAND\n 2.4 1231696 larry 6658 tmux\n 1.5 777204 moe 32234 tmux/tmux -CC\n 0.8 399964 curly 12161 /usr/sbin/gmond\n 0.7 384772 shep 1945 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/web.example.com.err --pid-file=/var/lib/mysql/web.example.com.pid\n 0.7 355148 root 1245 SCREEN\n\n\n", @formatter.content[:text][:additional_details]
84
+ end
85
+
86
+ def test_notes
87
+ @formatter.notes
88
+ # There are no notes in the example environment variables.
89
+ assert_equal "", @formatter.content[:html][:notes]
90
+ assert_equal "", @formatter.content[:text][:notes]
91
+ end
92
+
93
+ def test_action_url
94
+ @formatter.action_url
95
+ assert_equal "", @formatter.content[:html][:action_url]
96
+ assert_equal "", @formatter.content[:text][:action_url]
97
+ end
98
+
99
+ def test_short_state_detail
100
+ @formatter.short_state_detail
101
+ assert_equal "Memory CRITICAL - 98.1% used (22.986 GB total plus 0.171 GB cached, 0.098 GB reclaimable)<br>", @formatter.content[:html][:short_state_detail]
102
+ assert_equal "Memory CRITICAL - 98.1% used (22.986 GB total plus 0.171 GB cached, 0.098 GB reclaimable)\n", @formatter.content[:text][:short_state_detail]
103
+ end
104
+
105
+ def test_recipients_email_link
106
+ @formatter.recipients_email_link
107
+ assert_equal "Sent to ops<br><br>", @formatter.content[:html][:recipients_email_link]
108
+ assert_equal "Sent to ops\n\n", @formatter.content[:text][:recipients_email_link]
109
+ end
110
+
111
+ def test_ack_info
112
+ @formatter.ack_info
113
+ assert_equal "At Thu May 14 21:06:38 UTC 2014 ops acknowledged web.example.com/Memory.<br><br>Comment: ", @formatter.content[:html][:ack_info]
114
+ assert_equal "At Thu May 14 21:06:38 UTC 2014 ops acknowledged web.example.com/Memory.\n\nComment: ", @formatter.content[:text][:ack_info]
115
+ end
116
+
117
+ def test_short_ack_info
118
+ @formatter.short_ack_info
119
+ assert_equal "ops ack'd Memory on web.example.com.<br>", @formatter.content[:html][:short_ack_info]
120
+ assert_equal "ops ack'd Memory on web.example.com.\n", @formatter.content[:text][:short_ack_info]
121
+ end
122
+
123
+ def test_alert_ack_url
124
+ @formatter.alert_ack_url
125
+ assert_equal "Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Memory<br>Alternatively, <b>reply</b> to this message with the word '<b><font color='green'>ack</font></b>' in the body to acknowledge the alert.<br>", @formatter.content[:html][:alert_ack_url]
126
+ assert_equal "Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Memory\nAlternatively, reply to this message with the word 'ack' in the body to acknowledge the alert.\n", @formatter.content[:text][:alert_ack_url]
127
+ end
128
+
129
+ def test_clean_sandbox
130
+ @formatter.clean_sandbox
131
+ assert !File.directory?(@formatter.sandbox)
132
+ end
133
+
134
+ end
135
+
@@ -0,0 +1,31 @@
1
+ require 'minitest/autorun'
2
+
3
+ # I assume cat'ing to the LOAD path goes away when we're a real gem.
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
5
+ require 'nagios-herald'
6
+ require 'nagios-herald/executor'
7
+
8
+ # Test the Executor class.
9
+ class TestIcingaVariables < MiniTest::Unit::TestCase
10
+ include NagiosHerald::Util
11
+
12
+ # initial setup before we execute tests
13
+ def setup
14
+ @executor = NagiosHerald::Executor.new
15
+ @options = {}
16
+ @options[:env] = File.join(File.dirname(__FILE__), '..', 'env_files', 'check_disk.CRITICAL_ICINGA')
17
+ end
18
+
19
+ def teardown
20
+ end
21
+
22
+ # Read Icinga environment variables.
23
+ def test_icinga_variables
24
+ NagiosHerald::Config.config['icinga'] = true
25
+ @executor.load_env_from_file(@options[:env])
26
+ assert_equal "ops@example.com", get_nagios_var('NAGIOS_CONTACTEMAIL')
27
+ assert_equal "ops@example.com", get_nagios_var('ICINGA_CONTACTEMAIL')
28
+ assert_equal "PROBLEM", get_nagios_var('NAGIOS_NOTIFICATIONTYPE')
29
+ end
30
+
31
+ end
@@ -0,0 +1,35 @@
1
+ require 'minitest/autorun'
2
+
3
+ # I assume cat'ing to the LOAD path goes away when we're a real gem.
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
5
+ require 'nagios-herald'
6
+ require 'nagios-herald/config'
7
+ require 'nagios-herald/logging'
8
+
9
+ # Test the Config module.
10
+ class TestLogging < MiniTest::Unit::TestCase
11
+ include NagiosHerald::Logging
12
+
13
+ # Initial setup before we execute tests
14
+ def setup
15
+ @options = {}
16
+ @options['config_file'] = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'etc', 'config.yml.example'))
17
+ @tmp_logfile = '/tmp/nagios-herald-logging.log'
18
+ # Specify a log file
19
+ @options['logfile'] = @tmp_logfile
20
+ # Load the config
21
+ NagiosHerald::Config.load(@options)
22
+ end
23
+
24
+ def test_info_message
25
+ #INFO -- test_logging.rb (TestLogging): Testing nagios-herald logging
26
+ logger.info "Testing nagios-herald logging"
27
+ @log_message = File.new(@tmp_logfile, 'r').read
28
+ assert_match /INFO.+Testing nagios-herald logging/, @log_message
29
+ end
30
+
31
+ def teardown
32
+ File.delete(@tmp_logfile)
33
+ end
34
+
35
+ end
@@ -0,0 +1,69 @@
1
+ require 'minitest/autorun'
2
+ require 'mail'
3
+
4
+ # I assume cat'ing to the LOAD path goes away when we're a real gem.
5
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
6
+ require 'nagios-herald'
7
+ require 'nagios-herald/messages/email'
8
+
9
+ # Test Formatter::Base.
10
+ class TestMessageEmail < MiniTest::Unit::TestCase
11
+
12
+ # TODO: We need a similar set of tests for RECOVERY emails.
13
+ # Initial setup before we execute tests
14
+ def setup
15
+ @recipient = 'ops@example.com'
16
+ @options = { :replyto => 'nagios@example.com' }
17
+ @message = NagiosHerald::Message::Email.new(@recipient, @options)
18
+ @message.content = {
19
+ :attachments=>[],
20
+ :html => {
21
+ :host_info=>"<div style=''><br><b>Host</b>: web.example.com <b>Service</b>: Disk Space<br/><br></div>",
22
+ :state_info=>"<div style=''>State is now: <b><font style='color:red'>CRITICAL</font></b> for <b>0d 0h 5m 12s</b> (was CRITICAL) after <b>3 / 3</b> checks<br/><br></div>",
23
+ :additional_info=>"<div style=''><b>Additional Info</b>: DISK CRITICAL - free space: / 7002 MB (18% inode 60%): /data 16273093 MB (26% inode 99%):<br><br></div>",
24
+ :action_url=>"<div style=''><b>Action URL</b>: http://runbook.example.com/disk_space_alerts.html<br><br></div>",
25
+ :notes=>"<div style=''></div>",
26
+ :additional_details=>"<div style=''><b>Additional Details</b>: <pre>\nTHRESHOLDS - WARNING:15%;CRITICAL:20%;\n\nFilesystem Size Used Avail Use% Mounted on\n/dev/vda 40G 31G 6.9G 82% /\ntmpfs 2.5G 83M 2.4G 4% /dev/shm\nnfs.example.example.com:/mnt/user/homes\n 59T 43T 16T 74% /data\n</pre><br><br></div>",
27
+ :recipients_email_link=>"<div style=''>Sent to ops<br><br></div>",
28
+ :notification_info=>"<div style=''>Notification sent at: Thu May 16 21:06:38 UTC 2013 (notification number 1)<br><br></div>",
29
+ :alert_ack_url=>"<div style=''>Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Disk%20Space<br>Alternatively, <b>reply</b> to this message with the word '<b><font color='green'>ack</font></b>' in the body to acknowledge the alert.<br></div>"
30
+ },
31
+ :subject => "PROBLEM Service web.example.com/Disk Space is CRITICAL",
32
+ :text => {
33
+ :host_info=>"Host: web.example.com Service: Disk Space\n\n",
34
+ :state_info=>"State is now: CRITICAL for 0d 0h 5m 12s (was CRITICAL) after 3 / 3 checks\n\n",
35
+ :additional_info=>"Additional Info: DISK CRITICAL - free space: / 7002 MB (18% inode 60%): /data 16273093 MB (26% inode 99%):\n\n",
36
+ :action_url=>"Action URL: http://runbook.example.com/disk_space_alerts.html\n\n",
37
+ :notes=>"",
38
+ :additional_details=>"Additional Details: \nTHRESHOLDS - WARNING:15%;CRITICAL:20%;\n\nFilesystem Size Used Avail Use% Mounted on\n/dev/vda 40G 31G 6.9G 82% /\ntmpfs 2.5G 83M 2.4G 4% /dev/shm\nnfs.example.example.com:/mnt/user/homes\n 59T 43T 16T 74% /data\n\n",
39
+ :recipients_email_link=>"Sent to ops\n\n",
40
+ :notification_info=>"Notification sent at: Thu May 16 21:06:38 UTC 2013 (notification number 1)\n\n",
41
+ :alert_ack_url=>"Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Disk%20Space\nAlternatively, reply to this message with the word 'ack' in the body to acknowledge the alert.\n"
42
+ }
43
+ }
44
+ end
45
+
46
+ def teardown
47
+ end
48
+
49
+ # Test that we have a new NagiosHerald::Message::Email object.
50
+ def test_new_message_email
51
+ assert_instance_of NagiosHerald::Message::Email, @message
52
+ end
53
+
54
+ def test_message_delivery
55
+ # This test depends on the mailcatcher gem being installed and
56
+ # `mailcatcher` running. `mailcatcher` runs locally on tcp/1025.
57
+ # NOTE: NagiosHerald::Message::Email#send calls #build_message before
58
+ # delivering the message. We need to override some SMTP settings for this
59
+ # test so we call #deliver! here.
60
+ mail = @message.build_message
61
+ # Set 'return_response' to true so that #deliver! returns the
62
+ # Net::SMTP::Response for us to validate.
63
+ mail.delivery_method :smtp, { :address => 'localhost', :port => 1025, :return_response => true }
64
+ response = mail.deliver!
65
+ assert_equal "250", response.status
66
+ end
67
+
68
+ end
69
+
@@ -0,0 +1,69 @@
1
+ require 'minitest/autorun'
2
+ require 'mail'
3
+
4
+ # I assume cat'ing to the LOAD path goes away when we're a real gem.
5
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
6
+ require 'nagios-herald'
7
+ require 'nagios-herald/messages/pager'
8
+
9
+ # Test Formatter::Base.
10
+ class TestMessagePager < MiniTest::Unit::TestCase
11
+
12
+ # TODO: We need a similar set of tests for RECOVERY pages.
13
+ # Initial setup before we execute tests
14
+ def setup
15
+ @recipient = 'ops@example.com'
16
+ @options = { :replyto => 'nagios@example.com' }
17
+ @message = NagiosHerald::Message::Pager.new(@recipient, @options)
18
+ @message.content = {
19
+ :attachments=>[],
20
+ :html => {
21
+ :host_info=>"<div style=''><br><b>Host</b>: web.example.com <b>Service</b>: Disk Space<br/><br></div>",
22
+ :state_info=>"<div style=''>State is now: <b><font style='color:red'>CRITICAL</font></b> for <b>0d 0h 5m 12s</b> (was CRITICAL) after <b>3 / 3</b> checks<br/><br></div>",
23
+ :additional_info=>"<div style=''><b>Additional Info</b>: DISK CRITICAL - free space: / 7002 MB (18% inode 60%): /data 16273093 MB (26% inode 99%):<br><br></div>",
24
+ :action_url=>"<div style=''><b>Action URL</b>: http://runbook.example.com/disk_space_alerts.html<br><br></div>",
25
+ :notes=>"<div style=''></div>",
26
+ :additional_details=>"<div style=''><b>Additional Details</b>: <pre>\nTHRESHOLDS - WARNING:15%;CRITICAL:20%;\n\nFilesystem Size Used Avail Use% Mounted on\n/dev/vda 40G 31G 6.9G 82% /\ntmpfs 2.5G 83M 2.4G 4% /dev/shm\nnfs.example.example.com:/mnt/user/homes\n 59T 43T 16T 74% /data\n</pre><br><br></div>",
27
+ :recipients_email_link=>"<div style=''>Sent to ops<br><br></div>",
28
+ :notification_info=>"<div style=''>Notification sent at: Thu May 16 21:06:38 UTC 2013 (notification number 1)<br><br></div>",
29
+ :alert_ack_url=>"<div style=''>Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Disk%20Space<br>Alternatively, <b>reply</b> to this message with the word '<b><font color='green'>ack</font></b>' in the body to acknowledge the alert.<br></div>"
30
+ },
31
+ :subject => "PROBLEM Service web.example.com/Disk Space is CRITICAL",
32
+ :text => {
33
+ :host_info=>"Host: web.example.com Service: Disk Space\n\n",
34
+ :state_info=>"State is now: CRITICAL for 0d 0h 5m 12s (was CRITICAL) after 3 / 3 checks\n\n",
35
+ :additional_info=>"Additional Info: DISK CRITICAL - free space: / 7002 MB (18% inode 60%): /data 16273093 MB (26% inode 99%):\n\n",
36
+ :action_url=>"Action URL: http://runbook.example.com/disk_space_alerts.html\n\n",
37
+ :notes=>"",
38
+ :additional_details=>"Additional Details: \nTHRESHOLDS - WARNING:15%;CRITICAL:20%;\n\nFilesystem Size Used Avail Use% Mounted on\n/dev/vda 40G 31G 6.9G 82% /\ntmpfs 2.5G 83M 2.4G 4% /dev/shm\nnfs.example.example.com:/mnt/user/homes\n 59T 43T 16T 74% /data\n\n",
39
+ :recipients_email_link=>"Sent to ops\n\n",
40
+ :notification_info=>"Notification sent at: Thu May 16 21:06:38 UTC 2013 (notification number 1)\n\n",
41
+ :alert_ack_url=>"Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Disk%20Space\nAlternatively, reply to this message with the word 'ack' in the body to acknowledge the alert.\n"
42
+ }
43
+ }
44
+ end
45
+
46
+ def teardown
47
+ end
48
+
49
+ # Test that we have a new NagiosHerald::Message::Pager object.
50
+ def test_new_message_pager
51
+ assert_instance_of NagiosHerald::Message::Pager, @message
52
+ end
53
+
54
+ def test_message_delivery
55
+ # This test depends on the mailcatcher gem being installed and
56
+ # `mailcatcher` running. `mailcatcher` runs locally on tcp/1025.
57
+ # NOTE: NagiosHerald::Message::Pager#send calls #build_message before
58
+ # delivering the message. We need to override some SMTP settings for this
59
+ # test so we call #deliver! here.
60
+ mail = @message.build_message
61
+ # Set 'return_response' to true so that #deliver! returns the
62
+ # Net::SMTP::Response for us to validate.
63
+ mail.delivery_method :smtp, { :address => 'localhost', :port => 1025, :return_response => true }
64
+ response = mail.deliver!
65
+ assert_equal "250", response.status
66
+ end
67
+
68
+ end
69
+
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nagios-herald
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Frantz
8
+ - Nassim Kammah
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2014-09-26 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: app_conf
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: "0.4"
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.4.2
26
+ type: :runtime
27
+ version_requirements: *id001
28
+ - !ruby/object:Gem::Dependency
29
+ name: choice
30
+ prerelease: false
31
+ requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "0.1"
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 0.1.6
39
+ type: :runtime
40
+ version_requirements: *id002
41
+ - !ruby/object:Gem::Dependency
42
+ name: mail
43
+ prerelease: false
44
+ requirement: &id003 !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: "2.5"
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 2.5.4
52
+ type: :runtime
53
+ version_requirements: *id003
54
+ - !ruby/object:Gem::Dependency
55
+ name: chef
56
+ prerelease: false
57
+ requirement: &id004 !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 11.8.2
62
+ type: :runtime
63
+ version_requirements: *id004
64
+ - !ruby/object:Gem::Dependency
65
+ name: elasticsearch
66
+ prerelease: false
67
+ requirement: &id005 !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.0.2
72
+ type: :runtime
73
+ version_requirements: *id005
74
+ description: " A project that aims to make it easy to provide context in Nagios alerts.\n The project consists of a core notifier script that can be called with a formatter\n to tailor the content of the message sent to an operator.\n"
75
+ email:
76
+ - rfrantz@etsy.com
77
+ - nkammah@etsy.com
78
+ executables:
79
+ - nagios-herald
80
+ extensions: []
81
+
82
+ extra_rdoc_files: []
83
+
84
+ files:
85
+ - .gitignore
86
+ - .travis.yml
87
+ - CHANGELOG.md
88
+ - CONTRIBUTING.md
89
+ - Gemfile
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - bin/draw_stack_bars
94
+ - bin/dump_nagios_env.sh
95
+ - bin/get_ganglia_graph
96
+ - bin/get_graph
97
+ - bin/get_graphite_graph
98
+ - bin/nagios-herald
99
+ - bin/splunk_alert_frequency
100
+ - contrib/nrpe-plugins/check_cpu_stats.sh
101
+ - contrib/nrpe-plugins/check_disk.sh
102
+ - contrib/nrpe-plugins/check_mem.pl
103
+ - contrib/nrpe-plugins/nrpe-plugin-examples.md
104
+ - docs/config.md
105
+ - docs/example_alerts.md
106
+ - docs/formatters.md
107
+ - docs/helpers.md
108
+ - docs/images/cpu_no_context.png
109
+ - docs/images/cpu_with_context.png
110
+ - docs/images/disk_space_no_context.png
111
+ - docs/images/disk_space_with_context.png
112
+ - docs/images/memory_high_no_context.png
113
+ - docs/images/memory_high_with_context.png
114
+ - docs/images/nagios-herald-formatter-content-example.png
115
+ - docs/images/nagios-herald.png
116
+ - docs/images/stack-bars.png
117
+ - docs/images/vanilla-nagios.png
118
+ - docs/messages.md
119
+ - docs/nagios-config.md
120
+ - docs/tools.md
121
+ - etc/config.yml.example
122
+ - etc/readme.md
123
+ - lib/nagios-herald.rb
124
+ - lib/nagios-herald/config.rb
125
+ - lib/nagios-herald/executor.rb
126
+ - lib/nagios-herald/formatter_loader.rb
127
+ - lib/nagios-herald/formatters.rb
128
+ - lib/nagios-herald/formatters/base.rb
129
+ - lib/nagios-herald/formatters/check_cpu.rb
130
+ - lib/nagios-herald/formatters/check_disk.rb
131
+ - lib/nagios-herald/formatters/check_logstash.rb
132
+ - lib/nagios-herald/formatters/check_memory.rb
133
+ - lib/nagios-herald/formatters/example.rb
134
+ - lib/nagios-herald/helpers.rb
135
+ - lib/nagios-herald/helpers/ganglia_graph.rb
136
+ - lib/nagios-herald/helpers/graphite_graph.rb
137
+ - lib/nagios-herald/helpers/logstash_query.rb
138
+ - lib/nagios-herald/helpers/splunk_alert_frequency.rb
139
+ - lib/nagios-herald/helpers/splunk_query.rb
140
+ - lib/nagios-herald/helpers/url_image.rb
141
+ - lib/nagios-herald/logging.rb
142
+ - lib/nagios-herald/message_loader.rb
143
+ - lib/nagios-herald/messages.rb
144
+ - lib/nagios-herald/messages/base.rb
145
+ - lib/nagios-herald/messages/email.rb
146
+ - lib/nagios-herald/messages/irc.rb
147
+ - lib/nagios-herald/messages/pager.rb
148
+ - lib/nagios-herald/test_helpers/base_test_case.rb
149
+ - lib/nagios-herald/util.rb
150
+ - lib/nagios-herald/version.rb
151
+ - lib/stackbars/__init__.py
152
+ - lib/stackbars/chart_utils.py
153
+ - lib/stackbars/grouped_stackbars.py
154
+ - lib/stackbars/pilfonts/Tahoma.ttf
155
+ - lib/stackbars/pilfonts/aerial.ttf
156
+ - lib/stackbars/pilfonts/arial_black.ttf
157
+ - lib/stackbars/stackbar.py
158
+ - nagios-herald.gemspec
159
+ - test/env_files/check_cpu_idle.CRITICAL
160
+ - test/env_files/check_cpu_iowait.WARNING
161
+ - test/env_files/check_disk.CRITICAL
162
+ - test/env_files/check_disk.CRITICAL_ICINGA
163
+ - test/env_files/check_disk.RECOVERY
164
+ - test/env_files/check_memory.CRITICAL
165
+ - test/env_files/nagios_vars.EXAMPLE
166
+ - test/unit/test_config.rb
167
+ - test/unit/test_executor.rb
168
+ - test/unit/test_formatter_base.rb
169
+ - test/unit/test_formatter_check_cpu_idle_critical.rb
170
+ - test/unit/test_formatter_check_memory.rb
171
+ - test/unit/test_icinga_variables.rb
172
+ - test/unit/test_logging.rb
173
+ - test/unit/test_message_email.rb
174
+ - test/unit/test_message_pager.rb
175
+ homepage: https://github.com/etsy/nagios-herald
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+
180
+ post_install_message: Have fun and write your own formatters!
181
+ rdoc_options: []
182
+
183
+ require_paths:
184
+ - lib
185
+ required_ruby_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: 1.9.2
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: "0"
195
+ requirements: []
196
+
197
+ rubyforge_project:
198
+ rubygems_version: 2.2.2
199
+ signing_key:
200
+ specification_version: 4
201
+ summary: A project that aims to make it easy to provide context in Nagios alerts.
202
+ test_files: []
203
+
204
+ has_rdoc: