[ Avaa Bypassed ]




Upload:

Command:

www-data@3.19.218.250: ~ $
do 'smart-status-lib.pl';

# status_monitor_list()
# Just one type is supported
sub status_monitor_list
{
if (&has_command($config{'smartctl'})) {
	return ( [ "smart", $text{'monitor_type'} ],
		 [ "wearout", $text{'monitor_type2'} ] );
	}
else {
	return ( );
	}
}

# status_monitor_status(type, &monitor, from-ui)
# Check the drive status
sub status_monitor_status
{
local ($type, $mon, $ui) = @_;

local @drives = &list_smart_disks_partitions();
local ($d) = grep { ($_->{'device'} eq $mon->{'drive'} ||
		     &indexof($mon->{'drive'}, @{$_->{'ids'}}) >= 0) &&
		    $_->{'subdisk'} eq $mon->{'subdisk'} } @drives;
if (!$d) {
	# Not in list?!
	return { 'up' => -1,
		 'desc' => $text{'monitor_nosuch'} };
	}
local $st = &get_drive_status($d->{'device'}, $d);

if (!$st->{'support'} || !$st->{'enabled'}) {
	# SMART not enabled on device
	return { 'up' => -1,
		 'desc' => $text{'monitor_nosmart'} };
	}

if ($type eq "wearout") {
	# Check SSD wear level
	local $wo;
	foreach my $a (@{$st->{'attribs'}}) {
		if ($a->[0] eq "Media Wearout Indicator") {
			$wo = $a;
			last;
			}
		}
	if (!$wo) {
		return { 'up' => -1,
		         'desc' => $text{'monitor_nowearout'} };
		}
	if ($wo->[3] < $mon->{'wearlevel'}) {
		return { 'up' => 0,
			 'desc' => &text('monitor_wornout', $wo->[3]),
			 'value' => $wo->[3] };
		}
	else {
		return { 'up' => 1,
			 'value' => $wo->[3] };
		}
	}
else {
	# Record number of errors since last time
	local %errors;
	local $errors_file = "$module_config_directory/last-errors";
	&read_file($errors_file, \%errors);
	local %lasterrors = %errors;
	$errors{$mon->{'drive'}} = $st->{'errors'};
	&write_file($errors_file, \%errors);

	# Check for errors
	if (!$st->{'check'}) {
		# Check failed
		return { 'up' => 0 };
		}
	elsif ($st->{'errors'} && $mon->{'errors'} == 1) {
		# Errors found, and failing on any errors
		return { 'up' => 0,
			 'value' => $st->{'errors'},
			 'desc' => &text('monitor_errorsfound', $st->{'errors'}) };
		}
	elsif ($st->{'errors'} && $mon->{'errors'} == 2 &&
	       $st->{'errors'} > $lasterrors{$mon->{'drive'}}) {
		# Errors found and have increased
		return { 'up' => 0,
			 'value' => $st->{'errors'},
			 'desc' => &text('monitor_errorsinced', $st->{'errors'},
					 $lasterrors{$mon->{'drive'}}) };
		}
	else {
		# All OK!
		return { 'up' => 1,
			 'value' => $st->{'errors'} };
		}
	}
}

