Exemplo n.º 1
0
function getCpu(){
	
	$sock=new sockets();
	$cpu_purc=$sock->getFrameWork("cmd.php?cpualarm=yes");
	$cpu_purc_text=$cpu_purc."%";
	$cpu_color="#5DD13D";
	if($cpu_purc>70){$cpu_color="#F59C44";}
	if($cpu_purc>90){$cpu_color="#D32D2D";}
	$pouc_disk_io_text="<br><span style='font-size:9px'>% CPU:$pouc_disk_io%</span>";
	$cpu="
	<div style='width:100px;background-color:white;padding-left:0px;border:1px solid $color;margin-top:3px'>
		<div style='width:{$pouc_disk_io}px;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:$color'></div>
	</div>
	
	
	";
	
	
$cpu="<tr>
				<td width=1% nowrap class=legend nowrap>{cpu_usage}:</strong></td>
				<td align='left'>
					<div style='width:100px;background-color:white;padding-left:0px;border:1px solid $cpu_color'>
						<div style='width:{$cpu_purc}px;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:$cpu_color'>
							<strong>{$cpu_purc}%</strong></div>
					</div>
				</td>
				<td width=1% nowrap><strong style='color:$cpu_color'>{$cpu_purc}%</strong></td>
				</tr>";	
$load=getLoad();
	$html="<table>$cpu$load
		</table>";
	$tpl=new templates();
	echo $tpl->_ENGINE_parse_body($html);	
	
	
}
Exemplo n.º 2
0
 addInfo('Requests in last 5 minutes', $requests->count());
 $info = $redis->info();
 $mem = $info['used_memory_human'];
 $stats = $mdb->getDb()->command(['dbstats' => 1]);
 $dataSize = number_format($stats['dataSize'] / (1024 * 1024 * 1024), 2);
 $storageSize = number_format($stats['storageSize'] / (1024 * 1024 * 1024), 2);
 $memory = getSystemMemInfo();
 $memTotal = number_format($memory['MemTotal'] / (1024 * 1024), 2);
 $memUsed = number_format(($memory['MemTotal'] - $memory['MemFree'] - $memory['Cached']) / (1024 * 1024), 2);
 $maxLen = 0;
 foreach ($infoArray as $i) {
     foreach ($i as $key => $value) {
         $maxLen = max($maxLen, strlen("{$value}"));
     }
 }
 echo exec('date') . '  Load: ' . getLoad() . "  Memory: {$memUsed}G/{$memTotal}G  Redis: {$mem}  TokuDB: {$storageSize}G / {$dataSize}G\n";
 echo "\n";
 foreach ($infoArray as $i) {
     foreach ($i as $name => $count) {
         if (trim($name) == '') {
             echo "\n";
             continue;
         }
         while (strlen($count) < 20 + $maxLen) {
             $count = ' ' . $count;
         }
         echo "{$count} {$name}\n";
     }
 }
 $output = ob_get_clean();
 file_put_contents("{$baseDir}/public/ztop.txt", $output);
function makeLoadBars()
{
    printBar(getLoad(0), "1 min");
    printBar(getLoad(1), "5 min");
    printBar(getLoad(2), "15 min");
}
Exemplo n.º 4
0
">
    <input type="hidden" name="view" value="<?php 
echo $view;
?>
"/>
    <input type="hidden" name="action" value=""/>
    <div id="header">
      <h3 id="systemTime"><?php 
echo preg_match('/%/', DATE_FMT_CONSOLE_LONG) ? strftime(DATE_FMT_CONSOLE_LONG) : date(DATE_FMT_CONSOLE_LONG);
?>
</h3>
      <h3 id="systemStats"><?php 
echo translate('Load');
?>
: <?php 
echo getLoad();
?>
 / <?php 
echo translate('Disk');
?>
: <?php 
echo getDiskPercent();
?>
%</h3>
      <h2 id="title"><a href="http://www.zoneminder.com" target="ZoneMinder">ZoneMinder</a> <?php 
echo translate('Console');
?>
 - <?php 
echo makePopupLink('?view=state', 'zmState', 'state', $status, canEdit('System'));
?>
 - <?php 
