From 961847d5b0b182ad85ddac78af48a813165ae5cb Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 18 Jul 2006 14:02:20 +0000 Subject: [PATCH] updated AST_manager_listen.pl to use /etc/astguiclient.conf for configs git-svn-id: svn://192.168.202.10@74 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_manager_listen.pl | 53 +++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/bin/AST_manager_listen.pl b/bin/AST_manager_listen.pl index e2064a10..53ebc2b3 100644 --- a/bin/AST_manager_listen.pl +++ b/bin/AST_manager_listen.pl @@ -35,6 +35,7 @@ # 51222-1553 - fixed parentheses bug in manager output # 60403-1230 - Added SVN/1.4 support for different output # 60718-0909 - changed to DBI by Marin Blu +# 60718-0955 - changed to use /etc/astguiclient.conf for configs # # constants @@ -80,12 +81,48 @@ else } ### end parsing run-time options ### +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } -### Make sure this file is in a libs path or put the absolute path to it -require("/home/cron/AST_SERVER_conf.pl"); # local configuration file +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP -if (!$DB_port) {$DB_port='3306';} +if (!$VARDB_port) {$VARDB_port='3306';} &get_time_now; @@ -97,7 +134,7 @@ use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sle use DBI; use Net::Telnet (); - $dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") or die "Couldn't connect to database: " . DBI->errstr; $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; @@ -543,8 +580,8 @@ $action_log_date = "$year-$mon-$mday"; sub event_logger { ### open the log file for writing ### - open(Lout, ">>$LILOGfile") - || die "Can't open $LILOGfile: $!\n"; + open(Lout, ">>$PATHlogs/listen_process.$action_log_date") + || die "Can't open $PATHlogs/listen_process.$action_log_date: $!\n"; print Lout "$now_date|$event_string|\n"; @@ -558,8 +595,8 @@ $event_string=''; sub manager_output_logger { -open(MOout, ">>/home/cron/listen.$action_log_date") - || die "Can't open /home/cron/listen.$action_log_date: $!\n"; +open(MOout, ">>$PATHlogs/listen.$action_log_date") + || die "Can't open $PATHlogs/listen.$action_log_date: $!\n"; print MOout "$now_date|$manager_string|\n";