Get the App
SLTechnology News&Howtos  ›  Database  › 

Solve the problem of "standard in must be a tty" when getting client data from zabbix_get of zabbix

Shulou Source: shulou.com Published: 2022-06-01 09:04:43 09月25日 Update

(1) as shown in the question, there is a script on my zabbix client:

[root@mpdb01 scripts] # vim / usr/local/zabbix/scripts/paycompletion12.sh

Its contents are as follows:

#! / bin/bashecho "/ home/oracle/scripts/paymentcompletion.sh" | su-oracle

The meaning of the above script is very simple, which is to execute a statistical script as the oracle user

(2) modify the zabbix_agentd configuration file to add a "UserParameter":

[root@prx01 scripts] # vim / usr/local/zabbix/etc/zabbix_agentd.conf

The following has been added:

UserParameter=paycompletion12,/usr/local/zabbix/scripts/paycompletion12.sh

(3) then, when I tested and obtained the data on zabbix_server, I exposed the error shown in the question:

Thinking about [root@nmp01] # / usr/local/zabbix/bin/zabbix_get-s 10.110.80.117-k paycompletion12standard in must be a tty

For this problem, zabbix's mistake is that "the rule must be a tty". I think the reason for the problem is this: / usr/local/zabbix/scripts/paycompletion12.sh I tested this script with root users, so naturally I don't have to enter a password when su-oracle, but zabbix uses zabbix when executing this script, so I need to enter a password when executing su-oracle according to the normal process. But it is obvious that it is impossible for zabbix_get to get the data to provide you with an interactive interface to enter your password, so you report an error.

Problem solving

Everything else remains the same, just modify the zabbix_agentd configuration file and set "AllowRoot" to 1. In this way, the zabbix_agentd has root permissions, so you can naturally execute scripts to get the data. The specific operations are as follows:

[root@prx01 scripts] # vim / usr/local/zabbix/etc/zabbix_agentd.conf

Modify the following:

AllowRoot=1

If you use zabbix_get to obtain data again, you will obviously not make an error. The effect is as follows:

Tags: Script data question content password user input file nature test configuration customer client obvious no again reason meaning effect time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei Apple Docker Redmi