Home Data Center Series Deploy Your Own Operation and Maintenance Monitoring System Through wgcloud (Part 1): Construction
本文最后更新于 290 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。

Preface

In the real-time health monitoring and alarm of my cluster sites, I have always used the combination of uptime-kuma + bark server (for specific construction and configuration, see:Docker series builds a message push server based on bark serverandDocker series builds a real-time health monitoring and alarm system for applications based on uptime and bark).

However, to be honest, I mainly use the real-time alarm function of this combination, and rarely look at the real-time monitoring page of uptime-kuma. The reasons are as follows:
1. There is really no need to keep staring at the real-time monitoring page of uptime-kuma (unless you have dedicated operation and maintenance personnel like the real client)
2. The monitoring method of uptime-kuma is external detection, which has a single angle and you can't tell anything by just staring at it. For example: How much traffic does a certain device have? Is the resource consumption of a certain docker or a certain host abnormal? Which hosts have abnormal processes? How much CPU and memory does a process on a certain host occupy? Is there an error with a specified keyword in the log of a certain host? Has a key file on a certain host been tampered with? Does the content of a certain table in a certain database reach a certain threshold, etc.
3. The monitoring display page of uptime-server itself is also relatively monotonous and of low quality:

image.png

Based on the above reasons, I have always used the combination of uptime-kuma + bark server as a real-time alarm system, and I have never thought of its real-time monitoring function.

A few days ago, I suddenly had the urge to research (free) operation and maintenance monitoring systems. I didn't expect that I would find one that suits my taste: wgcloud. Although it has some flaws (the free version has an upper limit of 10 objects for each function), it generally meets my requirements: it can do what uptime-kuma mentioned above cannot do, and the display interface is much more tasteful. The final effect is as follows:

image.png

This article (Part 1) records the deployment process of wgcloud in detail, and the specific configuration is introduced in the next part.

Deploy wgcloud

Environment Preparation

Install Java Environment

WGCLOUD server can run on JDK1.8, JDK11 or higher versions of JDK, and OpenJDK also supports
I use Debian 12, so I use the following steps:
1. Update software sources

apt update

2. Install the default OpenJDK 11

apt-get install default-jdk

3. Verify whether Java is installed successfully

java -version

image.png

For installation methods of other systems, please refer to the official instructions:https://www.wgstart.com/help/docs7.html.

Note: JDK needs to be deployed only on the server side, but not on the agent host.

Create a database (optional)

wgcloud needs to use a database. Supported databases (data sources): MySQL (both MySQL 5.X and MySQL 8.X are acceptable), MariaDB, Oracle, PostgreSQL (version 10 or above is recommended). You can choose any of the above databases. Domestic databases such as openGauss and OceanBase are also supported. You can choose according to your usage habits. I use mariadb more often in other applications, so if it is available, I will directly choose mariadb (mysql is also acceptable, but mariadb is always preferred if there is a choice).

wgcloud needs to use the corresponding library in the existing database (mariadb in my case) and perform initial configuration. If there is no database yet, you need to create a new one.


The recommended process for creating a new mariadb database is as follows:
Create a directory on the host that needs to be mounted into the mariadb container

mkdir -p /docker/mariadb/db

Create mariadb container

docker run --name=mariadb01 -d --restart=always \ -p 3306:3306 \ #Map the host's port 3306 to the container's port 3306 -v /docker/mariadb/db:/var/lib/mysql \ #Mount the previously created host directory to the specified directory inside the container -e MARIADB_ROOT_PASSWORD=123 \ #Specify the password corresponding to the database root user, which you can modify by yourself mariadb:10.11

Create a new wgcloud library in mariadb

Please refer to my other article for details:Tips and tricks: Create a new empty database and grant permissions to corresponding usersIn the following text, it is assumed that the initialization database name, corresponding user name and password are all "wgcloud".

Deploy wgcloud server and agent

Download the server and unzip it

The download link of wgcloud on GitHub is as follows:https://github.com/tianshiyeben/wgcloud/releasesWhen I installed it, the latest release was wgcloud-v3.5.1.tar.gz (remember it was the server version). In addition, the v3.x version is a free, non-open source commercial version, and the free, open source version I have at this time is v2.3.7.

After the download is complete, unzip the server to a specific directory. I will put it directly in the /root directory and then unzip it:

cd ~ tar -zxvf wgcloud-v3.5.1.tar.gz

