#!/usr/bin/env ruby # # Copyright (C) 2006 SIPfoundry Inc. # Licensed by SIPfoundry under the LGPL license. # # Copyright (C) 2006 Pingtel Corp. # Licensed to SIPfoundry under a Contributor Agreement. # ############################################################################## # system requires require 'getoptlong' require 'parsedate' # set up the load path thisdir = File.dirname(__FILE__) # directory in which this file is located $:.unshift(thisdir) # application requires require 'call_resolver' require 'call_direction_plugin' require 'stunnel_connection' # Create a Call Resolver resolver = CallResolver.new if resolver.log.debug? resolver.log.debug("main called with these args: #{ARGV.join(' ')}") end # Parse command-line options # start: date/time from which to start analyzing call events # end: date/time at which to end the analysis (defaults to 1 day later) # daily: perform daily processing based on the configuration -- resolve # calls and/or purge old data # :TODO: Print out a helpful message if the caller enters no options or screws up opts = GetoptLong.new( [ "--start", "-s", GetoptLong::OPTIONAL_ARGUMENT ], [ "--end", "-e", GetoptLong::OPTIONAL_ARGUMENT ], [ "--daily", "-d", GetoptLong::NO_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ] ) # Init options start_time = end_time = nil purge_flag = false purge_time = 0 daily_flag = false # Extract option values # Convert start and end strings to date/time values. opts.each do |opt, arg| case opt when "--start" start_time = Time.parse(arg) when "--end" end_time = Time.parse(arg) when "--daily" daily_flag = true when "--help" print <