Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
float
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
ai3
float
Commits
312c1c30
Commit
312c1c30
authored
4 months ago
by
godog
Browse files
Options
Downloads
Plain Diff
Merge branch 'enumerate-raid' into 'master'
base: rework md array handling See merge request
!306
parents
c0814acc
1b1b9dc5
Branches
Branches containing commit
No related tags found
1 merge request
!306
base: rework md array handling
Pipeline
#82579
passed
4 months ago
Stage: docker_build
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
roles/float-base/files/node-exporter-scripts/md.sh
+8
-13
8 additions, 13 deletions
roles/float-base/files/node-exporter-scripts/md.sh
with
8 additions
and
13 deletions
roles/float-base/files/node-exporter-scripts/md.sh
+
8
−
13
View file @
312c1c30
...
...
@@ -3,18 +3,13 @@
#!/usr/bin/env bash
set
-eu
for
MD_DEVICE
in
/dev/md/
*
;
do
RAID_ARRAYS
=
$(
lsblk
--noheadings
--output
NAME,TYPE
--list
|
awk
'$2 ~ /^raid/ { print $1 }'
)
for
MD_DEVICE
in
${
RAID_ARRAYS
}
;
do
# Subshell to avoid eval'd variables from leaking between iterations
(
# Resolve symlink to discover device, e.g. /dev/md127
MD_DEVICE_NUM
=
$(
readlink
-f
"
${
MD_DEVICE
}
"
)
# Remove /dev/ prefix
MD_DEVICE_NUM
=
${
MD_DEVICE_NUM
#/dev/
}
MD_DEVICE
=
${
MD_DEVICE
#/dev/md/
}
# Query sysfs for info about md device
SYSFS_BASE
=
"/sys/devices/virtual/block/
${
MD_DEVICE
_NUM
}
/md"
SYSFS_BASE
=
"/sys/devices/virtual/block/
${
MD_DEVICE
}
/md"
MD_LAYOUT
=
$(
cat
"
${
SYSFS_BASE
}
/layout"
)
MD_LEVEL
=
$(
cat
"
${
SYSFS_BASE
}
/level"
)
MD_METADATA_VERSION
=
$(
cat
"
${
SYSFS_BASE
}
/metadata_version"
)
...
...
@@ -25,18 +20,18 @@ for MD_DEVICE in /dev/md/*; do
# Output RAID array informational metric.
# NOTE: Metadata version is a label rather than a separate metric because the version can be a string
echo
"node_md_info{md_device=
\"
${
MD_DEVICE
_NUM
}
\"
, md_name=
\"
${
MD_DEVICE
}
\"
, raid_level=
\"
${
MD_LEVEL
}
\"
, md_metadata_version=
\"
${
MD_METADATA_VERSION
}
\"
} 1"
echo
"node_md_info{md_device=
\"
${
MD_DEVICE
}
\"
, raid_level=
\"
${
MD_LEVEL
}
\"
, md_metadata_version=
\"
${
MD_METADATA_VERSION
}
\"
} 1"
# Fetch sync state and metrics.
SYNC_STATE
=
$(
cat
"
${
SYSFS_BASE
}
/sync_action"
)
echo
"node_md_sync_state{md_device=
\"
${
MD_DEVICE
_NUM
}
\"
,sync_state=
\"
${
SYNC_STATE
}
\"
} 1"
echo
"node_md_sync_state{md_device=
\"
${
MD_DEVICE
}
\"
,sync_state=
\"
${
SYNC_STATE
}
\"
} 1"
SYNC_SPEED
=
$(
cat
"
${
SYSFS_BASE
}
/sync_speed"
)
if
[
"
$SYNC_SPEED
"
=
"none"
]
;
then
SYNC_SPEED
=
0
fi
echo
"node_md_sync_speed{md_device=
\"
${
MD_DEVICE
_NUM
}
\"
}
${
SYNC_SPEED
}
"
echo
"node_md_sync_speed{md_device=
\"
${
MD_DEVICE
}
\"
}
${
SYNC_SPEED
}
"
DEGRADED
=
$(
cat
"
${
SYSFS_BASE
}
/degraded"
)
echo
"node_md_degraded{md_device=
\"
${
MD_DEVICE
_NUM
}
\"
}
${
DEGRADED
}
"
echo
"node_md_degraded{md_device=
\"
${
MD_DEVICE
}
\"
}
${
DEGRADED
}
"
)
done
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