Giter Club home page Giter Club logo

python-glances-api's People

Contributors

b0z02003 avatar bdraco avatar dependabot[bot] avatar engrbm87 avatar fabaff avatar freedom- avatar guykh avatar ludeeus avatar neuralyze avatar wittypluck avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

python-glances-api's Issues

Add smart to HA data

I would like to be able to see at least some basic SMART data from Glances in Home Assistant so I can set up alerts/automation for potential disk issues.

Here's a sample output from my instance at /api/3/smart

[
  {
    "DeviceName": "sda Hitachi HDS721010CLA330",
    "1": {
      "name": "Raw_Read_Error_Rate",
      "flags": "1",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "016",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "2": {
      "name": "Throughput_Performance",
      "flags": "2",
      "raw": "95",
      "value": "136",
      "worst": "136",
      "threshold": "054",
      "type": "Pre-fail",
      "updated": "Offline",
      "when_failed": "-"
    },
    "3": {
      "name": "Spin_Up_Time",
      "flags": "3",
      "raw": "286",
      "value": "135",
      "worst": "135",
      "threshold": "024",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "4": {
      "name": "Start_Stop_Count",
      "flags": "4",
      "raw": "1982",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "5": {
      "name": "Reallocated_Sector_Ct",
      "flags": "5",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "005",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "7": {
      "name": "Seek_Error_Rate",
      "flags": "7",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "067",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "8": {
      "name": "Seek_Time_Performance",
      "flags": "8",
      "raw": "31",
      "value": "138",
      "worst": "138",
      "threshold": "020",
      "type": "Pre-fail",
      "updated": "Offline",
      "when_failed": "-"
    },
    "9": {
      "name": "Power_On_Hours",
      "flags": "9",
      "raw": "14602",
      "value": "098",
      "worst": "098",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "10": {
      "name": "Spin_Retry_Count",
      "flags": "0",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "060",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "12": {
      "name": "Power_Cycle_Count",
      "flags": "2",
      "raw": "1706",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "192": {
      "name": "Power-Off_Retract_Count",
      "flags": "2",
      "raw": "1991",
      "value": "099",
      "worst": "099",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "193": {
      "name": "Load_Cycle_Count",
      "flags": "3",
      "raw": "1991",
      "value": "099",
      "worst": "099",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "194": {
      "name": "Temperature_Celsius",
      "flags": "4",
      "raw": "25",
      "value": "240",
      "worst": "240",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "196": {
      "name": "Reallocated_Event_Count",
      "flags": "6",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "197": {
      "name": "Current_Pending_Sector",
      "flags": "7",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "198": {
      "name": "Offline_Uncorrectable",
      "flags": "8",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Offline",
      "when_failed": "-"
    },
    "199": {
      "name": "UDMA_CRC_Error_Count",
      "flags": "9",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    }
  },
  {
    "DeviceName": "sdb WDC WD20EZRX-00D8PB0",
    "1": {
      "name": "Raw_Read_Error_Rate",
      "flags": "1",
      "raw": "449",
      "value": "200",
      "worst": "199",
      "threshold": "051",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "3": {
      "name": "Spin_Up_Time",
      "flags": "3",
      "raw": "4391",
      "value": "172",
      "worst": "166",
      "threshold": "021",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "4": {
      "name": "Start_Stop_Count",
      "flags": "4",
      "raw": "3123",
      "value": "097",
      "worst": "097",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "5": {
      "name": "Reallocated_Sector_Ct",
      "flags": "5",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "140",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "7": {
      "name": "Seek_Error_Rate",
      "flags": "7",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "9": {
      "name": "Power_On_Hours",
      "flags": "9",
      "raw": "17776",
      "value": "076",
      "worst": "076",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "10": {
      "name": "Spin_Retry_Count",
      "flags": "0",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "11": {
      "name": "Calibration_Retry_Count",
      "flags": "1",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "12": {
      "name": "Power_Cycle_Count",
      "flags": "2",
      "raw": "3098",
      "value": "097",
      "worst": "097",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "192": {
      "name": "Power-Off_Retract_Count",
      "flags": "2",
      "raw": "475",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "193": {
      "name": "Load_Cycle_Count",
      "flags": "3",
      "raw": "1110694",
      "value": "001",
      "worst": "001",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "194": {
      "name": "Temperature_Celsius",
      "flags": "4",
      "raw": "23",
      "value": "124",
      "worst": "102",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "196": {
      "name": "Reallocated_Event_Count",
      "flags": "6",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "197": {
      "name": "Current_Pending_Sector",
      "flags": "7",
      "raw": "10",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "198": {
      "name": "Offline_Uncorrectable",
      "flags": "8",
      "raw": "10",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Offline",
      "when_failed": "-"
    },
    "199": {
      "name": "UDMA_CRC_Error_Count",
      "flags": "9",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "200": {
      "name": "Multi_Zone_Error_Rate",
      "flags": "0",
      "raw": "11",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Offline",
      "when_failed": "-"
    }
  },
  {
    "DeviceName": "sdc WDC WD5000AAKX-60U6AA0",
    "1": {
      "name": "Raw_Read_Error_Rate",
      "flags": "1",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "051",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "3": {
      "name": "Spin_Up_Time",
      "flags": "3",
      "raw": "3816",
      "value": "143",
      "worst": "141",
      "threshold": "021",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "4": {
      "name": "Start_Stop_Count",
      "flags": "4",
      "raw": "459",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "5": {
      "name": "Reallocated_Sector_Ct",
      "flags": "5",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "140",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "7": {
      "name": "Seek_Error_Rate",
      "flags": "7",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "051",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "9": {
      "name": "Power_On_Hours",
      "flags": "9",
      "raw": "8014",
      "value": "090",
      "worst": "089",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "10": {
      "name": "Spin_Retry_Count",
      "flags": "0",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "051",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "11": {
      "name": "Calibration_Retry_Count",
      "flags": "1",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "12": {
      "name": "Power_Cycle_Count",
      "flags": "2",
      "raw": "401",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "184": {
      "name": "End-to-End_Error",
      "flags": "4",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "097",
      "type": "Pre-fail",
      "updated": "Always",
      "when_failed": "-"
    },
    "187": {
      "name": "Reported_Uncorrect",
      "flags": "7",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "188": {
      "name": "Command_Timeout",
      "flags": "8",
      "raw": "0",
      "value": "100",
      "worst": "100",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "190": {
      "name": "Airflow_Temperature_Cel",
      "flags": "0",
      "raw": "26",
      "value": "074",
      "worst": "054",
      "threshold": "040",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "192": {
      "name": "Power-Off_Retract_Count",
      "flags": "2",
      "raw": "57",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "193": {
      "name": "Load_Cycle_Count",
      "flags": "3",
      "raw": "401",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "196": {
      "name": "Reallocated_Event_Count",
      "flags": "6",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "197": {
      "name": "Current_Pending_Sector",
      "flags": "7",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "198": {
      "name": "Offline_Uncorrectable",
      "flags": "8",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Offline",
      "when_failed": "-"
    },
    "199": {
      "name": "UDMA_CRC_Error_Count",
      "flags": "9",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Always",
      "when_failed": "-"
    },
    "200": {
      "name": "Multi_Zone_Error_Rate",
      "flags": "0",
      "raw": "0",
      "value": "200",
      "worst": "200",
      "threshold": "000",
      "type": "Old_age",
      "updated": "Offline",
      "when_failed": "-"
    }
  }
]

Containers sections needs update to consume API version 3.4

3.4 puts container information under the "containers" plugin. (3.3 was "docker")

Also, "containers" omits some info, putting specific container data at top level. (i.e. http://localhost:61208/api/3/docker/containers becomes http://localhost:61208/api/3/containers

Glances v4 changes the containers structure, breaks get_ha_sensor_data

Containers API has changed again in Glances v4:
The dictionary becomes a list, which breaks get_ha_sensor_data

In v3.4:
"containers":{"version":{},"version_podman":{},"containers":[ { <CONTAINER1> }, { <CONTAINER2> } ]},

In v4:
"containers":[ { <CONTAINER1> }, { <CONTAINER2> } ],

home-assistant/core#118632

On line :
https://github.com/home-assistant-ecosystem/python-glances-api/blob/e2b55722b638fc3afa900b86ed724a17d2a9fbcf/glances_api/__init__.py#L173C9-L173C11

Error :

  File "/usr/local/lib/python3.12/site-packages/glances_api/__init__.py", line 173, in get_ha_sensor_data
    if data and (containers_data := data.get("containers")):
                                    ^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.