Compare commits

...

14 Commits

Author SHA1 Message Date
Tom Mortensen
bbed6047e3 Introduce 'Allocation profile' config setting for specifying pool/subpool data layout
Fix: spindown delay setting missing for parity devices
2024-07-12 11:53:32 -07:00
Tom Mortensen
a7f6ac7389 maybe needed in future 2024-07-10 23:01:09 -07:00
Tom Mortensen
f7748f7619 make executable 2024-07-10 23:00:20 -07:00
Tom Mortensen
d4968e1b19 simplify display of file system type on Main 2024-07-10 22:59:53 -07:00
Tom Mortensen
fb680469ac fix git glitch which resulted in file not updated 2024-07-10 22:58:42 -07:00
tom mortensen
eaabbec7e0 Merge pull request #1780 from unraid/fix-trim
Make trim consistent between "trim now" and cron job
2024-07-10 21:41:39 -07:00
ljm42
693a0260af Make trim consistent between "Run now" and cron job 2024-07-10 17:59:15 -07:00
tom mortensen
130c9c6373 Merge pull request #1779 from ich777/ich777-agents-fix
Fix for notification agents
2024-07-10 14:22:17 -07:00
73c264e9fe Fix
- Fix PushBits and Pushbullet not showing up
2024-07-10 14:47:06 +02:00
667741129a Fix
- Fix PushBits and Pushbullet not showing up
2024-07-10 14:45:49 +02:00
tom mortensen
42fe45595f Merge pull request #1778 from dlandon/master
Parity check does not show completed on array operations page.
2024-07-09 13:44:58 -07:00
dlandon
ed9b8322d4 Fix clobbering CAs $cfg variable. 2024-07-09 14:57:58 -05:00
dlandon
cfb2daa531 Update help text for PID Limit. 2024-07-09 06:37:58 -05:00
dlandon
694d35b412 Parity check does not show completed on array operations page. 2024-07-09 06:21:29 -05:00
10 changed files with 149 additions and 74 deletions

View File

