Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zabbix user customized key to detect memory information and monitor the status page of nginx

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

User-defined key:

Location: implemented on the zabbix agent side

Zabbix_agent.conf

UserParamenter

Syntax format:

UserParamenter=

Example:

~] # vim / etc/zabbix/zabbix_agentd.confUserParameter=memory.free,cat / proc/meminfo | awk'/ ^ MemFree:/ {print $2}'# if there is no parameter, if you want to use $, you can use it normally. If you have a parameter, you need to add another $~] # systemctl restart zabbix-agent.service to restart the service in the command.

Server-side authentication:

~] # zabbix_get-s 192.168.22.137-p 10050-k "memory.free"

Instances where parameters can be passed:

UserParameter=memory.usage [*], cat / proc/meminfo | awk'/ ^ $1proc/meminfo / {print $2}'# the first $represents the reference parameter, and the second $2 represents the $2 in the command

Server-side authentication:

~] # zabbix_get-s 192.168.22.137-p 10050-k "memory.usage [MemFree]"

Use examples: detect memory information and monitor the status page of nginx

~] # vim / etc/zabbix/zabbix_agentd.confUserParameter=memory.usage [*], cat / proc/meminfo | awk'/ ^ $1etc/zabbix/zabbix_agentd.confUserParameter=memory.usage / {print $2}'# get memory usage information UserParameter=memory.free,cat / proc/meminfo | awk'/ ^ MemFree:/ {print $2}'# No parameter UserParameter=ngx.active [*], curl-s http://$1:$2/$3 | awk'/ ^ Active/ {print $3}'# get Nginx status information UserParameter=ngx.accepts [*] Curl-s http://$1:$2/$3 | awk'/ ^ [[: space:]] * [0-9] / {print $$1}'# accepted request UserParameter=ngx.handled [*], curl-s http://$1:$2/$3 | awk'/ ^ [[: space:]] * [0-9] / {print $2}'# processed request UserParameter=ngx.requests [*] Curl-s http://$1:$2/$3 | awk'/ ^ [[: space:]] * [0-9] / {print $$3}'# all requests UserParameter=ngx.status [*], curl-s http://$1:$2/$3 | awk'/ ^ [[: space:]] * [0-9] / {print $1.

Zabbix Monitoring nginx status Page

Note: the status monitoring of nginx is based on nginx configuration file to enable status.

Use this command to view: # curl-s http://10.10.10.10/status

How to start status with nginx:

~] # vim / etc/nginx/nginx.conf location / {} location / status {stub_status on; allow 10.10.10.0.Unip 24; deny all;}

Note: after configuring zabbix_agent.conf and nginx.conf, remember to restart zabbix_agent and nginx

Verify:

Use the zabbix_get command in zabbix server to verify:

~] # zabbix_get-s 10.10.10.10-p 10050-k ngx.status [10.10.10.10 Magne80 scene status] 179 179 3

In zabbix web configuration:

View:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report