Ad Widget

Collapse

Trying to execute external trigger action scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • greydog_11
    Junior Member
    • Jul 2020
    • 2

    #1

    Trying to execute external trigger action scripts

    Hi,
    I am new to zabbix, but familiar with linux etc. I have setup two servers, one with zabbix server and one with GLPI helpdesk. All running well. I have installed the webservices plugin in GLPI and created the Trigger action in zabbix to generate tickets in GLPI. The active command for the trigger is

    /usr/bin/php /usr/lib/zabbix/externalscripts/zabbix-glpi/tickets_zabbix_glpi.php eventhost="{HOSTNAME}" event="DOWN" state="{TRIGGER.STATUS}" hostproblemid=0 lasthostproblemid=0 servico="{TRIGGER.NAME}" triggerid="{TRIGGER.ID}" eventzabbix="{EVENT.ID}"

    I have spent a day debugging the script to get it to work with the latest version of zabbix and GLPI and it all works well from the command line. For example if I execute this

    sudo runuser -l zabbix /usr/bin/php /usr/lib/zabbix/externalscripts/zabbix-glpi/tickets_zabbix_glpi.php eventhost="Graeme Phone" event="DOWN" state="PROBLEM" hostproblemid=0 lasthostproblemid=0 servico="ICMP" triggerid="16973" eventzabbix="1448"

    from the command line it runs fine and creates a ticket in the GLPI server.

    Problem is, I can't for the life of me get it to execute on an event. The event fires and I get this in the logs on zabbix/externalscripts/zabbix-glpi/tickets_zabbix_glpi

    Failed to execute command "/usr/bin/php /usr/lib/zabbix/externalscripts/zabbix-glpi/tickets_zabbix_glpi.php eventhost="Graeme Phone" event="DOWN" state="PROBLEM" hostproblemid=0 lasthostproblemid=0 servico="ICMP" triggerid="16973" eventzabbix="1624"": Could not open input file: /usr/lib/zabbix/externalscripts/zabbix-glpi/tickets_zabbix_glpi.php

    zabbix:zabbix is the owner of the php file.

    I am sure this looks like a permissions issue, but I can't work it out.
    The zabbix user has a shell /bin/bash defined. If I run "sudo runuser -l zabbix" and try to execute the command it works fine.

    Any ideas anyone ?
    thanks

  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    I don't think you mentioned what OS or distro and version you're using.

    That doesn't really look like a problem caused by an access control mechanism like SELinux or AppArmor, since if they were blocking access to that file or directory, the attempt probably wouldn't show up in the zabbix_server.log file. Still, you should verify they're not involved or causing the problem, just to be sure.

    If you cut & paste the path from the error message after "Could not open input file:", and do an "ls -l <paste the path here>", does that return the correct output? Using cut-and-paste with paths in error messages and "ls" will often quickly identify whether there's a hard to spot typo someplace.

    One other thought, though this is unlikely: rather than using "/usr/bin/php /path/to/your/script", can you use a shbang ( #! /usr/bin/php ) as the first line of the script, and then call it directly, without the /usr/bin/php on the command line? I've only done a little bit of PHP and never from the command line, so I don't know if it's possible to make PHP scripts directly runnable, the way you can with e.g. Perl or Python scripts. I'm bringing this up in case the issue has to do with path splitting when zabbix_server is exec'ing the script. If you don't know what I mean about shbang lines or executing the script directly, respond and I'll try explain in more detail, but you can also find more information doing web searches.

    Comment

    • greydog_11
      Junior Member
      • Jul 2020
      • 2

      #3
      Thanks Tim,
      I checked the SELinux logs and wasn't seeing anything, so I changed the script to a shbang script with the same result. As an experiment I set SELinux to permissive and it runs fine ????? Oh well, I will play with SELinux a bit now and tighten it up again and keep allowing this script to execute. Thanks for the pointers that led me in the right direction.

      Comment

      Working...