Monitoring with Open Monitoring Distro Kel Vanderlip 3-1-2012 UUASC-LA 1 Kelvin Vanderlip Oracle Linux systems administrator, Sunrider International, Torrance [email protected]1. Overview of Nagios 2. Check_MK 3. What is the “Open Monitoring Distribution”? 4. Operating a monitoring system TONIGHT’S OUTLINE:
53
Embed
Computer monitoring with the Open Monitoring Distribution
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 1
Kelvin Vanderlip Oracle Linux systems administrator, Sunrider International, Torrance [email protected]
1. Overview of Nagios 2. Check_MK 3. What is the “Open Monitoring Distribution”? 4. Operating a monitoring system
Better to remain silent and be thought a fool than to speak out and remove all doubt. -- Abraham Lincoln (also attr. Confucius)
A thought for the night:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 3
In the beginning…
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 4
•You choose a job in which success depend on hard disks, NFS, DNS, DHCP, NIS, mgetty, Cron jobs, postfix, routing, FTP, swap space, fans, UPS systems, switches, CPU registers…
Why do you care about monitoring?
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 5
So you ask you sole staffer “Is it running” He says “I don’t know. Can I install NetSaint?”
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 6
“NetSaint is not affiliated with World Wide Digital Security, Inc. (WWDSI); Richard S. Carson and Associates, Inc; and the marks WEB SAINT, SAINT, SAINTWRITER, SAINTEXPRESS, and SAINTBASIC owned by Richard S. Carson and Associate”
Time passes:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 7
“This website stands as as testament to a long-running Open Source project that began with a simple idea in my mind. I had no inkling of the future success that NetSaint (and later Nagios) would come by. I almost never released it to the OSS community, but thank goodness I did. For without the constant flow of ideas from NetSaint and Nagios users, the project would have died off a long time ago. Cheers to everyone in the community who has participated in this project at some point in their life. My hat is off to you... -Ethan Galstad: Creator, Developer, Founder of NetSaint, Nagios, and Nagios Enterprises -and happy participant in a wider movement”
Meet Ethan Galstadt:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 8
As I said, how do you get started in the monitoring business?
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 9
Your server room grows, and you are still asking yourself: “Is it still working?”
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 10
Nagios is a scheduling engine. It is written in C. In runs on Linux. Its an RPM and a DEB. Input: Text configuration files (lots and lots!) Output: Schedule many forks to run external monitoring applications, some locally, some on remote servers. Input: Each called monitoring application returns status and performance information Output: status.dat, a “snapshot” text file kept up to date several times a minute describing the last state for each thing Nagios is checking
All about Nagios:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 11
######################################## # NAGIOS STATE RETENTION FILE # # THIS FILE IS AUTOMATICALLY GENERATED # BY NAGIOS. DO NOT MODIFY THIS FILE! ######################################## info { created=1330182965 version=3.2.3 last_update_check=0 update_available=0 update_uid=1330021387 last_version= new_version= } program { modified_host_attributes=0 modified_service_attributes=0 enable_notifications=1 active_service_checks_enabled=1 passive_service_checks_enabled=1 active_host_checks_enabled=1 passive_host_checks_enabled=1 enable_event_handlers=1 obsess_over_services=0 obsess_over_hosts=0 check_service_freshness=1 check_host_freshness=0 enable_flap_detection=1 enable_failure_prediction=1 process_performance_data=1 global_host_event_handler= global_service_event_handler= next_comment_id=40 next_downtime_id=1 next_event_id=572 next_problem_id=290 next_notification_id=457 }
The file goes on for about 4 more megabytes. You will never read this.
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 13
Nagios’ CGI is a visualization engine. It is written in C. In runs on Linux. Input: status.dat Output: web pages describing what’s in status.dat Input: Mouse clicks from the operator Output: changes to what is viewed, and changes to Nagios’ current state
When you think of Nagios, you think of its web output:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 14
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 15
There are lots of books about using Nagios. I have read most of them, and they all helped me out. A good Nagios implementation is a study in organizational behavior. If you run Nagios, and you find that no one else in the organization ever fixes anything Based on Nagios findings, stop looking at the screen and start talking to people. Socially, using Nagios successfully forces you to involve your co-workers. They Have to “buy in” to the Nagios outputs, which means they have to understand what it does and how it reports its findings. Managerially, keeping the email notification flood from Nagios under control is a pre-requisite if you want anyone to actually use an email as a basis for corrective action. Festival (a loud speaker) and SMS work great. An report based on an SQL query works great. Creating a Navy-like “Officer of the watch” worked in the U.K.
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 16
Doing Nagios means: Visit a server, and poke around. List what is important to check; For each important thing you want to check: Find or write some code to check it Set limits which your code can test to decide whether what you are checking is OK, or not Schedule the code to run over and over
If the test is not OK, send a message to the interested party (email seems to be a favorite).
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 17
Find or write some code to check it Grab a check from Nagios libexec apps – C, Perl, Python, bash – and put it where it can perform the check Set limits so your code can decide whether it’s OK or not
Configure command line parameters for the check where it will be called Schedule the code to run over and over
Reconfigure Nagios’s inputs to include the check and run it, perhaps using a transport mechanism
If the test is not OK, send a message to the interested party
Nagios checks return state to Nagios, which can fork to send notifications
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 18
Nagios transport systems: ACTIVE CHECKS
PASSIVE CHECKS
EXPORT STATE
SSH WORKS AS WELL…
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 19
PROBLEMS WITH THE TRADITIONAL NAGIOS APPROACH: How many times do you have to visit each server? How many times do you have to modify Nagios’s input files? How many times to you discover something you are not monitoring? Is all this worth it?
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 20
Home is no better. Can you count the servers?
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 21
Welcome to Check_MK!
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 22
So how about a new approach to managing Nagios? 1. Write a shell script which check everything you can think of checking on a Linux
box in one operation 2. Send this script to each server once. Configure each server’s xinetd so that the
script can be called using port 6556 3. Remotely run this script and feed its output to a process which writes a separate
Nagios configuration for each “service” found 4. Schedule Nagios to run a single check once a minute: call the remote shell script
over port 6556, and process the result in the “check” itself 5. The check returns each individual “service” measurement it finds to Nagios by
writing to the Nagios passive “external command file”
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 23
Write a shell script which check everything you can think of checking on a Linux box in one operation
It is already written for you by M.K., for HP-UX, Linux and Windows, probably others. Send this script to each server once. Configure each server’s xinetd so that the
script can be called using port 6556 Installing the shell script, creating directories, and reconfiguring and restarting xinetd
are done for you by the check_mk_agent.rpm or .deb
Remotely run this script and feed its output to a process which writes a separate Nagios configuration for each “service” found
Edit /opt/omd/<site>/etc/check_mk/main.mk to add a host, or use WATO, then: > check_mk –I <hostname>
Schedule Nagios to run a single check once a minute: call the remote shell script
over port 6556, and process the result in the “check” itself
The check returns each individual “service” measurement it finds to Nagios by writing to the Nagios passive “external command file”
> check_mk –O
Update the whole Nagios configuration for a server which has a new
configuration
> check_mk –II <hostname>
> check-mk -O And loop forever…
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 30
Again, to test and see what check_mk_agent will report on your server, install the RPM and then, locally, run
> telnet localhost 6556
To see what configuration has been created for Nagios, look at these files on the Nagios server: > less /opt/omd/<site>/etc/nagios/conf.d/check_mk_objects.cfg
> less /opt/omd/<site>/etc/nagios/conf.d/check_mk_templates.cfg
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 31
Long-term performance history is important. SLAs, correlating things over time. Nagios keeps almost no history. MySQL can save history, but needs maintenance (it fills up and Nagios stalls). Besides, you still need to “visualize” what is going on. RRD is a great database service to keep temporal history. It never fills up. RRD includes visualization tools (graphs) Traditionally, it has been a job to incorporate RRD into Nagios, usually using 3rd party packages.
Charts and graphs:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 32
“PNP is an addon to Nagios which analyzes performance data provided by plugins and stores them automatically into RRD-databases (Round Robin Databases, see RRD Tool). During development of PNP we set value on easy installation and little maintenance while running it. An administrator should do other things than configure graphing tools. “
Besides configuring Nagios and RRD, other things an administrator should be doing include Documentation. Wouldn’t it be great if you could move between the Nagios CGI screens, the PNP4Nagios Charts and a documentation Wiki? DokuWiki has worked for me. Also used in OMD for users, passwords, privileges across OMD applications (eg NagViz)
“DokuWiki is a standards compliant, simple to use Wiki, mainly aimed at creating documentation of any kind. It is targeted at developer teams, workgroups and small companies. It has a simple but powerful syntax which makes sure the datafiles remain readable outside the Wiki and eases the creation of structured texts. All data is stored in plain text files – no database is required. “
OMD Quick introduction First install the package matching your operating system: # zypper install omd-0.50-sles11sp1-25.x86_64.rpm Now create a monitoring instance (OMD calls this "site"): # omd create UULAC And let's start Nagios and all other processes: # omd start UULAC Other OMD features: •Run several monitoring sites in parallel •Install and use several different versions of OMD in parallel •Easily update, duplicate, rename and manage sites
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 36
nagios-3.2.3 The current version Nagios nagios-plugins Standard external apps which take and report measurements Nsca The listener for passive checks from remote servers check_nrpe The check application which calls checks on remote hosts
Shinken-0.6.99 (drop-in Nagios replacement, a whole world to explore) Nagvis The management-level view of state – live maps, schematics Pnp4nagios RRD and useful graphs. Compare services across hosts. rrdtool/rrdcached Check_MK God’s gift to the sysadmin MK Livestatus replace status.dat with a callable data provider Multisite Easily add additional monitoring sites.
Dokuwiki A nice no-SQL wiki linked from Check_MK’s screens Thruk A Perl CGI to view Nagios state (unexplored) Mod-Gearman Process queue manager, reduces Nagios fork load check_logfiles Locally read log files and report to Nagios check_oracle_health Locally perform several Oracle DB checks check_mysql_health Locally perform several Oracle DB checks Jmx4perl (unexplored) check_webinject wget-like web site checker, easy to use from Nagios check_multi The all singing, all dancing, Python-writing Nagios check
On itauxap1 at /opt/nrpe/libexec/check_ypwhich.sh #!/bin/sh
SERVER=`ypwhich`
if [ -z $SERVER ]
then
echo "CRITICAL: ypwhich NULL"
exit 2
fi
if [ $SERVER != "itauxap1.sunrider.com" ]
then
echo "CRITICAL: ypwhich INCORRECT: $SERVER"
exit 2
fi
echo ypwhich OK: $SERVER
exit 0
Example of adding a custom check run on a remote host using ssh:
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 48
#more check_lpstat-o.sh
#!/bin/sh
COUNT=`lpstat -o | wc -l`
echo lpstat queue $COUNT \| queue=$COUNT
exit 0
Another custom check, returns count of printer queue depth on HP-UX. KISS!
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 49
livestatus.o: It is a replacement output method for Nagios’s status.dat Like NDO, uses Nagios Event Broken API and loads as a module into Nagios. Unlike NDO, does not write; just responds to queries Used by Check_MK_Multisite, NagVis, Thruk to populate CGIs with data. Of course, its automatically set up in OMD…
livescheck: It is a replacement output method for Nagios’s heavy fork() Lightweight (100k RAM) helper process, called by Nagios to execute external applications. New, only in latest distro, I have not used it yet.
OMD includes the gearmand helper process, works for me.
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 51
MultiSite: It’s the CGI created by Mithias - “Check_MK” – it is what you see in your browser. “Multisite allows each user to customize the builtin views or create completely new views. This is done in the GUI by flexibly combining datasources, layouts, filters, sortings, groupings, column-painters and inter-view-links. The idea behind is, that the administrators of the monitoring system should be able to create custom views for their users or customers, while those are presented a GUI as simple as possible.” Reads data from livestatus.o, so refresh is almost instant – triggered by Nagios events, I think. Allows “multi-site” Nagios monitoring to be trivially easy: •Set up more than one site using OMD (local or distributed) •Edit “multisite.mk” •Watch the world – I have Hong Kong, they have me.
Includes a configurable sidebar, I have not been there yet.
Monitoring with Open Monitoring Distro
Kel Vanderlip 3-1-2012 UUASC-LA 52
Check_MK things we might not have touched on tonight: Python I have not had to look at it yet! WATO GUI management for Multisite Application-level monitoring Aggregation, BI services Logwatch grep your favorite logs and read from the GUI Windows “check_mk_agent.exe install” NagViz The management view – pays your bills! Mailing lists sign up, they are active.