Skip to content

added script for ipmitool chassis status metrics #12

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions ipmitool_chassis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/awk -nf

#
# Converts output of `ipmitool chassis status` to prometheus format.
#
# With GNU awk:
# ipmitool chassis status | ./ipmitool_chassis.sh > ipmitool_chassis.prom
#
# With BSD awk:
# ipmitool chassis status | awk -f ./ipmitool_chassis.sh > ipmitool_chassis.prom
#

function export(values, name) {
if (values["metric_count"] < 1) {
return
}
delete values["metric_count"]

printf("# HELP %s%s %s sensor reading from ipmitool\n", namespace, name, help[name]);
printf("# TYPE %s%s gauge\n", namespace, name);
for (sensor in values) {
printf("%s%s{sensor=\"%s\"} %f\n", namespace, name, sensor, values[sensor]);
}
}

# Fields are colon separated, with space padding.
BEGIN {
FS = "[ ]*[:][ ]*";
namespace = "node_ipmi_chassis_";

# Friendly description of the type of sensor for HELP.
help["fault"] = "Chassis Fault";

fault["metric_count"] = 0;
}

# Not a valid line.
{
if (NF < 2) {
next
}
}

# $2 is value field.
$2 ~ /na/ {
next
}

# $1 is type field.
$1 ~ /Fault/ {
if ($2 == "true") {
fault[$1] = 1
} else {
fault[$1] = 0
}
fault["metric_count"]++;
}

END {
export(fault, "fault");
}