Skip to content

Commit

Permalink
adds support for persistent device names in diskstat
Browse files Browse the repository at this point in the history
  • Loading branch information
gurubert committed Dec 20, 2023
1 parent 4e19bb2 commit fd5416a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions agents/check_mk_agent.linux
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,10 @@ section_diskstat() {
echo '[vx_dsk]'
stat -c "%t %T %n" /dev/vx/dsk/*/*
fi
if [ -d /dev/disk/by-id ]; then
echo '[disk_id]'
ls -l /dev/disk/by-id/* | awk '{print $9 " " $11 ;}'
fi
else
echo "<<<docker_container_diskstat${CGROUP_SECTION_SUFFIX}>>>"
echo "[time]"
Expand Down
10 changes: 10 additions & 0 deletions cmk/base/plugins/agent_based/diskstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def parse_diskstat(string_table: type_defs.StringTable) -> diskstat.Section:
if major != "None" and minor != "None" and (int(major), int(minor)) in name_info:
device = name_info[(int(major), int(minor))]

if device in name_info:
device = name_info[device]

# There are 1000 ticks per second
disks[device] = {
"timestamp": timestamp,
Expand Down Expand Up @@ -234,6 +237,8 @@ def diskstat_extract_name_info(
phase = "dmsetup_info"
elif line[0] == "[vx_dsk]":
phase = "vx_dsk"
elif line[0] == "[disk_id]":
phase = "disk_id"
else:
if phase == "info":
if len(line) == 1:
Expand All @@ -256,6 +261,11 @@ def diskstat_extract_name_info(
group, disk = line[2].split("/")[-2:]
name = f"VxVM {group}-{disk}"
name_info[major, minor] = name
elif phase == "disk_id":
if line[0].startswith('/dev/disk/by-id/ata-') or line[0].startswith('/dev/disk/by-id/scsi-') or line[0].startswith('/dev/disk/by-id/nvme-'):
disk = line[1][6:]
name = '/'.join(line[0].split('/')[4:])
name_info[disk] = name
return timestamp, info_plain, name_info


Expand Down

0 comments on commit fd5416a

Please sign in to comment.