Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
custom-metrics-generator
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
cloud
custom-metrics-generator
Commits
0c31fcab
Commit
0c31fcab
authored
3 years ago
by
František Řezníček
Browse files
Options
Downloads
Patches
Plain Diff
fix: avoid crashing on read(line) when no GPU found
parent
0c515077
No related branches found
No related tags found
No related merge requests found
Pipeline
#161333
passed
3 years ago
Stage: build-image
Stage: release-image
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+4
-0
4 additions, 0 deletions
CHANGELOG.md
src/metric-generators/gpumon.sh
+21
-20
21 additions, 20 deletions
src/metric-generators/gpumon.sh
with
25 additions
and
20 deletions
CHANGELOG.md
+
4
−
0
View file @
0c31fcab
...
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [Unreleased]
## [1.2.2] - 2022-06-07
### Added
-
gpumon: avoid crashing on no GPU (readlink)
## [1.2.1] - 2022-06-07
## [1.2.1] - 2022-06-07
### Added
### Added
-
gpumon: avoid crashing on no GPU
-
gpumon: avoid crashing on no GPU
...
...
This diff is collapsed.
Click to expand it.
src/metric-generators/gpumon.sh
+
21
−
20
View file @
0c31fcab
...
@@ -56,26 +56,27 @@ fi
...
@@ -56,26 +56,27 @@ fi
# browse the GPUs and export metrics
# browse the GPUs and export metrics
METRIC_NAME
=
"gpumon_device_state_code"
METRIC_NAME
=
"gpumon_device_state_code"
STAGE_NAME
=
"GPU
card
s
${
METRIC_NAME
}
metrics generated"
STAGE_NAME
=
"GPU
device
s
${
METRIC_NAME
}
metrics generated"
if
[
-n
"
${
GPU_DEVICES
}
"
]
;
then
if
[
-n
"
${
GPU_DEVICES
}
"
]
;
then
get_metric_help
"
${
METRIC_NAME
}
"
"gauge"
"GPU device state code (0/1 ~ available free/unavailable used)."
get_metric_help
"
${
METRIC_NAME
}
"
"gauge"
"GPU device state code (0/1 ~ available free/unavailable used)."
echo
"
${
GPU_DEVICES
}
"
|
\
while
read
i_gpu_device
;
do
STAGE_NAME
=
"GPU device
${
METRIC_NAME
}
metrics generated (
${
i_gpu_device
}
)"
[
-z
"
${
i_gpu_device
}
"
]
&&
\
continue
i_gpu_device_location
=
"
$(
echo
"
${
i_gpu_device
}
"
|
awk
'{printf $1}'
)
"
i_gpu_device_vendor
=
"
$(
echo
"
${
i_gpu_device
}
"
| gawk
'BEGIN{FPAT = "(\"[^\"]+\")"}{printf $2}'
|
tr
-d
'"'
)
"
i_gpu_device_model
=
"
$(
echo
"
${
i_gpu_device
}
"
| gawk
'BEGIN{FPAT = "(\"[^\"]+\")"}{printf $3}'
|
tr
-d
'"'
)
"
i_gpu_device_revision
=
"
$(
echo
"
${
i_gpu_device
}
"
|
grep
-Eo
--
"-r[^
\t
]+"
)
"
i_gpu_attached
=
0
i_vm_domain_name
=
""
if
lspci
-v
-s
"
${
i_gpu_device_location
}
"
|
grep
-qE
'Kernel driver in use: .+'
;
then
i_gpu_attached
=
1
i_vm_domain_file
=
"
$(
find_gpu_passthough_vm_manifest
"
${
i_gpu_device_location
}
"
)
"
i_vm_domain_name
=
"
$(
basename
$(
echo
"
${
i_vm_domain_file
}
"
|
head
-1
)
|
sed
's/.xml//g'
)
"
fi
printf
'%s{device="%s",vendor="%s",location="%s",revision="%s",domain="%s"} %d\n'
"
${
METRIC_NAME
}
"
\
"
${
i_gpu_device_model
}
"
"
${
i_gpu_device_vendor
}
"
"
${
i_gpu_device_location
}
"
\
"
${
i_gpu_device_revision
:2
}
"
"
${
i_vm_domain_name
}
"
"
${
i_gpu_attached
}
"
done
fi
fi
echo
"
${
GPU_DEVICES
}
"
|
\
while
read
i_gpu_device
;
do
[
-z
"
${
i_gpu_device
}
"
]
&&
\
continue
i_gpu_device_location
=
"
$(
echo
"
${
i_gpu_device
}
"
|
awk
'{printf $1}'
)
"
i_gpu_device_vendor
=
"
$(
echo
"
${
i_gpu_device
}
"
| gawk
'BEGIN{FPAT = "(\"[^\"]+\")"}{printf $2}'
|
tr
-d
'"'
)
"
i_gpu_device_model
=
"
$(
echo
"
${
i_gpu_device
}
"
| gawk
'BEGIN{FPAT = "(\"[^\"]+\")"}{printf $3}'
|
tr
-d
'"'
)
"
i_gpu_device_revision
=
"
$(
echo
"
${
i_gpu_device
}
"
|
grep
-Eo
--
"-r[^
\t
]+"
)
"
i_gpu_attached
=
0
i_vm_domain_name
=
""
if
lspci
-v
-s
"
${
i_gpu_device_location
}
"
|
grep
-qE
'Kernel driver in use: .+'
;
then
i_gpu_attached
=
1
i_vm_domain_file
=
"
$(
find_gpu_passthough_vm_manifest
"
${
i_gpu_device_location
}
"
)
"
i_vm_domain_name
=
"
$(
basename
$(
echo
"
${
i_vm_domain_file
}
"
|
head
-1
)
|
sed
's/.xml//g'
)
"
fi
printf
'%s{device="%s",vendor="%s",location="%s",revision="%s",domain="%s"} %d\n'
"
${
METRIC_NAME
}
"
\
"
${
i_gpu_device_model
}
"
"
${
i_gpu_device_vendor
}
"
"
${
i_gpu_device_location
}
"
\
"
${
i_gpu_device_revision
:2
}
"
"
${
i_vm_domain_name
}
"
"
${
i_gpu_attached
}
"
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