2011-05-05 14:59:07 +00:00
|
|
|
<?php
|
|
|
|
|
2012-05-25 12:24:34 +00:00
|
|
|
// Generate some statistics to send along with the version request.
|
2011-05-05 14:59:07 +00:00
|
|
|
|
2011-05-12 14:15:20 +00:00
|
|
|
$stats['ports'] = dbFetchCell("SELECT count(*) FROM ports");
|
|
|
|
$stats['devices'] = dbFetchCell("SELECT count(*) FROM devices");
|
|
|
|
$stats['sensors'] = dbFetchCell("SELECT count(*) FROM sensors");
|
|
|
|
$stats['services'] = dbFetchCell("SELECT count(*) FROM services");
|
|
|
|
$stats['applications'] = dbFetchCell("SELECT count(*) FROM applications");
|
|
|
|
$stats['bgp'] = dbFetchCell("SELECT count(*) FROM bgpPeers");
|
|
|
|
|
2012-04-29 20:04:35 +00:00
|
|
|
foreach (dbFetch("SELECT COUNT(*) AS count,os from devices group by `os`") as $dt_data)
|
2011-05-05 14:59:07 +00:00
|
|
|
{
|
2012-04-30 17:28:09 +00:00
|
|
|
$stats['devicetypes'][$dt_data['os']] = $dt_data['count'];
|
2011-05-05 14:59:07 +00:00
|
|
|
}
|
|
|
|
|
2012-04-30 17:28:09 +00:00
|
|
|
$stat_serial = base64_encode(serialize($stats));
|
|
|
|
|
|
|
|
$url = "http://www.observium.org/latest.php?i=".$stats['ports']."&d=".$stats['devices']."&stats=".$stat_serial."&v=".$config['version'];
|
|
|
|
$dataHandle = fopen($url, r);
|
2011-05-05 14:59:07 +00:00
|
|
|
|
2012-04-29 20:04:35 +00:00
|
|
|
if ($dataHandle)
|
2011-05-05 14:59:07 +00:00
|
|
|
{
|
2012-04-29 20:04:35 +00:00
|
|
|
while (!feof($dataHandle))
|
|
|
|
{
|
|
|
|
$data.= fread($dataHandle, 4096);
|
|
|
|
}
|
|
|
|
if ($data)
|
|
|
|
{
|
|
|
|
list($omnipotence, $year, $month, $revision) = explode(".", $data);
|
|
|
|
list($cur, $tag) = explode("-", $config['version']);
|
|
|
|
list($cur_omnipotence, $cur_year, $cur_month, $cur_revision) = explode(".", $cur);
|
|
|
|
|
|
|
|
if ($argv[1] == "--cron" || isset($options['q']))
|
|
|
|
{
|
|
|
|
$fd = fopen($config['log_file'],'a');
|
|
|
|
fputs($fd,$string . "\n");
|
|
|
|
fclose($fd);
|
|
|
|
|
|
|
|
shell_exec("echo $omnipotence.$year.$month.$month > ".$config['rrd_dir']."/version.txt ");
|
|
|
|
} else {
|
|
|
|
if ($cur != $data)
|
|
|
|
{
|
2012-05-02 15:04:31 +00:00
|
|
|
echo("Current Revision : $cur_revision\n");
|
2012-04-29 20:04:35 +00:00
|
|
|
|
2012-05-02 22:02:30 +00:00
|
|
|
if ($omnipotence > $cur_revision)
|
2011-05-05 14:59:07 +00:00
|
|
|
{
|
2012-05-02 15:04:31 +00:00
|
|
|
echo("New Revision : $omnipotence\n");
|
2011-05-05 14:59:07 +00:00
|
|
|
}
|
2012-05-02 15:04:31 +00:00
|
|
|
|
|
|
|
# if ($omnipotence > $cur_omnipotence)
|
|
|
|
# {
|
|
|
|
# echo("New version : $omnipotence.$year.$month.$revision\n");
|
|
|
|
# } elseif ($year > $cur_year) {
|
|
|
|
# echo("New version : $omnipotence.$year.$month.$revision\n");
|
|
|
|
# } elseif ($month > $cur_month) {
|
|
|
|
# echo("New version : $omnipotence.$year.$month.$revision\n");
|
|
|
|
# } elseif ($revision > $cur_revision) {
|
|
|
|
# echo("New release : $omnipotence.$year.$month.$revision\n");
|
|
|
|
# }
|
2012-04-29 20:04:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose($dataHandle);
|
2011-05-05 14:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|