Hearthbeat,心跳,顧名思義,Hearthbeat可以用來定時探測服務是否正常運行。
Hearthbeat支持ICMP、TCP 和 HTTP,也支持TLS、身份驗證和代理。
Hearthbeat能夠與Logstash、Elasticsearch和Kibana無縫協作。安裝Hearthbeat,添加需要監控的服務,配置好Elasticsearch和Kibana,即可將結果輸出到Elasticsearch,並在Kibana顯示出來。
Kibana無須再配置Dashboard,直接點擊Uptime
菜單即可看到結果。
Elasticsearch和Kibana的安裝可參考:快速搭建ELK(7.2.0)
下載
curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-7.2.0-linux-x86_64.tar.gz
tar xzvf heartbeat-7.2.0-linux-x86_64.tar.gz -C /opt/elk/
配置
cd /opt/elk/heartbeat-7.2.0-linux-x86_64/
vi heartbeat.yml
比如通過簡單地探測console url來監控Websphere是否正常運行。
監控TCP可參考註釋裏的例子。Schedule表示每10秒監測一次。
# Configure monitors inline
heartbeat.monitors:
- type: http
# List or urls to query
urls: ["https://dummy.hostname.net:9043/ibm/console/logon.jsp"]
# Configure task schedule
schedule: '@every 10s'
#- type: tcp
#hosts: ["192.168.1.101:1414"]
#schedule: '@every 10s'
setup.kibana:
# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
host: "localhost:5601"
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["localhost:9200"]
啓動
chown elk:elk -R /opt/elk/heartbeat-7.2.0-linux-x86_64/
sudo chmod o+rx -R /opt/elk/heartbeat-7.2.0-linux-x86_64/
sudo -u elk ./heartbeat setup
sudo -u elk nohup ./heartbeat -e &
驗證
- Open http://localhost:5601/
- Go to Uptime.
- 重啓被監控服務