2014年4月20日 星期日

What is OMD

How to Setup OMD in 1 Hour



What is OMD

OMD bundles Nagios together with many important add-ons and can easily be installed on every major Linux distribution. We provide pre-built packages for all enterprise Linux distributions and also for some other, such as Ubuntu.
Want to learn more about what OMD is about and what it can do for you? Check out my other post - Best Monitoring Solution - OMD (Nagios + Check_MK)
enter image description here

Install OMD Server on Ubuntu 12.04

Setup OMD Repository

Run the following on the Ubuntu server command line.
Stable
gpg --keyserver keys.gnupg.net --recv-keys F8C1CA08A57B9ED7
gpg --armor --export F8C1CA08A57B9ED7 | apt-key add -
echo 'deb http://labs.consol.de/repo/stable/ubuntu precise main' >> /etc/apt/sources.list.d/omd-stable.list
apt-get update
Testing-Release
gpg --keyserver keys.gnupg.net --recv-keys F8C1CA08A57B9ED7
gpg --armor --export F8C1CA08A57B9ED7 | apt-key add -
echo 'deb http://labs.consol.de/repo/testing/ubuntu precise main' >> /etc/apt/sources.list.d/omd-testing.list
apt-get update

Install OMD

apt-get install omd
And then just follow the instructions on the screen.

Setup Check_MK Agent on the Monitoring Target

You want to install the Check_MK Linux agent on the server you want to monitor - a remote host. The Check_Mk agent version on the repository is not up to date, so we will just download it from the website.

Install Check_MK Agent

Go to the check_mk download page. Find the right version of Linux agent package for your Check_MK version. You can find the version information once you log in to the OMD web interface and choose the Multisite GUI. On the top left hand side corner, next to the Check_MK logo you will see the version number of the Check_MK that is running on your OMD server.
Let’s assume we are using Check_MK server version 1.2.2p2, so we want to download the same version of Check_MK Linux agent on the target server and install it.
cd /usr/src/
wget http://mathias-kettner.de/download/check-mk-agent_1.2.2p2-2_all.deb
dpkg -i check-mk-agent_1.2.2p2-2_all.deb

Patch for MegaCli Check

You want to do this if you are running hardware RAID with LSI raid controller on your servers, otherwise you can skip this step.
MegaCli command currently doesn’t work with Linux kernel newer than 2.6 without a fix. Create a bash script using the following example but change the path of the original MegaCli command relative to your environment. Save the script under /usr/local/bin/and name it MegaCli. Make it executable and it will work.
#!/bin/bash

setarch x86_64 --uname-2.6 /usr/local/sbin/MegaCli $@
change the path above to locate your MegaCli command accordingly.

Setup Firewall

You can also skip this step if you don’t care about security. The following iptable rules will allow only the OMD server to contact this target host through tcp port 6556 and ping test. And this is assuming you have everything else locked down in the iptable rules, or else this is useless.
# Monitoring Agent communication
/sbin/iptables -A INPUT -p tcp -s 1.1.1.1 --dport 6556 -j ACCEPT
/sbin/iptables -A INPUT -p icmp -s 1.1.1.1 --icmp-type 8 -j ACCEPT
/sbin/iptables -A OUTPUT -p icmp -d 1.1.1.1 --icmp-type 0 -j ACCEPT
Change the 1.1.1.1 IP address to your OMD server IP address

Setup xinetd Connection

First, make sure you have xinetd service installed on your target host. It is used to open a tcp port 6556 for the OMD server to connect to and execute the Check_MK agent this way. If xinetd is not yet installed, install it now:
apt-get install xinetd
By default, the xinetd connection configuration will be setup by the package itself and reloaded. We want to secure the connection to allow only the OMD server to connect to the xinetd port. Edit /etc/xinetd.d/check_mk, uncomment the following line and add the OMD server’s IP besides 127.0.0.1
only_from      = 127.0.0.1 xx.xx.xx.xx
Now reload xinetd service
service xinetd reload

Start Monitoring Target Hosts

Now that you have successfully installed and enabled the Check_MK agent on a target host. Let’s start monitoring this little pain in the butt without further ado.
Log in to Check_MK Multisite interface with admin privilege. Under the WATO - Configuration section on the left hand side panel. Click on Host & Folders, then on the right hand side of the page, click the New Host button. You will see the following:
enter image description here
Enter the host name or IP address for the Hostname field. If you entered FQDN instead of IP address, make sure it is able to translate by DNS server to an IP address that is pointing to the host you want to monitor. By default, the Agent Type for monitoring any new host is using Check_MK Agent (Server), so all you need to do is just enter Hostnameinformation and click the Save & go to Services button at the end.
Your OMD server is now connecting to the check_mk agent on the target host. In a few seconds, you will see a list of available services to be monitored on the browser. Click on Activate missing button and you will see on the top of the page it tells you that you’ve made 1 change to the system.
enter image description here
You want to click on that button that tells you how many changes you have and then followed up by clicking Activate Changes! button. Now you should see the host and its services are now being monitored by the OMD server. Give it a few more minutes to populate some monitoring data to give you some visuals in the PNP4Nagios graphs.
enter image description here
Look how beautiful it is with all the basic health information you need in nice descriptive format and dynamic historical performance graph at your finger tips. This is just the tip of the iceberg of what OMD can do for you. I will be showing you the more advanced stuff from here on.
Now you know how to setup agents and add target hosts to be monitored, we are going to move on and find out how can we have the OMD system send notifications when things go south on any of your servers or services.

