The process of adding a monitoring host to zabbix
Customized monitoring item implementation process
- The controlled end adds monitoring items /etc/zabbix_agent2.d/xxx.conf UserParameter=key , command; restart
- Server-side test zabbix_get -s host -k key
- web creation template
- web Add monitoring items to the template
- The web template is associated with the host
- Observe data and graphs
Create the name of the monitoring item.
Get the command of the monitoring item
. Web interface. Create a template.
Web interface. Create a customized monitoring item. Add it to the template.
Web interface. Associate the template to the monitored host.
Monitoring items added later will be added to the template.
Zabbix is an open source network monitoring solution that allows you to monitor various network devices and applications. Zabbix provides the function of custom monitoring items, which you can use to monitor specific indicators or data you are interested in.
To create a custom monitoring item, follow the steps below:
- Log in to Zabbix's web interface.
- Go to the "Configuration" menu and select "Hosts".
- Select the host to which you want to add custom monitoring items.
- On the host page, choose the Items tab.
- Click the "Create Monitoring Item" button.
- On the monitoring item configuration page, fill in the monitoring item's name, key value, and other relevant information.
- According to your needs, select the appropriate monitoring item type, such as numeric type, character type, etc.
- Configure options such as triggers, graphs, and alerts to take action when certain conditions are met.
- Click the "Add" button to save the monitoring item configuration.
After completing the above steps, your custom monitoring items will start to be monitored in Zabbix and provide corresponding data and alarm functions. Note that creating custom items requires some technical knowledge and understanding of basic Zabbix concepts. If you need more detailed guidance, please refer to Zabbix's official documentation or seek professional support.
Create monitoring items on the monitored host
root@ubuntu20:/etc/zabbix/zabbix_agent2.d# vim user_login_count.conf
UserParameter=user.login.count,uptime |awk -F " " ‘{print $4}’
Test monitoring items, there are 4 users connected to
root@ubuntu20:/etc/zabbix/zabbix_agent2.d# zabbix_agent2 -t user.login.count
user.login.count [s|4]
Restart the service
systemctl restart zabbix-agent2.service
Monitoring terminal test
root@ubuntu20:~# zabbix_get -s 192.168.1.151 -k user.login.count
4
Add template
Create new monitoring item
Fill in the key value and test
Host Parallel Template》View data
View graphics
Value mapping of monitoring items
In order to display the received value in a more "humanized" way, you can bind the relationship between the value and the string through value mapping. Example: http
response
code
'200' → 'OK'
'403' → 'Forbidden'
'404' → 'Not Found''
Update the monitoring item in the template, and add the value mapping created above to view the value
In Zabbix 6.0, value mapping is integrated in templates and triggers. You can find the value mapping by following these steps:
- Enter the Zabbix web interface.
- Navigate to Templates or Triggers under the Configuration tab.
- In the list of templates or triggers, select the template or trigger that interests you.
- Go to the detail page of a template or trigger.
- In the details page you can find the Value Mapping tab or section.
- Click Value Maps and you will see a list of value maps associated with that template or trigger.
Note that the specific interface layout may vary between Zabbix versions. If the value mapping cannot be found, please refer to Zabbix's documentation or seek further support.
Implement parameters for custom monitoring items
root@ubuntu20:/etc/zabbix/zabbix_agent2.d# cat tcp.state.conf
UserParameter=tcp.state.[*],netstat -ant| grep -c $1
root@ubuntu20:/etc/zabbix/zabbix_agent2.d# zabbix_agent2 -t tcp.state.[LISTEN]
tcp.state.[LISTEN] [s|24]
root@ubuntu20:/etc/zabbix/zabbix_agent2.d# zabbix_agent2 -t tcp.state.[TIME_WAIT]
tcp.state.[TIME_WAIT] [s|94]
服务端测试
root@ubuntu20:~# zabbix_get -s 192.168.1.151 -k tcp.state.[LISTEN]
24
Add monitoring items
View data
Add other monitoring items
Value of type “string” is not suitable for value type “Numeric (unsigned)” appears in zabbix6.0
. Value “min,” the
information type in the template is changed to text
Add memory monitoring items
root@server01:/etc/zabbix/zabbix_agent2.d# cat mem.conf
UserParameter=mem_use_percent,free | awk 'NR==2{print $3/$2*100}'
UserParameter=mem_unuse_percent,free | awk 'NR==2{print 100-($3/$2*100)}'
服务端测试
root@server02:~# zabbix_get -s 172.29.21.67 -k mem_use_percent
35.3378
Add monitoring items to the web page, and after the test passes
trigger
Template-》Trigger》Create trigger
Add an expression, and an alarm will be triggered when the user logs in to 5.
View the effect
Add graphics to templates
Template - "Graphics" to create graphics
Check
Create an aggregate graph
Method 1: Add it in the template, and then check after adding it - check in the host,
Method 2: Monitor - Add aggregation graph, add
Click Select, select the host group owner, select 151 and 220 machines respectively
Select, select the tcp connection status and memory usage respectively
Adjust the width and height to see the effect
Use multiple aggregated graphics to realize slideshow function (carousel graphics)
3.6.5.1 Create Slide
It can be observed that each aggregated graph will be rotated every 3s
zabbix user management
Configured as administrator privileges
Administrator, manage specific groups
Create a group owner
Configure mailbox
Generate authorization code
Configure media, you can create a new one
Configure the recipient
Find a user admin and add a mailbox
Configure actions.
Add an action,
add conditions
, configure the alarm operation, send it to the group, and restore it to the admin user
Custom message content
故障:{
TRIGGER.STATUS} 服务器:{
HOSTNAME1} 事件:{
TRIGGER.NAME}故障!
告警主机:{
HOSTNAME1}
告警时间:{
EVENT.DATE} {
EVENT.TIME}
告警等级:{
TRIGGER.SEVERITY}
告警信息:{
TRIGGER.NAME}
告警项目:{
TRIGGER.KEY1}
问题详情:{
ITEM.NAME}:{
ITEM.VALUE}
当前状态:{
TRIGGER.STATUS}:{
ITEM.VALUE1}
事件ID:{
EVENT.ID}
Step duration: How long the alarm will be sent
Step:
When the step is set to 0, it means that the alarm will be sent continuously. It is generally recommended that 1 to 3 means that it will be executed three times.
The step duration indicates the interval between execution of subsequent steps if there are any. The default value is 0, which means that the subsequent
steps minimum value cannot be less than 60s and the maximum cannot exceed 604800s. It can be set from 1 to 5m ( minutes) is more appropriate
Add which users the recovery operation is sent to, and configure custom message content
Stop the nginx service and test
Hierarchical alarm
1-2 Send emails to admin for the 1st-2nd time, every 1 minute
3-4 Send emails to admin2 for the 3rd-4th time
Script to send email
1. Deployment script
root@ubuntu20:/usr/lib/zabbix/alertscripts# ls
send_email
2. Create a medium
3. User adds media
4. Create an action
Clone the previous action and modify it as a script to send mail
5. Test