前言
httpMonitor适用于监控应用服务可用性的项目,可以自定义报警方式。自定义url监控返回值。
项目介绍
目录结构说明
httpmonitor 项目代码
README.md 说明文件
support 支持包
项目地址
httpMonitor
项目部署
go环境
# 安装命令
docker search go
docker pull docker.io/golang
# 查看镜像
docker images
# 使用镜像,查看go 版本
docker run -it --rm golang bash
创建数据库
CREATE DATABASE `httpmonitor` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
create user 'hmuser'@'172.18.0.%' IDENTIFIED BY '*********';
grant all privileges on httpmonitor.* to 'hmuser'@'172.18.0.%';
flush privileges;
修改配置
vim httpmonitor/conf/app.conf
iptables
# 更新规则
vim /etc/sysconfig/iptables
-A INPUT -p tcp -s 172.18.0.2 --dport 3306 -j ACCEPT
# 重启生效
systemctl restart iptables
启动
编译
# 进入容器
docker run -it --rm -v /opt/project/httpMonitor/support/src:/go/src -v /opt/project/httpMonitor/httpmonitor:/go/src/github.com/cnlh/httpMonitor --privileged docker.io/golang /bin/bash
# 容器内执行命令
cd src/github.com/cnlh/httpMonitor/
go env -w GO111MODULE=auto
go build
调试
# 进入容器
docker run -it --rm -p 802:8080 -v /opt/project/httpMonitor/support/src:/go/src -v /opt/project/httpMonitor/httpmonitor:/go/src/github.com/cnlh/httpMonitor -v /etc/localtime:/etc/localtime --privileged=true docker.io/golang /bin/bash
# 服务启动
go run main.go
运行
#!/bin/bash
cd /go/src/github.com/cnlh/httpMonitor/ && ./httpMonitor >> logs/access.log
# 启动容器
docker run -it -d -p 802:8080 --name httpMonitor -v /opt/project/httpMonitor/support/src:/go/src -v /opt/project/httpMonitor/httpmonitor:/go/src/github.com/cnlh/httpMonitor -v /etc/localtime:/etc/localtime --privileged=true docker.io/golang /go/src/github.com/cnlh/httpMonitor/start.sh
学习到了,感谢博主