<?php
+function bytes2h($SizeInBytes) {
+ $i = -1;
+ $byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
+ do {
+ $SizeInBytes /= 1024;
+ $i++;
+ } while ($SizeInBytes > 1024);
+
+ #return Math.max(SizeInBytes, 0.1).toFixed(1) + byteUnits[i];
+ return floor($SizeInBytes).$byteUnits[$i];
+}
+
$DBQ['data'] = [
'tables' => [
'host_info_err' => [
." OR (key LIKE '%.exit_code' AND val<> '0')"
,
],
+ 'host_info_backup' => [
+ 'sql' => preg_replace('/[\t\r\n]/','',"
+ SELECT host
+ ,REPLACE(REPLACE(hi.key,'backup_servers.',''),'.dirs','') as server
+ ,'' as time
+ ,'' as files_transfer
+ ,'' as files_total
+ ,'' as bytes_transfer
+ ,'' as bytes_total
+ ,max(updated) as updated
+ FROM host_info hi
+ WHERE key LIKE 'backup_servers.%.dirs'
+ GROUP BY host,server ORDER BY updated DESC, host
+"),
+ 'row_parse_pre' => function(&$row,$t) {
+
+ $sql = "SELECT key,val FROM host_info WHERE host=".$t->db()->quote($row['host'])
+ ." AND key LIKE 'backup_servers.".$row['server'].".%'";
+ ;
+ $rows = $t->db()->rows($sql,PDO::FETCH_ASSOC);
+ foreach($rows as $info) {
+ $info['key'] = preg_replace('/^.*\.([^\.]+)$/','$1',$info['key']);
+ if (preg_match('/^bytes/',$info['key']))
+ #if (preg_match('/(total|transfer)$/',$info['key']))
+ $info['val'] = bytes2h( $info['val'] )
+ ;
+ if (isset($row[ $info['key'] ])) $row[ $info['key'] ] = $info['val'];
+ }
+
+ foreach ($row as $k=>$v) {
+ if (strpos($k,'updated') !== false) $row[$k] = preg_replace('/\..*$/','',$v);
+ }
+ },
+ ],
'host_info_git' => [
'sql' => preg_replace('/[\t\r\n]/','',"
SELECT host