The file structure of the unzipped directory wgcloud-v3.5.1.tar.gz is as follows:

image.png


There are the following points to note:
1. The server directory comes with an agent client. If it is a single-agent host, it is recommended to put it in the same path for easy upgrade.
2. After decompressing the server and agent deployment, you can start running by making some necessary modifications to the configuration files without compiling.
3. Only one server needs to be deployed, and all agents report indicator data to this server unilaterally.
4. Deploy as many agents as the number of hosts that need to be monitored (even if the server host needs to be monitored, the agent must be started)
5. Server and agent need to maintain the same version
6. The monitoring host information is automatically collected and reported by the agent, so the host cannot be added on the server host list page. After the agent is deployed and started, you can see the monitoring host on the [Host Management] page
7. wgcloud-daemon-release is a daemon process. Executing server/start.sh will start wgcloud-server-release.jar and wgcloud-daemon-release at the same time. Do not shut down the daemon process. The server needs to communicate with the daemon process.
8. The system time of the host where the server and agent are located must be consistent. Even if there is a difference, the time difference should not exceed 15 hours (the agent will print the anti-tampering verification failure information during this time difference, please ignore it, it will not affect the monitoring collection)
9. Be careful not to edit/modify server/wgcloud-server-release.jar, otherwise the agent log will show information that the anti-tampering verification failed, and the data will no longer be reported after a certain period.
10. If the agent cannot directly access the server, you can use the proxy wgcloud-proxy to transfer the data to the server
11. If you are deploying and running the server on Windows, try not to have spaces in the directory path where the server is located (such as C:\Program Files (x86)\wgcloud). Sometimes, lower versions of Windows may fail to start due to spaces in the path.
12. Server and agent can be used interchangeably as long as they are of the same version. That is, if the server runs on Linux, the agent can run on Linux or Windows, and vice versa.


Initialize the wgcloud library

/root/wgcloud-v3.5.1There are 3 sql files in the directory:

image.png

Because I use mariadb, the initialization file selection is:wgcloud-MySQL.sql

There are many ways to apply the wgcloud-MySQL.sql file. Take phpmyadmin as an example:

image.png

Initialization completed:
image.png

Of course, you can also import it in command line format, as follows:

mysql -u root -p -h 127.0.0.1 # The database IP address can be modified according to the actual situation. If it is not the default 3306, use the -P parameter followed by the port. use wgcloud; source /root/wgcloud-v3.5.1/wgcloud-MySQL.sql

Configure the application.yml file

The database of wgcloud server points to/root/wgcloud-v3.5.1/server/config/application.ymlThe following contents of the file determine:

image.png

My actual configuration is as follows:
image.png

Other important parameters in the "application.yml" file are as follows, including the administrator's username and password, web ssh, cluster functions, etc. You can modify them according to your needs. Generally, except for the administrator's username and password, other parameters can be kept by default:

