Страница 2 из 6

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Пн фев 19, 2018 8:38 pm
Vovix
ahelper писал(а):Приветствую.
Внешний IP должен появляться при клике на него? Почему у меня нет?
....
тут все просто эти строки за это отвечают, но объекты.свойство должны быть ваши!

Код: Выделить всё

<td><br>Внешний IP<br><br></td>
<td align="right">
    <span style='font-size:12px; color:orange; display:%Sets.displayIPext|"none;block"%'><pre>%ThisComputer.MyIPext%</pre></span>
    <span style='font-size:12px; color:orange; display:%Sets.displayIPext|"block;none"%'><pre>***.***.***.***</pre></span>
</td> 
<td>
    <div class="toggle_ip" onclick="ajaxSetGlobal('Sets.displayIPext','0');" style = 'display:%Sets.displayIPext|"none;block"%'>
        <span class='toggle_icon fa fa-toggle-on' aria-hidden="true"></span>
    </div>
    <div class="toggle_ip" onclick="ajaxSetGlobal('Sets.displayIPext','1');" style = 'display:%Sets.displayIPext|"block;none"%'>
        <span class='toggle_icon fa fa-toggle-off' aria-hidden="true"></span>
    </div>
</td> 
а именно:
Sets.displayIPext - отвечает за "не отображать" или "отображать" (0 или 1)
ThisComputer.MyIPext - содержит значение внешнего IP (туда можно его либо получать автоматом, либо внести вручную)

UPD: да и переключение при нажатии на иконку toggle_icon

UPD: UPD: Да и вообще этот функционал, я сделал исключительно для удобства выкладки скринов на форум и его делать вам себе надо-ли?

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Пн фев 19, 2018 11:43 pm
ahelper
Спасибо получилось! Не думал что Sets.displayIPext объект.свойство, принял за временную переменную.
Vovix писал(а):У меня этот код в моем файле в папке lib лежит:
А как файл должен называться?
А внутренний IP как получаете? Или он просто прописан в свойстве?

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Вт фев 20, 2018 11:37 am
Vovix
ahelper писал(а):Спасибо получилось! Не думал что Sets.displayIPext объект.свойство, принял за временную переменную.
...А как файл должен называться?
не имеет значения название, только расширение .php
ahelper писал(а): А внутренний IP как получаете? Или он просто прописан в свойстве?
как вашей душе будет угодно: можно вычислять, парсить и т.п.
можно просто внести в ручную (он ведь у вас постоянный)!

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Чт мар 01, 2018 8:56 pm
ypiter2006
2) сценарий timer_Xs
цель которого запускать каждые 3 секунды сценарий OHM_data
Куда прописать выполнение сценария?
И почему-то у меня не отображается кнопка переключения видимости IP адрес
СпойлерПоказать
Снимок экрана 2018-03-01 в 23.13.27.png
Снимок экрана 2018-03-01 в 23.13.27.png (42.4 КБ) 6889 просмотров

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Чт мар 01, 2018 9:17 pm
Vovix
ypiter2006 писал(а):
2) сценарий timer_Xs
цель которого запускать каждые 3 секунды сценарий OHM_data
Куда прописать выполнениям сценария?
1) запустите его вручную, он рекурсивный
2) на всякий случай запланируйте его запуск каждый например час, на всякий случай, любым удобным вам способом (метод onNewHour, планировщик, крон и т.д.)

