Skip to content
Open
Show file tree
Hide file tree
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
87 changes: 52 additions & 35 deletions grafana/smart-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -194,7 +194,7 @@
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -284,7 +284,7 @@
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -386,7 +386,7 @@
"sort": "none"
}
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -464,7 +464,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -506,7 +506,7 @@
"content": "<p></p>\n<p style=\"text-align: center;font-size: x-large;face:arial;\">__________ Wear and Tear __________</p>",
"mode": "html"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"title": "",
"type": "text"
},
Expand Down Expand Up @@ -568,7 +568,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -643,7 +643,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -683,7 +683,7 @@
"content": "<p></p>\n<p style=\"text-align: center;font-size: x-large;face:arial;\">__________ SSD Specific Values __________</p>",
"mode": "html"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"title": "",
"type": "text"
},
Expand Down Expand Up @@ -747,7 +747,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -855,7 +855,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -898,7 +898,7 @@
"content": "<p></p>\n<p style=\"text-align: center;font-size: x-large;face:arial;\">__________ HDD Specific Values __________</p>",
"mode": "html"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"title": "",
"type": "text"
},
Expand Down Expand Up @@ -983,7 +983,7 @@
"sort": "none"
}
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -1060,7 +1060,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -1140,7 +1140,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -1217,7 +1217,7 @@
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -1266,7 +1266,20 @@
},
"unit": "short"
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byName",
"options": "capacity"
},
"properties": [
{
"id": "unit",
"value": "decbytes"
}
]
}
]
},
"gridPos": {
"h": 7,
Expand All @@ -1287,7 +1300,7 @@
},
"showHeader": true
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand All @@ -1308,6 +1321,7 @@
{
"id": "filterFieldsByName",
"options": {
"byVariable": false,
"include": {
"names": [
"disk",
Expand All @@ -1316,7 +1330,8 @@
"model_family",
"model_name",
"serial_number",
"type"
"type",
"user_capacity_bytes"
]
}
}
Expand All @@ -1327,16 +1342,18 @@
"excludeByName": {},
"includeByName": {},
"indexByName": {
"Value": 7,
"disk": 1,
"firmware_version": 5,
"instance": 0,
"model_family": 4,
"model_family": 6,
"model_name": 3,
"serial_number": 6,
"type": 2
"serial_number": 7,
"type": 2,
"user_capacity_bytes": 4
},
"renameByName": {}
"renameByName": {
"user_capacity_bytes": "capacity"
}
}
},
{
Expand Down Expand Up @@ -1507,7 +1524,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -1734,7 +1751,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -1961,7 +1978,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -2193,7 +2210,7 @@
}
]
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -2425,7 +2442,7 @@
}
]
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -2652,7 +2669,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -2879,7 +2896,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -3119,7 +3136,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -3346,7 +3363,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -3573,7 +3590,7 @@
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.4.0",
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -3662,7 +3679,7 @@
],
"preload": false,
"refresh": "",
"schemaVersion": 40,
"schemaVersion": 41,
"tags": [
"prometheus",
"node_exporter",
Expand Down
14 changes: 11 additions & 3 deletions src/smartmon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This script is designed to collect SMART data from various types of
# disks (ATA, NVMe) and format it for Prometheus monitoring.

smartmon_version="0.3.16"
smartmon_version="0.3.17"

# Configurable flag to indicate Seagate-specific behavior
seagate_special=false
Expand Down Expand Up @@ -64,7 +64,7 @@ parse_smartctl_info_json() {
local json="$3"
local labels="disk=\"${disk}\",type=\"${disk_type}\""

declare -a keys_general=("model_family" "model_name" "device_model" "serial_number" "firmware_version" "vendor" "product" "revision" "lun_id")
declare -a keys_general=("model_family" "model_name" "device_model" "serial_number" "firmware_version" "vendor" "product" "revision" "lun_id" "user_capacity.bytes")
declare -a keys_binary=("smart_support.available" "smart_support.enabled" "smart_status.passed")

# Print the extracted information in Prometheus format
Expand All @@ -76,7 +76,9 @@ EOF

for key in "${keys_general[@]}"; do
# Added escaping for special characters
device_infos+="$key="\"$(jq -r --arg key "$key" '.[$key] // empty' <<< "$json" | sed 's/"/\\"/g')\"\,
# Replace dots with underscores in label names for Prometheus compatibility
label_name="${key//./_}"
device_infos+="$label_name="\"$(jq -r --arg key "$key" 'getpath($key | split(".")) // empty' <<< "$json" | sed 's/"/\\"/g')\"\,
done

# Remove the last comma
Expand All @@ -97,6 +99,12 @@ EOF
fi
echo "$(echo "$key" | tr '.' '_'){${labels}} ${value}"
done

local disk_size_bytes
disk_size_bytes=$(echo "$json" | jq -r '.user_capacity.bytes // empty')
if [[ -n "$disk_size_bytes" && "$disk_size_bytes" != "null" ]]; then
echo "user_capacity_bytes{${labels}} ${disk_size_bytes}"
fi
}

# Parse and extract ATA SMART attributes from the provided JSON.
Expand Down