Ad Widget

Collapse

Custom Media types, script fails on action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zabbixx
    Member
    • Jul 2012
    • 71

    #1

    Custom Media types, script fails on action

    Hello i have a problem my simple script waont be executed on a action
    in events they still is the message "fails"
    aim using zabbix Zabbix Appliance 2.0.6

    in zabbix_server.cfg the default path of the alertscripts is defined as
    Code:
     ### Option: ExternalScripts
    #       Full path to location of external scripts.
    #       Default depends on compilation options.
    #
    # Mandatory: no
    # Default:
    # ExternalScripts=${datadir}/zabbix/externalscripts
    
    
    ### Option: AlertScriptsPath
    #       Full path to location of custom alert scripts.
    #       Default depends on compilation options.
    #
    # Mandatory: no
    # Default:
    AlertScriptsPath=${datadir}/zabbix/alertscripts
    by default Aplience this folder does not exist (the same by externalscripts!)
    but externalscripts works for me :-) => ${datadir} = /usr/share/

    so i created this folder
    /usr/share/zabbix/alertscripts
    i have a simple script there "test.sh"

    Code:
    #!/bin/bash
    echo `date >> /tmp/test_ok.txt`
    the user who has this media type is a superadmin ( no right problems for this zabbix user)

    Code:
    zabbix:/usr/share/zabbix/alertscripts # ls -als
    total 12
    4 drwxr-xr-x  2 root root 4096 Aug 23 15:18 .
    4 drwxr-xr-x 15 root root 4096 Aug 23 15:18 ..
    4 -rwxrwxrwx  1 root root   44 Aug 23 15:18 test.sh
    does zabbix executing this script as root ?
    for externalscripts it works :

    Code:
    zabbix:/usr/share/zabbix/externalscripts # ls -als
    total 28
    4 drwxr-xr-x  2 root root 4096 Aug 22 17:58 .
    4 drwxr-xr-x 15 root root 4096 Aug 23 15:18 ..
    4 -rwxrwxrwx  1 root root 2291 Jul 17 12:47 sanbox_get_connUnitId.sh
    4 -rwxrwxrwx  1 root root  702 Jul 17 12:47 sanbox_get_connUnitPortHWState_by_port.sh
    4 -rwxrwxrwx  1 root root 3778 Jul 17 16:54 sanbox_get_connUnitSensorMessage_by_sensor.sh
    8 -rwxrwxrwx  1 root root 7103 Jul 17 12:47 sanbox_get_connUnitSensorStatus_by_sensor.sh

    anny suggestions ?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    Setting file permissions in this context such "high" is no good practice.
    I suggest to restrict permissions a bit:
    Code:
    # chown root:zabbix test.sh
    # chmod 0750 test.sh
    That should be sufficient in most environments.

    What is the reason for failing according to Event details in frontend?
    Do you already have inspected the zabbix_server.log file for errors?

    Comment

    • zabbixx
      Member
      • Jul 2012
      • 71

      #3
      Hello BDiE8VNy,

      ok i changed the permission how you say.


      thx that you pointed me to the event details!



      Code:
      Error:
      ${datadir}/zabbix/alertscripts/test.sh: [2] No such file or directory
      Attached Files

      Comment

      Working...