как-то так

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Чт мар 01, 2018 9:20 pm
ypiter2006
СпойлерПоказать
Снимок экрана 2018-03-01 в 23.40.48.png
Снимок экрана 2018-03-01 в 23.40.48.png (371.62 КБ) 6883 просмотра
Запустил сценарий Timer_Xs, и в меню управления начала происходить чертовщина :shock: :roll:
Все меню забергалось и заморгало очень быстро , даже не мог поймать скринами

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Пт мар 02, 2018 11:56 am
Vovix
ypiter2006 писал(а):
СпойлерПоказать
Снимок экрана 2018-03-01 в 23.40.48.png
Запустил сценарий Timer_Xs, и в меню управления начала происходить чертовщина :shock: :roll:
Все меню забергалось и заморгало очень быстро , даже не мог поймать скринами
сценарий Timer_Xs в моем случае только и делает, что с периодичностью запускает сам себя и параллельно, опять же у меня,
сценарий опроса OHM!
Что-то вы не доделали из моего сообщения в первом посте!

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Пт мар 02, 2018 2:27 pm
ypiter2006
Vovix писал(а): сценарий Timer_Xs в моем случае только и делает, что с периодичностью запускает сам себя и параллельно, опять же у меня,
сценарий опроса OHM!
Что-то вы не доделали из моего сообщения в первом посте!
Вроде все сделал как у вас. Только параметры брал для малины
СпойлерПоказать

Код: Выделить всё

$color = "grey";
sg('ThisComputer.CPUtip', $cpu_tip);

 $g_line[0] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;";
 $g_line[1] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _";
 $g_line[2] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _";
 $g_line[3] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _";
 $g_line[4] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _";
 $g_line[5] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _";
 $g_line[6] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _";
 $g_line[7] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _";
 $g_line[8] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _";
 $g_line[9] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _";
$g_line[10] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _";
$g_line[11] = "&nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _";
$g_line[12] = "&nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[13] = "&nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[14] = "&nbsp; _ _ _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[15] = "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _";


// -------------------- Температура процессора --------------------------------------------------------
$cpu_temp=shell_exec('cat /sys/class/thermal/thermal_zone0/temp') / 1000;
$cpu_temp=round($cpu_temp,0);
$maxtemp = 75;
$mintemp = 25;
$kf = ($maxtemp - $mintemp)/15; // 15 это делений на индикаторе
sg('ThisComputer.CPUtemp', $cpu_temp);
$t15 = round (($cpu_temp - $mintemp) / $kf); // чтобы шкала начиналась с $mintemp 
if ($cpu_temp <= $mintemp) { 
   $t15 = 0; // и оганичим нижнее значение на 0
} elseif ($cpu_temp >= $maxtemp) {
   $t15 = 15; // ограничим максимум на 15 делений
}
$t15_line = $g_line[$t15];
sg('ThisComputer.CPUtemp_-1', $t15_line);

// и цвет для неё
if (($cpu_temp >= 0) && ($cpu_temp < 45)) {
   $color = 'lime';
} else if (($cpu_temp >= 45) && ($cpu_temp < 60)) {
   $color = 'greenyellow';
} else if (($cpu_temp >= 60) && ($cpu_temp < 70)) {
   $color = 'yellow';
} else if ($cpu_temp >= 70) {
   $color = 'red';
} else {
   $color = 'grey';
}

sg ('ThisComputer.CPUtemp_color', $color);
sg ('ThisComputer.CPUtemp_color_-1', $color);

// сдвинем значения с вылетом последнего
for ($i = 9; $i >= 0; $i--) {
   $j = $i - 1;
   sg ('ThisComputer.CPUtemp_'.$i, gg('ThisComputer.CPUtemp_'.$j));
   sg ('ThisComputer.CPUtemp_color_'.$i, gg('ThisComputer.CPUtemp_color_'.$j));
}

//---------------------- Загрузка процессора -----------------------------------------------------
$cpu_load=shell_exec('cat /proc/loadavg');
$pos1 = strpos($cpu_load," ");
$pos2 = strpos($cpu_load," ",$pos1+1);
$pos3 = strpos($cpu_load," ",$pos2+1);
$cpu_load1  = substr($cpu_load,0,$pos1);
$cpu_load5  = substr($cpu_load,$pos1+1,$pos2-$pos1-1);
$cpu_load15  = substr($cpu_load,$pos2+1,$pos3-$pos2-1);
$cpu_load = round($cpu_load1*100/5);
sg('ThisComputer.CPUload', $cpu_load);
//sg('ThisComputer.CPUload1', $cpu_load1);
//sg('ThisComputer.CPUload5', $cpu_load5);
//sg('ThisComputer.CPUload15', $cpu_load15);

