no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:asterisk-iax2 [2009/11/23 05:32] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== iax2.sh ====== | ||
+ | |||
+ | ^ Author | [[ etmsys@rit.edu | Eric Meddaugh ]] | | ||
+ | ^ Compatibility | Xymon 4.2 | | ||
+ | ^ Requirements | Perl | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2008-09-11 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | Monitor IAX2 on an Asterisk server. Needs access to UDP port 4569. | ||
+ | |||
+ | ===== Installation ===== | ||
+ | === Client configuration === | ||
+ | |||
+ | None. | ||
+ | |||
+ | === Server configuration === | ||
+ | |||
+ | Add following to the hobbitlaunch.cfg file | ||
+ | < | ||
+ | [iax2] | ||
+ | ENVFILE / | ||
+ | NEEDS hobbitd | ||
+ | CMD $BBHOME/ | ||
+ | LOGFILE $BBSERVERLOGS/ | ||
+ | INTERVAL 1m | ||
+ | </ | ||
+ | |||
+ | Add the " | ||
+ | |||
+ | ===== Source ===== | ||
+ | |||
+ | ==== Monitor Code ==== | ||
+ | iax2.sh -- Place in ext directory, this is the main script hobbit calls. | ||
+ | <hidden onHidden=" | ||
+ | < | ||
+ | #!/bin/sh | ||
+ | |||
+ | # | ||
+ | |||
+ | COLUMN=iax2 | ||
+ | TIMEOUT=10 | ||
+ | |||
+ | $BBHOME/ | ||
+ | while read L | ||
+ | do | ||
+ | set $L | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # linux use "/ | ||
+ | / | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | if [ ${OK} -eq 0 -a ${BAD} -ge 1 ] ; then | ||
+ | COLOR=red | ||
+ | MSG=" | ||
+ | |||
+ | `cat $BBTMP/ | ||
+ | |||
+ | Seconds: ${SECONDS} | ||
+ | " | ||
+ | elif [ ${OK} -ge 1 -a ${BAD} -ge 1 ] ; then | ||
+ | COLOR=yellow | ||
+ | MSG=" | ||
+ | |||
+ | `cat $BBTMP/ | ||
+ | |||
+ | Seconds: ${SECONDS} | ||
+ | " | ||
+ | else | ||
+ | COLOR=green | ||
+ | MSG=" | ||
+ | |||
+ | `cat $BBTMP/ | ||
+ | |||
+ | Seconds: ${SECONDS} | ||
+ | " | ||
+ | fi | ||
+ | |||
+ | $BB $BBDISP " | ||
+ | |||
+ | $MSG" | ||
+ | done | ||
+ | |||
+ | exit 0 | ||
+ | </ | ||
+ | </ | ||
+ | \\ | ||
+ | |||
+ | iax2ping.pl -- Place in ext folder | ||
+ | <hidden onHidden=" | ||
+ | <code perl> | ||
+ | # | ||
+ | #udp ping tool | ||
+ | |||
+ | use IO:: | ||
+ | $target = shift; #" | ||
+ | $target_port = 4569; | ||
+ | |||
+ | socket(PING, | ||
+ | |||
+ | # Build Packet ... | ||
+ | # Names from ethereal filter of registration packet | ||
+ | |||
+ | $src_call = " | ||
+ | $dst_call = " | ||
+ | $timestamp = " | ||
+ | $outbound_seq = " | ||
+ | $inbound_seq = " | ||
+ | $type = " | ||
+ | $iax_type = " | ||
+ | $msg = pack " | ||
+ | |||
+ | # Send UDP packet | ||
+ | |||
+ | $ipaddr = inet_aton($target); | ||
+ | $sendto = sockaddr_in($target_port, | ||
+ | |||
+ | send(PING, $msg, 0, $sendto) == length($msg) or die " | ||
+ | |||
+ | # Listen for responses... listen for TIMEOUT seconds and report all responders (works for broadcast pings) | ||
+ | |||
+ | $MAXLEN = 1024; | ||
+ | $TIMEOUT = 15; | ||
+ | |||
+ | eval { | ||
+ | local $SIG{ALRM} = sub { die "alarm time out"; }; | ||
+ | alarm $TIMEOUT; | ||
+ | $total = 3; | ||
+ | $count = 0; | ||
+ | while ($count < $total) { | ||
+ | $recvfrom = recv(PING, $msg, $MAXLEN, 0) or die "recv: $!"; | ||
+ | ($port, $ipaddr) = sockaddr_in($recvfrom); | ||
+ | $respaddr = inet_ntoa($ipaddr); | ||
+ | print " | ||
+ | $count++; | ||
+ | } | ||
+ | |||
+ | $type = " | ||
+ | $iax_type = " | ||
+ | $msg = pack " | ||
+ | send(PING, $msg, 0, $sendto) == length($msg) or die " | ||
+ | |||
+ | }; | ||
+ | |||
+ | if ($@) { | ||
+ | print "Error Timeout waiting for packet from: $target\r\n"; | ||
+ | $type = " | ||
+ | | ||
+ | $msg = pack " | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | |||
+ | ===== To Do ===== | ||
+ | |||
+ | ===== Credits ===== | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2008-09-11** | ||
+ | * Initial release | ||