Ad Widget

Collapse

Zabbix script input value window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • evgenys
    Junior Member
    • Apr 2015
    • 7

    #1

    Zabbix script input value window

    Hey. I am trying to create a new Zabbix script that will trigger the Gitlab job to put the host in maintenance
    The problem is that I want to let the NOC team input duration time.

    I thought to use JS 'window.prompt' or bash 'read' options, but it didn't work...
    Example:

    // JS
    var name = window.prompt("Enter your name: ");
    alert("Your name is " + name);

    //BASH
    read name
    echo $name
    ----------------------

    Besides, if somebody can provide info about zabbix (zabbix_js) javascript library.
    it would be nice as well. Maybe I can call Zabbix server directly from JS instead of using external CI/CD tools.

    Thanks
  • likvi
    Junior Member
    • Apr 2022
    • 2

    #2

    Hello, I have the same problem.

    I would like to call prompt in webhook and set some js var, which I can use later in HTTP request towards some API. Is there any way how?

    Here is script:

    Code:
    params = JSON.parse(value)
    result = params.name;
    result += '\n\r';
    result += params.description;
    assignTo = window.prompt('Assign to person?');
    result += assignTo;
    return result;
    Here is the error result:
    • cannot execute script: ReferenceError: identifier 'window' undefined
    • at [anon] (duktape.c:83869) internal
    • at [anon] (function:5) preventsyield

    Similar is if I use code like this:
    Code:
    let person = prompt("Assign to person", "person name");


    Thanks

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #3
      Originally posted by evgenys
      Besides, if somebody can provide info about zabbix (zabbix_js) javascript library.
      it would be nice as well. Maybe I can call Zabbix server directly from JS instead of using external CI/CD tools.
      Not a library....
      https://www.zabbix.com/documentation...al/concepts/js

      Comment

      Working...