$l15 = round ($cpu_load / 6.66); // чтобы из 15 значений 100/15 = 6,(6)
$l15_line = $g_line[$l15];
sg('ThisComputer.CPUload_-1', $l15_line);

// и цвет для неё
if (($cpu_load >= 0) && ($cpu_load < 30)) {
   $color = 'lime';
} else if (($cpu_load >= 30) && ($cpu_load < 45)) {
   $color = 'greenyellow';
} else if (($cpu_load >= 45) && ($cpu_load < 60)) {
   $color = 'yellow';
} else if ($cpu_load >= 60) {
   $color = 'red';
} else {
   $color = 'grey';
}

sg ('ThisComputer.CPUload_color', $color);
sg ('ThisComputer.CPUload_color_-1', $color);

// сдвинем значения с вылетом последнего
for ($i = 9; $i >= 0; $i--) {
   $j = $i - 1;
   sg ('ThisComputer.CPUload_'.$i, gg('ThisComputer.CPUload_'.$j));
   sg ('ThisComputer.CPUload_color_'.$i, gg('ThisComputer.CPUload_color_'.$j));
}

// -------------------- Использование Флешк-карты -------------------------------------------------------------
$bytes = disk_free_space("."); 
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
$temp = round($bytes / pow($base,$class)) . ' ' . $si_prefix[$class];
setGlobal('ThisComputer.DISKused', $temp);
$color = ($disk_used < 80) ? "lime" : "red";
sg ('ThisComputer.DISKused_color', $color);

// -------------------- преобразование Uptime -----------------------------------------------------------
$uptime = gg('ThisComputer.uptime');
$uptime_str = secondsToString($uptime);
sg ('ThisComputer.uptime_str', $uptime_str);

/**
 * Секунды в строку
 * Эта функция возвращает кол-во секунд преобразованное в дни, часы, минуты, секунды
 *
 * @param integer $seconds всего время в секундах.
 * @return string "1234567" возвращает "14 дн., 6 час., 56 мин., 7 сек.".
 */
function secondsToString($seconds) {
    $result = '';
    if ($seconds >= 86400) {
        $days = floor($seconds / 86400);
        $seconds = $seconds % 86400;
        $result = $days.' д., ';
    }
    if ($seconds >= 3600) {
        $hours = floor($seconds / 3600);
        $seconds = $seconds % 3600;
        $result .= $hours.' час., ';
    }
    if ($seconds >= 60) {
        $minutes = floor($seconds / 60);
        $seconds = $seconds % 60;
        $result .= $minutes.' мин., ';
    }
    $result .= $seconds.' сек.';
    return $result;
}

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Пт мар 02, 2018 11:31 pm
Vovix
ypiter2006 писал(а):
Vovix писал(а): сценарий Timer_Xs в моем случае только и делает, что с периодичностью запускает сам себя и параллельно, опять же у меня,
сценарий опроса OHM!
Что-то вы не доделали из моего сообщения в первом посте!
Вроде все сделал как у вас. Только параметры брал для малины
СпойлерПоказать

Код: Выделить всё

$color = "grey";
sg('ThisComputer.CPUtip', $cpu_tip);

 $g_line[0] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;";
 $g_line[1] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _";
 $g_line[2] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _";
 $g_line[3] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _";
 $g_line[4] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _";
 $g_line[5] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _";
 $g_line[6] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _";
 $g_line[7] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _";
 $g_line[8] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _";
 $g_line[9] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _";
$g_line[10] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _";
$g_line[11] = "&nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _";
$g_line[12] = "&nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[13] = "&nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[14] = "&nbsp; _ _ _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[15] = "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _";


