Output the power mode with the attr: tag like other attributes

This commit is contained in:
Andrea Mazzoleni 2025-12-21 17:31:35 +01:00
parent efcdfb9118
commit 67e4896671
5 changed files with 113 additions and 103 deletions

View file

@ -2661,14 +2661,17 @@ retry:
}
if (ret == 0) {
log_tag("device:%s:%s:active\n", file, name);
log_tag("attr:%s:%s:power:active\n", file, name);
*power = POWER_ACTIVE;
} else if (ret == 3) {
log_tag("device:%s:%s:standby\n", file, name);
log_tag("attr:%s:%s:power:standby\n", file, name);
*power = POWER_STANDBY;
} else {
log_tag("device:%s:%s:unknown\n", file, name);
*power = POWER_UNKNOWN;
/* LCOV_EXCL_START */
log_tag("device:%s:%s:exit:%d\n", file, name, ret);
log_fatal("Failed to run '%s' with return code %xh.\n", u16tou8(conv_buf, cmd), ret);
return -1;
/* LCOV_EXCL_STOP */
}
return 0;
@ -2758,7 +2761,7 @@ retry:
/* LCOV_EXCL_STOP */
}
log_tag("device:%s:%s:down\n", file, name);
log_tag("attr:%s:%s:power:down\n", file, name);
return 0;
}
@ -2841,7 +2844,7 @@ static int devup(uint64_t device, const char* name, const char* wfile)
VirtualFree(buffer, 0, MEM_RELEASE);
log_tag("device:%s:%s:up\n", file, name);
log_tag("attr:%s:%s:power:up\n", file, name);
return 0;
}

View file