# status_monitor_dialog(type, &monitor)
# Return form for selecting a drive
sub status_monitor_dialog
{
local ($type, $mon) = @_;
local $rv;
local @drives = &list_smart_disks_partitions();
local ($inlist, $invalue);
foreach my $d (@drives) {
	if ($d->{'device'} eq $mon->{'drive'} &&
	    $d->{'subdisk'} eq $mon->{'subdisk'}) {
		$inlist = 1;
		$invalue = $mon->{'drive'}.":".$mon->{'subdisk'};
		}
	elsif (&indexof($mon->{'drive'}, @{$d->{'ids'}}) >= 0 &&
	       $d->{'subdisk'} eq $mon->{'subdisk'}) {
		$inlist = 1;
		$invalue = $d->{'id'}.":".$mon->{'subdisk'};
		}
	}
$inlist = 1 if (!$mon->{'drive'});
$rv .= &ui_table_row($text{'monitor_drive'},
      &ui_select("drive",
		 !$mon->{'drive'} ? $drives[0]->{'device'} : $invalue,
		 [ (map { [ ($_->{'id'} || $_->{'device'}).':'.$_->{'subdisk'},
			   $_->{'desc'}.($_->{'model'} ?
				" ($_->{'model'})" : "") ] } @drives),
		   [ "", $text{'monitor_other'} ] ]).
      &ui_textbox("other", $inlist ? "" : $mon->{'drive'}, 15), 3);

if ($type eq "wearout") {
	$rv .= &ui_table_row($text{'monitor_wearlevel'},
		&ui_textbox("wearlevel", $mon->{'wearlevel'} || 10, 5)."%");
	}
else {
	$rv .= &ui_table_row($text{'monitor_errors'},
		&ui_radio("errors", $mon->{'errors'} || 0,
			[ [ 1, $text{'yes'} ], [ 0, $text{'no'} ],
			  [ 2, $text{'monitor_errorsinc'} ] ]));
	}
return $rv;
}

# status_monitor_parse(type, &monitor, &in)
# Parse form for selecting a rule
sub status_monitor_parse
{
local ($type, $mon, $in) = @_;
if ($in->{'drive'}) {
	($mon->{'drive'}, $mon->{'subdisk'}) = split(/:/, $in->{'drive'});
	}
else {
	$mon->{'drive'} = $in->{'other'};
	$mon->{'subdisk'} = undef;
	$mon->{'drive'} =~ /^\S+$/ || &error($text{'monitor_edrive'});
	}
if ($type eq "wearout") {
	$in->{'wearlevel'} =~ /^\d+(\.\d+)?$/ ||
		&error($text{'monitor_ewearlevel'});
	$mon->{'wearlevel'} = $in->{'wearlevel'};
	}
else {
	$mon->{'errors'} = $in->{'errors'};
	}
}

1;


Filemanager

Name Type Size Permission Actions
images Folder 0755
lang Folder 0755
CHANGELOG File 1.34 KB 0644
action.cgi File 810 B 0755
config File 41 B 0644
config-CentOS-Linux-5.0-6.9 File 41 B 0644
config-Redhat-Enterprise-Linux-5.0-6.9 File 41 B 0644
config.info File 221 B 0644
config.info.ca File 264 B 0644
config.info.de File 261 B 0644
config.info.es File 166 B 0644
config.info.fr File 0 B 0644
config.info.ms File 245 B 0644
config.info.nl File 251 B 0644
config.info.no File 230 B 0644
config.info.ru File 360 B 0644
index.cgi File 4.37 KB 0755
install_check.pl File 343 B 0755
module.info File 195 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 127 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 152 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 169 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 230 B 0644
module.info.ca File 136 B 0644
module.info.cs File 26 B 0644
module.info.cs.auto File 91 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 126 B 0644
module.info.de File 144 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 222 B 0644
module.info.es File 37 B 0644
module.info.es.auto File 102 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 127 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 190 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 116 B 0644
module.info.fr File 0 B 0644
module.info.fr.auto File 143 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 158 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 123 B 0644
module.info.hu File 0 B 0644
module.info.hu.auto File 163 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 132 B 0644
module.info.ja File 0 B 0644
module.info.ja.auto File 166 B 0644
module.info.ko File 0 B 0644
module.info.ko.auto File 156 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 135 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 129 B 0644
module.info.ms File 117 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 125 B 0644
module.info.nl File 27 B 0644
module.info.nl.auto File 110 B 0644
module.info.no File 25 B 0644
module.info.no.auto File 100 B 0644
module.info.pl File 0 B 0644
module.info.pl.auto File 120 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 130 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 136 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 136 B 0644
module.info.ru File 46 B 0644
module.info.ru.auto File 157 B 0644
module.info.sk File 26 B 0644
module.info.sk.auto File 95 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 120 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 134 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 273 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 145 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 190 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 213 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 172 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 109 B 0644
module.info.zh_TW File 0 B 0644
module.info.zh_TW.auto File 115 B 0644
prefs.info File 20 B 0644
smart-status-lib.pl File 12.98 KB 0755
status_monitor.pl File 4.17 KB 0755