Exemplo n.º 1
0
}
// Check if cache needs to be updated
if (filemtime("cache_" . $get . ".txt") + $cachetime > time() && $flag) {
    // Output the content of the cache
    echo file_get_contents("cache_" . $get . ".txt");
} else {
    // Save memInfo output to variable
    $time = time();
    if ($get == "NetSpeedUp") {
        $data["value"] = getSpeed("tx");
    } else {
        if ($get == "NetSpeedDown") {
            $data["value"] = getSpeed("rx");
        } else {
            if ($get == "NetExtIp") {
                $data["value"] = getExternalIP();
            } else {
                if ($get == "all") {
                    $memInfo = getMemInfo();
                    $i = 0;
                    foreach ($config["Software"] as $key => $value) {
                        $name = array_keys($value);
                        $name = $name[0];
                        $process = $value[$name];
                        $data[$key] = $name . " " . CheckRunningProcess($process);
                        $i++;
                    }
                    $data["HW_OS"] = getOperatingSystem();
                    $data["HW_KERNEL"] = getKernel();
                    $data["HW_CPU"] = getCPU();
                    $data["HW_RAM_USED"] = getSize($memInfo["MemTotal"] - $memInfo["MemFree"]);
Exemplo n.º 2
0
<?php

# FROM PUPPET, DONT EDIT
# will post an array with stats to $collectURL
$collectURL = 'http://domains.bellcom.dk/service/datacollector/';
// FIXME: should not be hardcoded
$hostStats = array();
$facterOutput = trim(shell_exec('facter'));
$facterLines = explode("\n", $facterOutput);
foreach ($facterLines as $line) {
    list($key, $value) = explode(' => ', $line);
    $hostStats[$key] = $value;
}
$hostStats['external_ip'] = getExternalIP();
if ($hostStats['virtual'] == 'xen0') {
    $domUs = parseXenDomUs();
    $hostStats['domUs'] = $domUs;
}
$vhosts = parseVhosts();
if (!empty($vhosts[0])) {
    $hostStats['vhosts'] = $vhosts;
}
$hostStats['disk']['partitions'] = partitionInfo();
if ($hostStats['virtual'] == 'xen0') {
    $hostStats['disk']['physical'] = physicalDiskInfo();
}
$hostStats['software_updates'] = softwareUpdates($hostStats['lsbdistid']);
$hostStats['uptime'] = getUptime();
function softwareUpdates($operatingsystem)
{
    $updates = array();