*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "lib/autoload.php";
$status = -1;
$elapsed = microtime(true);
try {
    $config = dirname(__FILE__) . "/logmon.conf.php";
    $requiredConfigs = array($config);
    CheckConfig::configs($requiredConfigs);
    require_once $config;
    $requiredExtensions = array("mbstring", "pcre", "PDO");
    CheckConfig::extensions($requiredExtensions);
    mb_internal_encoding("UTF-8");
    Options::setDebug(DEBUG || array_search("--debug", $argv));
    Options::setPretend(array_search("--pretend", $argv));
    Options::setVerbose(Options::debug() || Options::pretend() || array_search("--verbose", $argv));
    Log::open(__FILE__, true, Options::verbose(), Options::debug());
    Log::notice(sprintf("Running '%s'...", implode(" ", $argv)));
    $monitor = Monitor::create(dirname(__FILE__) . "/monitor");
    if ($monitor !== false) {
        $sources = $monitor->getEnabledSources();
        $dbh = new DBH(DBDSN, DBUSER, DBPASS);
        $processor = new Processor($dbh);
        foreach ($sources as $source) {