Ad Widget

Collapse

Accessing User Information in GUI Scripts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harry483
    Junior Member
    • Nov 2010
    • 5

    #1

    Accessing User Information in GUI Scripts?

    Hi,

    I would like to enable authorised users to click on a host entry to execute a shell script on the Zabbix server. I tried to realise this with the so called "Scripts" (Admin/Scripts), but I am lacking the ability of providing any user related information.

    According to the documentation, those "GUI Scripts" only accept {HOSTNAME}, {HOST.CONN} and {HOST.DNS}.

    I need to provide at least the name of the user that performed the action. Is there any other place of installing such a functionality? If not, how deep do I have to dig to extend Zabbix in that direction?

    Thanks
    Michael
  • alixen
    Senior Member
    • Apr 2006
    • 474

    #2
    Hi,

    Originally posted by harry483
    Is there any other place of installing such a functionality? If not, how deep do I have to dig to extend Zabbix in that direction?
    You'll have to modify some PHP scripts.
    scripts_exec.php seems to be a good starting point.

    Regards,
    Alixen
    http://www.alixen.fr/zabbix.html

    Comment

    • harry483
      Junior Member
      • Nov 2010
      • 5

      #3
      Originally posted by alixen
      Hi,

      You'll have to modify some PHP scripts.
      scripts_exec.php seems to be a good starting point.
      Hmm... As far as I had time to dig into this I found out the following:
      • Frontend / PHP:
        • scripts_exec.php can access $USER_DETAILS which actually contains useful information
        • insert_command_result_form() (found in forms.inc.php) is called with only a script and host id
          • execute_script() is called, again with script and host ID
            • execute_script() (found in scripts.inc.php) requests the script execution on the backend (zabbix_server) via a JSON call containing not really more than IDs for script and node


      • Backend / zabbix_server:
        • node_process_command() (found in nodecommand.c) seems to process the JSON call from the PHP frontend
          • execute_script() (on the server side, not to confuse with the PHP side) is called with those known two IDs to identify and load the script command (including parameters) from the database
            • substitute_simple_macros() is finally called to process macros, but they only comprise {HOSTNAME}, {HOST.CONN} and {HOST.DNS}


      So my conclusion is that only the PHP frontend is aware of the controlling user, but not the backend which in fact executes the script.
      BTW: What about authentication of the frontend/backend communication?

      Question: Did I get this right, or could there be a more elegant way to process user information without modifying at least a couple of files and functions? Is this functionality that has not been requested before?

      Regards
      Michael

      Comment

      • alixen
        Senior Member
        • Apr 2006
        • 474

        #4
        Hi,

        Originally posted by harry483

        So my conclusion is that only the PHP frontend is aware of the controlling user, but not the backend which in fact executes the script.
        BTW: What about authentication of the frontend/backend communication?

        Question: Did I get this right, or could there be a more elegant way to process user information without modifying at least a couple of files and functions?
        AFAIK, you are right, I forgot that command is not executed by frontend but by backend.

        Originally posted by harry483
        Is this functionality that has not been requested before?
        I haven't found anything about it in bug tracker (I may be wrong "script" is such a common word that it appears a lot in bug reports).

        Regards,
        Alixen
        http://www.alixen.fr/zabbix.html

        Comment

        Working...