Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support nagios plugins and their performance data (for graphite)
- Loading branch information
1 parent
b4bc699
commit 73facb1
Showing
12 changed files
with
152 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default["monitor"]["nagios_plugin_packages"] = ["nagios-plugins"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Nagios performance data to Graphite plain text mutator extension. | ||
# === | ||
# | ||
# Copyright 2013 Heavy Water Operations, LLC. | ||
# | ||
# Released under the same terms as Sensu (the MIT license); see LICENSE | ||
# for details. | ||
|
||
module Sensu | ||
module Extension | ||
class NagiosPerfData < Mutator | ||
def name | ||
'nagios_perfdata' | ||
end | ||
|
||
def description | ||
'converts nagios performance data to graphite plain text' | ||
end | ||
|
||
def run(event) | ||
result = [] | ||
client = event[:client] | ||
check = event[:check] | ||
|
||
# https://www.nagios-plugins.org/doc/guidelines.html#AEN200 | ||
perfdata = check[:output].split('|').last.strip | ||
|
||
perfdata.split(/\s+/).each do |data| | ||
# label=value[UOM];[warn];[crit];[min];[max] | ||
label, value = data.split('=') | ||
|
||
name = label.strip.gsub(/\W/, '_') | ||
measurement = value.strip.split(';').first.gsub(/[^-\d\.]/, '') | ||
|
||
path = [client[:name], check[:name], name].join('.') | ||
|
||
result << [path, measurement, check[:executed]].join("\t") | ||
end | ||
yield(result.join("\n") + "\n", 0) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Cookbook Name:: monitor | ||
# Recipe:: _filters | ||
# | ||
# Copyright 2013, Sean Porter Consulting | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
sensu_filter "actions" do | ||
attributes(:action => "eval: %w[create resolve].include? value") | ||
end | ||
|
||
sensu_filter "keepalives" do | ||
attributes( | ||
:check => { | ||
:name => "keepalive" | ||
} | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Cookbook Name:: monitor | ||
# Recipe:: _nagios_perfdata | ||
# | ||
# Copyright 2013, Sean Porter Consulting | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
cookbook_file "/etc/sensu/extensions/nagios_perfdata.rb" do | ||
source "extensions/nagios_perfdata.rb" | ||
mode 0755 | ||
notifies :create, "ruby_block[sensu_service_trigger]", :immediately | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Cookbook Name:: monitor | ||
# Recipe:: _nagios_plugins | ||
# | ||
# Copyright 2013, Sean Porter Consulting | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
node["monitor"]["nagios_plugin_packages"].each do |package_name| | ||
package package_name | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": "ntp", | ||
"type": "metric", | ||
"command": "/usr/lib/nagios/plugins/check_ntp -H time.nrc.ca", | ||
"subscribers": [ | ||
"all" | ||
], | ||
"interval": 60, | ||
"handlers": ["graphite_perfdata"] | ||
} |