Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
9579d7eb
Commit
9579d7eb
authored
Dec 04, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite print_disks.sh
parent
6890ba32
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
17 deletions
+65
-17
print_disks.sh
hdd/print_disks.sh
+65
-17
No files found.
hdd/print_disks.sh
View file @
9579d7eb
...
...
@@ -7,30 +7,38 @@ VERBOSE=
.
$(
dirname
$0
)
/functions.sh
#case "$(hostname -s)" in
# clients)
# PHYSORDER="4Q2H 6866 2690 2486 2471 0052 8696 4552 8520"
# ;;
# *)
# echo "Unknown hostname $(hostname -s)"
# exit 1
#esac
print_md
()
{
local
dev
=
"
$1
"
local
ARRAYUUID
ARRAYUUID
=
$(
get_array_uuid_by_device
$dev
)
[
-n
"
$ARRAYUUID
"
]
||
return
get_md_by_uuid
$ARRAYUUID
}
is_lvm
()
{
blkid
"
$1
"
|
grep
-q
"LVM2_member"
}
health
()
{
fdisk
-l
$1
2>/dev/null
>
/dev/null
}
echo
>
$0
.log
# FIXME: prepare some unused cache:
for
i
in
/dev/sd?
;
do
[
-n
"
$VERBOSE
"
]
&&
echo
[
-n
"
$VERBOSE
"
]
&&
hdparm
-i
$i
|
grep
-B2
SerialNo |
grep
-v
"^$"
SERNO
=
$(
hdparm
-i
$i
|
grep
SerialNo |
sed
-e
"s/.*SerialNo=//g"
|
tail
-c
5
)
[
-n
"
$VERBOSE
"
]
&&
blkid
${
i
}
1
LABEL
=
$(
blkid
-s
LABEL
${
i
}
1 |
sed
-e
's/.*LABEL="\(.*\)"/\1/'
)
#[ -n "$VERBOSE" ] && hdparm -i $i | grep -B2 SerialNo | grep -v "^$"
#SERNO=$(hdparm -i $i | grep SerialNo | sed -e "s/.*SerialNo=//g" | tail -c 5)
SERNO
=
$(
print_serno
${
i
})
#[ -n "$VERBOSE" ] && blkid ${i}1
#LABEL=$(blkid -s LABEL ${i}1 | sed -e 's/.*LABEL="\(.*\)"/\1/') #"
printf
"%s %s
\n
"
"
$i
"
"
$SERNO
"
|
tee
-a
$0
.log
done
health
()
{
fdisk
-l
$1
2>/dev/null
>
/dev/null
}
echo
>
$0
.log.found
echo
...
...
@@ -41,7 +49,19 @@ for i in $PHYSORDER ; do
if
grep
-q
"
$i
$"
$0
.log
;
then
DEV
=
"
$(
grep
"
$i
$"
$0
.log |
sed
-e
"s| .*||"
)
"
health
$DEV
||
echo
"NACCESS to
$DEV
"
printf
"%s %7s %s
\n
"
"
$(
print_dev_type
$DEV
)
"
"
$(
print_size
$DEV
)
"
"
$(
grep
"
$i
$"
$0
.log
)
"
MD
=
"
$(
print_md
$DEV
)
"
# TYPE SIZE DEV SERIAL MD
printf
"%3s %7s %-10s %4s %10s
\n
"
"
$(
print_dev_type
$DEV
)
"
"
$(
print_size
$DEV
)
"
"
$DEV
"
"
$(
print_serno
$DEV
)
"
"
$MD
"
if
[
-z
"
$MD
"
]
;
then
for
pd
in
$DEV
*
;
do
MD
=
"
$(
print_md
$pd
)
"
if
[
-z
"
$MD
"
]
;
then
is_lvm
$pd
&&
MD
=
"LVM2"
fi
[
-n
"
$MD
"
]
||
continue
printf
" %3s %7s %-10s %4s %10s
\n
"
""
"
$(
print_partsize
$pd
)
"
"
$pd
"
""
"
$MD
"
done
fi
grep
"
$i
$"
$0
.log
>>
$0
.log.found
else
echo
"
$i
is MISSED"
...
...
@@ -49,8 +69,36 @@ for i in $PHYSORDER ; do
n
=
$((
$n
+
1
))
done
is_in_physorder
()
{
local
i
for
i
in
$PHYSORDER
;
do
[
"
$i
"
=
"
$1
"
]
&&
return
done
return
1
}
echo
echo
"Drives not in PHYSORDER:"
REALSERNO
=
$(
cut
-d
" "
-f2
<print_disks.sh.log |
grep
-v
"^$"
)
for
i
in
$REALSERNO
;
do
is_in_physorder
$i
||
echo
" -
$(
grep
"
$i
$"
print_disks.sh.log
)
"
done
echo
echo
"Differences:"
sort
<
$0
.log
>
$0
.log.sort
sort
<
$0
.log.found
>
$0
.log.found.sort
diff
-u
$0
.log.sort
$0
.log.found.sort
echo
echo
"Drives not in active RAID:"
for
dev
in
/dev/sd
*
;
do
sdev
=
$(
basename
$dev
)
# strict
cat
/proc/mdstat |
grep
-q
"
$sdev
\[
"
&&
continue
# use parts from it
cat
/proc/mdstat |
grep
-q
"
$sdev
[0-9]*
\[
"
&&
continue
echo
"
$dev
"
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment