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
a14b8085
Commit
a14b8085
authored
Mar 12, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve print_disks.sh
parent
ebc950e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
functions.sh
hdd/functions.sh
+13
-0
print_disks.sh
hdd/print_disks.sh
+16
-2
No files found.
hdd/functions.sh
View file @
a14b8085
#!/bin/sh
fatal
()
{
echo
"
$*
"
>
&2
exit
1
}
# arg: /dev/sd?
is_hdd
()
{
...
...
@@ -16,6 +22,12 @@ is_hdd()
[
"
$rot
"
=
"1"
]
}
print_dev_type
()
{
is_hdd
"
$1
"
&&
echo
"HDD"
||
echo
"SSD"
}
# https://unix.stackexchange.com/questions/65595/how-to-know-if-a-disk-is-an-ssd-or-an-hdd
# lsblk -d -o name,rota
# NAME ROTA
...
...
@@ -50,3 +62,4 @@ print_partsize()
[
-n
"
$sectors
"
]
||
{
echo
"No info"
;
return
;
}
echo
"
$((
$sectors
/
2
/
1024
/
1024
))
GB"
}
hdd/print_disks.sh
View file @
a14b8085
...
...
@@ -4,6 +4,9 @@ VERBOSE=
[
"
$1
"
=
"-v"
]
&&
VERBOSE
=
1
.
$(
dirname
$0
)
/print_disks.physorder.sh
.
$(
dirname
$0
)
/functions.sh
#case "$(hostname -s)" in
# clients)
# PHYSORDER="4Q2H 6866 2690 2486 2471 0052 8696 4552 8520"
...
...
@@ -21,18 +24,29 @@ for i in /dev/sd? ; do
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/'
)
printf
"%s %
6s %s
\n
"
"
$i
"
"
$LABEL
"
"
$SERNO
"
|
tee
-a
$0
.log
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
echo
"In physical order:"
n
=
1
for
i
in
$PHYSORDER
;
do
if
grep
"
$i
$"
$0
.log
;
then
printf
"ata%2s. "
"
$n
"
if
grep
-q
"
$i
$"
$0
.log
;
then
DEV
=
"
$(
grep
"
$i
$"
$0
.log |
sed
-e
"s| .*||"
)
"
health
$DEV
||
echo
"NACCESS"
printf
"%s %7s %s
\n
"
"
$(
print_dev_type
$DEV
)
"
"
$(
print_size
$DEV
)
"
"
$(
grep
"
$i
$"
$0
.log
)
"
grep
"
$i
$"
$0
.log
>>
$0
.log.found
else
echo
"
$i
is MISSED"
fi
n
=
$((
$n
+
1
))
done
echo
...
...
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