JS

Zabbix v7.4번역일: 2026-09-09원본 보기

개요

zabbix_js는 임베디드 스크립트 테스트에 사용할 수 있는 명령줄 유틸리티입니다.

이 유틸리티는 문자열 매개변수를 사용하여 사용자 스크립트를 실행하고 결과를 출력합니다. 스크립트는 내장된 Zabbix 스크립팅 엔진을 사용하여 실행됩니다.

컴파일 또는 실행 오류가 발생하면 zabbix_js는 stderr에 오류를 출력하고 종료 코드 1로 종료됩니다.

사용법

zabbix_js -s script-file -p input-param [-l log-level] [-t timeout]
zabbix_js -s script-file -i input-file [-l log-level] [-t timeout]
zabbix_js -h
zabbix_js -V

zabbix_js는 다음 명령줄 매개변수를 지원합니다:

-s, --script script-file          Specify the file name of the script to execute
                                  If "-" is specified as the file name, the script will be read from stdin
-i, --input input-file            Specify the file name of the input information
                                  The content will be passed to the script as a value
                                  Mutually exclusive with -p
                                  If "-" is specified as the file name, the script will be read from stdin
-p, --param input-param           Specify the input parameter: the variable to be passed to the script as a value
                                  Mutually exclusive with -i
-l, --loglevel log-level          Specify the log level
                                  Range: 0-5
-t, --timeout timeout             Specify the timeout in seconds
                                  Valid range: 1-600 seconds (default: 10 seconds)
-h, --help                        Display help information
-V, --version                     Display the version number
-w <webdriver url>                Enables browser monitoring

예제:

예제 1: 값이 담긴 변수를 사용하여 스크립트 실행

스크립트 (script-file.js):

return value;

사용법:

zabbix_js -s script-file.js -p example_value

출력: example_value

예제 2: 입력 정보가 담긴 파일을 사용하여 스크립트 실행

스크립트가 담긴 파일 (script-file.js):

return value;

입력 정보가 담긴 파일 (example.txt):

Example of input information from the file

사용법:

zabbix_js -s script-file.js -i example.txt

출력: Example of input information from the file

예제 3: stdin에서 읽은 입력으로 스크립트 실행

스크립트가 담긴 파일 (script-file.js):

return value;

사용법:

zabbix_js -s script-file.js -i -

입력 (stdin):

Example of input from stdin

출력: Example of input from stdin