Add Custom Monitoring Script

This is a bigger topic which will be covered in future post. In short, there are 4 types of checks that sits on the target host instead of the OMD server.
  1. Check_MK local script
  2. Check_MK plug-in script
  3. Log watch plug-in
  4. Nagios plug-in via MRPE

Setup Notification

Flexible Notification from Check_MK

Source Document
Require Check_MK version > 1.2.1i2
Each user can have multiple notification methods with separate filters. That way you can for example send always emails, but SMS only for certain services or in certain time periods - without creating multiple contacts per user which is a huge shortcoming in traditional Nagios!
For each notification the Nagios core will simply pass them to the Check_MK flexible notification feature while providing all necessary information about the alert. Then Check_MK will process those notification however you want via the configuration in the GUI (WATO).

Preparing Notifications in General

Setting up the notifications requires some care. If you miss one of the following steps then the most probable case is that simply nothing will happen. You need to do the following:
  1. Create a contact group. WATO users: this is done with the module Contact Groups.
  2. Important: put some hosts/services into that contact group. WATO: Host & Service Parameters -> Grouping -> Assignment of hosts/services to contact groups.
  3. Create a user and put him into that contact group. Enable notifications for that user.
  4. Enter an email address. WATO: Users & Contacts
  5. Make sure that your monitoring server is correctly setup so that it can send emails. Test this with:
    root@linux# echo "Mailbody" | mail -s "Testsubject" test@example.com
  6. Restart your core with cmk -R in Linux command line or activating changes in WATO.

Testing and Debugging

When dealing with notifications it’s important to know how to test and debug your setup. A very easy way to send test-notifications is to pick a random service that is contained in the upper contact group, open the Commands dialog and select Custom Notification:
  1. Check nagios log
    ~/var/log/nagios.log
  2. Check Check_MK notification log
    ~/var/check_mk/notify/notify.log
WATO users find this setting in Global Settings -> Notifications -> Debug notifications. The resulting log file is in the directory notify below Check_MK’s var directory. OMD users find the file in ~/var/check_mk/notify/notify.log. Isn’t it great to have fixed paths in OMD?

Send Notification through Email to SMS Gateway

Some countries’ mobile carriers support sending Email to their SMS gateway which will convert that Email message to a SMS(text) message to the destination mobile phone number. For example if you have a 5555555555 T-Mobile phone number in the USA, you can send SMS message to that number with Email using the following Email address:
5555555555@tmomail.net
Having notifications being sent to mobile devices are extremely helpful if you are looking to setup some kind of 24/7 on call monitoring. I wrote a custom notification script that will let you send notification through Email to SMS gateway with the bare minimum information you need from an alert.
Download the most updated script email-sms-custom.sh from  Github.
Save my script into this directory on your OMD server and make it executable:
/omd/site/YOURSITE/local/share/check_mk/notifications/email-sms-custom.sh
Check_MK will consider every executable file in this directory as a notification script. You can use any programming language you want. If you use a scripting language (Shell, Perl, Python, etc.) then you can use a comment in the second line for giving the script aname. This name will appear in the UI for you to choose in a drop down list of different notification methods. I have named the script on the 2nd line to be SMS via Email to SMS Gateway.
Here is a list of all the Email to SMS Gateway provider in the world. Use them and test them at your own risk. All SMS message fees still applies.

Integration with Configuration Management Tools

Puppet

I am not sure if Orca is the best solution, but I have figured out how to use the Check_MK API to automate adding new hosts and services using the curl command. I am thinking to use that in combination with Puppet to automate the monitoring of new hosts. I will update the blog once that is in production.

OMD Maintenance

OMD Upgrade

  • OMD with lastest Check_MK version

OMD Backup/Migrate

  1. Install the same version of OMD package on your new hardware
  2. Stop omd on the source server
  3. Copy /omd/sites/ to your new target server.
  4. Mind the permission! Create the same “Site” user on the target server
  5. Start OMD on your target server

High Resolution Graphing for PNP4Nagios for One Year

When you have longer period of graphing data on PNP4Nagios, zooming into year graph down to the day seems to have averaged out greatly. You can’t rely on the graph to dig up any historic event metrics this way.
To address the issue, edit rra.cfg in your pnp4nagios config. Documentation is on rrdtool and pnp4nagios websites.
http://serverfault.com/questions/534186/how-to-change-the-amount-of-data-stored-in-pnp4nagios
http://apfelboymchen.net/gnu/rrd/create/

沒有留言:

張貼留言