Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrors
resmon
Commits
53312893
Commit
53312893
authored
3 years ago
by
Sergey Joseph Ivanov
Browse files
Options
Downloads
Patches
Plain Diff
check for state, status, and action
parent
4f3a0b53
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Site/ZpoolScrub.pm
+51
-9
51 additions, 9 deletions
lib/Site/ZpoolScrub.pm
with
51 additions
and
9 deletions
lib/Site/ZpoolScrub.pm
+
51
−
9
View file @
53312893
...
...
@@ -86,12 +86,51 @@ sub handler {
my
$oldhowlong
=
(
(
-
r
$statusfile
)
?
`
cat
$statusfile
`
:
0
);
chomp
$oldhowlong
;
$oldhowlong
=
0
unless
$oldhowlong
=~
/^[\d]+$/
;
my
(
$when
,
$days
,
$h
,
$m
,
$s
,
$howlong
,
$togo
,
$repaired
,
$errors
,
$canceled
)
=
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
);
my
(
$when
,
$days
,
$h
,
$m
,
$s
,
$howlong
,
$togo
,
$repaired
,
$errors
,
$canceled
,
$State
,
$Status
,
$Action
)
=
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'',
'',
''
);
my
$STATUSCMD
=
"
/usr/sbin/zpool status
$zpool
";
open
(
my
$status
,
"
-|
",
$STATUSCMD
)
or
die
"
can't run
$STATUSCMD
: $!
";
while
(
<
$status
>
)
{
if
(
/^\s*scan:\s+scrub\s+canceled\s+on\s+(.+)$/
){
LINE:
while
(
<
$status
>
)
{
=pod
state: ONLINE
=cut
if
(
/^\s*state:\s(\S*)\s*$/
)
{
$State
=
$
1
}
=pod
status: One or more devices are faulted in response to persistent errors.
Sufficient replicas exist for the pool to continue functioning in a
degraded state.
action: Replace the faulted device, or use 'zpool clear' to mark the device
repaired.
- or -
status: One or more devices has experienced an unrecoverable error. An
attempt was made to correct the error. Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
using 'zpool clear' or replace the device with 'zpool replace'.
=cut
elsif
(
/^\s*status:\s+(.+)$/
){
$Status
=
$
1
;
while
(
<
$status
>
)
{
redo
LINE
if
(
/^\s*[a-z]*:/
);
chomp
;
$_
=~
s/\s+/ /g
;
$Status
.=
$_
;
}
}
elsif
(
/^\s*action:\s+(.+)$/
){
$Action
=
$
1
;
while
(
<
$status
>
)
{
redo
LINE
if
(
/^\s*[a-z]*:/
);
chomp
;
$_
=~
s/\s+/ /g
;
$Action
.=
$_
;
}
}
=pod
scan: scrub cancelled on Thu Mar 7 01:46:05 2019
=cut
elsif
(
/^\s*scan:\s+scrub\s+canceled\s+on\s+(.+)$/
){
$when
=
$
1
;
$when
=
`
$DATE
'+%s'
`
-
`
$DATE
'+%s' -d "
$when
"
`;
$when
=
int
((
$when
+
30
)
/
60
);
...
...
@@ -178,12 +217,15 @@ sub handler {
$howlong
=
$when
+
$togo
}
return
{
"
when
"
=>
[
$when
,
"
i
"],
"
howlong
"
=>
[
$howlong
,
"
i
"],
"
togo
"
=>
[
$togo
,
"
i
"],
"
repaired
"
=>
[
$repaired
,
"
i
"],
"
when
"
=>
[
$when
,
"
i
"],
"
howlong
"
=>
[
$howlong
,
"
i
"],
"
togo
"
=>
[
$togo
,
"
i
"],
"
repaired
"
=>
[
$repaired
,"
i
"],
"
errors
"
=>
[
$errors
,
"
i
"],
"
canceled
"
=>
[
$canceled
,
"
i
"],
"
canceled
"
=>
[
$canceled
,"
i
"],
"
state
"
=>
[
$State
,
"
s
"],
"
status
"
=>
[
$Status
,
"
s
"],
"
action
"
=>
[
$Action
,
"
s
"],
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment