/********************************************************************** * uptimes.noctumdesign.com * Copyright (c) 2002 Ryan Grove . All rights reserved. * * This script 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA ********************************************************************** * stats.php * * Links to real-time statistics. **********************************************************************/ require_once("lib/functions.php"); require_once("lib/ui.class.php"); $ui = new infoui; $op = getVar("op"); switch($op) { case "": $ui->header(); $ui->template_open(); $ui->message("Statistics", "These statistics are generated on-the-fly from the latest uptime data. If you notice anything that looks bogus, please let me know."); $ui->statsbar(); $ui->template_close(); $ui->footer(); break; ################################### # All Hosts ################################### case "all": $ui->header("The Uptimes Project - All Hosts"); $ui->template_open(); $ui->message("All Hosts", ""); $ui->statsbar(); if (!isset($s)) $s = 0; $result = $db->query("SELECT COUNT(h.id) as count FROM hosts h, uptimes u WHERE h.auth_id = u.auth_id AND h.last_heard = u.reported"); $tmp = $result[0]; $hostcount = $tmp->count; $pages = ceil($hostcount / 30); // What should we order by? $sortfield = trim(@$_GET["f"]); $sorttype = trim(@$_GET["t"]); if ($sortfield == "") $sortfield = "h.name"; if ($sorttype == "") $sorttype = "ASC"; $hosts = $db->query("SELECT h.id, h.name, p.os, p.oslevel, p.cpu, p.uptime, p.cpu_load, p.idle, u.user FROM hosts h, uptimes p, users u WHERE u.id = h.user_id AND h.auth_id = p.auth_id AND p.reported = h.last_heard ORDER BY $sortfield $sorttype LIMIT $s, 30"); print "
| « Prev | \n"; else print "||||||
| \n"; print " | \n"; for($i = 0; $i < $pages; $i++) print " ".($i + 1)."\n"; print " | \n"; if ($hostcount > ($s + 30)) print "Next » | \n"; } print " | |||
| \n"; printSortLinks("Hostname", "h.name", $sortfield, $sorttype); print " | \n"; printSortLinks("Owner", "u.user", $sortfield, $sorttype); print " | \n"; printSortLinks("OS", "p.os", $sortfield, $sorttype); print " | \n"; printSortLinks("CPU", "p.cpu", $sortfield, $sorttype); print " | \n"; printSortLinks("Uptime", "p.uptime", $sortfield, $sorttype); print " | \n"; printSortLinks("Load", "p.cpu_load", $sortfield, $sorttype); print " | \n"; printSortLinks("Idle", "p.idle", $sortfield, $sorttype); print " |
| \n";
print " id."\">".wordwrap(sh($foo->name), 20, " ", 1)."\n"; print " | \n"; print " ".$foo->user."\n"; print " | \n"; print " ".$foo->os." ".$foo->oslevel."\n"; print " | \n"; print " ".$foo->cpu."\n"; print " | \n"; print " ".parseUptime($foo->uptime)."\n"; print " | \n"; if ($foo->cpu_load != "") print " ".$foo->cpu_load."%\n"; print " | \n"; if ($foo->idle != "") print " ".$foo->idle."%\n"; print " |
| « Prev | \n"; else print "||||||
| \n"; print " | \n"; for($i = 0; $i < $pages; $i++) print " ".($i + 1)."\n"; print " | \n"; if ($hostcount > ($s + 30)) print "Next » | \n"; } print " | |||
| « Prev | \n"; else print "|||||||
| \n"; print " | \n"; for($i = 0; $i < $pages; $i++) print " ".($i + 1)."\n"; print " | \n"; if ($hostcount > ($s + 30)) print "Next » | \n"; } print " | ||||
| \n"; print " #\n"; print " | \n"; print " Hostname\n"; print " | \n"; print " Owner\n"; print " | \n"; print " OS\n"; print " | \n"; print " CPU\n"; print " | \n"; print " Uptime\n"; print " | \n"; print " Load\n"; print " | \n"; print " Idle\n"; print " |
| \n"; print " $i.\n"; print " | \n"; print " host_id."\">".stripslashes($foo->name)."\n"; print " | \n"; print " $user->user\n"; print " | \n"; print " ".$foo->os." ".stripslashes($foo->oslevel)."\n"; print " | \n"; print " ".stripslashes($foo->cpu)."\n"; print " | \n"; print " ".parseUptime($foo->uptime)."\n"; print " | \n"; if ($foo->cpu_load != "") print " ".$foo->cpu_load."%\n"; print " | \n"; if ($foo->idle != "") print " ".$foo->idle."%\n"; print " |
| « Prev | \n"; else print "|||||||
| \n"; print " | \n"; for($i = 0; $i < $pages; $i++) print " ".($i + 1)."\n"; print " | \n"; if ($hostcount > ($s + 30)) print "Next » | \n"; } print " | ||||
| OS | Active Hosts | Highest Uptime | Average Uptime | Average CPU Load |
| =$foo->os?> | =$total?> | =parseUptime($uptimes->uptime)?> | =parseUptime($avg->uptime)?> | =round($avg->cpu_load, 2)?>% |
| \n"; print " CPU\n"; print " | \n"; print " Highest Uptime\n"; print " |
| \n"; print " ".stripslashes($foo->cpu)."\n"; print " | \n"; print " ".parseUptime($foo->uptime)."\n"; print " |
| \n"; print " Client Name\n"; print " | \n"; print " Active Hosts\n"; print " |
| \n"; print " ".sh($foo->client)."\n"; print " | \n"; print " $foo->count\n"; print " |