Monitoring Linux Using Open Source Real-Time Monitoring Tool HertzBeat
Tags: github, monitoring, java, docker
Published: 2023-03-22 15:15:26

## Use the open source real-time monitoring tool HertzBeat to monitoring and alarm Linux, and it will be done in 5 minutes!

### Introduction to HertzBeat

> HertzBeat is an open source, easy-to-use and friendly real-time monitoring tool that does not require Agent and has powerful custom monitoring capabilities.

- Integrate **monitoring-alarm-notification**, support monitoring of application services, databases, operating systems, middleware, cloud native, etc., threshold alarms, alarm notifications (email WeChat Dingding Feishu SMS Slack Discord Telegram).
- It configurable protocol specifications such as Http, Jmx, Ssh, Snmp, Jdbc, etc. You only need to configure YML to use these protocols to customize and collect any indicators you want to collect. Do you believe that you can immediately adapt to a new monitoring type such as K8s or Docker just by configuring YML?
- HertzBeat's powerful customization, multi-type support, easy expansion, and low coupling, hope to help developers and small and medium teams quickly build their own monitoring tools.

Github: https://github.com/dromara/hertzbeat

### Get Linux Monitoring Done in HertzBeat in 5 Minutes

#### Prerequisites, you already have a Linux environment and a HertzBeat environment.

- HertzBeat [Installation and deployment documentation](https://hertzbeat.com/docs/start/docker-deploy)

#### Add monitoring of the Linux operating system to the monitoring page of the open source monitoring tool HertzBeat

1. Click Add Linux Monitoring

Path: Menu -> Operating System Monitoring -> Linux Operating System -> Add Linux Operating System Monitoring

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i62ixya4t5p5a376t47w.png)

2. Configure the parameters required for new monitoring Linux

Fill in the Linux **peer IP**, **SSH port** (default 22), **account password, etc.** on the monitoring page, and finally click OK to add.
For other parameters such as **collection interval**, **timeout period**, etc., please refer to the help document https://hertzbeat.com/docs/help/mysql/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/386lr174ldqy1m27ejct.png)

3. Complete ✅, now we have added the monitoring of Linux, check the monitoring list to see our added items.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qpuwfsgght3noe0sghwn.png)


4. Click **Operation**->**Monitoring Details Icon** of the monitoring list item to browse the real-time monitoring indicator data of Linux.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5a4pr1122ciufwf1opd3.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apyoz7gqe9lq2ufjtbax.png)

5. Click **Monitoring History Details TAB** to browse the historical monitoring indicator data chart of Linux📈.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yd8a59u9iacarrdvpw1.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cq62zvpr2uh4nu130t7.png)


**DONE! Done! To sum up, it only takes one step**

- **On the HertzBeat monitoring page, configure the IP port account password and add Linux monitoring**


> Through the above two steps, we have completed the monitoring of Linux. We can view the monitoring details and indicators in HertzBeat at any time to observe its service status. 
> Of course, just looking at it is definitely not perfect. Monitoring is often accompanied by alarm thresholds. When Linux performance indicators exceed our expectations or are abnormal, we can promptly notify our corresponding person in charge. The person in charge receives the notification and handles the problem. It is a complete monitoring and alarm process. 

**Next, we will demonstrate step by step how to configure threshold alarm notifications in the HertzBeat system, so that when Linux indicators are found to be abnormal, they will be notified to us in time**

#### 3. Add Linux indicator threshold alarm in HertzBeat system

1. Configure an alarm threshold for an important indicator

Path: Menu -> Threshold Rules -> Add Threshold

- Select the configured indicator object. Linux monitors mainly related indicators such as cpu, memory, disk, network performance, etc. For example, we set the threshold for the indicator `CPU utilization` `cpu` -> `usage`. When the Linux cpu utilization is greater than 90% When a warning is issued.
- Here we configure to send an alarm when the `usage>90` of this indicator `cpu`, the alarm level is **Warning Alarm**, which will be triggered after three times, as shown in the figure below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bu08fsxlfhy1i9xzfea7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1nn90pgqydpg2tz65yiw.png)


2. Add message notification recipients

