hass_ben 发表于 2022-11-9 11:13:46

HASS监控搬瓦工服务器状态

利用搬瓦工官方API,每15秒获取一次服务器信息,展示到HASS前端,基本上就是探针的作用了。
实现效果(两种)如图:





第一张效果图前端卡片代码如下,其中的数值根据自己服务器实际情况更改即可,需要用到的前端集成有:https://github.com/benct/lovelace-multiple-entity-row#entity-objects https://github.com/custom-cards/bar-card 。使用前请自行安装。
type: entities
show_header_toggle: false
title: Bandwagon 服务器
icon: mdi:server
entities:
- type: custom:multiple-entity-row
    entity: sensor.bwh
    attribute: vps_status
    icon: mdi:restart
    name: 状况
    show_state: false
    entities:
      - attribute: vps_status
      name: Status
      - attribute: vps_suspended_status
      name: Suspended
      styles:
          width: 100px
          text-align: center
- type: custom:multiple-entity-row
    entity: sensor.bwh
    attribute: load_average
    icon: mdi:run
    name: 负载
- type: custom:bar-card
    entities:
      - entity: sensor.bwh
      attribute: ram_used
      name: 内存
    max: 512
    entity_row: true
    height: 25px
    color: green
    unit_of_measurement: MB
    positions:
      icon: 'off'
      indicator: inside
    style: |-
      bar-card-background {
      margin-left: 200px;
      }

      bar-card-value {
      margin-right: auto;
      font-size: 13px;
      font-weight: bold;
      text-shadow: 1px 1px #0005;
      }
    severity:
      - color: Red
      from: 460.8
      to: 512
      - color: Orange
      from: 307.2
      to: 460.8
      - color: Green
      from: 0
      to: 307.2
- type: custom:bar-card
    entities:
      - entity: sensor.bwh
      attribute: swap_used
      name: SWAP
    max: 256
    entity_row: true
    height: 25px
    color: green
    unit_of_measurement: MB
    positions:
      icon: 'off'
      indicator: inside
    style: |-
      bar-card-background {
      margin-left: 200px;
      }

      bar-card-value {
      margin-right: auto;
      font-size: 13px;
      font-weight: bold;
      text-shadow: 1px 1px #0005;
      }
    severity:
      - color: Red
      from: 204.8
      to: 256
      - color: Orange
      from: 153.6
      to: 204.8
      - color: Green
      from: 0
      to: 153.6
- type: custom:bar-card
    entities:
      - entity: sensor.bwh
      attribute: month_data_used
      name: 流量
    max: 300
    entity_row: true
    height: 25px
    color: green
    unit_of_measurement: GB
    positions:
      icon: 'off'
      indicator: inside
    style: |-
      bar-card-background {
      margin-left: 200px;
      }

      bar-card-value {
      margin-right: auto;
      font-size: 13px;
      font-weight: bold;
      text-shadow: 1px 1px #0005;
      }
    severity:
      - color: Red
      from: 240
      to: 300
      - color: Orange
      from: 180
      to: 240
      - color: Green
      from: 0
      to: 180

第二张效果图前端卡片代码如下,需要用到的前端集成有:https://github.com/benct/lovelace-multiple-entity-row#entity-objects。使用前请自行安装。
type: entities
show_header_toggle: false
title: Bandwagon 服务器
icon: mdi:server
entities:
- type: custom:multiple-entity-row
    entity: sensor.bwh
    attribute: vps_status
    icon: mdi:power
    name: 状况
    show_state: false
    entities:
      - attribute: vps_status
      name: Status
      - attribute: vps_suspended_status
      name: Suspended
      styles:
          width: 100px
          text-align: right
- type: custom:multiple-entity-row
    entity: sensor.bwh
    attribute: load_average
    icon: mdi:reload
    name: 负载
- type: custom:multiple-entity-row
    entity: sensor.bwh
    icon: mdi:memory
    name: 内存
    show_state: false
    entities:
      - attribute: ram_used
      name: RAM used
      unit: MB
      - attribute: swap_used
      name: SWAP used
      unit: MB
      styles:
          width: 100px
          text-align: right
- type: custom:multiple-entity-row
    entity: sensor.bwh
    icon: mdi:harddisk
    name: 磁盘
    show_state: false
    entities:
      - attribute: disk_used
      name: Disk used
      unit: GB
      - attribute: disk_plan
      name: Disk plan
      unit: GB
      styles:
          width: 100px
          text-align: right
- type: custom:multiple-entity-row
    entity: sensor.bwh
    icon: mdi:database-arrow-down-outline
    name: 流量
    show_state: false
    entities:
      - attribute: month_data_used
      name: Data used
      unit: GB
      - attribute: month_data_plan
      name: Data plan
      unit: GB
      styles:
          width: 100px
          text-align: right


NODE-RED流下载,参数设置请去搬瓦工后台获取:

bugensui 发表于 2022-11-9 11:37:22

windows服务器,有简单办法,可以监控吗?接入 ha展示 里面的状态

sorrypqa 发表于 2022-11-9 12:02:29

谢谢楼主的分享,要是ESXI服务器也能搞这么漂亮就太好了。

mistlotus 发表于 2022-11-10 11:35:16

你的搬瓦工还好吗,我的IP都被封好几回了,现在都不想用了

ergou 发表于 2022-11-10 14:03:51

sorrypqa 发表于 2022-11-9 12:02
谢谢楼主的分享,要是ESXI服务器也能搞这么漂亮就太好了。

esxi的界面其实也可以改的 需要会css 在服务器文件里

hass_ben 发表于 2022-11-10 20:26:09

mistlotus 发表于 2022-11-10 11:35
你的搬瓦工还好吗,我的IP都被封好几回了,现在都不想用了

一直很稳

feng22cn 发表于 2022-11-15 11:12:27

缺少ha-sensor节点,这个要安装什么node》?

guitengyue 发表于 2022-11-15 22:39:59

给力,收藏

671792320 发表于 2022-12-6 23:10:13

hass_ben 发表于 2022-11-10 20:26
一直很稳

我刚换ip还没有1周就被封了。。。。。

hass_ben 发表于 2022-12-7 08:21:58

671792320 发表于 2022-12-6 23:10
我刚换ip还没有1周就被封了。。。。。

啥协议,流量很大吗
页: [1]
查看完整版本: HASS监控搬瓦工服务器状态