// -------------------- Температура процессора --------------------------------------------------------
$cpu_temp=shell_exec('cat /sys/class/thermal/thermal_zone0/temp') / 1000;
$cpu_temp=round($cpu_temp,0);
$maxtemp = 75;
$mintemp = 25;
$kf = ($maxtemp - $mintemp)/15; // 15 это делений на индикаторе
sg('ThisComputer.CPUtemp', $cpu_temp);
$t15 = round (($cpu_temp - $mintemp) / $kf); // чтобы шкала начиналась с $mintemp 
if ($cpu_temp <= $mintemp) { 
   $t15 = 0; // и оганичим нижнее значение на 0
} elseif ($cpu_temp >= $maxtemp) {
   $t15 = 15; // ограничим максимум на 15 делений
}
$t15_line = $g_line[$t15];
sg('ThisComputer.CPUtemp_-1', $t15_line);

// и цвет для неё
if (($cpu_temp >= 0) && ($cpu_temp < 45)) {
   $color = 'lime';
} else if (($cpu_temp >= 45) && ($cpu_temp < 60)) {
   $color = 'greenyellow';
} else if (($cpu_temp >= 60) && ($cpu_temp < 70)) {
   $color = 'yellow';
} else if ($cpu_temp >= 70) {
   $color = 'red';
} else {
   $color = 'grey';
}

sg ('ThisComputer.CPUtemp_color', $color);
sg ('ThisComputer.CPUtemp_color_-1', $color);

// сдвинем значения с вылетом последнего
for ($i = 9; $i >= 0; $i--) {
   $j = $i - 1;
   sg ('ThisComputer.CPUtemp_'.$i, gg('ThisComputer.CPUtemp_'.$j));
   sg ('ThisComputer.CPUtemp_color_'.$i, gg('ThisComputer.CPUtemp_color_'.$j));
}

//---------------------- Загрузка процессора -----------------------------------------------------
$cpu_load=shell_exec('cat /proc/loadavg');
$pos1 = strpos($cpu_load," ");
$pos2 = strpos($cpu_load," ",$pos1+1);
$pos3 = strpos($cpu_load," ",$pos2+1);
$cpu_load1  = substr($cpu_load,0,$pos1);
$cpu_load5  = substr($cpu_load,$pos1+1,$pos2-$pos1-1);
$cpu_load15  = substr($cpu_load,$pos2+1,$pos3-$pos2-1);
$cpu_load = round($cpu_load1*100/5);
sg('ThisComputer.CPUload', $cpu_load);
//sg('ThisComputer.CPUload1', $cpu_load1);
//sg('ThisComputer.CPUload5', $cpu_load5);
//sg('ThisComputer.CPUload15', $cpu_load15);

$l15 = round ($cpu_load / 6.66); // чтобы из 15 значений 100/15 = 6,(6)
$l15_line = $g_line[$l15];
sg('ThisComputer.CPUload_-1', $l15_line);

// и цвет для неё
if (($cpu_load >= 0) && ($cpu_load < 30)) {
   $color = 'lime';
} else if (($cpu_load >= 30) && ($cpu_load < 45)) {
   $color = 'greenyellow';
} else if (($cpu_load >= 45) && ($cpu_load < 60)) {
   $color = 'yellow';
} else if ($cpu_load >= 60) {
   $color = 'red';
} else {
   $color = 'grey';
}

sg ('ThisComputer.CPUload_color', $color);
sg ('ThisComputer.CPUload_color_-1', $color);

// сдвинем значения с вылетом последнего
for ($i = 9; $i >= 0; $i--) {
   $j = $i - 1;
   sg ('ThisComputer.CPUload_'.$i, gg('ThisComputer.CPUload_'.$j));
   sg ('ThisComputer.CPUload_color_'.$i, gg('ThisComputer.CPUload_color_'.$j));
}

// -------------------- Использование Флешк-карты -------------------------------------------------------------
$bytes = disk_free_space("."); 
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
$temp = round($bytes / pow($base,$class)) . ' ' . $si_prefix[$class];
setGlobal('ThisComputer.DISKused', $temp);
$color = ($disk_used < 80) ? "lime" : "red";
sg ('ThisComputer.DISKused_color', $color);

