Added --run-check flag to audio processing steps 2-4 scripts to check for concurrency

git-svn-id: svn://192.168.202.10@1662 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2011-05-24 15:06:35 +00:00
parent 5f4fcfce08
commit 4a643e3ce0
4 changed files with 94 additions and 6 deletions
+23 -2
View File
@@ -26,13 +26,14 @@
#
# This program assumes that recordings are saved by Asterisk as .wav
#
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2011 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
#
# 80302-1958 - First Build
# 80731-2253 - Changed size comparisons for more efficiency
# 90727-1417 - Added GSW format option
# 101207-1024 - Change to GSW option because of SoX flag changes in 14.3.0
# 110524-1059 - Added run-check concurrency check option
#
$GSM=0; $MP3=0; $OGG=0; $GSW=0;
@@ -57,7 +58,8 @@ if (length($ARGV[0])>1)
print " [--GSM] = compress into GSM codec\n";
print " [--MP3] = compress into MPEG-Layer-3 codec\n";
print " [--OGG] = compress into OGG Vorbis codec\n";
print " [--GSW] = compress into GSM codec with RIFF headers and .wav extension\n\n";
print " [--GSW] = compress into GSM codec with RIFF headers and .wav extension\n";
print " [--run-check] = concurrency check, die if another instance is running\n\n";
exit;
}
else
@@ -77,6 +79,11 @@ if (length($ARGV[0])>1)
$T=1; $TEST=1;
print "\n-----TESTING -----\n\n";
}
if ($args =~ /--run-check/i)
{
$run_check=1;
if ($DB) {print "\n----- CONCURRENCY CHECK -----\n\n";}
}
if ($args =~ /--GSM/i)
{
$GSM=1;
@@ -167,6 +174,20 @@ foreach(@conf)
$i++;
}
### concurrency check
if ($run_check > 0)
{
my $grepout = `/bin/ps ax | grep $0 | grep -v grep`;
my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g);
if ($grepnum > 1)
{
if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";}
exit;
}
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
+22 -1
View File
@@ -32,7 +32,7 @@
#
# This program assumes that recordings are saved by Asterisk as .wav
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2011 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
#
# 80302-1958 - First Build
@@ -44,6 +44,7 @@
# 90818-1017 - Added a transfer limit and list limit options.
# 90827-2013 - Fixed list limit option
# 91123-0037 - Added FTP CLI options
# 110524-1049 - Added run-check concurrency check option
#
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -95,6 +96,7 @@ if (length($ARGV[0])>1)
print " [--WAV] = copy WAV files\n";
print " [--GSW] = copy GSM with RIFF headers and .wav extension files\n";
print " [--nodatedir] = do not put into dated directories\n";
print " [--run-check] = concurrency check, die if another instance is running\n";
print " [--ftp-server=XXX] = FTP server\n";
print " [--ftp-login=XXX] = FTP server login account\n";
print " [--ftp-pass=XXX] = FTP server password\n";
@@ -123,6 +125,11 @@ if (length($ARGV[0])>1)
$NODATEDIR=1;
if ($DB) {print "\n----- NO DATE DIRECTORIES -----\n\n";}
}
if ($args =~ /--run-check/i)
{
$run_check=1;
if ($DB) {print "\n----- CONCURRENCY CHECK -----\n\n";}
}
if ($args =~ /--transfer-limit=/i)
{
my @data_in = split(/--transfer-limit=/,$args);
@@ -271,6 +278,20 @@ foreach(@conf)
$i++;
}
### concurrency check
if ($run_check > 0)
{
my $grepout = `/bin/ps ax | grep $0 | grep -v grep`;
my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g);
if ($grepnum > 1)
{
if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";}
exit;
}
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
+27 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# AST_CRON_audio_3_newftp.pl version 2.2.0
# AST_CRON_audio_3_newftp.pl version 2.4
#
# This is a STEP-3 program in the audio archival process. Normally you can run it
# every 3 minutes and copies the recording files to an FTP server.
@@ -52,10 +52,12 @@
# --ftp-host="10.10.10.15" --ftp-port=21 --ftp-user="username" --ftp-pass="password" --ftp-dir="RECORDINGS" \
# --url-path="http://10.10.10.15/RECORDINGS" --transfer-limit=50 --list-limit=200 --campaign_id="TESTCAMP1-TESTCAMP2"
#
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2011 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG:
# 90930-1405 - mikec - first build
# 110524-1054 - Added run-check concurrency check option
#
use 5.008;
use strict;
@@ -72,6 +74,7 @@ use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sle
my $debug = 0;
my $debugX = 0;
my $test = 0;
my $run_check = 0;
my $pingtype = "tcp";
my $pingtimeout = 5;
@@ -192,6 +195,7 @@ if (length($ARGV[0])>1) {
print " [--transfer-limit=XXX] = the number of files to transfer before giving up. Default is 1000\n";
print " [--list-limit=XXX] = number of files to list in the directory before moving on\n";
print " [--no-date-dir] = does not put the files in a dated directory.\n";
print " [--run-check] = concurrency check, die if another instance is running\n";
print " [--campaign_id] = which OUTBOUND campaigns to transfer files for in a '-' delimited list \n";
print " (this only works for outbound calls, not inbound or transfers)\n";
print " [--ingroup_id] = which ingroups to transfer files for in a '-' delimited list\n";
@@ -217,6 +221,12 @@ if (length($ARGV[0])>1) {
print "\n----- NO DATE DIRECTORIES -----\n\n";
}
}
if ($args =~ /--run-check/i)
{
$run_check=1;
if ($debug) {print "\n----- CONCURRENCY CHECK -----\n\n";}
}
if ($args =~ /--ping-type=/i) {
my @data_in = split(/--ping-type=/,$args);
$pingtype = $data_in[1];
@@ -369,6 +379,21 @@ if ($ingrp_check) {
@ingrp_array = split(/-/,$ingroups);
}
### concurrency check
if ($run_check > 0)
{
my $grepout = `/bin/ps ax | grep $0 | grep -v grep`;
my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g);
if ($grepnum > 1)
{
if ($debug) {print "I am not alone! Another $0 is running! Exiting...\n";}
exit;
}
}
#### connect to the db ####
my $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
+22 -1
View File
@@ -26,10 +26,11 @@
#
# This program assumes that recordings are saved by Asterisk as .wav
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2011 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
#
# 91123-0005 - First Build
# 110524-1052 - Added run-check concurrency check option
#
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -71,6 +72,7 @@ if (length($ARGV[0])>1)
print " [--help] = this screen\n";
print " [--debug] = debug\n";
print " [--debugX] = super debug\n";
print " [--run-check] = concurrency check, die if another instance is running\n";
print " [--transfer-limit=XXX] = number of files to transfer before exiting\n";
print " [--list-limit=XXX] = number of files to list in the directory before moving on\n";
print " [--ftp-server=XXX] = FTP server\n";
@@ -104,6 +106,11 @@ if (length($ARGV[0])>1)
$NODATEDIR=1;
if ($DB) {print "\n----- NO DATE DIRECTORIES -----\n\n";}
}
if ($args =~ /--run-check/i)
{
$run_check=1;
if ($DB) {print "\n----- CONCURRENCY CHECK -----\n\n";}
}
if ($args =~ /--transfer-limit=/i)
{
my @data_in = split(/--transfer-limit=/,$args);
@@ -215,6 +222,20 @@ foreach(@conf)
$i++;
}
### concurrency check
if ($run_check > 0)
{
my $grepout = `/bin/ps ax | grep $0 | grep -v grep`;
my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g);
if ($grepnum > 1)
{
if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";}
exit;
}
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}