added ability to start and stop system performance logging from astguiclient/admin.php page in the servers section. changes take one minute to go into effect

git-svn-id: svn://192.168.202.10@169 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-08-14 20:02:21 +00:00
parent 4f65a5f16c
commit 6a5b20dee2
4 changed files with 63 additions and 10 deletions
+35 -6
View File
@@ -51,13 +51,15 @@
# 60807-1605 - Changed to DBI
# 60808-1005 - changed to use /etc/astguiclient.conf for configs
# 60808-1500 - Fixed another bug in that caused crash with ** in extension
# 60814-1523 - SYSLOG and SYSPERF looked up from database, dynamic settings
#
$build = '60808-1500';
$build = '60814-1523';
# constants
$SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds
$SYSPERF_rec=0; # is dial-time recording turned on
$SYSLOG=0; # set to 1 to write log to a file
$DB=0; # Debug flag, set to 1 for debug messages WARNING LOTS OF OUTPUT!!!
$DBX=0; # Debug flag, set to 1 for debug messages WARNING LOTS OF OUTPUT!!!
$US='__';
@@ -186,7 +188,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
&event_logger;
### Grab Server values from the database
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,asterisk_version FROM servers where server_ip = '$server_ip';";
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,asterisk_version,sys_perf_log,vd_server_logs FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -206,6 +208,8 @@ while ($sthArows > $rec_count)
$DBSERVER_GMT = "$aryA[9]";
$DBext_context = "$aryA[10]";
$DBasterisk_version = "$aryA[11]";
$DBsys_perf_log = "$aryA[12]";
$DBvd_server_logs = "$aryA[13]";
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
@@ -218,6 +222,8 @@ while ($sthArows > $rec_count)
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;}
if ($DBsys_perf_log =~ /Y/) {$SYSPERF = '1';}
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
$rec_count++;
}
$sthA->finish();
@@ -626,6 +632,26 @@ if (!$telnet_port) {$telnet_port = '5038';}
print STDERR "Zap Clients: $Zap_client_list\n";
print STDERR "IAX2 Clients: $IAX2_client_list\n";
print STDERR "SIP Clients: $SIP_client_list\n";
### Grab Server values from the database
$stmtA = "SELECT sys_perf_log,vd_server_logs FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBsys_perf_log = "$aryA[0]";
$DBvd_server_logs = "$aryA[1]";
if ($DBsys_perf_log =~ /Y/) {$SYSPERF = '1';}
else {$SYSPERF = '0';}
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
}
$sthA->finish();
if ($SYSPERFDB)
{print "SYSPERF RELOAD: $DBsys_perf_log:$SYSPERF|$DBvd_server_logs:$SYSLOG\n";}
}
@list_chan_12=@MT;
@@ -1163,9 +1189,12 @@ $now_date = "$year-$mon-$mday $hour:$min:$sec";
##### open the log file for writing ###
sub event_logger
{
open(Lout, ">>$UPLOGfile")
|| die "Can't open $UPLOGfile: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
if ($SYSLOG)
{
open(Lout, ">>$UPLOGfile")
|| die "Can't open $UPLOGfile: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
}
$event_string='';
}
+3 -1
View File
@@ -85,7 +85,9 @@ ASTmgrUSERNAMEsend VARCHAR(20) NOT NULL default 'sendcron',
local_gmt VARCHAR(5) default '-5',
voicemail_dump_exten VARCHAR(20) NOT NULL default '85026666666666',
answer_transfer_agent VARCHAR(20) NOT NULL default '8365',
ext_context VARCHAR(20) NOT NULL default 'default'
ext_context VARCHAR(20) NOT NULL default 'default',
sys_perf_log ENUM('Y','N') default 'N',
vd_server_logs ENUM('Y','N') default 'Y'
);
@@ -1,7 +1,8 @@
############################################################ ADMIN
If you want to allow Consultative Transfers, a fronter to a closer, you can place CXFER as one of the number-to-dial presets and the proper dialstring will be sent to do a Local Consultative Transfer, then the agent can just LEAVE-3WAY-CALL and move on to their next call. If you want to allow Blind transfers of customers to a VICIDIAL AGI script for logging or an IVR, then place AXFER in the number-to-dial field. You can also specify an custom extension after the AXFER or CXFER, for instance if you want to do Internal Consultative transfers instead of Local you would put CXFER90009 in the number-to-dial field||
System Performance -<\/B> Setting this option to Y will enable logging of system performance stats for the server machine including system load, system processes and Asterisk channels in use. Default is N||
Server Logs -<\/B> Setting this option to Y will enable logging of all VICIDIAL related scripts to their text log files. Setting this to N will stop writing logs to files for these processes, also the screen logging of asterisk will be disabled if this is set to N when Asterisk is started. Default is Y||
############################################################ CLIENT
+23 -2
View File
@@ -16,10 +16,11 @@
# 60427-1137 - Fixed phone search bug
# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat
# 60814-1402 - Added off-hour gmt values (India, Australia, etc...)
# 60814-1540 - Added system performance logging and script logging options
#
$version = '2.0.1';
$build = '60814-1402';
$build = '60814-1540';
require("dbconnect.php");
@@ -198,6 +199,10 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];}
elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];}
if (isset($_GET["sys_perf_log"])) {$sys_perf_log=$_GET["sys_perf_log"];}
elseif (isset($_POST["sys_perf_log"])) {$sys_perf_log=$_POST["sys_perf_log"];}
if (isset($_GET["vd_server_logs"])) {$vd_server_logs=$_GET["vd_server_logs"];}
elseif (isset($_POST["vd_server_logs"])) {$vd_server_logs=$_POST["vd_server_logs"];}
##### BEGIN VARIABLE FILTERING FOR SECURITY #####
@@ -209,6 +214,8 @@ $computer_ip = ereg_replace("[^\.0-9]","",$computer_ip);
### Y or N ONLY ###
$active = ereg_replace("[^NY]","",$active);
$sys_perf_log = ereg_replace("[^NY]","",$sys_perf_log);
$vd_server_logs = ereg_replace("[^NY]","",$vd_server_logs);
### DIGITS ONLY ###
$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number);
@@ -857,6 +864,16 @@ echo "<TABLE WIDTH=98% BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR><TD ALIGN
<BR>
<B>Default Context -</B> The default dialplan context used for scripts that operate for this server. Default is 'default'
<BR>
<A NAME="servers-sys_perf_log">
<BR>
<B>System Performance -</B> Setting this option to Y will enable logging of system performance stats for the server machine including system load, system processes and Asterisk channels in use. Default is N.
<BR>
<A NAME="servers-vd_server_logs">
<BR>
<B>Server Logs -</B> Setting this option to Y will enable logging of all VICIDIAL related scripts to their text log files. Setting this to N will stop writing logs to files for these processes, also the screen logging of asterisk will be disabled if this is set to N when Asterisk is started. Default is Y.
<BR><BR><BR><BR>
@@ -1292,6 +1309,8 @@ echo "<tr bgcolor=#B6D3FC><td align=right>Local GMT: </td><td align=left><select
echo "<tr bgcolor=#B6D3FC><td align=right>VMail Dump Exten: </td><td align=left><input type=text name=voicemail_dump_exten size=20 maxlength=20 value=\"$row[14]\">$NWB#servers-voicemail_dump_exten$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>VICIDIAL AD extension: </td><td align=left><input type=text name=answer_transfer_agent size=20 maxlength=20 value=\"$row[15]\">$NWB#servers-answer_transfer_agent$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Default Context: </td><td align=left><input type=text name=ext_context size=20 maxlength=20 value=\"$row[16]\">$NWB#servers-ext_context$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>System Performance: </td><td align=left><select size=1 name=sys_perf_log><option>Y</option><option>N</option><option selected>$row[17]</option></select>$NWB#servers-sys_perf_log$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Server Logs: </td><td align=left><select size=1 name=vd_server_logs><option>Y</option><option>N</option><option selected>$row[18]</option></select>$NWB#servers-vd_server_logs$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=submit VALUE=SUBMIT></td></tr>\n";
echo "</TABLE></center>\n";
@@ -1510,7 +1529,7 @@ if ($ADD==41)
{
echo "<br>SERVER MODIFIED: $server_ip\n";
$stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';";
$stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs' where server_id='$old_server_id';";
$rslt=mysql_query($stmt, $link);
}
}
@@ -1542,6 +1561,8 @@ echo "<tr bgcolor=#B6D3FC><td align=right>Local GMT: </td><td align=left><select
echo "<tr bgcolor=#B6D3FC><td align=right>VMail Dump Exten: </td><td align=left><input type=text name=voicemail_dump_exten size=20 maxlength=20 value=\"$row[14]\">$NWB#servers-voicemail_dump_exten$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>VICIDIAL AD extension: </td><td align=left><input type=text name=answer_transfer_agent size=20 maxlength=20 value=\"$row[15]\">$NWB#servers-answer_transfer_agent$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Default Context: </td><td align=left><input type=text name=ext_context size=20 maxlength=20 value=\"$row[16]\">$NWB#servers-ext_context$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>System Performance: </td><td align=left><select size=1 name=sys_perf_log><option>Y</option><option>N</option><option selected>$row[17]</option></select>$NWB#servers-sys_perf_log$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Server Logs: </td><td align=left><select size=1 name=vd_server_logs><option>Y</option><option>N</option><option selected>$row[18]</option></select>$NWB#servers-vd_server_logs$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=submit VALUE=SUBMIT></td></tr>\n";
echo "</TABLE></center>\n";