Ad Widget

Collapse

External script error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    External script error

    I'm trying to start a Curl script from Administration - Scripts but it keeps giving me an error.

    For now the script calls a simple Curl that reads a JSON file and receives a JSON response.
    Code:
    IN_JSON="rde_post.json"
    OUT_JSON="rde_return.json"
    
    curl \
        --netrc-file /usr/lib/zabbix/externalscripts/rde/teste/.netrc/ \
        --request POST \
        --header "Content-Type: application/json" \
        --data "@${IN_JSON}" \
        --output ${OUT_JSON} \
        http://URI...
    I can execute this script correctly from the command line.

    In Zabbix, I use the following line to start the script:
    Code:
    /usr/lib/zabbix/externalscripts/rde/test/curl_test.sh
    Click image for larger version  Name:	script_command.PNG Views:	0 Size:	12.8 KB ID:	430368

    When I try to start it from the trigger menu at the Dashboard, it gives me the error below.
    Code:
    Cannot execute script.
    Warning: Couldn't read data from file "rde_post.json", this makes an empty
    Warning: POST.
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0Warning: Failed to create the file rde_return.json: Permission denied
    100 111 100 111 0 0 12333 0 --:--:-- --:--:-- --:--:-- 12333
    curl: (23) Failed writing body (0 != 111)
    Click image for larger version  Name:	script_error.PNG Views:	0 Size:	13.6 KB ID:	430369

    I'm not sure, but the issue seems to be related to file permissions. I changed files ownership to Zabbix user but the error repeats itself.
    Code:
    rwxr-xr-x 1 zabbix zabbix 369 Aug 24 11:40 curl_test.sh
    rw-r--r-- 1 zabbix zabbix 61 Aug 24 10:36 .netrc
    rw-r--r-- 1 zabbix zabbix 1.1K Aug 23 12:45 rde_post.json
    rw-r--r-- 1 zabbix zabbix 849 Aug 24 10:40 rde_return.json

    This is a newly installed
    Zabbix 5.4.3.

    Any help is apreciated.
    Thanks.
    Last edited by markfree; 24-08-2021, 21:55.
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #2
    Zabbix user, which server is run as, has probably home directory set to something like /var/lib/zabbix, so it tries to read those files from there. For a start, I'd try setting full path to those:
    Code:
    IN_JSON="/full/path/to/file/rde_post.json"
    OUT_JSON="/full/path/to/file/rde_return.json"

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #3
      Thank you dimir
      Using full path works.

      Comment

      Working...