Exemplo n.º 5
0
function parseFilter(&$filter, $saveToSession = false, $querySep = '&amp;')
{
    $filter['query'] = '';
    $filter['sql'] = '';
    $filter['fields'] = '';
    if (isset($filter['terms']) && count($filter['terms'])) {
        for ($i = 0; $i < count($filter['terms']); $i++) {
            if (isset($filter['terms'][$i]['cnj'])) {
                $filter['query'] .= $querySep . "filter[terms][{$i}][cnj]=" . urlencode($filter['terms'][$i]['cnj']);
                $filter['sql'] .= " " . $filter['terms'][$i]['cnj'] . " ";
                $filter['fields'] .= "<input type=\"hidden\" name=\"filter[terms][{$i}][cnj]\" value=\"" . htmlspecialchars($filter['terms'][$i]['cnj']) . "\"/>\n";
            }
            if (isset($filter['terms'][$i]['obr'])) {
                $filter['query'] .= $querySep . "filter[terms][{$i}][obr]=" . urlencode($filter['terms'][$i]['obr']);
                $filter['sql'] .= " " . str_repeat("(", $filter['terms'][$i]['obr']) . " ";
                $filter['fields'] .= "<input type=\"hidden\" name=\"filter[terms][{$i}][obr]\" value=\"" . htmlspecialchars($filter['terms'][$i]['obr']) . "\"/>\n";
            }
            if (isset($filter['terms'][$i]['attr'])) {
                $filter['query'] .= $querySep . "filter[terms][{$i}][attr]=" . urlencode($filter['terms'][$i]['attr']);
                $filter['fields'] .= "<input type=\"hidden\" name=\"filter[terms][{$i}][attr]\" value=\"" . htmlspecialchars($filter['terms'][$i]['attr']) . "\"/>\n";
                switch ($filter['terms'][$i]['attr']) {
                    case 'MonitorName':
                        $filter['sql'] .= 'M.' . preg_replace('/^Monitor/', '', $filter['terms'][$i]['attr']);
                        break;
                    case 'DateTime':
                        $filter['sql'] .= "E.StartTime";
                        break;
                    case 'Date':
                        $filter['sql'] .= "to_days( E.StartTime )";
                        break;
                    case 'Time':
                        $filter['sql'] .= "extract( hour_second from E.StartTime )";
                        break;
                    case 'Weekday':
                        $filter['sql'] .= "weekday( E.StartTime )";
                        break;
                    case 'Id':
                    case 'Name':
                    case 'MonitorId':
                    case 'Length':
                    case 'Frames':
                    case 'AlarmFrames':
                    case 'TotScore':
                    case 'AvgScore':
                    case 'MaxScore':
                    case 'Cause':
                    case 'Notes':
                    case 'Archived':
                        $filter['sql'] .= 'E.' . $filter['terms'][$i]['attr'];
                        break;
                    case 'DiskPercent':
                        $filter['sql'] .= getDiskPercent();
                        break;
                    case 'DiskBlocks':
                        $filter['sql'] .= getDiskBlocks();
                        break;
                    case 'SystemLoad':
                        $filter['sql'] .= getLoad();
                        break;
                }
                $valueList = array();
                foreach (preg_split('/["\'\\s]*?,["\'\\s]*?/', preg_replace('/^["\']+?(.+)["\']+?$/', '$1', $filter['terms'][$i]['val'])) as $value) {
                    switch ($filter['terms'][$i]['attr']) {
                        case 'MonitorName':
                        case 'Name':
                        case 'Cause':
                        case 'Notes':
                            $value = dbEscape($value);
                            break;
                        case 'DateTime':
                            $value = "'" . strftime(STRF_FMT_DATETIME_DB, strtotime($value)) . "'";
                            break;
                        case 'Date':
                            $value = "to_days( '" . strftime(STRF_FMT_DATETIME_DB, strtotime($value)) . "' )";
                            break;
                        case 'Time':
                            $value = "extract( hour_second from '" . strftime(STRF_FMT_DATETIME_DB, strtotime($value)) . "' )";
                            break;
                        default:
                            $value = dbEscape($value);
                            break;
                    }
                    $valueList[] = $value;
                }
                switch ($filter['terms'][$i]['op']) {
                    case '=':
                    case '!=':
                    case '>=':
                    case '>':
                    case '<':
                    case '<=':
                        $filter['sql'] .= " " . $filter['terms'][$i]['op'] . " {$value}";
                        break;
                    case '=~':
                        $filter['sql'] .= " regexp " . $value;
                        break;
                    case '!~':
                        $filter['sql'] .= " not regexp " . $value;
                        break;
                    case '=[]':
                        $filter['sql'] .= " in (" . join(",", $valueList) . ")";
                        break;
                    case '![]':
                        $filter['sql'] .= " not in (" . join(",", $valueList) . ")";
                        break;
                }
                $filter['query'] .= $querySep . "filter[terms][{$i}][op]=" . urlencode($filter['terms'][$i]['op']);
                $filter['fields'] .= "<input type=\"hidden\" name=\"filter[terms][{$i}][op]\" value=\"" . htmlspecialchars($filter['terms'][$i]['op']) . "\"/>\n";
                $filter['query'] .= $querySep . "filter[terms][{$i}][val]=" . urlencode($filter['terms'][$i]['val']);
                $filter['fields'] .= "<input type=\"hidden\" name=\"filter[terms][{$i}][val]\" value=\"" . htmlspecialchars($filter['terms'][$i]['val']) . "\"/>\n";
            }
            if (isset($filter['terms'][$i]['cbr'])) {
                $filter['query'] .= $querySep . "filter[terms][{$i}][cbr]=" . urlencode($filter['terms'][$i]['cbr']);
                $filter['sql'] .= " " . str_repeat(")", $filter['terms'][$i]['cbr']) . " ";
                $filter['fields'] .= "<input type=\"hidden\" name=\"filter[terms][{$i}][cbr]\" value=\"" . htmlspecialchars($filter['terms'][$i]['cbr']) . "\"/>\n";
            }
        }
        if ($filter['sql']) {
            $filter['sql'] = " and ( " . $filter['sql'] . " )";
        }
        if ($saveToSession) {
            $_SESSION['filter'] = $filter;
        }
    }
}
Exemplo n.º 6
0
    $uri = @$_SERVER['REQUEST_URI'];
    header("Location: https://zkillboard.com{$uri}");
    die;
}
$timer = new Timer();
// Starting Slim Framework
$app = new \Slim\Slim($config);
// Session
session_set_save_handler(new RedisSessionHandler(), true);
session_cache_limiter(false);
session_start();
$visitors = new RedisTtlCounter('ttlc:visitors', 300);
$visitors->add(IP::get());
$requests = new RedisTtlCounter('ttlc:requests', 300);
$requests->add(uniqid());
$load = getLoad();
// Check if the user has autologin turned on
if ($load < 20 && !User::isLoggedIn()) {
    User::autoLogin();
}
if ($load >= 20) {
    $uri = @$_SERVER['REQUEST_URI'];
    if ($uri != '') {
        $contents = $redis->get("cache:{$uri}");
        if ($contents !== false) {
            echo $contents;
            exit;
        }
        $_SERVER['requestDttm'] = $mdb->now();
        $qServer = new RedisQueue('queueServer');
        $qServer->push($_SERVER);