Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added MongoDB monitoring feature #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ These cookbooks are defined as external dependencies:
* [zabbix-cookbook]
* [nginx]
* [chef_handler]
* [php]
* [cron]

All of them are available through the Opscode [community site][opscommunity].

Expand All @@ -62,6 +64,12 @@ Monitors the output of `apt-check` and reports, whether security or normal updat

Monitors the duration of `chef-client` runs and the success status. Failed runs and continuously slow execution (>60 seconds) are reported. Makes use of [chef_handler] and registers as a [report handler][chef-wiki-handler].

### <a name="recipes-mongodb"></a> MongoDB

Monitors **MongoDB** through a custom PHP script connectiong to the MongoDB server instance. Originally based on the [mikoomi MongoDB plugin](https://code.google.com/p/mikoomi/wiki/03) using an [updated fork](https://github.com/nightw/mikoomi-zabbix-mongodb-monitoring)

Credits for the original script go to the [mikoomi](https://code.google.com/p/mikoomi/) project.

### <a name="recipes-nginx"></a> nginx

Monitors **Nginx** through the output of `HttpStubStatusModule` at `/server_status`. This means that Nginx has to be compiled with `--with-http_stub_status_module`.
Expand Down
9 changes: 8 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
default["zabbix_custom_checks"]["nginx"]["port"] = 80
default["zabbix_custom_checks"]["nginx"]["port"] = 80

default["zabbix_custom_checks"]["zabbix_server_address"] = '127.0.0.1'
default["zabbix_custom_checks"]["zabbix_server_port"] = 10051

default["zabbix_custom_checks"]["mongodb"]["host"] = '127.0.0.1'
default["zabbix_custom_checks"]["mongodb"]["port"] = 27017
default["zabbix_custom_checks"]["mongodb"]["node_name_in_zabbix"] = 'mongo_node1.mydomain.tld'
3 changes: 3 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
recipe "zabbix-custom-checks::apache2", "Monitors Apache2 status"
recipe "zabbix-custom-checks::apt-check-update", "Monitors for system software updates"
recipe "zabbix-custom-checks::chef-client", "Monitors results und execution time of chef run (as Zabbix traps)"
recipe "zabbix-custom-checks::mongodb", "Monitors MongoDB status using a modified version of mikoomi Zabbix plugins"
recipe "zabbix-custom-checks::nginx", "Monitors Nginx status"
recipe "zabbix-custom-checks::openvz-virtual", "Monitors OpenVZ guest status"
recipe "zabbix-custom-checks::redis", "Monitors Redis status"
Expand All @@ -17,3 +18,5 @@
depends "zabbix"
depends "nginx"
depends "chef_handler"
depends "php"
depends "cron"
42 changes: 42 additions & 0 deletions recipes/mongodb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Cookbook Name:: zabbix-custom-checks
# Recipe:: mongodb
#
# Copyright 2014, Pal David Gergely <[email protected]>
#
# 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.
#

include_recipe "zabbix-custom-checks::default"

# Install PHP with the Mongo PECL package, since it's required for
# the mikoomi script to work
include_recipe 'php'
php_pear 'mongo'

template "#{node[:zabbix][:external_dir]}/mikoomi-mongodb-plugin.php" do
source "mongodb/mikoomi-mongodb-plugin.php.erb"
mode "755"
end

template "#{node[:zabbix][:external_dir]}/mikoomi-mongodb-plugin.sh" do
source "mongodb/mikoomi-mongodb-plugin.sh.erb"
mode "755"
end

# Adding cron job to run the MongoDB monitoring script in every minute
cron_d 'mongodb-monitoring' do
user node[:zabbix][:agent][:user]
shell '/bin/bash'
command "#{node[:zabbix][:external_dir]}/mikoomi-mongodb-plugin.sh -h #{node[:zabbix_custom_checks][:mongodb][:host]} -p #{node[:zabbix_custom_checks][:mongodb][:port]} -z #{node[:zabbix_custom_checks][:mongodb][:node_name_in_zabbix]} > /dev/null 2>&1"
end
Loading