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:
|
||||
- capacity
|
||||
- device
|
||||
- device_model
|
||||
- enabled
|
||||
- health
|
||||
- model
|
||||
- serial_no
|
||||
- wwn
|
||||
- fields:
|
||||
|
@ -104,10 +103,13 @@ Defaults!SMARTCTL !logfile, !syslog, !pam_session
|
|||
|
||||
- smart_attribute:
|
||||
- tags:
|
||||
- capacity
|
||||
- device
|
||||
- enabled
|
||||
- fail
|
||||
- flags
|
||||
- id
|
||||
- model
|
||||
- name
|
||||
- serial_no
|
||||
- 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_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,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-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,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{})
|
||||
|
||||
if collectAttributes {
|
||||
deviceNode := strings.Split(device, " ")[0]
|
||||
tags["device"] = path.Base(deviceNode)
|
||||
|
||||
if serial, ok := deviceTags["serial_no"]; ok {
|
||||
tags["serial_no"] = serial
|
||||
}
|
||||
if wwn, ok := deviceTags["wwn"]; ok {
|
||||
tags["wwn"] = wwn
|
||||
keys := [...]string{"device", "model", "serial_no", "wwn", "capacity", "enabled"}
|
||||
for _, key := range keys {
|
||||
if value, ok := deviceTags[key]; ok {
|
||||
tags[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "1",
|
||||
"name": "Raw_Read_Error_Rate",
|
||||
"flags": "-O-RC-",
|
||||
|
@ -67,8 +70,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "5",
|
||||
"name": "Reallocated_Sector_Ct",
|
||||
"flags": "PO--CK",
|
||||
|
@ -85,8 +91,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "9",
|
||||
"name": "Power_On_Hours",
|
||||
"flags": "-O--CK",
|
||||
|
@ -103,8 +112,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "12",
|
||||
"name": "Power_Cycle_Count",
|
||||
"flags": "-O--CK",
|
||||
|
@ -121,8 +133,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "169",
|
||||
"name": "Unknown_Attribute",
|
||||
"flags": "PO--C-",
|
||||
|
@ -139,8 +154,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "173",
|
||||
"name": "Wear_Leveling_Count",
|
||||
"flags": "-O--CK",
|
||||
|
@ -157,8 +175,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "190",
|
||||
"name": "Airflow_Temperature_Cel",
|
||||
"flags": "-O---K",
|
||||
|
@ -175,8 +196,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "192",
|
||||
"name": "Power-Off_Retract_Count",
|
||||
"flags": "-O--C-",
|
||||
|
@ -193,8 +217,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "194",
|
||||
"name": "Temperature_Celsius",
|
||||
"flags": "-O---K",
|
||||
|
@ -211,8 +238,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "197",
|
||||
"name": "Current_Pending_Sector",
|
||||
"flags": "-O---K",
|
||||
|
@ -229,8 +259,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "199",
|
||||
"name": "UDMA_CRC_Error_Count",
|
||||
"flags": "-O-RC-",
|
||||
|
@ -247,8 +280,11 @@ func TestGatherAttributes(t *testing.T) {
|
|||
},
|
||||
map[string]string{
|
||||
"device": "ada0",
|
||||
"model": "APPLE SSD SM256E",
|
||||
"serial_no": "S0X5NZBC422720",
|
||||
"wwn": "5002538043584d30",
|
||||
"enabled": "Enabled",
|
||||
"capacity": "251000193024",
|
||||
"id": "240",
|
||||
"name": "Head_Flying_Hours",
|
||||
"flags": "------",
|
||||
|
@ -466,6 +502,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"id": "9",
|
||||
"name": "Power_On_Hours",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": 6038,
|
||||
|
@ -478,6 +515,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"id": "12",
|
||||
"name": "Power_Cycle_Count",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": 472,
|
||||
|
@ -489,6 +527,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"device": ".",
|
||||
"name": "Media_and_Data_Integrity_Errors",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": 0,
|
||||
|
@ -500,6 +539,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"device": ".",
|
||||
"name": "Error_Information_Log_Entries",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": 119699,
|
||||
|
@ -511,6 +551,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"device": ".",
|
||||
"name": "Available_Spare",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": 100,
|
||||
|
@ -523,6 +564,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"id": "194",
|
||||
"name": "Temperature_Celsius",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": 38,
|
||||
|
@ -534,6 +576,7 @@ func TestGatherNvme(t *testing.T) {
|
|||
"device": ".",
|
||||
"name": "Critical_Warning",
|
||||
"serial_no": "D704940282?",
|
||||
"model": "TS128GMTE850",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"raw_value": int64(9),
|
||||
|
|
Loading…
Reference in New Issue