// -------------------- преобразование Uptime -----------------------------------------------------------
$uptime = gg('ThisComputer.uptime');
$uptime_str = secondsToString($uptime);
sg ('ThisComputer.uptime_str', $uptime_str);

/**
 * Секунды в строку
 * Эта функция возвращает кол-во секунд преобразованное в дни, часы, минуты, секунды
 *
 * @param integer $seconds всего время в секундах.
 * @return string "1234567" возвращает "14 дн., 6 час., 56 мин., 7 сек.".
 */
function secondsToString($seconds) {
    $result = '';
    if ($seconds >= 86400) {
        $days = floor($seconds / 86400);
        $seconds = $seconds % 86400;
        $result = $days.' д., ';
    }
    if ($seconds >= 3600) {
        $hours = floor($seconds / 3600);
        $seconds = $seconds % 3600;
        $result .= $hours.' час., ';
    }
    if ($seconds >= 60) {
        $minutes = floor($seconds / 60);
        $seconds = $seconds % 60;
        $result .= $minutes.' мин., ';
    }
    $result .= $seconds.' сек.';
    return $result;
} 
да, только этот сценарий только готовит данные для отображения в свойства объектов
отображением занимается другой код - "3) ну собственно код самого виджета в меню"

и видя как у вас отображается например громкость системы, становится понятно, что у вас не применяются стили виджета! Проверьте как вы вставили в меню всё!

