Пример #1
0
        echo "\t{$size} kB of {$type} at {$mount}\n";
    }
    echo "\n";
}
function print_info($hostname, $ip, $dmi)
{
    echo "Host info:\n";
    echo "\t{$hostname} [IP: {$ip}]\n";
    $psk = "/proc/sys/kernel";
    if (file_exists("{$psk}/ostype")) {
        $type = trim(file_get_contents("{$psk}/ostype"));
        $rel = trim(file_get_contents("{$psk}/osrelease"));
        $ver = trim(file_get_contents("{$psk}/version"));
        echo "\t{$type} {$rel} {$ver}\n";
    }
    if (isset($dmi["product_name"])) {
        $product = $dmi["product_name"];
        $vendor = $dmi["vendor"];
        echo "\t{$product} by {$vendor}\n";
    }
    echo "\n";
}
$hostname = get_hostname();
$ip = get_ip($hostname);
$dmi = parse_dmi();
print_info($hostname, $ip, $dmi);
$cpu = parse_cpuinfo();
print_cpu($cpu, $dmi);
$mem = parse_meminfo();
$swap = parse_swaps();
print_memory($mem, $swap);
Пример #2
0
    }
    if ($argv[1] != 'cron') {
        system('clear');
    }
    return $output;
}
$postfix_queue = '/var/spool/postfix';
$SPACER = array('');
$num_sec_sleep = 20;
list(, $_num) = $_SERVER['argv'];
if (is_numeric($_num)) {
    $num_sec_sleep = $_num;
}
$db = new MySQL_Access('mle');
while (true) {
    $mem = parse_meminfo(popen2('cat /proc/meminfo'));
    // check my yahoo notes 'ECCM Help'
    list($eccm) = popen2('cat /sys/devices/system/edac/mc/mc0/ce_count');
    $mem[] = 'ErrorCount:            ' . $eccm;
    $df = popen2('df -h');
    $mdstat = parse_mdstat(popen2('cat /proc/mdstat'));
    $nginx = parse_server_prog(popen2('ps aux | grep nginx: | grep -v grep'), 'nginx:');
    $php5fpm = parse_server_prog(popen2('ps aux | grep php-fpm | grep -v grep'), 'php-fpm');
    $uptime = pws(popen2('uptime'));
    $uptime[0] = str_replace('load average:', '', $uptime[0]);
    $postfix = parse_postfix(popen2('ps aux | grep postfix | grep -v grep'));
    $postfix_queue_size = popen2("find {$postfix_queue}/active -type f -print | wc -l");
    $postfix[] = $postfix_queue_size[0] .= ' active queue';
    $postfix_queue_size = popen2("find /{$postfix_queue}/deferred -type f -print | wc -l");
    $postfix[] = $postfix_queue_size[0] .= ' deferred queue';
    $mysql = parse_mysql(popen2('ps aux | grep mysql | grep -v grep'));