optimize sql for versioncheck stats

git-svn-id: http://www.observium.org/svn/observer/trunk@3098 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2012-04-29 20:04:35 +00:00
parent 2e2d60f6ac
commit 571c9d5b0e
2 changed files with 46 additions and 44 deletions

View File

@@ -116,7 +116,8 @@ if($options['h'] != "new" && $config['version_check']) {
include("includes/versioncheck.inc.php");
}
if(!isset($options['q'])) {
if (!isset($options['q']))
{
echo('MySQL: Cell['.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,2).'s]'.
' Row['.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,2).'s]'.
' Rows['.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,2).'s]'.

View File

@@ -9,16 +9,16 @@ $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)
foreach (dbFetch("SELECT COUNT(*) AS count,os from devices group by `os`") as $dt_data)
{
$stats['devicetypes'][$dt_data[os]] = dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `os` = '".$dt_data['os']."'");
$stats['devicetypes2'][$dt_data['os']] = $dt_data['count'];
}
$stats = serialize($stats[$dt_data[os]]);
$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)
if ($dataHandle)
{
while (!feof($dataHandle))
{
@@ -30,20 +30,20 @@ if($dataHandle)
list($cur, $tag) = explode("-", $config['version']);
list($cur_omnipotence, $cur_year, $cur_month, $cur_revision) = explode(".", $cur);
if ($argv[1] == "--cron" || isset($options['q'])) {
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) {
if ($cur != $data)
{
echo("Current Version : $cur_omnipotence.$cur_year.$cur_month.$cur_revision \n");
if ($omnipotence > $cur_omnipotence) {
if ($omnipotence > $cur_omnipotence)
{
echo("New version : $omnipotence.$year.$month.$revision\n");
} elseif ($year > $cur_year) {
echo("New version : $omnipotence.$year.$month.$revision\n");
@@ -55,6 +55,7 @@ if($dataHandle)
}
}
}
fclose($dataHandle);
}