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

Use zabbix_sender

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

zabbix_sender is a command used to send data to zabbix_server. zabbix_server's capture tool creates items based on the captured information, and the incoming data is only used by the specified host item.

zabbix_sender is used when you need to run some statistics scripts or get data from another machine but want to unify monitoring into one machine.

2. Usage:

[root@salt-master ~]# /usr/local/zabbix/bin/zabbix_sender -husage: zabbix_sender [-v] -z server [-p port] [-I IP-address] -s host -k key -o value zabbix_sender [-v] -z server [-p port] [-I IP-address] [-s host] [-T] [-r] -i input-file zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address] [-s host] -k key -o value zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address] [-s host] [-T] [-r] -i input-file

-c --config Specifies the configuration file

-z --zabbix_server zabbix_server hostname or ip address

-p --port Specifies the port of the trapper of zabbix_server, default is 10051

-s --hostSpecify the hostname, hostname defined in zabbix_agent configuration file

-I --source-address Specifies the source address

-k --key specifies item key

-o --value The value of item key, which can be a specific value or the result of executing a script.

-i --input-file Loads value from the specified file. Get standard input by line, spaces are separators

Format:

-T --with-timestamps If you want to specify the time of the key in the file, you can use this option, where the time is the unix timestamp. Format:

-r --real-time The key sent is based on the real time, without specifying a value.

3. An example

According to the demand, it is necessary to count the "total number of people","daily active users","maximum simultaneous online number" and "number of new players" of a certain project once a day.

(1)Getting values through scripts, which is getting data by querying the database, may not make sense, just an example:

[root@salt-master ~]# cat /etc/zabbix/scripts/test_count.sh#!/ bin/bash# Shell EnvUSER="test"PASSWD="test"HOST="localhost"DAY=$(date -d"yesterday" +"%F")# Shell Usageshell_usage(){ echo "Usage $0: [ total_players | daily_active | new_player | max_online ]"}Total_players(){ mysql -u $USER -h $HOST -p$PASSWD -e "select count(*) from test.player" | grep [0-9]}Daily_active_players(){ mysql -u $USER -h $HOST -p$PASSWD -e "select count(*) from test.player where LastLoginTime >= unix_timestamp('$DAY 00:00:00') and LastLoginTime = unix_timestamp('$DAY 00:00:00') and RegisterTime = unix_timestamp('$DAY 00:00:00') and datetime

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