Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes & added NVMe total capacity metric #154

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

k0ste
Copy link
Contributor

@k0ste k0ste commented Aug 24, 2023

  • split block mine to mineBlockSize() from mineCapacity()
  • remove redundant meta labels from SCSI metrics
  • added smartctl_device_nvme_capacity_bytes metric
  • for some devices, such as 2.5" NVMe Intel & Micron the family field may be empty

The .user_capacity exists only when NVMe have single namespace. Otherwise, for NVMe deivces with multiple namespaces, when device name used witout namespace number (exporter case) .user_capacity will be absent

smartctl --info --health --attributes \
--tolerance=verypermissive --nocheck=standby --format=brief --log=error \
/dev/nvme11 --json | jq '.user_capacity'

null

smartctl --info --health --attributes \
--tolerance=verypermissive --nocheck=standby --format=brief --log=error \
/dev/nvme11 --json | jq '.nvme_total_capacity'

3840755982336
# HELP smartctl_device_available_spare Normalized percentage (0 to 100%) of the remaining spare capacity available
# HELP smartctl_device_capacity_blocks Device capacity in blocks
# TYPE smartctl_device_capacity_blocks gauge
smartctl_device_capacity_blocks{device="nvme0"} 0
smartctl_device_capacity_blocks{device="nvme1"} 0
smartctl_device_capacity_blocks{device="nvme10"} 0
smartctl_device_capacity_blocks{device="nvme11"} 0
smartctl_device_capacity_blocks{device="nvme2"} 0
smartctl_device_capacity_blocks{device="nvme3"} 0
smartctl_device_capacity_blocks{device="nvme4"} 0
smartctl_device_capacity_blocks{device="nvme5"} 0
smartctl_device_capacity_blocks{device="nvme6"} 0
smartctl_device_capacity_blocks{device="nvme7"} 0
smartctl_device_capacity_blocks{device="nvme8"} 0
smartctl_device_capacity_blocks{device="nvme9"} 0
smartctl_device_capacity_blocks{device="sda"} 9.37703088e+08
smartctl_device_capacity_blocks{device="sdb"} 9.37703088e+08
# HELP smartctl_device_capacity_bytes Device capacity in bytes
# TYPE smartctl_device_capacity_bytes gauge
smartctl_device_capacity_bytes{device="nvme0"} 0
smartctl_device_capacity_bytes{device="nvme1"} 0
smartctl_device_capacity_bytes{device="nvme10"} 0
smartctl_device_capacity_bytes{device="nvme11"} 0
smartctl_device_capacity_bytes{device="nvme2"} 0
smartctl_device_capacity_bytes{device="nvme3"} 0
smartctl_device_capacity_bytes{device="nvme4"} 0
smartctl_device_capacity_bytes{device="nvme5"} 0
smartctl_device_capacity_bytes{device="nvme6"} 0
smartctl_device_capacity_bytes{device="nvme7"} 0
smartctl_device_capacity_bytes{device="nvme8"} 0
smartctl_device_capacity_bytes{device="nvme9"} 0
smartctl_device_capacity_bytes{device="sda"} 4.80103981056e+11
smartctl_device_capacity_bytes{device="sdb"} 4.80103981056e+11
# HELP smartctl_device_total_capacity_bytes NVMe device capacity bytes (only for devices with multiple NVMe namespaces)
# TYPE smartctl_device_total_capacity_bytes gauge
smartctl_device_total_capacity_bytes{device="nvme0"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme1"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme10"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme11"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme2"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme3"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme4"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme5"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme6"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme7"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme8"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="nvme9"} 3.840755982336e+12
smartctl_device_total_capacity_bytes{device="sda"} 0
smartctl_device_total_capacity_bytes{device="sdb"} 0

@k0ste
Copy link
Contributor Author

k0ste commented Aug 24, 2023

[root@host /]# nvme list
Node                  SN                   Model                                    Namespace Usage                      Format           FW Rev
--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1          BTAC212301FS3P8AGN   INTEL SSDPF2KX038TZ                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   JCV10300
/dev/nvme1n1          BTAX238301TZ3P8CGN   INTEL SSDPF2KX038T1                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   9CV10410
/dev/nvme10n1         22293A3A9C71         Micron_7450_MTFDKCC3T8TFR                1           3.70  TB /   3.84  TB      4 KiB +  0 B   E2MU110
/dev/nvme11n1         22293A3A9C5C         Micron_7450_MTFDKCC3T8TFR                1           3.70  TB /   3.84  TB      4 KiB +  0 B   E2MU110
/dev/nvme2n1          BTAX238300MC3P8CGN   INTEL SSDPF2KX038T1                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   9CV10410
/dev/nvme3n1          BTAX238400FK3P8CGN   INTEL SSDPF2KX038T1                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   9CV10410
/dev/nvme4n1          BTAC2123020Z3P8AGN   INTEL SSDPF2KX038TZ                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   JCV10300
/dev/nvme5n1          BTAX238303YY3P8CGN   INTEL SSDPF2KX038T1                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   9CV10410
/dev/nvme6n1          BTAC2123016Q3P8AGN   INTEL SSDPF2KX038TZ                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   JCV10300
/dev/nvme7n1          BTAC212200WZ3P8AGN   INTEL SSDPF2KX038TZ                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   JCV10300
/dev/nvme8n1          BTAC212300M23P8AGN   INTEL SSDPF2KX038TZ                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   JCV10300
/dev/nvme9n1          BTAC212302203P8AGN   INTEL SSDPF2KX038TZ                      1           3.84  TB /   3.84  TB      4 KiB +  8 B   JCV10300

@k0ste
Copy link
Contributor Author

k0ste commented Aug 24, 2023

@NiceGuyIT

Copy link
Member

@NiceGuyIT NiceGuyIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple spelling changes and discussion about metric name.

smartctl.go Outdated Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
Copy link
Member

@NiceGuyIT NiceGuyIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last one

smartctl.go Outdated Show resolved Hide resolved
* remove redundant meta labels from SCSI metrics
* added `smartctl_device_nvme_capacity_bytes` metric
* for some devices, such as 2.5" NVMe Intel & Micron the `family` field may be empty

The `.user_capacity` exists only when NVMe have single namespace. Otherwise,
for NVMe deivces with multiple namespaces, when device name used witout
namespace number (exporter case) `.user_capacity` will be absent

```
smartctl --info --health --attributes \
--tolerance=verypermissive --nocheck=standby --format=brief --log=error \
/dev/nvme11 --json | jq '.user_capacity'

null

smartctl --info --health --attributes \
--tolerance=verypermissive --nocheck=standby --format=brief --log=error \
/dev/nvme11 --json | jq '.nvme_total_capacity'

3840755982336
```

Signed-off-by: Konstantin Shalygin <k0ste@k0ste.ru>
@NiceGuyIT NiceGuyIT merged commit f3588bb into prometheus-community:master Aug 26, 2023
2 checks passed
@k0ste k0ste mentioned this pull request Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants