『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 1985|回复: 9

[流程系列] HASS监控搬瓦工服务器状态

[复制链接]

1

主题

17

帖子

260

积分

论坛分享达人

积分
260
金钱
243
HASS币
0
发表于 2022-11-9 11:13:46 | 显示全部楼层 |阅读模式
利用搬瓦工官方API,每15秒获取一次服务器信息,展示到HASS前端,基本上就是探针的作用了。
实现效果(两种)如图:
截屏2022-11-09 10.57.14.png

截屏2022-11-09 11.02.07.png

截屏2022-11-09 11.11.03.png
第一张效果图前端卡片代码如下,其中的数值根据自己服务器实际情况更改即可,需要用到的前端集成有:https://github.com/benct/lovelac ... -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/lovelac ... -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流下载,参数设置请去搬瓦工后台获取:
BWH_FLOW.json.zip (2.85 KB, 下载次数: 26)

评分

参与人数 4金钱 +52 收起 理由
guitengyue + 12 论坛有你更精彩!
+ 20 感谢楼主分享!
sorrypqa + 8 大神666!
zxyny1989 + 12 感谢楼主分享!

查看全部评分

回复

使用道具 举报

110

主题

1600

帖子

5056

积分

元老级技术达人

积分
5056
金钱
3451
HASS币
30
发表于 2022-11-9 11:37:22 | 显示全部楼层
windows服务器,有简单办法,可以监控吗?接入 ha展示 里面的状态
回复

使用道具 举报

50

主题

1301

帖子

4927

积分

论坛DIY达人

积分
4927
金钱
3626
HASS币
20
发表于 2022-11-9 12:02:29 | 显示全部楼层
谢谢楼主的分享,要是ESXI服务器也能搞这么漂亮就太好了。
回复

使用道具 举报

2

主题

34

帖子

820

积分

高级会员

Rank: 4

积分
820
金钱
776
HASS币
60
发表于 2022-11-10 11:35:16 | 显示全部楼层
你的搬瓦工还好吗,我的IP都被封好几回了,现在都不想用了
回复

使用道具 举报

3

主题

33

帖子

256

积分

中级会员

Rank: 3Rank: 3

积分
256
金钱
223
HASS币
0
发表于 2022-11-10 14:03:51 | 显示全部楼层
sorrypqa 发表于 2022-11-9 12:02
谢谢楼主的分享,要是ESXI服务器也能搞这么漂亮就太好了。

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

使用道具 举报

1

主题

17

帖子

260

积分

论坛分享达人

积分
260
金钱
243
HASS币
0
 楼主| 发表于 2022-11-10 20:26:09 | 显示全部楼层
mistlotus 发表于 2022-11-10 11:35
你的搬瓦工还好吗,我的IP都被封好几回了,现在都不想用了

一直很稳
回复

使用道具 举报

3

主题

81

帖子

810

积分

高级会员

Rank: 4

积分
810
金钱
729
HASS币
0
发表于 2022-11-15 11:12:27 | 显示全部楼层
缺少ha-sensor节点,这个要安装什么node》?
回复

使用道具 举报

60

主题

737

帖子

4243

积分

论坛元老

Rank: 8Rank: 8

积分
4243
金钱
3501
HASS币
20
发表于 2022-11-15 22:39:59 | 显示全部楼层
给力,收藏
回复

使用道具 举报

8

主题

270

帖子

1335

积分

金牌会员

Rank: 6Rank: 6

积分
1335
金钱
1065
HASS币
0
发表于 2022-12-6 23:10:13 | 显示全部楼层

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

使用道具 举报

1

主题

17

帖子

260

积分

论坛分享达人

积分
260
金钱
243
HASS币
0
 楼主| 发表于 2022-12-7 08:21:58 | 显示全部楼层
671792320 发表于 2022-12-6 23:10
我刚换ip还没有1周就被封了。。。。。

啥协议,流量很大吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-9 09:18 , Processed in 0.631379 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表