Re: [Виджет] состояния системы (процессора) с индикаторами (

Добавлено: Пт мар 16, 2018 7:44 am
Alex77
ypiter2006 писал(а):
Vovix писал(а): сценарий Timer_Xs в моем случае только и делает, что с периодичностью запускает сам себя и параллельно, опять же у меня,
сценарий опроса OHM!
Что-то вы не доделали из моего сообщения в первом посте!
Доброе утро.получилось на линуксе сделать?
Вроде все сделал как у вас. Только параметры брал для малины
СпойлерПоказать

Код: Выделить всё

$color = "grey";
sg('ThisComputer.CPUtip', $cpu_tip);

 $g_line[0] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;";
 $g_line[1] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _";
 $g_line[2] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _";
 $g_line[3] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _";
 $g_line[4] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _";
 $g_line[5] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _";
 $g_line[6] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _";
 $g_line[7] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _";
 $g_line[8] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _";
 $g_line[9] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _";
$g_line[10] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _";
$g_line[11] = "&nbsp; &nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _";
$g_line[12] = "&nbsp; &nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[13] = "&nbsp; &nbsp; _ _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[14] = "&nbsp; _ _ _ _ _ _ _ _ _ _ _ _ _ _";
$g_line[15] = "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _";


// -------------------- Температура процессора --------------------------------------------------------
$cpu_temp=shell_exec('cat /sys/class/thermal/thermal_zone0/temp') / 1000;
$cpu_temp=round($cpu_temp,0);
$maxtemp = 75;
$mintemp = 25;
$kf = ($maxtemp - $mintemp)/15; // 15 это делений на индикаторе
sg('ThisComputer.CPUtemp', $cpu_temp);
$t15 = round (($cpu_temp - $mintemp) / $kf); // чтобы шкала начиналась с $mintemp 
if ($cpu_temp <= $mintemp) { 
   $t15 = 0; // и оганичим нижнее значение на 0
} elseif ($cpu_temp >= $maxtemp) {
   $t15 = 15; // ограничим максимум на 15 делений
}
$t15_line = $g_line[$t15];
sg('ThisComputer.CPUtemp_-1', $t15_line);

// и цвет для неё
if (($cpu_temp >= 0) && ($cpu_temp < 45)) {
   $color = 'lime';
} else if (($cpu_temp >= 45) && ($cpu_temp < 60)) {
   $color = 'greenyellow';
} else if (($cpu_temp >= 60) && ($cpu_temp < 70)) {
   $color = 'yellow';
} else if ($cpu_temp >= 70) {
   $color = 'red';
} else {
   $color = 'grey';
}

sg ('ThisComputer.CPUtemp_color', $color);
sg ('ThisComputer.CPUtemp_color_-1', $color);

// сдвинем значения с вылетом последнего
for ($i = 9; $i >= 0; $i--) {
   $j = $i - 1;
   sg ('ThisComputer.CPUtemp_'.$i, gg('ThisComputer.CPUtemp_'.$j));
   sg ('ThisComputer.CPUtemp_color_'.$i, gg('ThisComputer.CPUtemp_color_'.$j));
}

//---------------------- Загрузка процессора -----------------------------------------------------
$cpu_load=shell_exec('cat /proc/loadavg');
$pos1 = strpos($cpu_load," ");
$pos2 = strpos($cpu_load," ",$pos1+1);
$pos3 = strpos($cpu_load," ",$pos2+1);
$cpu_load1  = substr($cpu_load,0,$pos1);
$cpu_load5  = substr($cpu_load,$pos1+1,$pos2-$pos1-1);
$cpu_load15  = substr($cpu_load,$pos2+1,$pos3-$pos2-1);
$cpu_load = round($cpu_load1*100/5);
sg('ThisComputer.CPUload', $cpu_load);
//sg('ThisComputer.CPUload1', $cpu_load1);
//sg('ThisComputer.CPUload5', $cpu_load5);
//sg('ThisComputer.CPUload15', $cpu_load15);

$l15 = round ($cpu_load / 6.66); // чтобы из 15 значений 100/15 = 6,(6)
$l15_line = $g_line[$l15];
sg('ThisComputer.CPUload_-1', $l15_line);

// и цвет для неё
if (($cpu_load >= 0) && ($cpu_load < 30)) {
   $color = 'lime';
} else if (($cpu_load >= 30) && ($cpu_load < 45)) {
   $color = 'greenyellow';
} else if (($cpu_load >= 45) && ($cpu_load < 60)) {
   $color = 'yellow';
} else if ($cpu_load >= 60) {
   $color = 'red';
} else {
   $color = 'grey';
}

sg ('ThisComputer.CPUload_color', $color);
sg ('ThisComputer.CPUload_color_-1', $color);

// сдвинем значения с вылетом последнего
for ($i = 9; $i >= 0; $i--) {
   $j = $i - 1;
   sg ('ThisComputer.CPUload_'.$i, gg('ThisComputer.CPUload_'.$j));
   sg ('ThisComputer.CPUload_color_'.$i, gg('ThisComputer.CPUload_color_'.$j));
}

// -------------------- Использование Флешк-карты -------------------------------------------------------------
$bytes = disk_free_space("."); 
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
$temp = round($bytes / pow($base,$class)) . ' ' . $si_prefix[$class];
setGlobal('ThisComputer.DISKused', $temp);
$color = ($disk_used < 80) ? "lime" : "red";
sg ('ThisComputer.DISKused_color', $color);

// -------------------- преобразование Uptime -----------------------------------------------------------
$uptime = gg('ThisComputer.uptime');
$uptime_str = secondsToString($uptime);
sg ('ThisComputer.uptime_str', $uptime_str);

/**
 * Секунды в строку
 * Эта функция возвращает кол-во секунд преобразованное в дни, часы, минуты, секунды
 *
 * @param integer $seconds всего время в секундах.
 * @return string "1234567" возвращает "14 дн., 6 час., 56 мин., 7 сек.".
 */
function secondsToString($seconds) {
    $result = '';
    if ($seconds >= 86400) {
        $days = floor($seconds / 86400);
        $seconds = $seconds % 86400;
        $result = $days.' д., ';
    }
    if ($seconds >= 3600) {
        $hours = floor($seconds / 3600);
        $seconds = $seconds % 3600;
        $result .= $hours.' час., ';
    }
    if ($seconds >= 60) {
        $minutes = floor($seconds / 60);
        $seconds = $seconds % 60;
        $result .= $minutes.' мин., ';
    }
    $result .= $seconds.' сек.';
    return $result;
}