@@ -12,11 +12,6 @@
*/
?>
<?
/* Read the docker configuration file. */
$cfgfile = "/boot/config/docker.cfg";
$config_ini = @parse_ini_file($cfgfile, true, INI_SCANNER_RAW);
$cfg = ($config_ini !== false) ? $config_ini : [];
function addRoute($ct) {
// add static route(s) for remote WireGuard access
[$pid,$net] = array_pad(explode(' ',exec("docker inspect --format='{{.State.Pid}} {{.NetworkSettings.Networks}}' $ct")),2,'');
@@ -242,7 +237,7 @@ function xmlSecurity(&$template) {
}
function xmlToCommand($xml, $create_paths=false) {
global $docroot, $var, $cfg, $driver;
global $docroot, $var, $driver;
$xml = xmlToVar($xml);
$cmdName = strlen($xml['Name']) ? '--name='.escapeshellarg($xml['Name']) : '';
$cmdPrivileged = strtolower($xml['Privileged'])=='true' ? '--privileged=true' : '';
@@ -307,12 +302,17 @@ function xmlToCommand($xml, $create_paths=false) {
}
}
/* Read the docker configuration file. */
$cfgfile = "/boot/config/docker.cfg";
$config_ini = @parse_ini_file($cfgfile, true, INI_SCANNER_RAW);
$docker_cfg = ($config_ini !== false) ? $config_ini : [];
// Add pid limit if user has not specified it as an extra parameter
$pidsLimit = preg_match('/--pids-limit (\d+)/', $xml['ExtraParams'], $matches) ? $matches[1] : null;
if ($pidsLimit === null) {
$pid_limit = "--pids-limit ";
if (($cfg['DOCKER_PID_LIMIT']??'') != "") {
$pid_limit .= $cfg['DOCKER_PID_LIMIT'];
if (($docker_cfg['DOCKER_PID_LIMIT']??'') != "") {
$pid_limit .= $docker_cfg['DOCKER_PID_LIMIT'];
} else {
$pid_limit .= "2048";
}

View File

@@ -18,22 +18,18 @@ Nchan="device_list,disk_load,parity_list"
<?
$keyfile = file_exists(_var($var,'luksKeyfile'));
$missing = file_exists('/var/tmp/missing.tmp');
$encrypt = false;
$spot = _var($var,'mdResyncPos',0)>0;
$poolsOnly = (_var($var,'SYS_ARRAY_SLOTS') == 0 ) ? true : false;
/* only one of $present, $missing, or $wrong will be true, or all will be false */
$forced = $present = $wrong = false;
foreach ($disks as $disk) {
if (!isset($disk['fsType'])) continue;
if (strpos(_var($disk,'fsType'),'luks:')!==false || (_var($disk,'fsType')=='auto' && (strpos(_var($var,'defaultFsType'),'luks:')!==false || _var($disk,'luksState',0)==2 || _var($disk,'luksState',0)==3))) {
$encrypt = true;
if (_var($disk,'luksState',0)==0) $forced = true;
if (_var($disk,'luksState',0)==1) $present = true;
if (_var($disk,'luksState',0)==2) $missing = true;
if (_var($disk,'luksState',0)==3) $wrong = true;
}
if (strpos(_var($disk,'fsType'),'luks:')!==false || (_var($disk,'fsType')=='auto' && strpos(_var($var,'defaultFsType'),'luks:')!==false)) $forced = true;
if (_var($disk,'luksState',0)==1) $present = true;
if (_var($disk,'luksState',0)==2) $missing = true;
if (_var($disk,'luksState',0)==3) $wrong = true;
}
$encrypt = $forced || $present || $missing || $wrong;
if ($forced && ($present || $missing || $wrong)) $forced = false;
function check_encryption() {
@@ -383,7 +379,7 @@ devices.on('message', function(msg,meta) {
$.each(get,function(k,v) {if ($('#line'+k).length>0) $('#line'+k).html(v);});
// button control
if ($('#pauseButton').length>0 && $('#pauseButton').prop('disabled')==false) {
if (!msg && $('#cancelButton').length>0 && $('#cancelButton').val()=="_(Cancel)_") {
if ((get === "") && $('#cancelButton').val()=="_(Cancel)_") {
$('#cancelButton').val("_(Done)_").prop('onclick',null).off('click').click(function(){refresh();});
$('#pauseButton').prop('disabled',true);
$('#cancelText').html('');

View File

@@ -267,7 +267,11 @@ function selectDiskFsProfile(init) {
}
<?endif;?>
} else if (($('#diskFsType').val()||'').indexOf('zfs') != -1) {
var subpool = "<?=isSubpool(_var($disk,'name'))?>";
$('#diskFsProfileBTRFS').prop('disabled',true).hide();
if (subpool.length) {
$('#diskFsType').prop('disabled',true).hide();
}
if (!init) {
$('#diskFsProfileZFS').prop('disabled',false);
$('#diskFsWidthZFS').prop('disabled',false);
@@ -601,7 +605,7 @@ _(Spinup group(s))_:
: <input type="text" name="diskSpinupGroup.<?=_var($disk,'idx',0)?>" maxlength="256" value="<?=_var($disk,'spinupGroup')?>">
<?endif;?>
<?if (diskType('Data') || isPool($tag)):?>
<?if (diskType('Data','Parity') || isPool($tag)):?>
_(Spin down delay)_:
: <select name="diskSpindownDelay.<?=_var($disk,'idx',0)?>">
<?=mk_option(_var($disk,'spindownDelay'), "-1", _('Use default'))?>
@@ -620,11 +624,13 @@ _(Spin down delay)_:
<?=mk_option(_var($disk,'spindownDelay'), "9", "9 "._('hours'))?>
</select><span id="smart_selftest" class='orange-text'></span>
<?endif;?>
<?if (diskType('Data') || isPool($tag)):?>
<?$fsTypeImmutable = (_var($var,'fsState')=="Stopped" && !empty(_var($disk,'uuid'))) || (_var($var,'fsState')=="Started" && _var($disk,'fsType')!='auto')?>
<?if (diskType('Data') || (!isSubpool($name) && _var($disk,'slots',0)==1)):?>
_(File system status)_:
: <?=_(_var($disk,'fsStatus'))?>&nbsp;
<?$fsTypeImmutable = (_var($var,'fsState')=="Stopped" && !empty(_var($disk,'uuid'))) || (_var($var,'fsState')=="Started" && _var($disk,'fsType')!='auto')?>
<?if (diskType('Data') || (!isSubpool($name) && _var($disk,'slots',0)==1)):?>
_(File system type)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" onchange="changeFsType()" <?=disabled_if($fsTypeImmutable)?>>
<?=mk_option(_var($disk,'fsType'), "auto", _('auto'))?>
@@ -641,6 +647,9 @@ _(File system type)_:
:info_file_system_help:
<?elseif (!isSubpool($name) && _var($disk,'slots',0)>1):?>
_(File system status)_:
: <?=_(_var($disk,'fsStatus'))?>&nbsp;
_(File system type)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" onchange="selectDiskFsProfile(false)" <?=disabled_if($fsTypeImmutable)?>>
<?=mk_option(_var($disk,'fsType'), "auto", _('auto'))?>
@@ -649,7 +658,9 @@ _(File system type)_:
<?=mk_option(_var($disk,'fsType'), "luks:zfs", _('zfs')." - "._('encrypted'))?>
<?=mk_option(_var($disk,'fsType'), "luks:btrfs", _('btrfs')." - "._('encrypted'))?>
</select>
<select id="diskFsProfileBTRFS" name="diskFsProfile.<?=_var($disk,'idx',0)?>" style="display:none" <?=disabled_if($fsTypeImmutable)?>>
_(Allocation profile)_:
: <select id="diskFsProfileBTRFS" name="diskFsProfile.<?=_var($disk,'idx',0)?>" style="display:none" <?=disabled_if($fsTypeImmutable)?>>
<?=mk_option(_var($disk,'fsProfile'),"single", _('single'))?>
<?if (_var($disk,'slots',0)>=2) echo mk_option(_var($disk,'fsProfile'),"raid0", _('raid0'))?>
<?if (_var($disk,'slots',0)>=2) echo mk_option(_var($disk,'fsProfile'),"raid1", _('raid1'))?>
@@ -670,8 +681,8 @@ _(File system type)_:
<select id="diskFsWidthZFS" name="diskFsWidth.<?=_var($disk,'idx',0)?>" style="display:none" <?=disabled_if($fsTypeImmutable)?>>
</select>
<?elseif (isSubpool($name)=="special" || isSubpool($name)=="logs" || isSubpool($name)=="dedup"):?>
_(File system type)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" onchange="selectDiskFsProfile(false)" <?=disabled_if($fsTypeImmutable)?>>
_(Allocation profile)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" disabled>>
<?=mk_option(_var($disk,'fsType'), "zfs", _('zfs'))?>
</select>
<select id="diskFsProfileZFS" name="diskFsProfile.<?=_var($disk,'idx',0)?>" onchange="selectDiskFsWidth()" <?=disabled_if($fsTypeImmutable)?>>
@@ -682,8 +693,8 @@ _(File system type)_:
<select id="diskFsWidthZFS" name="diskFsWidth.<?=_var($disk,'idx',0)?>" style="display:none" <?=disabled_if($fsTypeImmutable)?>>
</select>
<?elseif (isSubpool($name)=="cache"):?>
_(File system type)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" onchange="selectDiskFsProfile(false)" <?=disabled_if($fsTypeImmutable)?>>
_(Allocation profile)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" disabled>>
<?=mk_option(_var($disk,'fsType'), "zfs", _('zfs'))?>
</select>
<select id="diskFsProfileZFS" name="diskFsProfile.<?=_var($disk,'idx',0)?>" onchange="selectDiskFsWidth()" <?=disabled_if($fsTypeImmutable)?>>
@@ -693,10 +704,6 @@ _(File system type)_:
<select id="diskFsWidthZFS" name="diskFsWidth.<?=_var($disk,'idx',0)?>" style="display:none" <?=disabled_if($fsTypeImmutable)?>>
</select>
<?elseif (isSubpool($name)=="spares"):?>
_(File system type)_:
: <select id="diskFsType" name="diskFsType.<?=_var($disk,'idx',0)?>" onchange="selectDiskFsProfile(false)" <?=disabled_if($fsTypeImmutable)?>>
<?=mk_option(_var($disk,'fsType'), "zfs", _('zfs'))?>
</select>
<?endif;?>
<?if (isSubpool($name)===false):?>

View File

@@ -37,26 +37,3 @@
]]>
</Script>
</Agent>
<Agent>
<Name>Pushbullet</Name>
<Variables>
<Variable Help="The Access Token can be found [a href='https://www.pushbullet.com/account' target='_blank'] [u]here[/u].[/a]" Desc="Access Token" Default="">TOKEN</Variable>
<Variable Help="Specify the fields which are included in the title of the notification." Desc="Notification Title" Default="$SUBJECT">TITLE</Variable>
<Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable>
</Variables>
<Script>
<![CDATA[
#!/bin/bash
##########
{0}
##########
MESSAGE=$(echo "$MESSAGE" | sed -e 's:<br[ /]*>:\\n:gI' -e 's/<[^>]*>//g')
curl -s -k \
-X POST --header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
-d "{\"type\": \"note\", \"title\": \"$TITLE\", \"body\": \"$MESSAGE\"}" \
https://api.pushbullet.com/v2/pushes 2>&1
]]>
</Script>
</Agent>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Agent>
<Name>Pushbullet</Name>
<Variables>
<Variable Help="The Access Token can be found [a href='https://www.pushbullet.com/account' target='_blank'] [u]here[/u].[/a]" Desc="Access Token" Default="">TOKEN</Variable>
<Variable Help="Specify the fields which are included in the title of the notification." Desc="Notification Title" Default="$SUBJECT">TITLE</Variable>
<Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable>
</Variables>
<Script>
<![CDATA[
#!/bin/bash
##########
{0}
##########
MESSAGE=$(echo "$MESSAGE" | sed -e 's:<br[ /]*>:\\n:gI' -e 's/<[^>]*>//g')
curl -s -k \
-X POST --header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
-d "{\"type\": \"note\", \"title\": \"$TITLE\", \"body\": \"$MESSAGE\"}" \
https://api.pushbullet.com/v2/pushes 2>&1
]]>
</Script>
</Agent>

View File

@@ -119,12 +119,12 @@ function assignment(&$disk) {
function vfs_luks($fs) {
return str_starts_with($fs,'luks:');
}
function vfs_type(&$disk, $parent=false) {
function vfs_type(&$disk) {
global $disks, $pools, $crypto;
$fsType = _var($disk,'fsType');
$name = _var($disk,'name');
$type = ($parent || _var($disk,'type')=='Cache' && !in_array($name,$pools)) ? _var($disks[prefix($name)],'fsType') : $fsType;
$fsType = _var($disk,'fsType','');
$luks = '';
if (empty($fsType))
return $fsType;
if ($crypto) switch (_var($disk,'luksState',0)) {
case 0:
if (vfs_luks($fsType))
@@ -146,14 +146,14 @@ function vfs_type(&$disk, $parent=false) {
$luks = "<a class='info'><i class='padlock fa fa-lock red-text'></i><span>"._('Device locked: unknown error')."</span></a>";
break;
}
return $luks.str_replace('luks:','',$type);
return $luks.str_replace('luks:','',$fsType);
}
function fs_info(&$disk) {
global $display, $pools;
global $display;
$echo = [];
if (empty($disk['fsStatus']) || $disk['fsStatus']=='-') {
return (_var($disk,'type')=='Cache') ? "<td>".vfs_type($disk,true)."</td><td colspan='3'>"._('Device is part of a pool')."</td>" : "<td colspan='4'></td>";
} elseif (_var($disk,'fsStatus')=='Mounted') {
if (empty($disk['fsStatus']) || $disk['fsStatus']=='-')
return "<td>".$disk['fsStatus']."</td><td colspan='3'></td>";
if (_var($disk,'fsStatus')=='Mounted') {
$echo[] = "<td>".vfs_type($disk)."</td>";
$echo[] = "<td>".my_scale(_var($disk,'fsSize',0)*1024,$unit,-1)." $unit</td>";
if ($display['text']%10==0) {
@@ -194,7 +194,7 @@ function array_offline(&$disk, $pool='') {
if (_var($disk,'type')=='Parity') $warning = $text;
} elseif (_var($var,'mdState')=='RECON_DISK') {
if (in_array(_var($disk,'status'),$status)) $warning = $text;
} elseif (_var($disk['status'])=='DISK_NEW') {
} elseif (_var($disk['status'])=='DISK_NEW' && _var($var,'mdResyncAction')=='clear') {
$warning = $text;
}
}
@@ -209,7 +209,9 @@ function array_offline(&$disk, $pool='') {
case 'DISK_NP_MISSING':
$echo[] = "<td>".device_info($disk,false)."<br><span class='diskinfo'><em>"._('Missing')."</em></span></td>";
$echo[] = "<td>".assignment($disk)."<em>{$disk['idSb']} - ".my_scale(_var($disk,'sizeSb',0)*1024,$unit)." $unit</em></td>";
$echo[] = "<td colspan='8'></td>";
$echo[] = "<td colspan='4'></td>";
$echo[] = "<td>".vfs_type($disk)."</td>";
$echo[] = "<td colspan='3'></td>";
break;
case 'DISK_NP_DSBL':
$echo[] = "<td>".device_info($disk,false)."</td>";

View File

@@ -107,6 +107,9 @@ while (true) {
file_put_contents($log, "$timestamp|$duration|$speed|$status|$error|$action|$size\n", FILE_APPEND);
delete_file($stamps, $resync);
/* Parity check is completed. */
$echo = "";
}
}
@@ -130,7 +133,7 @@ while (true) {
$process = 2;
} elseif (exec('ps -C btrfs -o cmd=|grep -cv show') > 0) {
$process = 3;
} elseif (exec("zpool status|grep -c 'scrub in progress'") > 0) {
} elseif (exec("zpool status 2>/dev/null | grep -c 'scrub in progress'") > 0) {
$process = 4;
} else {
$process = 0;

View File

@@ -19,7 +19,7 @@ extract(parse_plugin_cfg('dynamix',true));
// cron operation
if ($argc==2 && $argv[1]=='cron') {
// trim btrfs, xfs
echo shell_exec("fstrim -va 2>/dev/null");
xfs_btrfs_trim(false);
// trim zfs
zfs_trim(false);
exit(0);
@@ -72,16 +72,24 @@ function zfs_trim($write) {
}
}
function xfs_btrfs_trim($write) {
exec("findmnt -lnt btrfs,xfs -o target,source|awk '\$2!~\"\\\\[\"{print \$1,\$2}'",$mounts);
foreach ($mounts as $mount) {
[$target,$source] = explode(' ',$mount);
if (is_hdd($source)) continue;
if ($write) write("$target: ... <i class='fa fa-spin fa-circle-o-notch'></i>\r");
$trim = exec("fstrim -v $target 2>/dev/null");
if ($write) {
if ($trim) write("$trim on $source\r","\n"); else write("\r");
} else {
if ($trim) echo("$trim on $source\n");
}
}
}
write(_("TRIM operation started")."\n","\n","\n");
// trim btrfs, xfs
exec("findmnt -lnt btrfs,xfs -o target,source|awk '\$2!~\"\\\\[\"{print \$1,\$2}'",$mounts);
foreach ($mounts as $mount) {
[$target,$source] = explode(' ',$mount);
if (is_hdd($source)) continue;
write("$target: ... <i class='fa fa-spin fa-circle-o-notch'></i>\r");
$trim = exec("fstrim -v $target 2>/dev/null");
if ($trim) write("$trim on $source\r","\n"); else write("\r");
}
xfs_btrfs_trim(true);
// trim zfs
zfs_trim(true);
write(_("Finished")."\n",'_DONE_','');

0
emhttp/plugins/dynamix/system/ZFS_cache Normal file → Executable file
View File

58
etc/rc.d/rc.sysstat Normal file
View File

@@ -0,0 +1,58 @@
#!/bin/sh
#
# chkconfig: 12345 01 99
# description: Reset the system activity logs
#
# /etc/rc.d/rc.sysstat
# (C) 2000-2024 Sebastien Godard (sysstat <at> orange.fr)
#
### BEGIN INIT INFO
# Provides: sysstat
# Required-Start:
# Required-Stop:
# Default-Start: 1 2 3 4 5
# Default-Stop: 0 6
# Description: Reset the system activity logs
# Short-Description: Reset the system activity logs
### END INIT INFO
#@(#) sysstat-12.7.6 startup script:
#@(#) Insert a dummy record in current daily data file.
#@(#) This indicates that the counters have restarted from 0.
# Source functions library
[ -r /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
RETVAL=0
PIDFILE=/var/run/sysstat.pid
[ -z "$UID" ] && UID=`id -u`
# See how we were called.
case "$1" in
start)
[ $UID -eq 0 ] || exit 4
echo $$ > $PIDFILE || exit 1
echo -n "Calling the system activity data collector (sadc)... "
/usr/lib64/sa/sa1 --boot
[ $? -eq 0 ] || RETVAL=1
rm -f $PIDFILE
echo
;;
status)
[ -f $PIDFILE ] || RETVAL=3
;;
stop)
[ $UID -eq 0 ] || exit 4
;;
restart|reload|force-reload|condrestart|try-restart)
;;
*)
echo "Usage: sysstat {start|stop|status|restart|reload|force-reload|condrestart|try-restart}"
RETVAL=2
esac
exit ${RETVAL}