增加运维监控项目的Docker配置和启动脚本

This commit is contained in:
柏码の讲师 2024-12-19 02:00:14 +08:00
commit e2d41c3c22
4 changed files with 267 additions and 0 deletions

82
itbaima-monitor/client.sh Normal file
View File

@ -0,0 +1,82 @@
#!/bin/bash
#这里可替换为你自己的执行程序,其他代码无需更改
APP_NAME=itbaima-monitor-client.jar
#项目路径
PROJECT_PATH=.
#使用说明,用来提示输入参数
usage() {
echo "使用方法: 脚本名.sh [start|stop|restart|status]"
echo "使用方法: ./脚本名.sh start 是启动"
echo "使用方法: ./脚本名.sh stop 是停止"
echo "使用方法: ./脚本名.sh status 是查看输出运行状态"
echo "使用方法: ./脚本名.sh restart 是重启"
exit 1
}
#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' `
#如果不存在返回1存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start(){
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is already running. pid=${pid} ."
else
nohup java -jar $PROJECT_PATH/$APP_NAME > /dev/null 2>&1 &
echo "${APP_NAME} start success"
fi
}
#停止方法
stop(){
is_exist
if [ $? -eq "0" ]; then
kill -9 $pid
else
echo "${APP_NAME} is not running"
fi
}
#输出运行状态
status(){
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is running. Pid is ${pid}"
else
echo "${APP_NAME} is NOT running."
fi
}
#重启
restart(){
stop
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac

View File

@ -0,0 +1,79 @@
networks:
work:
driver: bridge
services:
mysql:
image: mysql:8.0.40
container_name: mysql
environment:
MYSQL_DATABASE: monitor
MYSQL_ROOT_PASSWORD: 123456
TZ: Asia/Shanghai
volumes:
- ./mysql:/var/lib/mysql
- ./monitor.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "3306:3306"
networks:
- work
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
environment:
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: admin
volumes:
- ./rabbitmq:/var/lib/rabbitmq
ports:
- "5672:5672"
- "15672:15672"
networks:
- work
influxdb:
image: influxdb:2
ports:
- "8086:8086"
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=admin
- DOCKER_INFLUXDB_INIT_PASSWORD=12345678
- DOCKER_INFLUXDB_INIT_ORG=itbaima
- DOCKER_INFLUXDB_INIT_BUCKET=monitor
volumes:
- ./influxdb/data:/var/lib/influxdb2
- ./influxdb/config:/etc/influxdb2
container_name: influxdb
networks:
- work
redis:
image: redis
container_name: redis
ports:
- "6379:6379"
volumes:
- ./redis:/data
networks:
- work
itbaima-monitor-server:
image: itbaimastydu/itbaima-monitor-server:1.0.0
container_name: monitor-server
environment:
- MYSQL_URL=jdbc:mysql://mysql:3306/monitor
- RABBITMQ_ADDRESS=rabbitmq
- INFLUX_DB_URL=http://influxdb:8086
- REDIS_HOST=redis
volumes:
- ./logs:/work/logs
ports:
- "8080:80"
networks:
- work
itbaima-monitor-web:
image: itbaimastydu/itbaima-monitor-web:1.0.0
container_name: monitor-web
environment:
- API_BASE_URL=http://10.211.55.4:8080
ports:
- "80:80"
networks:
- work

Binary file not shown.

106
itbaima-monitor/monitor.sql Normal file
View File

@ -0,0 +1,106 @@
/*
Navicat Premium Dump SQL
Source Server : 10.211.55.4_3306
Source Server Type : MySQL
Source Server Version : 80040 (8.0.40)
Source Host : 10.211.55.4:3306
Source Schema : monitor
Target Server Type : MySQL
Target Server Version : 80040 (8.0.40)
File Encoding : 65001
Date: 18/12/2024 23:48:12
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for db_account
-- ----------------------------
DROP TABLE IF EXISTS `db_account`;
CREATE TABLE `db_account` (
`id` int NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`role` varchar(255) DEFAULT NULL,
`clients` json DEFAULT NULL,
`register_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_email` (`email`),
UNIQUE KEY `unique_username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ----------------------------
-- Records of db_account
-- ----------------------------
BEGIN;
INSERT INTO `db_account` (`id`, `username`, `email`, `password`, `role`, `clients`, `register_time`) VALUES (1, 'admin', 'monitor-test@qq.com', '$2a$10$EEGWiiUpyhamMpQdQNS8xuwfjznm65aN51F1zDt1RJlJWOrtF6Vlm', 'admin', NULL, '2024-12-06 18:09:55');
COMMIT;
-- ----------------------------
-- Table structure for db_client
-- ----------------------------
DROP TABLE IF EXISTS `db_client`;
CREATE TABLE `db_client` (
`id` int NOT NULL,
`name` varchar(255) DEFAULT NULL,
`token` varchar(255) DEFAULT NULL,
`location` varchar(255) DEFAULT NULL,
`node` varchar(255) DEFAULT NULL,
`register_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ----------------------------
-- Records of db_client
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for db_client_detail
-- ----------------------------
DROP TABLE IF EXISTS `db_client_detail`;
CREATE TABLE `db_client_detail` (
`id` int NOT NULL,
`os_arch` varchar(255) DEFAULT NULL,
`os_name` varchar(255) DEFAULT NULL,
`os_version` varchar(255) DEFAULT NULL,
`os_bit` int DEFAULT NULL,
`cpu_name` varchar(255) DEFAULT NULL,
`cpu_core` int DEFAULT NULL,
`memory` double DEFAULT NULL,
`disk` double DEFAULT NULL,
`ip` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ----------------------------
-- Records of db_client_detail
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for db_client_ssh
-- ----------------------------
DROP TABLE IF EXISTS `db_client_ssh`;
CREATE TABLE `db_client_ssh` (
`id` int NOT NULL,
`port` int DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ----------------------------
-- Records of db_client_ssh
-- ----------------------------
BEGIN;
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;