- 创建主机并加入主机组
1.手动添加监控项
即获取数据的监控指标
增加用户,修改用户,删除用户etc/passwd文件都会发生改变,
添加监控录像
[root@client ~]# cd /tmp/
[root@client tmp]# ls
vmware-root_866-2722763301 vmware-root_932-2722632322 zabbix_agentd.pid
vmware-root_916-2689078442 vmware-root_941-4022177618
vmware-root_927-3980167416 zabbix_agentd.log
[root@client tmp]# touch abc
[root@client tmp]# ll
total 12
-rw-r--r--. 1 root root 0 Sep 6 00:08 abc
drwx------. 2 root root 6 Sep 5 23:41 vmware-root_866-2722763301
drwx------. 2 root root 6 Sep 5 23:43 vmware-root_916-2689078442
drwx------. 2 root root 6 Sep 5 23:39 vmware-root_927-3980167416
drwx------. 2 root root 6 Sep 5 23:23 vmware-root_932-2722632322
drwx------. 2 root root 6 Sep 4 20:43 vmware-root_941-4022177618
-rw-rw-r--. 1 zabbix zabbix 4686 Sep 5 23:48 zabbix_agentd.log
-rw-rw-r--. 1 zabbix zabbix 4 Sep 5 23:48 zabbix_agentd.pid
[root@client tmp]#
[root@client tmp]# echo "haha" > abc
[root@client tmp]# echo "haha" >> abc
[root@client tmp]# cat abc
haha
haha
添加触发器
[root@client tmp]# echo "haha" >> abc
[root@client tmp]# echo "haha" >> abc
[root@client tmp]# cat abc
haha
haha
haha
haha
配置媒介
配置动作
然后需要更新
手动触发警告
[root@client tmp]# echo "haha" >> abc
[root@client tmp]# cat abc
haha
haha
haha
haha
haha
[root@client tmp]#
2. 使用模板添加监控项
添加监控对象
因防火墙没关,获取不到数值,才会变红
[root@client ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset>
Active: active (running) since Mon 2022-09-05 09:27:28 CST; 13h ago
Docs: man:firewalld(1)
Main PID: 980 (firewalld)
Tasks: 2 (limit: 24717)
Memory: 38.8M
CGroup: /system.slice/firewalld.service
└─980 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid
Sep 05 09:27:28 agent1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 05 09:27:28 agent1 systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 05 09:27:28 agent1 firewalld[980]: WARNING: AllowZoneDrifting is enabled. This i>
[root@client ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@client ~]# getenforce
Enforcing
[root@client ~]# setenforce 0
[root@client ~]# vim /etc/selinux/config
SELINUX=disabled
3.0 邮件告警
- 用命令行发送邮件
[root@localhost ~]# dnf -y install mailx
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 70 *:33060 *:*
[root@localhost ~]# dnf -y install postfix
[root@localhost ~]# systemctl enable --now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 70 *:33060 *:*
[root@localhost ~]# hostnamectl set-hostname localhost.example.com
You have new mail in /var/spool/mail/root
[root@localhost ~]# bash
[root@localhost ~]# echo "hello world" | mail -s "test page" [email protected]
[root@localhost ~]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[root@localhost etc]# vim zabbix_server.conf
# AlertScriptsPath=${datadir}/zabbix/alertscripts
AlertScriptsPath=/scripts/ ---添加这一行
[root@localhost etc]# mkdir -p /scripts
[root@localhost etc]# cd /scripts/
[root@localhost scripts]# ls
[root@localhost scripts]# vim sendmail.sh
#!/bin/bash
echo "$1" | mail -s "$2" $3
[root@localhost scripts]# chmod +x sendmail.sh
[root@localhost scripts]# ll
total 4
-rwxr-xr-x 1 root root 41 Sep 6 02:39 sendmail.sh
[root@localhost scripts]# cd
[root@localhost ~]# ll /
total 24
lrwxrwxrwx. 1 root root 7 May 19 2020 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Aug 1 15:52 boot
drwxr-xr-x 20 root root 3140 Sep 5 23:23 dev
drwxr-xr-x. 85 root root 8192 Sep 6 02:30 etc
drwxr-xr-x. 2 root root 6 May 19 2020 home
lrwxrwxrwx. 1 root root 7 May 19 2020 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 May 19 2020 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 May 19 2020 media
drwxr-xr-x. 3 root root 18 Aug 1 15:50 mnt
drwxr-xr-x. 3 root root 18 Sep 3 14:38 opt
dr-xr-xr-x 281 root root 0 Sep 5 23:23 proc
dr-xr-x---. 7 root root 4096 Sep 6 02:39 root
drwxr-xr-x 24 root root 700 Sep 5 23:23 run
lrwxrwxrwx. 1 root root 8 May 19 2020 sbin -> usr/sbin
drwxr-xr-x 2 root root 25 Sep 6 02:39 scripts
drwxr-xr-x. 2 root root 6 May 19 2020 srv
dr-xr-xr-x 13 root root 0 Sep 5 23:23 sys
drwxrwxrwt. 11 root root 4096 Sep 6 02:31 tmp
drwxr-xr-x. 12 root root 144 Aug 1 15:49 usr
drwxr-xr-x. 20 root root 278 Aug 1 15:55 var
[root@localhost ~]# /scripts/sendmail.sh "maxiaorui" "qixiaoting" [email protected]
- 在web页面配置
重启
[root@localhost ~]# pkill zabbix
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 70 *:33060 *:*
[root@localhost ~]# zabbix_server
[root@localhost ~]# zabbix_agentd
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 70 *:33060 *:*
[root@localhost ~]#