Ejemplo n.º 1
0
function get_server_status(&$tpl)
{
    $vhcs_status = new status();
    // Enable logging?
    $vhcs_status->log = FALSE;
    // Default is false
    $vhcs_status->AddService('localhost', 9876, 'VHCS Daemon', 'tcp');
    $vhcs_status->AddService('localhost', 21, 'FTP', 'tcp');
    $vhcs_status->AddService('localhost', 22, 'SSH', 'tcp');
    $vhcs_status->AddService('localhost', 23, 'Telnet', 'tcp');
    $vhcs_status->AddService('localhost', 25, 'SMTP', 'tcp');
    $vhcs_status->AddService('localhost', 53, 'DNS', 'tcp');
    $vhcs_status->AddService('localhost', 80, 'HTTP', 'tcp');
    $vhcs_status->AddService('localhost', 443, 'HTML-SSL', 'tcp');
    $vhcs_status->AddService('localhost', 110, 'POP3', 'tcp');
    $vhcs_status->AddService('localhost', 995, 'POP3-SSL', 'tcp');
    $vhcs_status->AddService('localhost', 143, 'IMAP', 'tcp');
    $vhcs_status->AddService('localhost', 993, 'IMAP-SSL', 'tcp');
    $vhcs_status->CheckStatus(1);
    $data = $vhcs_status->GetStatus();
    for ($i = 0; $i <= count($data) - 1; $i++) {
        if ($data[$i]['status']) {
            $img = $on = 'UP';
            $class = "content";
        } else {
            $img = $off = '<b><font color="#FF0000">DOWN</font></b>';
            $class = "content2";
        }
        $tpl->assign(array('HOST' => $data[$i]['ip'], 'PORT' => $data[$i]['port'], 'SERVICE' => $data[$i]['service'], 'STATUS' => $img, 'CLASS' => $class));
        $tpl->parse('SERVICE_STATUS', '.service_status');
    }
}