Files
librenms-librenms/includes/versioncheck.inc.php
T

62 lines
2.4 KiB
PHP
Raw Normal View History

2011-05-05 14:59:07 +00:00
<?php
### Generate some statistics to send along with the version request.
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");
foreach(dbFetch("SELECT `os` FROM `devices` GROUP BY `os`") as $dt_data)
2011-05-05 14:59:07 +00:00
{
2011-05-12 14:15:20 +00:00
$stats['devicetypes'][$dt_data[os]] = dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `os` = '".$dt_data['os']."'");
2011-05-05 14:59:07 +00:00
}
$stats = serialize($stats[$dt_data[os]]);
$dataHandle = fopen("http://www.observium.org/latest.php?i=".$stats['ports']."&d=".$stats['devices']."&stats=".$stats."&v=".$config['version'], r);
if($dataHandle)
{
while (!feof($dataHandle))
{
$data.= fread($dataHandle, 4096);
}
2011-09-20 14:22:34 +00:00
if ($data)
2011-05-05 14:59:07 +00:00
{
list($omnipotence, $year, $month, $revision) = explode(".", $data);
list($cur, $tag) = explode("-", $config['version']);
list($cur_omnipotence, $cur_year, $cur_month, $cur_revision) = explode(".", $cur);
2011-09-20 14:22:34 +00:00
if ($argv[1] == "--cron" || isset($options['q'])) {
2011-05-05 14:59:07 +00:00
$fd = fopen($config['log_file'],'a');
fputs($fd,$string . "\n");
fclose($fd);
2011-09-15 22:35:22 +00:00
shell_exec("echo $omnipotence.$year.$month.$month > ".$config['rrd_dir']."/version.txt ");
2011-05-05 14:59:07 +00:00
} else {
2011-09-20 14:22:34 +00:00
if ($cur != $data) {
2011-05-05 14:59:07 +00:00
echo("Current Version : $cur_omnipotence.$cur_year.$cur_month.$cur_revision \n");
2011-09-15 22:35:22 +00:00
2011-09-20 14:22:34 +00:00
if ($omnipotence > $cur_omnipotence) {
2011-05-05 14:59:07 +00:00
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");
}
}
}
}
fclose($dataHandle);
}
?>