Add device tags to smart_attributes (#6201)
This commit is contained in:
parent
61f6794846
commit
1c1c41c300
|
@ -89,9 +89,8 @@ Defaults!SMARTCTL !logfile, !syslog, !pam_session
|
||||||
- tags:
|
- tags:
|
||||||
- capacity
|
- capacity
|
||||||
- device
|
- device
|
||||||
- device_model
|
|
||||||
- enabled
|
- enabled
|
||||||
- health
|
- model
|
||||||
- serial_no
|
- serial_no
|
||||||
- wwn
|
- wwn
|
||||||
- fields:
|
- fields:
|
||||||
|
@ -104,10 +103,13 @@ Defaults!SMARTCTL !logfile, !syslog, !pam_session
|
||||||
|
|
||||||
- smart_attribute:
|
- smart_attribute:
|
||||||
- tags:
|
- tags:
|
||||||
|
- capacity
|
||||||
- device
|
- device
|
||||||
|
- enabled
|
||||||
- fail
|
- fail
|
||||||
- flags
|
- flags
|
||||||
- id
|
- id
|
||||||
|
- model
|
||||||
- name
|
- name
|
||||||
- serial_no
|
- serial_no
|
||||||
- wwn
|
- wwn
|
||||||
|
@ -163,6 +165,6 @@ smartctl --info --health --attributes --tolerance=verypermissive --nocheck NOCHE
|
||||||
|
|
||||||
```
|
```
|
||||||
smart_device,enabled=Enabled,host=mbpro.local,device=rdisk0,model=APPLE\ SSD\ SM0512F,serial_no=S1K5NYCD964433,wwn=5002538655584d30,capacity=500277790720 udma_crc_errors=0i,exit_status=0i,health_ok=true,read_error_rate=0i,temp_c=40i 1502536854000000000
|
smart_device,enabled=Enabled,host=mbpro.local,device=rdisk0,model=APPLE\ SSD\ SM0512F,serial_no=S1K5NYCD964433,wwn=5002538655584d30,capacity=500277790720 udma_crc_errors=0i,exit_status=0i,health_ok=true,read_error_rate=0i,temp_c=40i 1502536854000000000
|
||||||
smart_attribute,serial_no=S1K5NYCD964433,wwn=5002538655584d30,id=199,name=UDMA_CRC_Error_Count,flags=-O-RC-,fail=-,host=mbpro.local,device=rdisk0 threshold=0i,raw_value=0i,exit_status=0i,value=200i,worst=200i 1502536854000000000
|
smart_attribute,capacity=500277790720,device=rdisk0,enabled=Enabled,fail=-,flags=-O-RC-,host=mbpro.local,id=199,model=APPLE\ SSD\ SM0512F,name=UDMA_CRC_Error_Count,serial_no=S1K5NYCD964433,wwn=5002538655584d30 exit_status=0i,raw_value=0i,threshold=0i,value=200i,worst=200i 1502536854000000000
|
||||||
smart_attribute,device=rdisk0,serial_no=S1K5NYCD964433,wwn=5002538655584d30,id=240,name=Unknown_SSD_Attribute,flags=-O---K,fail=-,host=mbpro.local exit_status=0i,value=100i,worst=100i,threshold=0i,raw_value=0i 1502536854000000000
|
smart_attribute,capacity=500277790720,device=rdisk0,enabled=Enabled,fail=-,flags=-O---K,host=mbpro.local,id=199,model=APPLE\ SSD\ SM0512F,name=Unknown_SSD_Attribute,serial_no=S1K5NYCD964433,wwn=5002538655584d30 exit_status=0i,raw_value=0i,threshold=0i,value=100i,worst=100i 1502536854000000000
|
||||||
```
|
```
|
||||||
|
|
|
@ -303,14 +303,11 @@ func gatherDisk(acc telegraf.Accumulator, usesudo, collectAttributes bool, smart
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
|
|
||||||
if collectAttributes {
|
if collectAttributes {
|
||||||
deviceNode := strings.Split(device, " ")[0]
|
keys := [...]string{"device", "model", "serial_no", "wwn", "capacity", "enabled"}
|
||||||
tags["device"] = path.Base(deviceNode)
|
for _, key := range keys {
|
||||||
|
if value, ok := deviceTags[key]; ok {
|
||||||
if serial, ok := deviceTags["serial_no"]; ok {
|
tags[key] = value
|
||||||
tags["serial_no"] = serial
|
}
|
||||||
}
|
|
||||||
if wwn, ok := deviceTags["wwn"]; ok {
|
|
||||||
tags["wwn"] = wwn
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "Raw_Read_Error_Rate",
|
"name": "Raw_Read_Error_Rate",
|
||||||
"flags": "-O-RC-",
|
"flags": "-O-RC-",
|
||||||
|
@ -67,8 +70,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "5",
|
"id": "5",
|
||||||
"name": "Reallocated_Sector_Ct",
|
"name": "Reallocated_Sector_Ct",
|
||||||
"flags": "PO--CK",
|
"flags": "PO--CK",
|
||||||
|
@ -85,8 +91,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "9",
|
"id": "9",
|
||||||
"name": "Power_On_Hours",
|
"name": "Power_On_Hours",
|
||||||
"flags": "-O--CK",
|
"flags": "-O--CK",
|
||||||
|
@ -103,8 +112,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "12",
|
"id": "12",
|
||||||
"name": "Power_Cycle_Count",
|
"name": "Power_Cycle_Count",
|
||||||
"flags": "-O--CK",
|
"flags": "-O--CK",
|
||||||
|
@ -121,8 +133,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "169",
|
"id": "169",
|
||||||
"name": "Unknown_Attribute",
|
"name": "Unknown_Attribute",
|
||||||
"flags": "PO--C-",
|
"flags": "PO--C-",
|
||||||
|
@ -139,8 +154,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "173",
|
"id": "173",
|
||||||
"name": "Wear_Leveling_Count",
|
"name": "Wear_Leveling_Count",
|
||||||
"flags": "-O--CK",
|
"flags": "-O--CK",
|
||||||
|
@ -157,8 +175,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "190",
|
"id": "190",
|
||||||
"name": "Airflow_Temperature_Cel",
|
"name": "Airflow_Temperature_Cel",
|
||||||
"flags": "-O---K",
|
"flags": "-O---K",
|
||||||
|
@ -175,8 +196,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "192",
|
"id": "192",
|
||||||
"name": "Power-Off_Retract_Count",
|
"name": "Power-Off_Retract_Count",
|
||||||
"flags": "-O--C-",
|
"flags": "-O--C-",
|
||||||
|
@ -193,8 +217,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "194",
|
"id": "194",
|
||||||
"name": "Temperature_Celsius",
|
"name": "Temperature_Celsius",
|
||||||
"flags": "-O---K",
|
"flags": "-O---K",
|
||||||
|
@ -211,8 +238,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "197",
|
"id": "197",
|
||||||
"name": "Current_Pending_Sector",
|
"name": "Current_Pending_Sector",
|
||||||
"flags": "-O---K",
|
"flags": "-O---K",
|
||||||
|
@ -229,8 +259,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "199",
|
"id": "199",
|
||||||
"name": "UDMA_CRC_Error_Count",
|
"name": "UDMA_CRC_Error_Count",
|
||||||
"flags": "-O-RC-",
|
"flags": "-O-RC-",
|
||||||
|
@ -247,8 +280,11 @@ func TestGatherAttributes(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "ada0",
|
"device": "ada0",
|
||||||
|
"model": "APPLE SSD SM256E",
|
||||||
"serial_no": "S0X5NZBC422720",
|
"serial_no": "S0X5NZBC422720",
|
||||||
"wwn": "5002538043584d30",
|
"wwn": "5002538043584d30",
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"capacity": "251000193024",
|
||||||
"id": "240",
|
"id": "240",
|
||||||
"name": "Head_Flying_Hours",
|
"name": "Head_Flying_Hours",
|
||||||
"flags": "------",
|
"flags": "------",
|
||||||
|
@ -466,6 +502,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"id": "9",
|
"id": "9",
|
||||||
"name": "Power_On_Hours",
|
"name": "Power_On_Hours",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": 6038,
|
"raw_value": 6038,
|
||||||
|
@ -478,6 +515,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"id": "12",
|
"id": "12",
|
||||||
"name": "Power_Cycle_Count",
|
"name": "Power_Cycle_Count",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": 472,
|
"raw_value": 472,
|
||||||
|
@ -489,6 +527,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"device": ".",
|
"device": ".",
|
||||||
"name": "Media_and_Data_Integrity_Errors",
|
"name": "Media_and_Data_Integrity_Errors",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": 0,
|
"raw_value": 0,
|
||||||
|
@ -500,6 +539,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"device": ".",
|
"device": ".",
|
||||||
"name": "Error_Information_Log_Entries",
|
"name": "Error_Information_Log_Entries",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": 119699,
|
"raw_value": 119699,
|
||||||
|
@ -511,6 +551,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"device": ".",
|
"device": ".",
|
||||||
"name": "Available_Spare",
|
"name": "Available_Spare",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": 100,
|
"raw_value": 100,
|
||||||
|
@ -523,6 +564,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"id": "194",
|
"id": "194",
|
||||||
"name": "Temperature_Celsius",
|
"name": "Temperature_Celsius",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": 38,
|
"raw_value": 38,
|
||||||
|
@ -534,6 +576,7 @@ func TestGatherNvme(t *testing.T) {
|
||||||
"device": ".",
|
"device": ".",
|
||||||
"name": "Critical_Warning",
|
"name": "Critical_Warning",
|
||||||
"serial_no": "D704940282?",
|
"serial_no": "D704940282?",
|
||||||
|
"model": "TS128GMTE850",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"raw_value": int64(9),
|
"raw_value": int64(9),
|
||||||
|
|
Loading…
Reference in New Issue