Skip to content

Commit 232847a

Browse files
authored
Merge pull request #619 from stackhpc/nvmemon-update
Add physical size to nvmemon metrics
2 parents f968667 + 3211dbf commit 232847a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

etc/kayobe/ansible/scripts/nvmemon.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ format_output() {
4444
nvme_version="$(nvme version | awk '$1 == "nvme" {print $3}')"
4545
echo "nvmecli{version=\"${nvme_version}\"} 1" | format_output
4646

47-
# Get devices
48-
device_list="$(nvme list -o json | jq -r '.Devices | .[].DevicePath')"
47+
# Get devices (DevicePath and PhysicalSize)
48+
device_info="$(nvme list -o json | jq -c '.Devices[] | {DevicePath: .DevicePath, PhysicalSize: .PhysicalSize}')"
4949

5050
# Loop through the NVMe devices
51-
for device in ${device_list}; do
51+
echo "$device_info" | while read -r device_data; do
52+
device=$(echo "$device_data" | jq -r '.DevicePath')
5253
json_check="$(nvme smart-log -o json "${device}")"
5354
disk="${device##*/}"
5455

56+
physical_size=$(echo "$device_data" | jq -r '.PhysicalSize')
57+
echo "physical_size_bytes{device=\"${disk}\"} ${physical_size}"
58+
5559
# The temperature value in JSON is in Kelvin, we want Celsius
5660
value_temperature="$(echo "$json_check" | jq '.temperature - 273')"
5761
echo "temperature_celsius{device=\"${disk}\"} ${value_temperature}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Nvmemon now reports physical size of the disk.

0 commit comments

Comments
 (0)