> Configure the receiver to let the alarm message know who to send and how to send it.

Path: Menu -> Alarm Notification -> Alarm Recipient -> Add New Recipient

Message notification methods support **email, DingTalk, WeChat Work, Feishu, WebHook, SMS**, etc. Here we take the commonly used DingTalk as an example.

- Refer to this [Help Documentation](https://hertzbeat.com/docs/help/alert_dingtalk) https://hertzbeat.com/docs/help/alert_dingtalk to configure the robot on DingTalk and set the security custom keyword `HertzBeat `, get the corresponding `access_token` value.
- Configure the receiver parameters in HertzBeat as follows.

【Alarm Notification】->【New Recipient】->【Select DingTalk Robot Notification Method】->【Set DingTalk Robot ACCESS_TOKEN】->【OK】


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11dxgpdxj3eb1tb3nbar.png)


3. Configure the associated alarm notification strategy ⚠️ [Add notification strategy] -> [Associate the recipient just set] -> [OK]

> Configure the alarm notification policy to bind the alarm message with the receiver, so that you can decide which alarms to send to whom.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aholtt3po7of9z8cdrl2.png)


### Finished, now wait for the warning message to come. ding ding ding ding

```
[HertzBeat warning notification]
Alarm target object: linux.cpu.usage
Affiliated monitoring ID: 483783444839382
Belonging monitoring name: Linux_182.33.34.2
Alarm level: warning alarm
Alarm trigger time: 2023-02-15 21:13:44
Content details: The linux cpu usage is too high. now is 95.
```

## Summary


> This practical article took us to experience how to use the open source real-time monitoring tool HertzBeat to monitor Linux indicator data. We can find that HertzBeat, which integrates `monitoring-alarm-notification`, is more convenient in operation and use. Linux can be included in the monitoring and alarm notification, and there is no need to deploy multiple components and write configuration files.

> Only one docker command is needed to install and experience heartbeat:

`docker run -d -p 1157:1157 --name hertzbeat tancloud/hertzbeat`

## More powerful

> Through the simple steps above, we have realized the monitoring of linux, but the built-in indicators in it do not meet the needs. Can we customize and monitor more indicators of Linux? The answer is of course yes, through **Monitoring Definition**->**Linux** on the page, you can customize and modify the performance indicators you want to monitor by editing the following YML configuration file at any time.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlwphk48uoh8ypq6mcuy.png)


## What is Hertz Beat?

> [HertzBeat Hertz Beat](https://github.com/dromara/hertzbeat) is a real-time monitoring and alarm system with powerful custom monitoring capabilities and no Agent required. Monitoring of application services, databases, operating systems, middleware, cloud native, etc., threshold alarms, and alarm notifications (email, WeChat, Dingding, Feishu, SMS, Discord, Slack, Telegram).

> We make protocol specifications such as `Http, Jmx, Ssh, Snmp, Jdbc` configurable, and you only need to configure YML to use these protocols to customize and collect any indicators you want to collect.
> Do you believe that you can immediately adapt to a new monitoring type such as K8s or Docker just by configuring YML?

> The powerful customization of `HertzBeat`, multi-type support, easy expansion, and low coupling, hope to help developers and small and medium-sized teams quickly build their own monitoring tools.

**Github: https://github.com/dromara/hertzbeat**
**Gitee: https://gitee.com/dromara/hertzbeat**

## ⛄ Supported

- Website Monitoring, Port Availability, Http Api, Ping Connectivity, Jvm, SiteMap, Ssl Certificate, SpringBoot, FTP Server
- Mysql, PostgreSQL, MariaDB, Redis, ElasticSearch, SqlServer, Oracle, MongoDB, Dameng, OpenGauss, ClickHouse, IoTDB
- Linux, Ubuntu, CentOS, Windows
- Tomcat, Nacos, Zookeeper, RabbitMQ, Flink, Kafka, ShenYu, DynamicTp, Jetty, ActiveMQ
  -Kubernetes, Docker
- and more for your custom monitoring.
- Notification support `Discord` `Slack` `Telegram` `Mail` `DingTalk` `WeChat` `Feishu` `SMS` `Webhook`.