@ -1221,7 +1221,7 @@ static int devsmart(dev_t device, const char* name, const char* smartctl, uint64
if (!WIFEXITED(ret)) {
/* LCOV_EXCL_START */
log_tag("device:%s:%s:error:abort\n", file, name);
log_tag("device:%s:%s:abort\n", file, name);
log_fatal("Failed to run '%s' (not exited).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
@ -1314,11 +1314,12 @@ static int devprobe(dev_t device, const char* name, const char* smartctl, int* p
return -1;
/* LCOV_EXCL_STOP */
}
if (WEXITSTATUS(ret) == 0) {
log_tag("device:%s:%s:active\n", file, name);
log_tag("attr:%s:%s:power:active\n", file, name);
*power = POWER_ACTIVE;
} else if (WEXITSTATUS(ret) == 3) {
log_tag("device:%s:%s:standby\n", file, name);
log_tag("attr:%s:%s:power:standby\n", file, name);
*power = POWER_STANDBY;
} else {
/* LCOV_EXCL_START */
@ -1413,7 +1414,7 @@ static int devdown(dev_t device, const char* name, const char* smartctl)
/* LCOV_EXCL_STOP */
}
log_tag("device:%s:%s:down\n", file, name);
log_tag("attr:%s:%s:power:down\n", file, name);
return 0;
}
@ -1494,7 +1495,7 @@ static int devup(dev_t device, const char* name)
/* LCOV_EXCL_STOP */
}
log_tag("device:%s:%s:up\n", file, name);
log_tag("attr:%s:%s:power:up\n", file, name);
free(buf);
return 0;

View file

@ -512,8 +512,9 @@ device.
.HP 4
.I <disk_name>[/<split_number>]
The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension \`/N\`, where N starts from 1.
In case of split parity, the parity name is followed
by \`/N\` to indicate the split number, where N starts
from 0. The \`/0\` is always omitted.
.HP 4
.I <device>
The unique device ID (uint64).
@ -1440,9 +1441,10 @@ Note that a \`<disk_name>\` may be associated with more \`<device_file>\`,
in case the logical disk uses more physical disks. In such a case,
you\'ll see multiple tags for the same \`<disk_name>\` but with different
\`<device_file>\`.
.SS SMART Attributes
Tags logging specific disk identification and raw SMART attribute
values.
In case of split parity, the parity name is followed by \`/N\` to indicate
the split number, where N starts from 0. The \`/0\` is always omitted.
.SS Attributes
Tags logging specific disk identification and attribute values.
.TP
.B smart:<device_file>:<disk_name>[/<split_number>]
Logs the start of the SMART report for a device.
@ -1454,8 +1456,9 @@ The file path of the device (e.g., /dev/sdb).
.HP 4
.I <disk_name>[/<split_number>]
The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension \`/N\`, where N starts from 1.
In case of split parity, the parity name is followed
by \`/N\` to indicate the split number, where N starts
from 0. The \`/0\` is always omitted.
.PD
.RE
.TP
@ -1568,6 +1571,22 @@ The raw attribute value (uint64, decimal).
The raw attribute value (uint64, hexadecimal).
.PD
.RE
.TP
.B attr:<device_file>:<disk_name>[/<split_number>]:power:active
Logs that the device was confirmed to be in an active power
state after a status probe.
.TP
.B attr:<device_file>:<disk_name>[/<split_number>]:power:standby
Logs that the device was confirmed to be in a standby/spun\-down
state.
.TP
.B attr:<device_file>:<disk_name>[/<split_number>]:power:up
Logs a successful spin\-up operation via direct O_DIRECT
read.
.TP
.B attr:<device_file>:<disk_name>[/<split_number>]:power:down
Logs a successful spin\-down operation initiated via the
smartctl command.
.SS Summary
Tags logging the overall failure probabilities for the array.
.TP
@ -1590,13 +1609,10 @@ the next year (double).
.RE
.SH DEVICE STATUS TAGS
These tags log the lifecycle of hardware interactions and external
command execution. They are primarily output during the \`up\`
(spin\-up), \`down\` (spin\-down), and \`probe\` (power state check)
commands.
command execution with the \`smartctl\` command.
.TP
.B device:<device_file>:<disk_name>[/<split_number>]:active
Logs that the device was confirmed to be in an active power
state after a status probe.
.B device:<device_file>:<disk_name>[/<split_number>]:shell
Logs a failure in the command shell execution environment.
.RS 4
.PD 0
.HP 4
@ -1605,26 +1621,12 @@ The system path to the device node.
.HP 4
.I <disk_name>[/<split_number>]
The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension \`/N\`, where N starts from 1.
In case of split parity, the parity name is followed
by \`/N\` to indicate the split number, where N starts
from 0. The \`/0\` is always omitted.
.PD
.RE
.TP
.B device:<device_file>:<disk_name>[/<split_number>]:standby
Logs that the device was confirmed to be in a standby/spun\-down
state.
.TP
.B device:<device_file>:<disk_name>[/<split_number>]:up
Logs a successful spin\-up operation via direct O_DIRECT
read.
.TP
.B device:<device_file>:<disk_name>[/<split_number>]:down
Logs a successful spin\-down operation initiated via the
smartctl command.
.TP
.B device:<device_file>:<disk_name>[/<split_number>]:shell
Logs a failure in the command shell execution environment.
.TP
.B device:<device_file>:<disk_name>[/<split_number>]:error:<errno>
Logs a low\-level system error during direct file operations.
This is triggered when open(), read(), or close()

View file

@ -345,8 +345,9 @@ Thermal Tags
device.
<disk_name>[/<split_number>] - The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension `/N`, where N starts from 1.
In case of split parity, the parity name is followed
by `/N` to indicate the split number, where N starts
from 0. The `/0` is always omitted.
<device> - The unique device ID (uint64).
<temp> - The current temperature read from the disk in degrees
Celsius.
@ -921,18 +922,20 @@ Command Smart Tags
in case the logical disk uses more physical disks. In such a case,
you'll see multiple tags for the same `<disk_name>` but with different
`<device_file>`.
In case of split parity, the parity name is followed by `/N` to indicate
the split number, where N starts from 0. The `/0` is always omitted.
SMART Attributes
Tags logging specific disk identification and raw SMART attribute
values.
Attributes
Tags logging specific disk identification and attribute values.
=smart:<device_file>:<disk_name>[/<split_number>]
Logs the start of the SMART report for a device.
<device_file> - The file path of the device (e.g., /dev/sdb).
<disk_name>[/<split_number>] - The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension `/N`, where N starts from 1.
In case of split parity, the parity name is followed
by `/N` to indicate the split number, where N starts
from 0. The `/0` is always omitted.
=attr:<device_file>:<disk_name>[/<split_number>]:serial:<serial_number>
Logs the disk's serial number.
@ -991,6 +994,22 @@ Command Smart Tags
<value_decimal> - The raw attribute value (uint64, decimal).
<value_hex> - The raw attribute value (uint64, hexadecimal).
=attr:<device_file>:<disk_name>[/<split_number>]:power:active
Logs that the device was confirmed to be in an active power
state after a status probe.
=attr:<device_file>:<disk_name>[/<split_number>]:power:standby
Logs that the device was confirmed to be in a standby/spun-down
state.
=attr:<device_file>:<disk_name>[/<split_number>]:power:up
Logs a successful spin-up operation via direct O_DIRECT
read.
=attr:<device_file>:<disk_name>[/<split_number>]:power:down
Logs a successful spin-down operation initiated via the
smartctl command.
Summary
Tags logging the overall failure probabilities for the array.
@ -1005,34 +1024,17 @@ Command Smart Tags
Device Status Tags
These tags log the lifecycle of hardware interactions and external
command execution. They are primarily output during the `up`
(spin-up), `down` (spin-down), and `probe` (power state check)
commands.
=device:<device_file>:<disk_name>[/<split_number>]:active
Logs that the device was confirmed to be in an active power
state after a status probe.
<device_file> - The system path to the device node.
<disk_name>[/<split_number>] - The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension `/N`, where N starts from 1.
=device:<device_file>:<disk_name>[/<split_number>]:standby
Logs that the device was confirmed to be in a standby/spun-down
state.
=device:<device_file>:<disk_name>[/<split_number>]:up
Logs a successful spin-up operation via direct O_DIRECT
read.
=device:<device_file>:<disk_name>[/<split_number>]:down
Logs a successful spin-down operation initiated via the
smartctl command.
command execution with the `smartctl` command.
=device:<device_file>:<disk_name>[/<split_number>]:shell
Logs a failure in the command shell execution environment.
<device_file> - The system path to the device node.
<disk_name>[/<split_number>] - The configured name of the disk.
In case of split parity, the parity name is followed
by `/N` to indicate the split number, where N starts
from 0. The `/0` is always omitted.
=device:<device_file>:<disk_name>[/<split_number>]:error:<errno>
Logs a low-level system error during direct file operations.
This is triggered when open(), read(), or close()

View file

@ -363,8 +363,9 @@ disk access.
device.
<disk_name>[/<split_number>] - The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension `/N`, where N starts from 1.
In case of split parity, the parity name is followed
by `/N` to indicate the split number, where N starts
from 0. The `/0` is always omitted.
<device> - The unique device ID (uint64).
<temp> - The current temperature read from the disk in degrees
Celsius.
@ -963,18 +964,20 @@ Note that a `<disk_name>` may be associated with more `<device_file>`,
in case the logical disk uses more physical disks. In such a case,
you'll see multiple tags for the same `<disk_name>` but with different
`<device_file>`.
In case of split parity, the parity name is followed by `/N` to indicate
the split number, where N starts from 0. The `/0` is always omitted.
---- 14.0.1 SMART Attributes ----
Tags logging specific disk identification and raw SMART attribute
values.
---- 14.0.1 Attributes ----
Tags logging specific disk identification and attribute values.
smart:<device_file>:<disk_name>[/<split_number>]
Logs the start of the SMART report for a device.
<device_file> - The file path of the device (e.g., /dev/sdb).
<disk_name>[/<split_number>] - The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension `/N`, where N starts from 1.
In case of split parity, the parity name is followed
by `/N` to indicate the split number, where N starts
from 0. The `/0` is always omitted.
attr:<device_file>:<disk_name>[/<split_number>]:serial:<serial_number>
Logs the disk's serial number.
@ -1033,6 +1036,22 @@ values.
<value_decimal> - The raw attribute value (uint64, decimal).
<value_hex> - The raw attribute value (uint64, hexadecimal).
attr:<device_file>:<disk_name>[/<split_number>]:power:active
Logs that the device was confirmed to be in an active power
state after a status probe.
attr:<device_file>:<disk_name>[/<split_number>]:power:standby
Logs that the device was confirmed to be in a standby/spun-down
state.
attr:<device_file>:<disk_name>[/<split_number>]:power:up
Logs a successful spin-up operation via direct O_DIRECT
read.
attr:<device_file>:<disk_name>[/<split_number>]:power:down
Logs a successful spin-down operation initiated via the
smartctl command.
---- 14.0.2 Summary ----
Tags logging the overall failure probabilities for the array.
@ -1050,34 +1069,17 @@ Tags logging the overall failure probabilities for the array.
=====================
These tags log the lifecycle of hardware interactions and external
command execution. They are primarily output during the `up`
(spin-up), `down` (spin-down), and `probe` (power state check)
commands.
device:<device_file>:<disk_name>[/<split_number>]:active
Logs that the device was confirmed to be in an active power
state after a status probe.
<device_file> - The system path to the device node.
<disk_name>[/<split_number>] - The configured name of the disk.
In case of multiple splits, the splits after the first
one have an extension `/N`, where N starts from 1.
device:<device_file>:<disk_name>[/<split_number>]:standby
Logs that the device was confirmed to be in a standby/spun-down
state.
device:<device_file>:<disk_name>[/<split_number>]:up
Logs a successful spin-up operation via direct O_DIRECT
read.
device:<device_file>:<disk_name>[/<split_number>]:down
Logs a successful spin-down operation initiated via the
smartctl command.
command execution with the `smartctl` command.
device:<device_file>:<disk_name>[/<split_number>]:shell
Logs a failure in the command shell execution environment.
<device_file> - The system path to the device node.
<disk_name>[/<split_number>] - The configured name of the disk.
In case of split parity, the parity name is followed
by `/N` to indicate the split number, where N starts
from 0. The `/0` is always omitted.
device:<device_file>:<disk_name>[/<split_number>]:error:<errno>
Logs a low-level system error during direct file operations.
This is triggered when open(), read(), or close()