Merge pull request #17 from bergware/master

Updated diagnostics utility
This commit is contained in:
Eric Schultz
2016-05-07 17:39:47 -05:00
7 changed files with 197 additions and 85 deletions

View File

@@ -3,7 +3,7 @@
// Copyright 2015, Lime Technology LLC.
// License: GPLv2 only
//
// Program updates made by Bergware International (December 2014)
// Program updates made by Bergware International (April 2016)
$usage = <<<EOF
Process plugin files.
@@ -196,7 +196,7 @@ function error_desc($code) {
//
function logger($message) {
// echo "$message\n";
shell_exec( "logger $message");
shell_exec("logger $message");
}
// Interpret a plugin file
@@ -207,6 +207,7 @@ function logger($message) {
// is processed for any of those methods.
//
function plugin($method, $plugin_file, &$error) {
global $unraid;
$methods = array("install", "remove");
// parse plugin definition XML file
@@ -245,9 +246,19 @@ function plugin($method, $plugin_file, &$error) {
if (isset($file->attributes()->Method)) {
if (!in_array($method, explode(" ", $file->attributes()->Method))) continue;
} else if ($method != "install") continue;
// Name can be missing but only makes sense if Run attribute is present
$name = $file->attributes()->Name;
// bergware - check unRAID version dependency (if present)
$min = $file->attributes()->Min;
if ($min && version_compare($unraid['version'],$min,'<')) {
echo "plugin: skipping: ".basename($name)." - unRAID version too low, requires at least version $min\n";
continue;
}
$max = $file->attributes()->Max;
if ($max && version_compare($unraid['version'],$max,'>')) {
echo "plugin: skipping: ".basename($name)." - unRAID version too high, requires at most version $max\n";
continue;
}
// Name can be missing but only makes sense if Run attribute is present
if ($name) {
// Ensure parent directory exists
//
@@ -382,6 +393,7 @@ if ($argc < 3) {
// b) [plugin_file] is a URL
// c) dirname of [plugin_file] is not /boot/config/plugins
//
$unraid = parse_ini_file('/etc/unraid-version');
if ($method == "install") {
echo "plugin: installing: $argv[2]\n";
// check for URL
@@ -396,9 +408,18 @@ if ($method == "install") {
}
} else
$plugin_file = realpath($argv[2]);
// bergware - check unRAID version dependency (if present)
$min = plugin("min", $plugin_file, $error);
if ($min && version_compare($unraid['version'],$min,'<')) {
echo "plugin: installed unRAID version is too low, require at least version $min\n";
exit(1);
}
$max = plugin("max", $plugin_file, $error);
if ($max && version_compare($unraid['version'],$max,'>')) {
echo "plugin: installed unRAID version is too high, require at most version $max\n";
exit(1);
}
$plugin = basename($plugin_file);
// check for re-install
$installed_plugin_file = @readlink("/var/log/plugins/$plugin");
if ($installed_plugin_file !== false) {
@@ -418,13 +439,12 @@ if ($method == "install") {
exit(1);
}
// do not re-install if same plugin already installed or has higher version
if (strcmp($version, $installed_version) <= 0) {
if (strcmp($version, $installed_version) < 0) {
echo "plugin: not installing older version\n";
}
if (strcmp($plugin_version, $installed_version) == 0) {
echo "plugin: not reinstalling same version\n";
}
if (strcmp($version, $installed_version) < 0) {
echo "plugin: not installing older version\n";
exit(1);
}
if (strcmp($version, $installed_version) == 0) {
echo "plugin: not reinstalling same version\n";
exit(1);
}
if (plugin("install", $plugin_file, $error) === false) {
@@ -445,9 +465,8 @@ if ($method == "install") {
exit(1);
}
}
// register successful install
// Bergware change: add user or system plugin selection
// Bergware change: add user or system plugin selection - deprecated
$plugintype = plugin("plugintype", $plugin_file, $error);
$target = $plugintype != "system" ? "/boot/config/plugins/$plugin" : "/boot/plugins/$plugin";
if ($target != $plugin_file) copy($plugin_file, $target);
@@ -533,6 +552,17 @@ if ($method == "update") {
echo "plugin: $plugin_file does not exist, check first\n";
exit (1);
}
// bergware - check unRAID version dependency (if present)
$min = plugin("min", $plugin_file, $error);
if ($min && version_compare($unraid['version'],$min,'<')) {
echo "plugin: installed unRAID version is too low, require at least version $min\n";
exit(1);
}
$max = plugin("max", $plugin_file, $error);
if ($max && version_compare($unraid['version'],$max,'>')) {
echo "plugin: installed unRAID version is too high, require at most version $max\n";
exit(1);
}
// install the updated plugin
if (plugin("install", $plugin_file, $error) === false) {
echo "plugin: $error\n";

View File

@@ -33,8 +33,8 @@ $memory_maximum = exec("dmidecode -t 16 | awk -F: '/^\tMaximum Capacity: [0-9]+
// If maximum < installed then roundup maximum to the next power of 2 size of installed. E.g. 6 -> 8 or 12 -> 16
if ($memory_maximum*1024 < $memory_installed) $memory_maximum = pow(2,ceil(log($memory_installed/1024)/log(2)));
function init_row($label,$slots) {
echo "<tr><td>$label</td>".str_repeat("<td></td>",$slots)."</tr>";
function init_row($label) {
echo "<tr><td>$label</td>".str_repeat("<td></td>",30)."</tr>";
}
function parity_status() {
global $var,$disks;
@@ -105,6 +105,11 @@ function export_settings($protocol,$share) {
if ($share['export']=='e') return ucfirst($share['security']);
return '<em>'.ucfirst($share['security']).'</em>';
}
function active_disks($disk) {
return $disk['status']!='DISK_NP' && preg_match('/^(Parity|Data|Cache)$/',$disk['type']);
}
$disks = array_filter($disks,'active_disks');
$slots = count($disks) + count($devs);
?>
<link type="text/css" rel="stylesheet" href="/webGui/styles/context.standalone.css">
<script src="/webGui/javascript/context.js"></script>
@@ -112,32 +117,48 @@ function export_settings($protocol,$share) {
<table class='share_status fixed'>
<thead><tr>
<?
$slots = max(count($disks)+count($devs)-1, 25);
$row0 = array_fill(0,$slots,"<td>-</td>"); $i = 0;
foreach ($disks as $disk)
if ($disk['type']=='Parity' && $disk['status']!='DISK_NP')
$row0[$i++] = "<td>Parity<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($disks as $disk)
if ($disk['type']=='Data' && $disk['status']!='DISK_NP')
$row0[$i++] = "<td>Disk<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($disks as $disk)
if ($disk['type']=='Cache' && $disk['status']!='DISK_NP')
$row0[$i++] = "<td>Cache<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($devs as $dev)
$row0[$i++] = "<td>{$dev['device']}</td>";
$row0 = array_fill(0,30,"<td>-</td>"); $i = 0;
foreach ($disks as $disk) if ($disk['type']=='Parity') $row0[$i++] = "<td>Parity<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($disks as $disk) if ($disk['type']=='Data') $row0[$i++] = "<td>Disk<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
if ($slots <= 30) {
foreach ($disks as $disk) if ($disk['type']=='Cache') $row0[$i++] = "<td>Cache<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($devs as $dev) $row0[$i++] = "<td>{$dev['device']}</td>";
}
echo "<td>Array Status</td>".implode('',$row0);
?>
</tr></thead>
<tbody id='dash0'>
<?init_row('Active')?>
<?init_row('Inactive')?>
<?init_row('Unassigned')?>
<?init_row('Faulty')?>
<?init_row('Heat alarm')?>
<?init_row('SMART status')?>
<?init_row('Utilization')?>
</tbody>
</table>
<?if ($slots > 30):?>
<br>
<table class='share_status fixed'>
<thead><tr>
<?
$row0 = array_fill(0,30,"<td>-</td>"); $i = 0;
foreach ($disks as $disk) if ($disk['type']=='Cache' && $disk['status']!='DISK_NP') $row0[$i++] = "<td>Cache<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
echo "<td>Array Status</td>".implode('',$row0);
?>
</tr></thead>
<tbody id='dash1'>
<?init_row('Active',$slots)?>
<?init_row('Inactive',$slots)?>
<?init_row('Unassigned',$slots)?>
<?init_row('Faulty',$slots)?>
<?init_row('Heat alarm',$slots)?>
<?init_row('SMART status',$slots)?>
<?init_row('Utilization',$slots)?>
<?init_row('Active')?>
<?init_row('Inactive')?>
<?init_row('Unassigned')?>
<?init_row('Faulty')?>
<?init_row('Heat alarm')?>
<?init_row('SMART status')?>
<?init_row('Utilization')?>
</tbody>
</table>
<?endif;?>
<table class='share_status table'>
<thead><tr><td colspan='2'>Parity Status</td></tr></thead>
<tbody><?=parity_status()?></tbody>
@@ -400,8 +421,12 @@ function update30() {
$.post('<?=$url?>',{cmd:'port',view:tag,ports:'<?=implode(',',$ports)?>'},function(data) {
if (data) $.each(data.split('#'),function(k,v) {$('#'+tag+k).html(v);});
});
$.post('<?=$url?>',{cmd:'disk',hot:'<?=$display['hot']?>',max:'<?=$display['max']?>',unit:'<?=$display['unit']?>'},function(data) {
if (data) $('#dash1').html(data);
$.post('<?=$url?>',{cmd:'disk',hot:'<?=$display['hot']?>',max:'<?=$display['max']?>',unit:'<?=$display['unit']?>',slots:<?=$slots?>},function(data) {
<?if ($slots <= 30):?>
if (data) $('#dash0').html(data);
<?else:?>
if (data) $.each(data.split('#'),function(k,v) {$('#dash'+k).html(v);});
<?endif;?>
clearTimeout(timer2);
timer2 = setTimeout(heatAlarm,2000);
$('[id^="smart-"]').each(function() {

View File

@@ -65,25 +65,28 @@ function mhz($speed) {
function rpm($speed) {
return "$speed RPM";
}
function active_disks($disk) {
return $disk['status']!='DISK_NP' && preg_match('/^(Parity|Data|Cache)$/',$disk['type']);
}
$path = '/webGui/images';
$failed = ['FAILED','NOK'];
switch ($_POST['cmd']) {
case 'disk':
$i = 1;
$var = [];
$disks = @parse_ini_file('state/disks.ini',true);
$disks = @array_filter(parse_ini_file('state/disks.ini',true),'active_disks');
$devs = @parse_ini_file('state/devs.ini',true);
$saved = @parse_ini_file('state/monitor.ini',true);
require_once 'CustomMerge.php';
require_once 'Preselect.php';
$slots = max(count($disks)+count($devs)-1, 25)+1;
$row1 = array_fill(0,$slots,'<td></td>'); my_insert($row1[0],'Active');
$row2 = array_fill(0,$slots,'<td></td>'); my_insert($row2[0],'Inactive');
$row3 = array_fill(0,$slots,'<td></td>'); my_insert($row3[0],'Unassigned');
$row4 = array_fill(0,$slots,'<td></td>'); my_insert($row4[0],'Faulty');
$row5 = array_fill(0,$slots,'<td></td>'); my_insert($row5[0],'Heat alarm');
$row6 = array_fill(0,$slots,'<td></td>'); my_insert($row6[0],'SMART status');
$row7 = array_fill(0,$slots,'<td></td>'); my_insert($row7[0],'Utilization');
$slots = $_POST['slots'];
$row1 = array_fill(0,31,'<td></td>'); my_insert($row1[0],'Active');
$row2 = array_fill(0,31,'<td></td>'); my_insert($row2[0],'Inactive');
$row3 = array_fill(0,31,'<td></td>'); my_insert($row3[0],'Unassigned');
$row4 = array_fill(0,31,'<td></td>'); my_insert($row4[0],'Faulty');
$row5 = array_fill(0,31,'<td></td>'); my_insert($row5[0],'Heat alarm');
$row6 = array_fill(0,31,'<td></td>'); my_insert($row6[0],'SMART status');
$row7 = array_fill(0,31,'<td></td>'); my_insert($row7[0],'Utilization');
$funcRenderRow = function($n,$disk) use (&$row1,&$row2,&$row3,&$row4,&$row5,&$row6,&$row7,$path,$_POST) {
if ($n>0) {
$state = $disk['color'];
@@ -115,22 +118,16 @@ case 'disk':
my_usage($row7[$n],($disk['type']!='Parity' && $disk['fsStatus']=='Mounted')?(round((1-$disk['fsFree']/$disk['fsSize'])*100).'%'):'');
}
};
foreach ($disks as $disk)
if ($disk['type']=='Parity' && $disk['status']!='DISK_NP')
$funcRenderRow($i++,$disk);
foreach ($disks as $disk)
if ($disk['type']=='Data' && $disk['status']!='DISK_NP')
$funcRenderRow($i++,$disk);
foreach ($disks as $disk)
if ($disk['type']=='Cache' && $disk['status']!='DISK_NP') {
if ($disk['name']!='cache') $disk['fsStatus']=='-';
$funcRenderRow($i++,$disk);
foreach ($disks as $disk) if ($disk['type']=='Parity') $funcRenderRow($i++,$disk);
foreach ($disks as $disk) if ($disk['type']=='Data') $funcRenderRow($i++,$disk);
if ($slots <= 30) {
foreach ($disks as $disk) if ($disk['type']=='Cache') $funcRenderRow($i++,$disk);
foreach ($devs as $dev) {
$device = $dev['device'];
$state = exec("hdparm -C /dev/$device|grep -Po active") ? 'blue-on' : 'blue-blink';
if ($state=='blue-on') my_smart($row6[$i],$device,'New');
my_insert($row3[$i++],"<img src=$path/$state.png>");
}
foreach ($devs as $dev) {
$device = $dev['device'];
$state = exec("hdparm -C /dev/$device|grep -Po active") ? 'blue-on' : 'blue-blink';
if ($state=='blue-on') my_smart($row6[$i],$device,'New');
my_insert($row3[$i++],"<img src=$path/$state.png>");
}
echo "<tr>".implode('',$row1)."</tr>";
echo "<tr>".implode('',$row2)."</tr>";
@@ -139,6 +136,30 @@ case 'disk':
echo "<tr>".implode('',$row5)."</tr>";
echo "<tr>".implode('',$row6)."</tr>";
echo "<tr>".implode('',$row7)."</tr>";
if ($slots > 30) {
echo '#'; $i = 1;
$row1 = array_fill(0,31,'<td></td>'); my_insert($row1[0],'Active');
$row2 = array_fill(0,31,'<td></td>'); my_insert($row2[0],'Inactive');
$row3 = array_fill(0,31,'<td></td>'); my_insert($row3[0],'Unassigned');
$row4 = array_fill(0,31,'<td></td>'); my_insert($row4[0],'Faulty');
$row5 = array_fill(0,31,'<td></td>'); my_insert($row5[0],'Heat alarm');
$row6 = array_fill(0,31,'<td></td>'); my_insert($row6[0],'SMART status');
$row7 = array_fill(0,31,'<td></td>'); my_insert($row7[0],'Utilization');
foreach ($disks as $disk) if ($disk['type']=='Cache') $funcRenderRow($i++,$disk);
foreach ($devs as $dev) {
$device = $dev['device'];
$state = exec("hdparm -C /dev/$device|grep -Po active") ? 'blue-on' : 'blue-blink';
if ($state=='blue-on') my_smart($row6[$i],$device,'New');
my_insert($row3[$i++],"<img src=$path/$state.png>");
}
echo "<tr>".implode('',$row1)."</tr>";
echo "<tr>".implode('',$row2)."</tr>";
echo "<tr>".implode('',$row3)."</tr>";
echo "<tr>".implode('',$row4)."</tr>";
echo "<tr>".implode('',$row5)."</tr>";
echo "<tr>".implode('',$row6)."</tr>";
echo "<tr>".implode('',$row7)."</tr>";
}
break;
case 'sys':
exec("grep -Po '^Mem(Total|Available):\s+\K\d+' /proc/meminfo",$memory);

View File

@@ -325,8 +325,6 @@ echo "</span></div>";
?>
<script>
$(function() {
var updateText = '';
var pluginName = '';
<?if ($notify['entity'] & 1 == 1):?>
$.post('/webGui/include/Notify.php',{cmd:'init'},function(x){timers.notifier = setTimeout(notifier,0);});
<?endif;?>
@@ -340,15 +338,16 @@ $(function() {
var top = ($.cookie('top')||0) - $('.tabs').offset().top - 75;
if (top>0) {$('html,body').scrollTop(top);}
$.removeCookie('top',{path:'/'});
<?if (strpos(file_get_contents('/proc/cmdline'),'unraidsafemode')!==false):?>
showNotice('System running in <b>safe</b> mode');
<?else:?>
<?if ($version = plugin_update_available('unRAIDServer')):?>
updateText = 'unRAID OS v<?=$version?> is available. <a>Download Now</a>';
pluginName = 'unRAIDServer';
showNotice('unRAID OS v<?=$version?> is available. <a>Download Now</a>','unRAIDServer');
<?elseif ($version = plugin_update_available('dynamix')):?>
showNotice('Dynamix webGUI v<?=$version?> is available. <a>Download Now</a>','dynamix');
<?endif;?>
<?if ($version = plugin_update_available('dynamix')):?>
if (!updateText) {updateText = 'Dynamix GUI <b><?=$version?></b> is available. <a>Download Now</a>'; pluginName = 'dynamix';}
<?endif;?>
if (updateText) showNotice(updateText,pluginName);
if (location.pathname.indexOf('/AddVM')==-1 && location.pathname.indexOf('/UpdateVM')==-1 && location.pathname.indexOf('/AddContainer')==-1 && location.pathname.indexOf('/UpdateContainer')==-1) {
if (location.pathname.search(/\/(AddVM|UpdateVM|AddContainer|UpdateContainer)/)==-1) {
$('blockquote.inline_help').each(function(i) {
$(this).attr('id','helpinfo'+i);
var pin = $(this).prev();

View File

@@ -16,6 +16,10 @@ $opt = getopt('a',['all']);
$all = isset($opt['a']) || isset($opt['all']);
$zip = $all ? $argv[2] : $argv[1];
$cli = empty($zip);
$get = "/var/local/emhttp";
$var = file_exists("$get/var.ini") ? parse_ini_file("$get/var.ini") : [];
$folders = ['/boot','/boot/config','/boot/config/plugins','/boot/extra','/boot/syslinux','/var/log','/var/log/plugins','/var/log/packages','/tmp'];
function anonymize($text,$select) {
global $all;
@@ -47,7 +51,6 @@ if ($cli) {
// script is called from CLI
echo "Starting diagnostics collection... ";
exec("mkdir -p /boot/logs");
$var = @parse_ini_file("/var/local/emhttp/var.ini");
$server = isset($var['NAME']) ? str_replace(' ','_',strtolower($var['NAME'])) : 'tower';
$date = date('Ymd-Hi');
$diag = "$server-diagnostics-$date";
@@ -60,8 +63,11 @@ if ($cli) {
}
// create folder structure
exec("mkdir -p /$diag/system /$diag/config /$diag/logs /$diag/shares /$diag/smart /$diag/qemu");
// make unRAID version reference
$unraid = parse_ini_file('/etc/unraid-version');
file_put_contents("/$diag/unRAID-".$unraid['version'].".txt",$unraid['version']);
// copy ini variables
foreach (glob("/var/local/emhttp/*.ini") as $file) {
foreach (glob("$get/*.ini") as $file) {
$ini = basename($file,".ini");
// skip users file in anonymized mode
if ($all || $ini != "users") file_put_contents("/$diag/system/vars.txt",preg_replace(["/\n/","/^Array/"],["\r\n",$ini],anonymize(print_r(parse_ini_file($file,true),true),1)),FILE_APPEND);
@@ -73,6 +79,7 @@ exec("free -mt 2>/dev/null|todos >/$diag/system/memory.txt");
exec("ps -ef 2>/dev/null|todos >/$diag/system/ps.txt");
exec("lsof -Pni 2>/dev/null|todos >/$diag/system/lsof.txt");
exec("lsmod 2>/dev/null|todos >/$diag/system/lsmod.txt");
exec("df -h 2>/dev/null|todos >/$diag/system/df.txt");
exec("ifconfig -s 2>/dev/null|grep -Po '^(eth|bond)[0-9]+'", $ports);
// create ethernet information information (suppress errors)
foreach ($ports as $port) {
@@ -85,6 +92,11 @@ exec("ifconfig 2>/dev/null|todos >/$diag/system/ifconfig.txt");
// create system information (suppress errors)
exec("find /sys/kernel/iommu_groups/ -type l 2>/dev/null|todos >/$diag/system/iommu_groups.txt");
exec("todos </proc/cmdline >/$diag/system/cmdline.txt");
// create folder structure listing
$dest = "/$diag/system/folders.txt";
foreach ($folders as $folder) {
if (is_dir($folder)) exec("echo -ne \"\r\n$folder\r\n\" >>$dest;ls -l $folder|todos >>$dest"); else exec("echo -ne \"\r\n$folder\r\nfolder does not exist\r\n\" >>$dest");
}
// copy configuration files (suppress errors)
exec("cp /boot/config/*.{cfg,conf,dat} /boot/config/go /$diag/config 2>/dev/null");
// anonymize configuration files
@@ -98,27 +110,29 @@ foreach ($files as $file) {
if (!$all) exec("sed -ri 's/^(share(Comment|ReadList|WriteList)=\")[^\"]+/\\1.../' '$dest' 2>/dev/null");
}
// create default user shares information
$ini = "/var/local/emhttp/shares.ini";
$shares = file_exists($ini) ? parse_ini_file($ini, true) : [];
$shares = file_exists("$get/shares.ini") ? parse_ini_file("$get/shares.ini", true) : [];
foreach ($shares as $share) {
$name = $share['name'];
if (!in_array("/boot/config/shares/$name.cfg",$files)) file_put_contents(anonymize("/$diag/shares/$name.cfg",2),"# This share has default settings.\r\n");
}
// copy syslog information (anonymize if applicable)
$max = 3*1024*1024; //3MB
foreach (glob("/var/log/syslog*") as $file) {
$dest = "/$diag/logs/".basename($file).".txt";
exec("todos <$file >$dest");
$log = "/$diag/logs/".basename($file);
exec("todos <$file >$log.txt");
if (!$all) {
unset($titles,$rows);
exec("grep -Po 'logger: moving \"\K[^\"]+' $dest 2>/dev/null|sort|uniq", $titles);
exec("sed -ri 's|\b\S+@\S+\.\S+\b|xxx@removed.com|;s|\b(username\|password)([=:])\S+\b|\\1\\2xxx|;s|(GUID: \S)\S+(\S) |\\1..\\2 |;s|(moving \"\S\|\"/mnt/user/\S).*(\S)\"|\\1..\\2\"|' $dest");
exec("grep -Po 'logger: moving \"\K[^\"]+' $log.txt 2>/dev/null|sort|uniq", $titles);
exec("sed -ri 's|\b\S+@\S+\.\S+\b|xxx@removed.com|;s|\b(username\|password)([=:])\S+\b|\\1\\2xxx|;s|(GUID: \S)\S+(\S) |\\1..\\2 |;s|(moving \"\S\|\"/mnt/user/\S).*(\S)\"|\\1..\\2\"|' $log.txt");
foreach ($titles as $mover) {
$title = "/{$mover[0]}..".substr($mover,-1)."/...";
exec("sed -ri 's|(logger: [.>cr].*)[ /]$mover/.*$|\\1 file: $title|' $dest 2>/dev/null");
exec("sed -ri 's|(logger: [.>cr].*)[ /]$mover/.*$|\\1 file: $title|' $log.txt 2>/dev/null");
}
exec("grep -n ' cache_dirs: -' $dest 2>/dev/null|cut -d: -f1", $rows);
for ($i = 0; $i < count($rows); $i += 2) for ($row = $rows[$i]+1; $row < $rows[$i+1]; $row++) exec("sed -ri '$row s|(cache_dirs: \S).*(\S)|\\1..\\2|' $dest 2>/dev/null");
exec("grep -n ' cache_dirs: -' $log.txt 2>/dev/null|cut -d: -f1", $rows);
for ($i = 0; $i < count($rows); $i += 2) for ($row = $rows[$i]+1; $row < $rows[$i+1]; $row++) exec("sed -ri '$row s|(cache_dirs: \S).*(\S)|\\1..\\2|' $log.txt 2>/dev/null");
}
exec("tail -n 200 $log.txt >$log.last200.txt");
exec("truncate -s '<$max' $log.txt");
}
// copy docker information (if existing)
$docker = "/var/log/docker.log";
@@ -131,10 +145,31 @@ if ($qemu)
else
file_put_contents("/$diag/qemu/no qemu log files","");
// create SMART reports (suppress errors)
$disks = file_exists("$get/disks.ini") ? parse_ini_file("$get/disks.ini", true) : [];
include_once '/usr/local/emhttp/webGui/include/CustomMerge.php';
exec("ls -l /dev/disk/by-id/[au]* 2>/dev/null|awk '$0!~/-part/{split($11,a,\"/\");print a[3],substr($9,21)}'", $devices);
foreach ($devices as $device) {
$disk = explode(' ',$device);
exec("smartctl -a /dev/${disk[0]} 2>/dev/null|todos >/$diag/smart/${disk[1]}-$date.txt");
$type = '';
foreach ($disks as $find) {
if ($find['device']==$disk[0]) {
$type = isset($find['smType']) ? $find['smType'] : -1;
if ($type==-1) $type = isset($var['smType']) ? $var['smType'] : '';
if ($type) {
$ports = [];
if (isset($find['smDevice']) && strlen($find['smDevice'])) $port = $find['smDevice'];
if (isset($find['smPort1']) && strlen($find['smPort1'])) $ports[] = $find['smPort1'];
if (isset($find['smPort2']) && strlen($find['smPort2'])) $ports[] = $find['smPort2'];
if (isset($find['smPort3']) && strlen($find['smPort3'])) $ports[] = $find['smPort3'];
if ($ports) {
$glue = isset($find['smGlue']) ? $find['smGlue'] : ',';
$type .= ','.implode($glue,$ports);
}
}
break;
}
}
exec("smartctl -a $type /dev/${disk[0]} 2>/dev/null|todos >/$diag/smart/${disk[1]}-$date.txt");
}
// create resulting zip file and remove temp folder
exec("zip -qmr $zip /$diag");

View File

@@ -148,7 +148,8 @@ table.share_status tr.share_status_size>td+td{padding-left:15px;}
table.share_status tbody tr:nth-child(even){background-color:#0C0C0C;}
table.share_status.share tr td:last-child{width:4%;text-align:right;padding-right:10px;}
table.share_status.fixed{border:1px solid #202020;}
table.share_status.fixed tr>td+td{width:45px;text-align:center;padding:0;}
table.share_status.fixed thead tr>td+td{font-size:11px;}
table.share_status.fixed tr>td+td{width:38px;text-align:center;padding:0;}
table.share_status.fixed tbody tr{border-bottom:1px #202020 dotted;}
table.share_status.fixed tbody tr:nth-child(even){background-color:#000000;}
table.share_status.fixed tbody tr td:nth-child(even){background-color:#0C0C0C;}

View File

@@ -146,7 +146,8 @@ table.share_status tr.share_status_size>td+td{padding-left:15px;}
table.share_status tbody tr:nth-child(even){background-color:#F8F8F8;}
table.share_status.share tr td:last-child{width:4%;text-align:right;padding-right:10px;}
table.share_status.fixed{border:1px solid #D0D0D0;}
table.share_status.fixed tr>td+td{width:45px;text-align:center;padding:0;}
table.share_status.fixed thead tr>td+td{font-size:11px;}
table.share_status.fixed tr>td+td{width:38px;text-align:center;padding:0;}
table.share_status.fixed tbody tr{border-bottom:1px #D0D0D0 dotted;}
table.share_status.fixed tbody tr:nth-child(even){background-color:#FFFFFF;}
table.share_status.fixed tbody tr td:nth-child(even){background-color:#F8F8F8;}