Integration von Nagios & Asterisk Gerd Müller NETWAYS GmbH
Agenda http://www.netways.de Einleitung Standardalamierung Features Prinzipieller Aufbau benötigte Komponenten Gründe für Asterisk Installation Asterisk MBROLA, Voices Text2Pho Konfiguration Nagios Asterisk Demonstration Weitere Möglichkeiten
Einleitung
Standardalarmierung mit Nagios email + einfache Integration + nahezu Echtzeit + Direkte Integration in das Nagios Webfrontend + sehr gut verständlich - nicht interaktiv - benötigt entsprechendes Endgerät - von vielen Systemen abhängig => im Fehlerfall unzuverlässig SMS + einfache Integration + von wenigen Systemen abhängig + Handy als Empfänger genügt - nicht immer in Echtzeit - nicht ineraktiv Audiovisuell + zuverlässig - nicht standorunabhängig - komplexe Integration
Wichtigsten Features der Nagios Asterisk Integration Sichere Alarmieren Bestätigung des Erhalts Interaktives Alarmieren Steuerung von Nagios per Tastendruck Anspruchslos beliebiges DTMF fähiges Telefon als Gegenstelle genügt HFC/Fritzcard/Fritzbox/... zum Versand genügt Leicht erweiterbar über Dialplan innerhalb von Asterisk
benötigte Komponenten Nagios MBROLA Asterisk
Prinzipeller Ablauf Vorfall Alarm Wave Callfile Anwahl Menü Nagios MBROLA Asterisk
beliebige Kanäle direkt: ISDN, analog, GSM,... indirekt: SIP, IAX,... Gründe für Asterisk Hohe Ausfallsicherheit durch einfache Redundanz direkte Anbindung an verschiedene Mehrgeräteanschluss nahezu beliebig viele Kanäle möglich Hohe Zustellsicherheit durch Asterisk Spoolen der Calls Gruppieren von Kanälen Interactive voice response menus (IVR) External Commands Wiederholung OpenSource
Installation
Asterisk http://www.asterisk.org/ Download MBROLA / Voices http://tcts.fpms.ac.be/synthesis/mbrola.html Text2PHO http://www.ikp.uni-bonn.de/dt/forsch/phonetik/hadifix/hadif Nagios http://nagios.org :-)
Asterisk (1) nagiosdemo:/usr/local/src/asterisk 1.2.12.1# make install if cmp s.cleancount.lastclean ; then echo ; else \ make clean; cp f.cleancount.lastclean;\ fi build_tools/make_version_h > include/asterisk/version.h.tmp if cmp s include/asterisk/version.h.tmp include/asterisk/version... mv include/asterisk/version.h.tmp include/asterisk/version.h ; \ fi rm f include/asterisk/version.h.tmp... nagiosdemo:/usr/local/src/asterisk 1.2.12.1# make sample
Asterisk (2) nagiosdemo:/usr/local/src/asterisk 1.2.12.1# cp \ contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk nagiosdemo:/usr/local/src/asterisk 1.2.12.1# chmod 0755 /etc/init.d/asterisk nagiosdemo:/usr/local/src/asterisk 1.2.12.1# /etc/init.d/asterisk start Starting Asterisk PBX: asterisk. nagiosdemo:/usr/local/src/asterisk 1.2.12.1# asterisk r Asterisk 1.2.12.1, Copyright (C) 1999 2006 Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'show license' for details. ========================================================================= Connected to Asterisk 1.2.12.1 currently running on nagiosdemo (pid = 9528) X connectionli> Verbosity is at least 3 nagiosdemo*cli> exit
MBROLA nagiosdemo:/usr/local/src# mkdir /usr/local/bin/mbrola nagiosdemo:/usr/local/src# cd /usr/local/bin/mbrola/ nagiosdemo:/usr/local/bin/mbrola# unzip /usr/local/src/mbr301h.zip Archive: /usr/local/src/mbr301h.zip inflating: mbrola linux alpha inflating: mbrola linux i386 inflating: mbrola206a linux ppc inflating: mbrola SuSElinux ultra1.dat inflating: readme.txt inflating: mbrola_linux_libc5 inflating: mbrola302b linux ppc nagiosdemo:/usr/local/bin/mbrola# ln s mbrola linux i386 mbrola
Voices nagiosdemo:/usr/local/src# mkdir /usr/local/bin/mbrola/voices nagiosdemo:/usr/local/src# cd /usr/local/bin/mbrola/voices nagiosdemo:/usr/local/bin/mbrola/voices# unzip /usr/local/src/de3 000307.zip Archive: /usr/local/src/de3 000307.zip creating: de3/ inflating: de3/de3 creating: de3/test/ inflating: de3/test/demo.pho inflating: de3/test/de3test.pho extracting: de3/test/mbroli.ini inflating: de3/test/wetter.pho inflating: de3/test/de3tts.pho inflating: de3/de3.txt inflating: de3/license.txt
Text2Pho (1) nagiosdemo:/usr/local/bin/mbrola# unzip /usr/local/src/txt2pho.zip Archive: /usr/local/src/txt2pho.zip inflating: txt2pho/data/de1.mdp inflating: txt2pho/data/de2.mdp inflating: txt2pho/data/de3.mdp inflating: txt2pho/data/female.amp inflating: txt2pho/data/female.dur inflating: txt2pho/data/female.int inflating: txt2pho/data/female.prt inflating: txt2pho/data/hadifix.abk inflating: txt2pho/data/hadifix.cfg...
Text2Pho (2) nagiosdemo:/usr/local/bin/mbrola/txt2pho# vi txt2phorc DATAPATH=/usr/local/bin/mbrola/txt2pho/data/ INVPATH=/usr/local/bin/mbrola/txt2pho/data/ INVENTORY=female REDUCTION=0 SPEECHRATE=1.50 nagiosdemo:/usr/local/bin/mbrola/txt2pho# cp txt2phorc data/hadifix.cfg
Konfiguration
Nagios command define command{ command_name command_line } define command{ command_name command_line } host notify by voice /usr/bin/printf "%b" "Dies ist eine Nachricht von Nagios. Der Host.$HOSTNAME$. mit der Addresse.$HOSTADDRESS$. Hat den Status.$HOSTSTATE$. Die Details sind $HOSTOUTPUT$." /usr/lib/nagios/contrib/nagios2asterisk/call.pl n $CONTACTPAGER$ c 110 C "SIP/alarmphone" notify by voice /usr/bin/printf "%b" "Dies ist eine Nachricht von Nagios. Der Service.$SERVICEDESC$. auf dem Host.$HOSTNAME$. mit der Addresse.$HOSTADDRESS$. Hat den Status.$SERVICESTATE$. Die Details sind $SERVICEOUTPUT$." /usr/lib/nagios/contrib/nagios2asterisk/call.pl n $CONTACTPAGER$ c 110 C "SIP/alarmphone"
Nagios Call-Skript / Call-File nagiosdemo:/var/spool/asterisk/outgoing# cat 3975.call Channel: SIP/alarmphone MaxRetries: 2 RetryTime: 60 WaitTime: 30 Context: Voicealerts Extension: s Priority: 1 Callerid: 110 Set: MSG=voicealerts/3975 Set: CONTACT=1234 Set: HOST=passivehost Set: SERVICE=Passive Check StartRetry: 2094 1 (1158673213)
Asterisk sip.conf Lokales SIP-Phone als Beispiel für einen Kanal/ ein Endgerät: [alarmphone] type=friend user=alarmphone secret=alarmphone disallow=all allow=ulaw reinvite=no canreinvite=no qualify=yes dtmfmode=inband relaydtmf=yes host=dynamic
Asterisk extensions.conf [Voicealerts] exten => s,1,set(loop="54321") exten => s,2,set(group()=voicealert) exten => s,3,set(timeout(response)=4) exten => s,4,background(${msg}) exten => s,5,background(nag2ast/acknowledge) exten => s,6,background(nag2ast/disablenotification) exten => s,7,set(loop=${loop:1}) exten => s,8,gotoif($["${loop}x"!= "x"]?4) exten => s,9,hangup ; loop n times ; Wait for Digits ; Play Msg ; Loopcounter ; Finished? ; Hangup exten => 1,1,AGI(acknowledge.agi ${HOST} ${SERVICE} ${CONTACT}) exten => 1,2,Playback(nag2ast/acknowledged) exten => 1,3,Hangup exten => 2,1,AGI(disablenotifications.agi ${HOST} ${SERVICE} ${CONTACT}) exten => 2,2,Playback(nag2ast/disablednotifications) exten => 2,3,Hangup
Asterisk AGIs acknowledge.agi #!/bin/sh now=`date +%s` commandfile='/usr/local/nagios/var/rw/nagios.cmd' if [ $2 eq "" ] then printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;$1;1;1;0;$3;\n" $now > $commandfile else printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;$1;$2;1;1;0;$3;\n" $now > $commandfile fi
Demonstration
Weitere Möglichkeiten
Bei aktiven Alarmieren Nachricht per SMS anfordern. Eventhandler aktivieren External Commands Escalation Schedule Downtime...... Weitere Möglichkeiten Als Durchwahl zur Steuerung von Nagios Tactical Overview als IVR Disable Notifications...
weitere Fragen?
Herzlichen Dank!