zabbix添加自動發現端口,提示Value should be a JSON object.

現象:zabbix添加自動發現端口,提示Value should be a JSON object.python

用zabbix_get提示: (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)服務器

# zabbix_get -s 127.0.0.1 -k tcp_port_listen
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
{
    "data": [
        {
            "{#TCP_PORT}": "3306"
        }, 
        {
            "{#TCP_PORT}": "80"
        }, 
        {
            "{#TCP_PORT}": "10051"
        }, 
        {
            "{#TCP_PORT}": "22"
        }, 
        {
            "{#TCP_PORT}": "10050"
        }
    ]
}

緣由爲python腳本中使用了netstat -p參數,權限問題,zabbix_agentd是zabbix用戶啓動的,默認不能執行netstat -p等命令,致使從服務器取到的自動發現腳本爲空。tcp

解決辦法: chmod +s /bin/netstatide

爲了方便普通用戶執行一些特權命令,SUID/SGID程序容許普通用戶以root身份暫時執行該程序,並在執行結束後再恢復身份。chmod +s 就是給某個程序或者教本以suid權限。ui

相關文章
相關標籤/搜索