#Core configuration parametersbase: #Administrator login accountaccount: admin #Administrator login account passwordaccountPwd: 111111 #Whether to enable password-free login, yes to enable, no to disable. This feature requires upgrading to the professional versionopenSSO: no #Communication key between server and agent. The wgToken values in the server and agent configuration files must be consistentwgToken: wgcloud #How many data items are displayed per page? It is recommended that no less than 10pageSize: 20 #Whether to enable the web ssh client, yes to enable, no to disablewebSsh: yes #The service port of the web ssh client. If you want to use web ssh, port 9998 of the server host must be allowed in the firewall. If you don't use web ssh, you don't need to enable webSshPort: 9998 # daemon access url, used by server service, not used by agent. If the daemon port is modified, the port here should also be modified synchronously (usually keep the default) daemonUrl: http://localhost:9997 #Whether to enable the public dashboard, yes to enable, no to disable. After enabling, the dashboard page does not require login dashView: yes #Whether to enable the data open interface, yes to enable, no to disable openDataAPI: yes #Whether to enable anonymized display of the host IP of the public dashboard page, yes to enable, no to disable dashViewIpHide: yes #Whether to enable the large-screen display dashboard, yes to enable, no to disable. After enabling, the dashboard page does not require login dapingView: yes #Whether to automatically close the left menu, yes, no sidebarCollapse: yes #Whether to display the number of alarms on the list page, yes, no, it is generally not recommended to enable (at least not recommended to enable for a long time) because it may affect performance showWarnCount: no #Whether to enable command delivery (if disabled, no new commands can be added or delivered), yes, noshellToRun: yes #Sensitive characters that cannot be included in command delivery, lowercase letters are sufficient, and multiple statements are separated by commasshellToRunBlock: 'rm ,mkfs, /dev/,:(){:|:&};:,mv ,wget , install ,del ,delete ,format ,ren ,rd ,rd/s/q ,rmdir ' #Sensitive characters that cannot appear in sql statements for data monitoring (i.e. keywords that may be injected into sql) are sufficient, lowercase letters are sufficient, and multiple statements are separated by commassqlInKeys: 'execute ,update ,delete ,insert ,create ,drop ,alter ,rename ,modify ' # data table monitoring interval, in seconds, default 60 minutesdbTableTimes: 3600 # service interface monitoring interval, in seconds, default 10 minutesheathTimes: 600 #ftp/sftp service monitoring interval, in seconds, default 10 minutesftpTimes: 600 # data communication equipment PING monitoring interval, in seconds, default 15 minutesdceTimes: 900 # data communication equipment snmp monitoring interval, in seconds, default 20 minutessnmpTimes: 1200 # alarm cache time (i.e. silent time) interval (the same alarm notification will no longer be sent repeatedly during this time period), in seconds, default 120 minutes. During this period, only the alarm will not be pushed to the third party (email, DingTalk, WeChat, etc.), and the system monitoring and scanning work will continue normallywarnCacheTimes: 7200 #The number of days for monitoring data retention, the default is 30 dayshistoryDataOut: 30 #The maximum amount of data displayed in each chart for each query. If the amount of data exceeds this value, the system will automatically balance the data, and the final amount of data retained will be equal to this value, mainly to prevent the chart from displaying too much data at a time and causing the browser to freeze. Configuring 0 means not to compress and balance the datachartDataMaxShowValue: 4000 #Node type, master or slave, a cluster can only have one master and N (up to 31) slaves, such as slave1, slave2nodeType: master #Whether to enable the use of tags, yes to enable, no to disablehostGroup: no

Start the server

cd /root/wgcloud-v3.5.1/server ls -l

image.png
If you do not have execution permission, add it using the following command:

chmod +x start.sh chmod +x stop.sh

Start the wgcloud server:

sh start.sh # restart also uses this command. If you need to stop the process, use sh stop.sh

The results are as follows:

image.png

Note 1: When you start the server, the daemon process wgcloud-daemon-relese will also be started. Do not shut down the daemon process.
Note 2: If the host where wgcloud server is deployed has a firewall or security group, you need to open ports 9999 and 9998 (9998 is the web ssh port, which can be left open if not needed).

Start the agent

The agent also has a corresponding configuration file, the path is:

/root/wgcloud-v3.5.1/agent/config/application.properties

The only thing that needs to be modified in the agent configuration file is serverUrl, which needs to be changed to the address of the server. The only exception is the agent on the server itself, which does not need to be modified:

image.png

Note 1:wgTokenThe key for communication between agent and server, equivalent to the password, can be customized as your own configuration password (needs to be the same as the password in server/config/application.ymlwgTokenThe default value is consistent with the current value).
Note 2: The agent actively reports collected data to the server in a unidirectional manner. The agent host does not need to open any ports because the server will not access the agent.

Starting the agent is the same as starting the server in the previous section, except that the directory is different:

cd /root/wgcloud-v3.5.1/agent ls -l

image.png

Start the wgcloud agent:

sh start.sh # restart also uses this command. If you need to stop the process, use sh stop.sh

The results are as follows:

image.png

Please download other versions of the agent yourself, from the same release link downloaded on the server.

If you need to set the agent to start at boot, you can refer to my other article on Linux:3 common ways to set up commands or scripts for Debian series to start at boot, macos can add the script to the login item, and the win version of the agent can register the agent as a service by running the batch file regAgentService.bat, and then directly set the service to start at boot. I won’t say more here, it’s all very simple.

For the next part (function part), see:Home data center series deploys its own operation and maintenance monitoring system through wgcloud (Part 2): Functional part.

The content of the blog is original. Please indicate the source when reprinting! For more blog articles, you can go toSitemapUnderstand. The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠(ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ°Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Emoticons
Emoji
Little Dinosaur
flower!
Previous
Next
       
error:
en_US
Spring Festival
hapiness