#!/usr/bin/perl ### ### This program has no warranty or anything. ### Consider it public domain. ### ### This Update Script uses Perl LWP and HTTP::Request::Common ### If you would prefer a a script which uses CURL, look ### at http://netmonks.ca/projects/opensource/asterisk/dundi-update-curl.txt ### #### Settings: #### ## Set this to your local EID my $LOCAL_EID = "00:YO:UR:EI:DH:ER"; ## Set this to your hostname or IP, ## or blank if you don't want one to show my $LOCAL_NAME = "your.host.or.ip"; ## The command to issue to get your 'dundi show peers' my $ASTERISK = "/usr/sbin/asterisk -rx 'dundi show peers'"; ## DUNDi Mapping Target my $TARGET = 'http://vulcan.dmacc.cc.ia.us/dundi/add.cgi'; #### Stop Changing Here #### my $SHOWPEERS = ""; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->agent("DundiUpdate/LWP-1.0"); open F, "$ASTERISK|"; while() { $SHOWPEERS .= $_ if m/^[0-9a-f]/; } close F; my $req = POST $TARGET, [ label => $LOCAL_NAME, local_eid => $LOCAL_EID, showpeers => $SHOWPEERS ]; print "Sending the following peer list:\n"; print $SHOWPEERS; my $resp = $ua->request($req)->content(); if($resp =~ m/^DUNDI_UPDATE_OK/) { print "Server Update Successful\n"; } else { $resp =~ m/:\s+(.*)$/; print "Server Update FAILED: $1\n"; }