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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +28 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +94 -0
- data/Rakefile +9 -0
- data/bin/draw_stack_bars +76 -0
- data/bin/dump_nagios_env.sh +25 -0
- data/bin/get_ganglia_graph +82 -0
- data/bin/get_graph +50 -0
- data/bin/get_graphite_graph +58 -0
- data/bin/nagios-herald +6 -0
- data/bin/splunk_alert_frequency +54 -0
- data/contrib/nrpe-plugins/check_cpu_stats.sh +186 -0
- data/contrib/nrpe-plugins/check_disk.sh +34 -0
- data/contrib/nrpe-plugins/check_mem.pl +181 -0
- data/contrib/nrpe-plugins/nrpe-plugin-examples.md +11 -0
- data/docs/config.md +62 -0
- data/docs/example_alerts.md +48 -0
- data/docs/formatters.md +180 -0
- data/docs/helpers.md +12 -0
- data/docs/images/cpu_no_context.png +0 -0
- data/docs/images/cpu_with_context.png +0 -0
- data/docs/images/disk_space_no_context.png +0 -0
- data/docs/images/disk_space_with_context.png +0 -0
- data/docs/images/memory_high_no_context.png +0 -0
- data/docs/images/memory_high_with_context.png +0 -0
- data/docs/images/nagios-herald-formatter-content-example.png +0 -0
- data/docs/images/nagios-herald.png +0 -0
- data/docs/images/stack-bars.png +0 -0
- data/docs/images/vanilla-nagios.png +0 -0
- data/docs/messages.md +16 -0
- data/docs/nagios-config.md +74 -0
- data/docs/tools.md +79 -0
- data/etc/config.yml.example +14 -0
- data/etc/readme.md +2 -0
- data/lib/nagios-herald/config.rb +25 -0
- data/lib/nagios-herald/executor.rb +265 -0
- data/lib/nagios-herald/formatter_loader.rb +82 -0
- data/lib/nagios-herald/formatters/base.rb +524 -0
- data/lib/nagios-herald/formatters/check_cpu.rb +71 -0
- data/lib/nagios-herald/formatters/check_disk.rb +143 -0
- data/lib/nagios-herald/formatters/check_logstash.rb +155 -0
- data/lib/nagios-herald/formatters/check_memory.rb +42 -0
- data/lib/nagios-herald/formatters/example.rb +19 -0
- data/lib/nagios-herald/formatters.rb +1 -0
- data/lib/nagios-herald/helpers/ganglia_graph.rb +99 -0
- data/lib/nagios-herald/helpers/graphite_graph.rb +85 -0
- data/lib/nagios-herald/helpers/logstash_query.rb +125 -0
- data/lib/nagios-herald/helpers/splunk_alert_frequency.rb +170 -0
- data/lib/nagios-herald/helpers/splunk_query.rb +119 -0
- data/lib/nagios-herald/helpers/url_image.rb +76 -0
- data/lib/nagios-herald/helpers.rb +5 -0
- data/lib/nagios-herald/logging.rb +48 -0
- data/lib/nagios-herald/message_loader.rb +40 -0
- data/lib/nagios-herald/messages/base.rb +56 -0
- data/lib/nagios-herald/messages/email.rb +150 -0
- data/lib/nagios-herald/messages/irc.rb +58 -0
- data/lib/nagios-herald/messages/pager.rb +75 -0
- data/lib/nagios-herald/messages.rb +3 -0
- data/lib/nagios-herald/test_helpers/base_test_case.rb +82 -0
- data/lib/nagios-herald/util.rb +45 -0
- data/lib/nagios-herald/version.rb +3 -0
- data/lib/nagios-herald.rb +7 -0
- data/lib/stackbars/__init__.py +0 -0
- data/lib/stackbars/chart_utils.py +25 -0
- data/lib/stackbars/grouped_stackbars.py +97 -0
- data/lib/stackbars/pilfonts/Tahoma.ttf +0 -0
- data/lib/stackbars/pilfonts/aerial.ttf +0 -0
- data/lib/stackbars/pilfonts/arial_black.ttf +0 -0
- data/lib/stackbars/stackbar.py +100 -0
- data/nagios-herald.gemspec +33 -0
- data/test/env_files/check_cpu_idle.CRITICAL +199 -0
- data/test/env_files/check_cpu_iowait.WARNING +199 -0
- data/test/env_files/check_disk.CRITICAL +197 -0
- data/test/env_files/check_disk.CRITICAL_ICINGA +197 -0
- data/test/env_files/check_disk.RECOVERY +197 -0
- data/test/env_files/check_memory.CRITICAL +197 -0
- data/test/env_files/nagios_vars.EXAMPLE +197 -0
- data/test/unit/test_config.rb +31 -0
- data/test/unit/test_executor.rb +65 -0
- data/test/unit/test_formatter_base.rb +131 -0
- data/test/unit/test_formatter_check_cpu_idle_critical.rb +135 -0
- data/test/unit/test_formatter_check_memory.rb +135 -0
- data/test/unit/test_icinga_variables.rb +31 -0
- data/test/unit/test_logging.rb +35 -0
- data/test/unit/test_message_email.rb +69 -0
- data/test/unit/test_message_pager.rb +69 -0
- metadata +204 -0
data/docs/formatters.md
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
# Formatters
|
2
|
+
|
3
|
+
Adding context to alerts is done by the formatters. Formatters generate all the content that may
|
4
|
+
be used by one or more message types. For example, text returned by a Nagios check
|
5
|
+
can be highlighted to grab the operator's attention. Helper functions can be called to generate
|
6
|
+
additional content such as image attachments or search results.
|
7
|
+
|
8
|
+
All content generated by a formatter is stored in a hash (a class instance variable in the
|
9
|
+
formatter object). The hash looks similar to the following:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
@content = {
|
13
|
+
:attachments => [],
|
14
|
+
:html => {
|
15
|
+
:additonal_info => "",
|
16
|
+
:additional_details => ""
|
17
|
+
},
|
18
|
+
:subject => "",
|
19
|
+
:text => {
|
20
|
+
:additonal_info => "",
|
21
|
+
:additional_details => ""
|
22
|
+
}
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
**NOTE**: The subkeys under the ``:html`` and ``:text`` keys are generated by formatter methods of the
|
27
|
+
same name.
|
28
|
+
|
29
|
+
## Formatter Methods
|
30
|
+
|
31
|
+
The base formatter (``Formatter::Base``) defines a set of core formatting methods useful for generating content.
|
32
|
+
These methods can be overridden in subclassed formatters to do anything. **The only limit is your
|
33
|
+
imagination.**
|
34
|
+
|
35
|
+
ack_info
|
36
|
+
additional_details
|
37
|
+
additional_info
|
38
|
+
alert_ack_url
|
39
|
+
host_info
|
40
|
+
notes
|
41
|
+
notification_info
|
42
|
+
recipients_email_link
|
43
|
+
short_ack_info
|
44
|
+
short_state_detail
|
45
|
+
state_info
|
46
|
+
|
47
|
+
``Formatter::Base`` also includes basic methods that are used to store or manipulate content in the
|
48
|
+
``@content`` hash:
|
49
|
+
|
50
|
+
add_attachments - Add an attachment path to be referenced in an Email message.
|
51
|
+
add_html - Concatenate HTML for the given section.
|
52
|
+
add_text - Concatenate text for the given section.
|
53
|
+
line_break - Generate a line break for both text and HTML content.
|
54
|
+
|
55
|
+
See below for an example of content generated using some of the above methods.
|
56
|
+
|
57
|
+

|
58
|
+
|
59
|
+
## Writing the Formatter
|
60
|
+
|
61
|
+
To write a formatter, create a new formatter class (i.e. ``check_disk.rb``) and inherit from ``NagiosHerald::Formatter``.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
module NagiosHerald
|
65
|
+
module Formatter
|
66
|
+
class CheckDisk < NagiosHerald::Formatter
|
67
|
+
include NagiosHerald::Logging
|
68
|
+
|
69
|
+
def additional_details
|
70
|
+
section = __method__ # this defines the section key in the formatter's content hash
|
71
|
+
add_text(section, "nagios-herald makes alerting more bearable.")
|
72
|
+
add_html(section, "<b>nagios-herald</b> makes alerting more bearable.<br>")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
### Naming Convention
|
81
|
+
|
82
|
+
* Built-in formatters live in ``lib/nagios-herald/formatters/``.
|
83
|
+
* Custom formatters (those **you'll** write) can live in any location.
|
84
|
+
* Specify the location of your custom formatters via the ``--formatter-dir`` option
|
85
|
+
on the command line or the ``formatter_dir`` variable in the configuration file.
|
86
|
+
* The file names **MUST** lower-cased and underscored.
|
87
|
+
* The class names **MUST** be CamelCased.
|
88
|
+
|
89
|
+
For example, our ``CheckDisk`` formatter class would reside in a file named ``check_disk.rb``.
|
90
|
+
|
91
|
+
This is necessary as ``nagios-herald`` preloads all known formatters when it starts so that it can
|
92
|
+
dynamically instantiate the appropriate formatter it needs when it's ready.
|
93
|
+
|
94
|
+
### Overriding Methods
|
95
|
+
|
96
|
+
Any of the core formatting methods can be overridden in your subclass. It's recommended that the helper methods
|
97
|
+
(i.e. ``add_(attachment|html|text)`` not be overridden.
|
98
|
+
|
99
|
+
An example of an overridden ``additional_info`` method could be:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
def additional_info
|
103
|
+
section = __method__ # this defines the section key in the formatter's content hash
|
104
|
+
hostname = get_nagios_var("NAGIOS_HOSTNAME")
|
105
|
+
add_text(section, "#{hostname} blew up!")
|
106
|
+
add_html(section, "#{hostname} <b>blew</b> up!")
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
## Helpers
|
111
|
+
|
112
|
+
Helpers are libraries available to all formatters that can be used to supplement the content they generate. For example, a helper can pull in external information (such as a graph) that is relevant to a service that Nagios is alerting on.
|
113
|
+
|
114
|
+
To learn more, see the [helpers](/docs/helpers.md) page.
|
115
|
+
|
116
|
+
## Testing Your Formatter
|
117
|
+
|
118
|
+
**PLEASE TEST YOUR FORMATTER. NOT DOING SO INCREASES THE POSSIBILITY THAT A NEW FORMATTER WILL PREVENT DELIVERY OF CRITICAL ALERTS.**
|
119
|
+
|
120
|
+
There are two ways that formatters can be tested: unit tests and manually running ``nagios-herald``.
|
121
|
+
|
122
|
+
### Unit Tests
|
123
|
+
|
124
|
+
**THIS IS A WORK IN PROGRESS. BETTER TESTING IS ON THE ROADMAP**
|
125
|
+
|
126
|
+
### ``nagios-herald``
|
127
|
+
|
128
|
+
``nagios-herald`` can be called manually from the command line to test new formatters:
|
129
|
+
|
130
|
+
```
|
131
|
+
./bin/nagios-herald --env-file ../test/env_files/check_mem.vars --formatter=check_mem -r ops@example.com -y nagios@example.com --message-type email -u http://nagios.example.com --trace
|
132
|
+
```
|
133
|
+
|
134
|
+
For a full listing of available options, run ``nagios-herald --help``.
|
135
|
+
|
136
|
+
### A Note About Nagios Data
|
137
|
+
|
138
|
+
Nagios stores important information in environment variables. The formatter methods can retrieve that
|
139
|
+
information by using the ``get_nagios_var()`` method. For reference, see an
|
140
|
+
example [environment file](/test/env_files/nagios_vars.EXAMPLE).
|
141
|
+
|
142
|
+
**NOTE**: Do not directly call ``ENV['YOUR_VAR']`` in your Ruby code as it will be harder to test.
|
143
|
+
|
144
|
+
### Testing the Formatter with Offline Data
|
145
|
+
|
146
|
+
Because Nagios stores information in environment variables that are generated during runtime, ``nagios-herald``
|
147
|
+
provides a few example environment files that can be used for testing. Files in ``test/env_files/`` can be specified via the
|
148
|
+
``--env-file`` argument to mimic an alerting event. During normal operation ``nagios-herald`` grabs
|
149
|
+
the information it needs from Nagios' environment variables.
|
150
|
+
|
151
|
+
One can generate environment files for testing by using the [dump_nagios_env.sh](/docs/tools.md#dump_nagios_env.sh) tool.
|
152
|
+
|
153
|
+
**NOTE**: ``--no-send`` forces ``nagios-herald`` to output content to the terminal.
|
154
|
+
|
155
|
+
```
|
156
|
+
./bin/nagios-herald --no-send --env-file ../test/env_files/check_disk.vars --formatter=check_disk -r ops@example.com -y nagios@example.com --message-type email -u http://nagios.example.com --trace
|
157
|
+
------------------
|
158
|
+
Subject : ** PROBLEM Service ALERT: web.example.com/Disk Space is CRITICAL **
|
159
|
+
------------------
|
160
|
+
Host: web.example.com
|
161
|
+
Service: Disk Space
|
162
|
+
|
163
|
+
State is now: CRITICAL for 0d 0h 5m 12s (was CRITICAL) after 3 / 3 checks
|
164
|
+
|
165
|
+
Additional info:
|
166
|
+
DISK CRITICAL - free space: / 7002 MB (82% inode 60%): /data 16273093 MB (99% inode 99%):
|
167
|
+
|
168
|
+
Additional Details:
|
169
|
+
Filesystem Size Used Avail Use% Mounted on
|
170
|
+
/dev/sda 40G 33G 7.2G 82% /
|
171
|
+
tmpfs 2.5G 83M 2.4G 4% /dev/shm
|
172
|
+
/dev/sdb 16G 16G 158M 99% /data
|
173
|
+
|
174
|
+
Sent to ops-engineer
|
175
|
+
Notification sent at: Thu May 16 21:06:38 UTC 2013 (notification number 1)
|
176
|
+
|
177
|
+
Acknowledge this alert: http://nagios.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=web.example.com&service=Disk%20Space%0A%3Cbr%3E
|
178
|
+
|
179
|
+
------------------
|
180
|
+
```
|
data/docs/helpers.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Helpers
|
2
|
+
|
3
|
+
Helpers are libraries available to all formatters that can be used to supplement the content they generate. For example, a helper can pull in external information (such as a graph) that is relevant to a service that Nagios is alerting on.
|
4
|
+
|
5
|
+
``nagios-herald`` comes with the following helpers as examples:
|
6
|
+
|
7
|
+
* GangliaGraph - Downloads relevant graphs to be embedded in (email) messages.
|
8
|
+
* SplunkReporter - Queries Splunk for information to add to an alert.
|
9
|
+
* LogstashQuery - Queries logstash with either a kibaba-style query or a file containing query JSON
|
10
|
+
* UrlImage - Generic helper to download images.
|
11
|
+
|
12
|
+
Helpers are located in ``lib/nagios-herald/helpers/``.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/docs/messages.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Messages
|
2
|
+
|
3
|
+
While [formatters](/docs/formatters.md) are crucial to contextualizing alerts, it doesn't matter much if the alerts are never sent. This is where messages come in to play.
|
4
|
+
|
5
|
+
``nagios-herald`` provides a base Message class (``Message::Base``) from which all Message subclasses inherit. ``Message::Base`` knows that all messages have content and recipients; it's the job of the Message subclasses to define additional behavior (such as how to send a message).
|
6
|
+
|
7
|
+
Three message types are defined in ``nagios-herald``: Email, Pager, and IRC. Feel free to cook up any new message types (i.e. CarrierPigeon, SmokeSignal) as you see fit.
|
8
|
+
|
9
|
+
## Getting Content into Messages
|
10
|
+
|
11
|
+
Content generated by formatters is assigned to a message in ``Executor`` via the following code:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
formatter.generate_message_content
|
15
|
+
message.content = formatter.content
|
16
|
+
```
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Nagios Configuration
|
2
|
+
|
3
|
+
## Notification Command Configuration
|
4
|
+
|
5
|
+
Nagios needs to be instructed to use ``nagios-herald`` for notifications. The main notification program in
|
6
|
+
``nagios-herald`` is called ``nagios-herald``.
|
7
|
+
|
8
|
+
To configure Nagios to generate alerts via ``nagios-herald``, update the relevant stanza(s) in ``commands.cfg``.
|
9
|
+
The below example assumes ``nagios-herald`` is installed in ``/usr/local/bin``.
|
10
|
+
|
11
|
+
```
|
12
|
+
# email
|
13
|
+
define command {
|
14
|
+
command_name notify-host-by-email
|
15
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type email --formatter=$_HOSTMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com
|
16
|
+
}
|
17
|
+
|
18
|
+
# specify the location of custom formatters
|
19
|
+
define command {
|
20
|
+
command_name notify-service-by-email
|
21
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type email --formatter=$_SERVICEMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com --formatter-dir=/usr/local/nagios-herald-formatters
|
22
|
+
}
|
23
|
+
|
24
|
+
# pager
|
25
|
+
define command {
|
26
|
+
command_name notify-host-by-pager
|
27
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type pager --formatter=$_HOSTMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com
|
28
|
+
}
|
29
|
+
|
30
|
+
define command {
|
31
|
+
command_name notify-service-by-pager
|
32
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type pager --formatter=$_SERVICEMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com
|
33
|
+
}
|
34
|
+
|
35
|
+
# IRC (optional)
|
36
|
+
define command {
|
37
|
+
command_name notify-service-by-irc
|
38
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type irc --formatter=$_SERVICEMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com
|
39
|
+
}
|
40
|
+
|
41
|
+
define command {
|
42
|
+
command_name notify-service-by-irc
|
43
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type irc --formatter=$_SERVICEMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
**NOTE**: ``$_HOSTMESSAGE_FORMATTER_NAME$`` and ``$_SERVICEMESSAGE_FORMATTER_NAME$`` are Nagios macros, generated
|
48
|
+
from a custom variable in a relevant service check definition.
|
49
|
+
|
50
|
+
### Tracing Errors
|
51
|
+
If ``nagios-herald`` is failing to notify, you can turn up the logging via the ``--trace`` option to gather
|
52
|
+
more information, like so:
|
53
|
+
|
54
|
+
```
|
55
|
+
command_line /usr/local/nagios-herald/bin/nagios-herald --message-type email --formatter=$_SERVICEMESSAGE_FORMATTER_NAME$ --nagios-cgi-url=http://nagios.example.com/nagios/cgi-bin/cmd.cgi --reply-to=nagios@example.com --trace
|
56
|
+
```
|
57
|
+
|
58
|
+
## Service Configuration
|
59
|
+
|
60
|
+
To apply a formatter to a service check, add the ``_message_formatter_name`` custom variable in the relevant stanza in ``services.cfg``:
|
61
|
+
The value of the variable is the name of the formatter.
|
62
|
+
|
63
|
+
```
|
64
|
+
define service {
|
65
|
+
hostgroup_name web_servers
|
66
|
+
service_description Disk Space
|
67
|
+
notification_interval 20
|
68
|
+
check_command check_nrpe!check_disk
|
69
|
+
_message_formatter_name check_disk <<<< custom variable
|
70
|
+
contact_groups ops
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
74
|
+
**NOTE**: If no formatter is specified, ``nagios-herald`` defaults to the base formatter and generates generic content for messages.
|
data/docs/tools.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Tools
|
2
|
+
|
3
|
+
This project comes with a few tools you can use that mimic the behavior of helpers and formatters. These are
|
4
|
+
really useful for testing functionality outside of ``nagios-herald``.
|
5
|
+
|
6
|
+
The following tools reside under the ``bin/`` directory.
|
7
|
+
|
8
|
+
<a name="dump_nagios_env.sh"></a>
|
9
|
+
## ``dump_nagios_env.sh`` - Dump Nagios Environment
|
10
|
+
|
11
|
+
``dump_nagios_env.sh`` is a handy script that dumps the Nagios environment variables at the time an alert fires.
|
12
|
+
Follow the instuctions in the [script](/bin/dump_nagios_env.sh) to configure and use it.
|
13
|
+
|
14
|
+
The environment file that is generated can be used to test new formatters.
|
15
|
+
|
16
|
+
## ``draw_stack_bars`` - Draw Stack Bars
|
17
|
+
|
18
|
+
``draw_stack_bars`` can generate horizontal stacked bars.
|
19
|
+
|
20
|
+
TODO: This needs better documentation. Are we missing command line arguments in the below output?
|
21
|
+
|
22
|
+
```
|
23
|
+
$ ./draw_stack_bars -h
|
24
|
+
usage: draw_stack_bars [options] label=value label=value
|
25
|
+
|
26
|
+
options:
|
27
|
+
-h, --help show this help message and exit
|
28
|
+
-w WIDTH, --width=WIDTH
|
29
|
+
Picture width
|
30
|
+
-o OUTPUT_FILE, --output=OUTPUT_FILE
|
31
|
+
The file name to save the results in
|
32
|
+
--bar-area-ratio=BAR_AREA_RATIO
|
33
|
+
How wide should the bar area be compared to the total
|
34
|
+
width
|
35
|
+
--bar-height-ratio=BAR_HEIGHT_RATIO
|
36
|
+
How tall should the bars be compared to their width
|
37
|
+
--bar-border=BAR_BORDER
|
38
|
+
Width of the border around the bars
|
39
|
+
```
|
40
|
+
|
41
|
+
For example: ``./draw_stack_bars /var=10`` will generate:
|
42
|
+
|
43
|
+

|
44
|
+
|
45
|
+
## ``get_ganglia_graph`` - Draw Ganglia Graphs
|
46
|
+
|
47
|
+
``get_ganglia_graph`` will download one or more images of Ganglia graphs.
|
48
|
+
|
49
|
+
```
|
50
|
+
$ ./get_ganglia_graph -h
|
51
|
+
Usage: get_ganglia_graph [-hmpr]
|
52
|
+
|
53
|
+
get_ganglia_graph is used to generate images from Ganglia graphs.
|
54
|
+
|
55
|
+
It takes one or more hostnames and a single metric to build the appropriate URI(s) from which to generate images.
|
56
|
+
The script outputs the full path for each of the images that have been written.
|
57
|
+
|
58
|
+
-h, --host *HOST The FQDN of the host required to look up a metric/image in Ganglia. Specify multiple hosts with multiple '-h' arguments.
|
59
|
+
-m, --metric The name of the metric we want to see.
|
60
|
+
-p, --path An optional path in which to write the image files.
|
61
|
+
DEFAULT: /tmp
|
62
|
+
-r, --range The range of time for which the graph should look back.
|
63
|
+
Acceptable values are the same as thouse used by Ganglia (i.e '8hours', '8h, '1day', '1d', '3weeks', '3w')
|
64
|
+
DEFAULT: 8h (8 hours)
|
65
|
+
|
66
|
+
EXAMPLES
|
67
|
+
--------
|
68
|
+
1. Passing a single hostname and metric to get_ganglia_graph:
|
69
|
+
|
70
|
+
get_ganglia_graph -h mysql01.example.com -m part_max_used
|
71
|
+
|
72
|
+
2. Passing multiple hostnames and a metric to get_ganglia_graph:
|
73
|
+
|
74
|
+
get_ganglia_graph -h mysql01.example.com -h memcached01.example.com -m disk_free
|
75
|
+
|
76
|
+
3. Including an optional time range (12 hours):
|
77
|
+
|
78
|
+
get_ganglia_graph -h mysql01.example.com -h memcached01.example.com -m disk_free -r 12h
|
79
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# define the FQDN of servers we call on to provide context in notifications
|
2
|
+
servers:
|
3
|
+
ganglia: ganglia.example.com
|
4
|
+
graphite: graphite.example.com
|
5
|
+
splunk:
|
6
|
+
url: https://splunk.example.com:8089/services/search/jobs
|
7
|
+
username: splunkuser
|
8
|
+
password: splunkpass
|
9
|
+
logstash:
|
10
|
+
url: http://logstash.example.com:9200
|
11
|
+
result_field_trucate: 200
|
12
|
+
num_results: 10
|
13
|
+
logfile: /tmp/nagios-herald.log
|
14
|
+
formatter_dir: /usr/local/nagios-herald-formatters
|
data/etc/readme.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'app_conf'
|
2
|
+
|
3
|
+
module NagiosHerald
|
4
|
+
module Config
|
5
|
+
extend self
|
6
|
+
|
7
|
+
@config = {}
|
8
|
+
attr_accessor :config
|
9
|
+
|
10
|
+
# Public: Load the configuration file for use globally.
|
11
|
+
#
|
12
|
+
# options - The options hash built from command-line arguments.
|
13
|
+
#
|
14
|
+
# Returns a hash of the parsed config file merged with the command line options.
|
15
|
+
def load(options = {})
|
16
|
+
abort("Config file not found #{options['config_file']}") unless File.exists? options['config_file']
|
17
|
+
@config = AppConf.new
|
18
|
+
@config.load(options['config_file'])
|
19
|
+
@config = @config.to_hash
|
20
|
+
@config.merge!(options) # runtime options should override
|
21
|
+
@config
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|