Merlin Nürnberg, 07.10.2010 Open Source Monitoring Conference 2010 Wolfgang Barth 1
Urgeschichtliches Merlin war ursprünglich für verteiltes Monitoring gedacht als Ersatz für NSCA und nicht als Alternative zu NDOutils verteilt, redundant Datenbank Open Source Monitoring Conference 2010 Wolfgang Barth 2
Verteiltes Monitoring (1) View Web / Gui view view on demand nagios1 nagios2 zentrale Sicht auf autonome Nagios-Installationen Thruk, Multisite, aber auch NagVis Open Source Monitoring Conference 2010 Wolfgang Barth 3
Verteiltes Monitoring (2) Collect nagios collect nagios1 nagios2 zentrale Instanz sammelt alle Daten Nagios (OCHP, OCSP), Merlin Open Source Monitoring Conference 2010 Wolfgang Barth 4
Verteiltes Monitoring (3) Redundant nagios1 exchange nagios2 identisch konfigurierte Nagios-Server Redundanz durch: vollständige Doppelinstallation Clustermechanismen (z.b. DRDB) echten Datenaustausch (Merlin) Open Source Monitoring Conference 2010 Wolfgang Barth 5
Verteiltes Monitoring (4) Worker nagios order collect order worker1 worker2 eine Nagios-Instanz, verteilte Taskausführung DNX, mod_gearman Open Source Monitoring Conference 2010 Wolfgang Barth 6
Verteiltes Einsammeln!= verteiltes Nagios eine einzelne Nagios-Installation kann ebenfalls verteilte Information einsammeln: check_multi check_mk Passive Checks allgemein: > z.b. NSCA + Addons (z.b. Cron) Open Source Monitoring Conference 2010 Wolfgang Barth 7
Merlin Releases 0.6.8, which is widely used in production: database capabilities were added and stabilized 0.7 stable but never feature-tweaked to perfection: report-data functionality merged in birth of merlin-apps 0.8 never released as stable: command propagation implemented performance data from poller and peer nodes are handled properly 0.9 scheduled for stable before end of october: config sync from master to poller and between peers implemented merlin-apps helper scripts added Open Source Monitoring Conference 2010 Wolfgang Barth 8
Merlin 0.9.x 0.9.0 : ~ 25.10.2010 (stable) kommt bei ca. 500 Kunden von op5 produktiv zum Einsatz Bugfixes, zusätzliche Features, Addons abhängig von Kundenwünschen 0.9.2: feature stable production proved version Dezember 2010... Januar 2011 Open Source Monitoring Conference 2010 Wolfgang Barth 9
Dämonisches... nagios1 mod /* Both of these conversions involve a fair deal of Black Magic. If you don't understand what's happening, please don't fiddle. */ proprietäres Protokoll nagios2 mod backlog merlind merlind backlog DB DB Open Source Monitoring Conference 2010 Wolfgang Barth 10
Nagios Event Broker Module abonnieren Channels einklinken von Callback-Routinen Callbacks blockieren Nagios so schnell wie möglich wieder zu Nagios zurückgeben Daemon statt direktes Schreiben in die Datenbank Callbacks = ReadOnly One-Way: Information aus Nagios Schreiben: globale Nagios- Datenstrukturen modifizieren Open Source Monitoring Conference 2010 Wolfgang Barth 11
Was wird übertragen? peer peer Kommandos Check-Ergebnisse incl. Performancedaten nicht aber Konfiguration => manuelle Synchronisation! Open Source Monitoring Conference 2010 Wolfgang Barth 12
Installation (1) Git verwenden: git clone git://git.op5.org/nagios/merlin.git Tar auf www.op5.org ist selten aktuell! git checkout master next git tag -l Aktuell: v0.9.0-beta2 (2010-10-01) Webseite... hinkt ständig hinter Open Source Monitoring Conference 2010 Wolfgang Barth 13
Installation (2) Kompilieren: benötigt libdbi! Debian: make aptitude install libdbd-mysql \ libdbi0-dev php5-cli php5-mysql Kein./configure... aber nicht: make install! Open Source Monitoring Conference 2010 Wolfgang Barth 14
Installation (3) Installskript benötigt passwortlosen Zugriff als root zu MySQL: ~/.my.cnf verwenden [client] password=verysecret Test: mysql als root bash install-merlin.sh \ --nagios-cfg=/etc/nagios3/nagios.cfg \ --dest-dir=/usr/local/nagios/addons/merlin \ --db-type=mysql --db-user=merlin \ --db-pass=merlin --db-name=merlin Open Source Monitoring Conference 2010 Wolfgang Barth 15
Konfiguration: merlin.conf ipc_socket = /var/run/merlin/ipc.sock; module { log_file = /var/log/merlin/neb.log; log_level = warn; } daemon { pidfile = /var/run/merlin/merlin.pid; log_level = warn; log_file = /var/log/merlin/daemon.log; import_program = php /usr/lib/merlin/import.php; port = 15551; database { name = merlin; user = merlin; pass = mostlysecret; host = localhost; type = mysql; } } Open Source Monitoring Conference 2010 Wolfgang Barth 16
merlin.conf - backlog ipc_socket = /var/run/merlin/ipc.sock; ipc_binlog_dir = /var/spool/merlin/backlogs; module {... } daemon {... } Bug: ipc_binlog_dir wird nicht ausgewertet Binlog wird erst ab 10MByte geschrieben Open Source Monitoring Conference 2010 Wolfgang Barth 17
Merlin redundant alle Informationen werden an die anderen Instanzen übermittelt Arbeitsteilung: der Check führt immer nur ein Peer aus (Theorie) Failover: fällt ein peer aus, übernimmt der andere die Checks vollständig (Theorie) nagios1 + merlin peer exchange nagios2 + merlin peer Open Source Monitoring Conference 2010 Wolfgang Barth 18
peer2peer: wer führt was aus? Jeder Peer checkt die Verfügbarkeit anderer Peers CTRL_ACTIVE, CTRL_INACTIVE, disconnect Logik: if (num_checks % num_peers == peer_id) return NEBERROR_CALLBACK_OVERRIDE; /* block the check */ else return GO_AHEAD_AND_RUN_THE_CHECK_MR_NAGIOS; Open Source Monitoring Conference 2010 Wolfgang Barth 19
Konfiguration: peer nagios1 peer nagios2 { address = 192.168.1.2; port = 15551; } nagios2 peer nagios1 { } address = 192.168.1.1; port = 15551; nagios1 + merlin peer exchange nagios2 + merlin peer Open Source Monitoring Conference 2010 Wolfgang Barth 20
Merlin verteilt Einer für Alle: NOC (Zentrale) Alle für Einen: Poller (Sender) Ein Nagios-Host kann gleichzeitig NOC und Poller sein! Multi-Tier noc chief collect nagios1 poller nagios2 poller Open Source Monitoring Conference 2010 Wolfgang Barth 21
Konfiguration: noc-poller chief (=noc): poller slave { address = 192.168.1.1; port = 15551; hostgroup = SLAVE_SHOULD_WATCH_ON; } slave (=poller): noc chief { address = 192.168.1.2; port = 15551; Pflichtangabe } wer führt was aus? Open Source Monitoring Conference 2010 Wolfgang Barth 22
peer, noc, poller (1) jeder Host kann gleichzeitig peer, noc und poller sein maximal 65534 neighbours haben: neighbour = poller noc peer Empfehlung: eindeutige Hierarchie hosta ist entweder noc, oder poller, oder peer von hostb Open Source Monitoring Conference 2010 Wolfgang Barth 23
peer, noc, poller (2) kritisch: gleiche Nagios-Konfiguration Synchronisationsmechanismus ab 0.9.x vorhanden: erfordert ssh object_config { # peer, poller; normal case push = mon oconf push # peer, noc; should not happen # fetch = mon oconf fetch } Open Source Monitoring Conference 2010 Wolfgang Barth 24
Merlin: Big Picture peer to peer noc noc noc noc noc noc noc poller poller poller poller poller poller Open Source Monitoring Conference 2010 Wolfgang Barth 25
Merlins Datenbank Warum überhaupt eine Datenbank? Weil's einfach ist Weil die NDOutils ein furchtbares Datenbanklayout haben anständiges GUI Prinzip: ein Objekt, eine Tabelle keine historischen Daten (außer: statechanges, program start/stop, downtimes) M:N-Relationen in eigener Tabelle, z.b. host_hostgroups Open Source Monitoring Conference 2010 Wolfgang Barth 26
SELECT Service Status NDOutils: SELECT nagios_instances.instance_id, nagios_instances.instance_name, nagios_services.host_object_id, obj1.name1 AS host_name, nagios_services.service_object_id, obj1.name2 AS service_description, nagios_servicestatus.* FROM `nagios_servicestatus` LEFT JOIN nagios_objects as obj1 ON nagios_servicestatus.service_object_id = obj1.object_id LEFT JOIN nagios_services ON nagios_servicestatus.service_object_id = nagios_services.service_object_id LEFT JOIN nagios_instances ON nagios_services.instance_id = nagios_instances.instance_id WHERE nagios_services.config_type = '1' ORDER BY instance_name ASC, host_name ASC, service_description ASC Merlin: SELECT * FROM service ORDER by host_name, service_description ASC Open Source Monitoring Conference 2010 Wolfgang Barth 27
MerlinDB (1): Tabellen command, comment, contact, contact_access, contact_contactgroup, contactgroup, custom_vars, db_version, downtime, gui_access, gui_action_log, host, host_contact, host_contactgroup, host_hostgroup host_parents, hostdependency, hostescalation, hostescalation_contact, hostescalation_contactgroup, hostgroup, notification, program_status, report_data, scheduled_downtime, service, service_contact, service_contactgroup, service_servicegroup, servicedependency, serviceescalation, serviceescalation_contact, serviceescalation_contactgroup, servicegroup, timeperiod, timeperiod_exclude Open Source Monitoring Conference 2010 Wolfgang Barth 28
MerlinDB (2) Verknüpfung von Tabellen:... where hosts.host_name = comments.host_name... keine Objekt-IDs brandneu: jetzt auch Performance- Daten Tabelle muss manuell angelegt werden Open Source Monitoring Conference 2010 Wolfgang Barth 29
Merlin als NDO-Ersatz Support durch NagVis??? (1.4.x) backendtype = merlinmy DB- Performance ndo +merlin merlin Open Source Monitoring Conference 2010 Wolfgang Barth 30
Merlins Orakel 1.0 (well, it could be): node capability exchange and configuration better notification management (requires changes in Nagios core) poller-to-master configuration pushing 1.1 (also unplanned): encrypted communication dynamic poller/peer configuration with preshared keys 1.2 (may never happen): daemon-to-daemon file transfer capabilities 2.0 (far ahead): introduction of leaf-pollers for self-checking auto-configuration of servers 2.1 (even further ahead): master autodiscovery, making server installation supersimple Open Source Monitoring Conference 2010 Wolfgang Barth 31
Ressourcen http://www.op5.org/community/ op5-users@lists.op5.com Open Source Monitoring Conference 2010 Wolfgang Barth 32
das wars... Vielen Dank für Ihre Aufmerksamkeit. Fragen? Open Source Monitoring Conference 2010 Wolfgang Barth 33