function getAllEvents()
	{
		$events = fetch("FETCH node WHERE property:class_name='event' NODESORTBY property:version SORTBY var:date,var:time");
		$events = getReadable($events);
		
		for ($n = 0; $n < count($events); $n++)
		{
			if (!isset($events[$n]->rand_color))
				$events[$n]->rand_color = colour('light');
		}
			
		return $events;
	}
	function fillCalendars()
	{
		$this->calendars = array();
		$home_id = $_SESSION['murrix']['user']->home_id;
		if ($home_id > 0)
		{
			$home = new mObject($home_id);
			$calendar_id = getNode($home->getPath()."/calendar", "eng");
			if ($calendar_id > 0)
			{
				$name = $home->getName();
				$count = 0;
				while (isset($this->calendars[$name]))
				{
					$count++;
					$name .= $count;
				}
				
				$children = fetch("FETCH node WHERE link:node_top='$calendar_id' AND link:type='sub' AND property:class_name='folder' NODESORTBY property:version SORTBY property:name");
				
				for ($n = 0; $n < count($children); $n++)
				{
					$children[$n]->color = colour('light');
					$children[$n]->active = true;
				}
				
				$this->calendars[$name] = $children;
			}
		}
			
		$groups = $_SESSION['murrix']['user']->getGroups();
		foreach ($groups as $groupname)
		{
			$group = new mGroup();
			$group->setByName($groupname);
			
			$home_id = $group->home_id;
			
			if ($home_id > 0)
			{
				$home = new mObject($home_id);
				$calendar_id = getNode($home->getPath()."/calendar", "eng");
				if ($calendar_id > 0)
				{
					$name = $home->getName();
					$count = 0;
					while (isset($this->calendars[$name]))
					{
						$count++;
						$name .= $count;
					}
					
					$children = fetch("FETCH node WHERE link:node_top='$calendar_id' AND link:type='sub' AND property:class_name='folder' NODESORTBY property:version SORTBY property:name");
				
					for ($n = 0; $n < count($children); $n++)
					{
						$children[$n]->color = colour('light');
						$children[$n]->active = true;
					}
				
					$this->calendars[$name] = $children;
				}
			}
		}
	}
Exemple #3
0
 function loadaverage()
 {
     sleep(1);
     $uptime = trim(shell_exec("cat /proc/uptime  |awk '{print \$1}' |cut -d '.' -f 1"));
     $load_average_1min = trim(shell_exec("cat /proc/loadavg |awk '{print \$1}'"));
     $load_average_5min = trim(shell_exec("cat /proc/loadavg |awk '{print \$2}'"));
     $load_average_15min = trim(shell_exec("cat /proc/loadavg |awk '{print \$3}'"));
     if ($load_average_1min <= 1) {
         $stats = '当前系统空闲';
     } elseif ($load_average_1min <= 4) {
         $stats = '当前系统正常';
     } else {
         $stats = '当前系统繁忙';
     }
     $days = floor($uptime / 86400);
     $hours = floor($uptime % 86400 / 3600);
     $minutes = floor($uptime % 3600 / 60);
     $title = new title("系统平均负载\n{$stats}");
     $title->set_style("{font-size: 12px; font-family: Times New Roman; font-weight: bold; color: #A2ACBA; text-align: center;}");
     settype($load_average_1min, "float");
     settype($load_average_5min, "float");
     settype($load_average_15min, "float");
     $load_average = array($load_average_1min, $load_average_5min, $load_average_15min);
     function colour($value)
     {
         if ($value <= 1) {
             $colour = "#339900";
         } elseif ($value <= 4) {
             $colour = "#FFFF00";
         } else {
             $colour = "#FF0033";
         }
         return $colour;
     }
     if (max($load_average) <= 0.5) {
         $y_axis_max = 0.5;
     } elseif (max($load_average) <= 1) {
         $y_axis_max = 1;
     } elseif (max($load_average) <= 5) {
         $y_axis_max = 5;
     } elseif (max($load_average) <= 10) {
         $y_axis_max = 10;
     } elseif (max($load_average) <= 50) {
         $y_axis_max = 50;
     } else {
         $y_axis_max = 100;
     }
     $y_axis_step = $y_axis_max / 5;
     if ($load_average_1min == 0) {
         $data[0] = new bar_value($y_axis_max / 100);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip(0);
     } else {
         $data[0] = new bar_value($load_average_1min);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip('#val#');
     }
     if ($load_average_5min == 0) {
         $data[1] = new bar_value($y_axis_max / 100);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip(0);
     } else {
         $data[1] = new bar_value($load_average_5min);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip('#val#');
     }
     if ($load_average_15min == 0) {
         $data[2] = new bar_value($y_axis_max / 100);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip(0);
     } else {
         $data[2] = new bar_value($load_average_15min);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip('#val#');
     }
     $bar = new bar_glass();
     $bar->set_values($data);
     $x = new x_axis();
     $x->set_labels_from_array(array('1分钟', '5分钟', '15分钟'));
     $y = new y_axis();
     $y->set_range(0, $y_axis_max, $y_axis_step);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_bg_colour('#FFFFFF');
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $x_legend = new x_legend("系统当前已运行 {$days} 天 {$hours} 小时 {$minutes} 分钟");
     $x_legend->set_style('{font-size: 12px; color: #778877}');
     $chart->set_x_legend($x_legend);
     header("Cache-Control: cache, must-revalidate");
     header("Pragma: public");
     echo $chart->toString();
 }
Exemple #4
0
        $diff = $output ^ $flipOutput;
        foreach (str_split(sprintf("%032s", decbin($diff))) as $idx => $val) {
            if (!isset($totals[$j][$idx])) {
                $totals[$j][$idx] = 0;
            }
            if ($val == '1') {
                $totals[$j][$idx]++;
            }
        }
    }
}
echo "     ";
for ($i = 0; $i < 32; $i++) {
    echo sprintf("%02d  ", $i);
}
echo "\n    ";
for ($i = 0; $i < 32; $i++) {
    echo "--- ";
}
echo "\n";
$cols = [46, 46, 46, 190, 172, 166, 160];
for ($i = 0; $i < 32; $i++) {
    echo sprintf("%02d | ", $i);
    for ($j = 0; $j < 32; $j++) {
        $pct = isset($totals[$i][$j]) ? round($totals[$i][$j] / $limit * 100) : 0;
        $pad = sprintf("%-3s ", $pct);
        $col = abs($pct - 50);
        colour($pad, isset($cols[$col]) ? $cols[$col] : 160);
    }
    echo "\n";
}