- 初始化操作
- systemctl disable --now firewalld
- setenforce 0
- vim /etc/selinux/config
- SELINUX=disabled
- cd /opt
- grafana-enterprise-9.4.7-1.x86_64.rpm #上传软件包
- yum localinstall -y grafana-enterprise-9.4.7-1.x86_64.rpm #安装
- systemctl enable --now grafana-server.service #开启服务
- netstat -lntp | grep 3000 #查询是否已经开启服务
浏览器输入http://192.168.10.50:3000
账号/密码:admin / admin
之后返回到Plugins界面,zabbix已安装
我们这里只监控cpu和 load average 两种状态
修改cpu内核数量,不可以直接修改,需要先下面这些操作
这样子即可实现对cpu数量的监控
之后操作大体都相同,先找到图标上面的关键词然后重新输入即可
最后结果如这样子
相对于zabbix来说,更容易观察到具体的状态
要实现对nginx的监控要先有这个配置--with-http stub status module
- vim /etc/nginx/conf.d/default.conf
-
- location / {
- root /var/www/zbx;
- index index.php index.html index.htm;
- }
- systemctl reload nginx.service
-
- curl -s http://192.168.10.20/nginx_state
- vim nginx_status.sh
-
- chmod +x nginx_status.sh
-
- ./nginx_status.sh waiting
检测 nginx 状态的脚本
- #!/bin/bash
- IP=192.168.10.20
- PORT=80
- STUB_URI=nginx_state
-
- active() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==1 {print $3}'
- }
-
- accepts() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==3 {print $1}'
- }
-
- handled() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==3 {print $2}'
- }
-
- requests() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==3 {print $3}'
- }
-
- Reading() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==4 {print $2}'
- }
-
- writing() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==4 {print $4}'
- }
-
- waiting() {
- curl -s http://$IP:$PORT/$STUB_URI | awk 'NR==4 {print $6}'
- }
-
- process() {
- pidof nginx | wc -w
- }
-
- case $1 in
- active)
- active
- ;;
- accepts)
- accepts
- ;;
- handled)
- handled
- ;;
- requests)
- requests
- ;;
- Reading)
- Reading
- ;;
- Writing)
- writing
- ;;
- Waiting)
- waiting
- ;;
- process)
- process
- ;;
- *)
- echo "Usage: $0 {active|accepts|handled|requests|Reading|writing|waiting|process}" exit 1
- esac
- exit 0
验证是否可以查看状态
- vim nginx_state.conf
-
- UserParameter=nginx.status[*],/etc/zabbix/zabbix_agent2.d/nginx_status.sh $1
(1)创建模板
(2)创建监控项
(3)创建触发器