Ad Widget

Collapse

Timeout while executing a shell script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • toms359
    Junior Member
    • Nov 2019
    • 3

    #1

    Timeout while executing a shell script

    Hello! I have a zabbix server v3.4.15.

    I have a problem with this template: https://share.zabbix.com/operating-s...sing-systemctl

    Its is not showing values in our zabbix server:

    Click image for larger version

Name:	zabbix problem.PNG
Views:	6732
Size:	51.2 KB
ID:	389386

    Code:
    839278:20191105:162252.933 Starting Zabbix Agent [X.X.X.X]. Zabbix 3.4.15 (revision 86739).
    839278:20191105:162252.934 **** Enabled features ****
    839278:20191105:162252.934 IPv6 support:          YES
    839278:20191105:162252.934 TLS support:           YES
    839278:20191105:162252.934 **************************
    839278:20191105:162252.934 using configuration file: /etc/zabbix/zabbix_agentd.conf
    839278:20191105:162252.934 agent #0 started [main process]
    839279:20191105:162252.935 agent #1 started [collector]
    839280:20191105:162252.935 agent #2 started[listener #1]
    839281:20191105:162252.935 agent #3 started[listener #2]
    839282:20191105:162252.936 agent #4 started[listener #3]
    839283:20191105:162252.936 agent #5 started [active checks #1]
    839283:20191105:162322.941 active check "systemctl.status[chronyd]" is not supported: Timeout while executing a shell script.
    839283:20191105:162352.941 active check "systemctl.status[crond]" is not supported: Timeout while executing a shell script.
    839283:20191105:162422.943 active check "systemctl.status[ip6tables]" is not supported: Timeout while executing a shell script.
    839283:20191105:162452.944 active check "systemctl.status[iptables]" is not supported: Timeout while executing a shell script.
    839283:20191105:162522.946 active check "systemctl.status[iscsid]" is not supported: Timeout while executing a shell script.
    839283:20191105:162552.948 active check "systemctl.status[iscsiuio]" is not supported: Timeout while executing a shell script.
    839283:20191105:162622.949 active check "systemctl.status[neutron-openvswitch-agent]" is not supported: Timeout while executing a shell script.
    839283:20191105:162652.951 active check "systemctl.status[nginx]" is not supported: Timeout while executing a shell script.
    839283:20191105:162722.953 active check "systemctl.status[openvswitch]" is not supported: Timeout while executing a shell script.
    839283:20191105:162752.954 active check "systemctl.status[pacemaker]" is not supported: Timeout while executing a shell script.
    839283:20191105:162822.956 active check "systemctl.status[qemu-guest-agent]" is not supported: Timeout while executing a shell script.
    839283:20191105:162852.958 active check "systemctl.status[rsyslog]" is not supported: Timeout while executing a shell script.

    Permissions for the script:
    -rwxrwxr-x. 1 zabbix zabbix 275 Nov 5 12:28 /etc/zabbix/zabbix_agentd.d/service_monitoring_via_systemctl.conf

    Script:
    Code:
    UserParameter=services.systemctl,echo "{\"data\":[$(systemctl list-unit-files --type=service|grep \.service|grep -v "@"|sed -E -e "s/\.service\s+/\",\"{#STATUS}\":\"/;s/(\s+)?$/\"},/;s/^/{\"{#NAME}\":\"/;$ s/.$//")]}"
    
    UserParameter=systemctl.status[*],systemctl status $1
    Sealert:
    found 0 alerts in /var/log/audit/audit.log

    Zabbix-agent config:
    Code:
    Timeout=30
    EnableRemoteCommands=1
    User=zabbix
    AllowRoot=0
    UnsafeUserParameters=1
    Iptables:
    Code:
    -A INPUT -s X.X.X.X -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
    -A INPUT -s X.X.X.X -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
    Visudo config:
    Code:
    zabbix ALL = NOPASSWD: /sbin/systemctl
    zabbix ALL = NOPASSWD: /usr/lib/systemd

    Can't figure out what is the problem

  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    You configured sudo, but you aren't using it in the Zabbix UserParameter, you need:

    UserParameter=systemctl.status[*],sudo systemctl status $1

    Comment

    • jameskirsop
      Member
      • Jul 2018
      • 32

      #3
      toms359 did you ever get this resolved? I'm seeing the same issue for both the discovery job and the systemctl direct check.

      I'm experiencing the same situation (nothing in audit.log, nothing helpful in the Zabbix Agent log) and I've applied LenR's advice to add sudo to the user parameters - which also didn't help.

      If I run
      Code:
      zabbix_agentd -t services.systemctl
      from the host in question (in this particular case it's also the zabbix server), I get a correctly formatted JSON object in about 1 to 1.5 seconds, so the config and user parameter appears to be correct.
      Last edited by jameskirsop; 05-01-2021, 05:54.

      Comment

      Working...