2008-04-03 19:04:24 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
|
2010-02-15 23:56:30 +00:00
|
|
|
|
2010-02-27 14:44:38 +00:00
|
|
|
include("includes/defaults.inc.php");
|
2008-04-03 19:04:24 +00:00
|
|
|
include("config.php");
|
|
|
|
include("includes/functions.php");
|
2010-02-15 23:56:30 +00:00
|
|
|
include("includes/discovery/functions.inc.php");
|
2008-04-03 19:04:24 +00:00
|
|
|
|
|
|
|
$start = utime();
|
|
|
|
|
|
|
|
### Observer Device Discovery
|
|
|
|
|
|
|
|
echo("Observer v".$config['version']." Discovery\n\n");
|
|
|
|
|
|
|
|
if($argv[1] == "--device" && $argv[2]) {
|
|
|
|
$where = "AND `device_id` = '".$argv[2]."'";
|
|
|
|
} elseif ($argv[1] == "--os") {
|
|
|
|
$where = "AND `os` = '".$argv[2]."'";
|
|
|
|
} elseif ($argv[1] == "--odd") {
|
|
|
|
$where = "AND MOD(device_id,2) = 1";
|
|
|
|
} elseif ($argv[1] == "--even") {
|
|
|
|
$where = "AND MOD(device_id,2) = 0";
|
|
|
|
} elseif ($argv[1] == "--all") {
|
|
|
|
$where = "";
|
|
|
|
} else {
|
|
|
|
echo("--device <device id> Poll single device\n");
|
|
|
|
echo("--os <os string> Poll all devices of a given OS\n");
|
|
|
|
echo("--all Poll all devices\n\n");
|
|
|
|
echo("No polling type specified!\n");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2009-03-30 11:20:18 +00:00
|
|
|
if ($argv[2] == "--type" && $argv[3]) {
|
|
|
|
$type = $argv[3];
|
|
|
|
} elseif ($argv[3] == "--type" && $argv[4]) {
|
|
|
|
$type = $argv[4];
|
|
|
|
} else {
|
|
|
|
echo("Require valid discovery type.\n");
|
|
|
|
exit;
|
|
|
|
}
|
2008-04-03 19:04:24 +00:00
|
|
|
|
|
|
|
$devices_polled = 0;
|
|
|
|
|
2009-05-28 13:03:52 +00:00
|
|
|
echo("includes/discovery/".$type.".php \n");
|
|
|
|
|
2010-02-21 05:08:58 +00:00
|
|
|
$debug = 1;
|
|
|
|
|
2009-05-28 13:03:52 +00:00
|
|
|
|
2009-04-13 19:16:22 +00:00
|
|
|
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id ASC");
|
2008-04-03 19:04:24 +00:00
|
|
|
while ($device = mysql_fetch_array($device_query)) {
|
|
|
|
|
2009-09-18 09:11:52 +00:00
|
|
|
echo($device['hostname'] . "(".$device['sysName']."|".$device['device_id'].")\n");
|
2008-04-03 19:04:24 +00:00
|
|
|
|
2009-11-09 15:52:04 +00:00
|
|
|
include("includes/discovery/".$type);
|
2008-04-03 19:04:24 +00:00
|
|
|
|
|
|
|
echo("\n"); $devices_polled++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$end = utime(); $run = $end - $start;
|
|
|
|
$proctime = substr($run, 0, 5);
|
|
|
|
|
2009-11-09 15:52:04 +00:00
|
|
|
echo("$devices_polled devices polled in $proctime secs\n $mysql SQL");
|
2008-04-03 19:04:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
?>
|