#!/usr/bin/php
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2006-2008 Xinn.org |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| 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. |
+-------------------------------------------------------------------------+
| ClearSite/ALOE, A Long Overdue Enterprise network managment solution! |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Xinn.org. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://aloeusers.net |
| http://clearsite.sourceforge.net |
| http://aloenms.net |
| http://clear-site.net |
| http://clear-site.info |
| http://xinn.org/ClearSite.html |
+-------------------------------------------------------------------------+
*/
$action = $argv[1];
$configpath = str_replace(array("/aloe/cron/aloe_cron.php", "\aloe\cron\aloe_cron.php"), "", __FILE__) . "/config.php";
include_once($configpath);
include_once("$cs_base_path/include/aloe/aloe_config.php");
if ($action == "dbwalk") {
include_once("$base_path/cron/aloe_rarpwalk.php");
};
// Creates device arrays
$device_ID = array();
mysql_connect("$DBhost:$DBport",$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$devicelist_query = "SELECT device_ID, new_device FROM devices WHERE device_status=\"online\"";
$devicelist_result = mysql_query($devicelist_query);
while ($devicelist_row = mysql_fetch_assoc($devicelist_result)) {
if (($action != "rrdwalk") or ($action == "rrdwalk" and $devicelist_row["new_device"] == "N")) {
$device_ID[] = $devicelist_row["device_ID"];
};
};
// Kicks off walks for each device using arrays created above
for ($x=0; $x<count($device_ID); $x++) {
$fh[$x] = popen("$base_path/cron/aloe_$action.php $device_ID[$x]", "r");
};
// Grabs results from the walks and prints them to the screen
$rs = "";
for ($x=0; $x<count($device_ID); $x++) {
$st = "";
while (!feof($fh[$x])) {
$st .= fgets($fh[$x]);
};
$rs .= $st;
};
print "$rs";
mysql_close();
?>