Zabbix Documentation 3.4

2.23.04.04.2 (current)In development:4.4 (devel)Unsupported:1.82.02.43.23.4

User Tools

Site Tools


manual:appendix:command_execution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:appendix:command_execution [2017/01/23 15:33]
VSI Added description of conditions for command/script exit code checking and description of possible error messages.
manual:appendix:command_execution [2017/10/10 14:42] (current)
martins-v more links to additional info about various command options
Line 1: Line 1:
-==== Command execution ====+==== 10 Command execution ====
  
-Zabbix uses common functionality ​to execute ​user parameters, remote commands, system.run[] items without the "​nowait"​ flagscripts (alert, ​external and global) and some internal ​commands. ​+Zabbix uses common functionality ​for external checks, ​user parameters, system.run items, ​custom ​alert scriptsremote ​commands ​and user scripts.
  
 === Execution steps === === Execution steps ===
Line 12: Line 12:
   - Zabbix reads from the pipe until timeout occurs or no one is writing to the other end (ALL handles/​file descriptors have been closed). Note that the child process can create more processes and exit before they exit or close the handle/file descriptor.   - Zabbix reads from the pipe until timeout occurs or no one is writing to the other end (ALL handles/​file descriptors have been closed). Note that the child process can create more processes and exit before they exit or close the handle/file descriptor.
   - If the timeout has not been reached, Zabbix waits until the initial child process exits or timeout occurs   - If the timeout has not been reached, Zabbix waits until the initial child process exits or timeout occurs
-  - If the initial child process exited and the timeout has not been reached, Zabbix checks exit code of the initial child process and compares it to 0 (non-zero value is considered as execution failure)+  - If the initial child process exited and the timeout has not been reached, Zabbix checks exit code of the initial child process and compares it to 0 (non-zero value is considered as execution failure, only for custom alert scripts, remote commands and user scripts executed on Zabbix server and Zabbix proxy)
   - At this point it is assumed that everything is done and the whole process tree (i.e. the process group or the job) is terminated   - At this point it is assumed that everything is done and the whole process tree (i.e. the process group or the job) is terminated
- 
-<note important>​Steps 5-8 do not refer to remote commands as they are executed with a "​nowait"​ flag. Step 7 does not refer to custom scripts executed by Zabbix agent.</​note>​ 
  
 <note important>​Zabbix assumes that a command/​script has done processing when the initial child process has exited AND no other process is still keeping the output handle/file descriptor open. When processing is done, ALL created processes are terminated.</​note>​ <note important>​Zabbix assumes that a command/​script has done processing when the initial child process has exited AND no other process is still keeping the output handle/file descriptor open. When processing is done, ALL created processes are terminated.</​note>​
Line 23: Line 21:
 === Exit code checking === === Exit code checking ===
  
-Exit code checks for the executed commands/​scripts ​are performed ​with the following conditions:+Exit code are checked ​with the following conditions:
  
-  *Exit codes for script media types, remote commandsuser parameters ​executed ​by Zabbix server and for **system.run** (without the "​nowait"​ flag), **system.hw.devices**,​ and **system.sw.packages** ​Zabbix ​[[manual/​config/​items/​itemtypes/​zabbix_agent|agent items]] are checked.+  *Only for custom alert scripts, remote commands ​and user scripts ​executed ​on Zabbix server and Zabbix ​proxy.
   *Any exit code that is different from 0 is considered as execution failure.   *Any exit code that is different from 0 is considered as execution failure.
   *Contents of standard error and standard output for failed executions are collected and available in frontend (where execution result is displayed).   *Contents of standard error and standard output for failed executions are collected and available in frontend (where execution result is displayed).
-  *Additional log entry is created for remote commands on Zabbix server to save script execution output.+  *Additional log entry is created for remote commands on Zabbix server to save script execution output ​and can be enabled using LogRemoteCommands agent [[:​manual/​appendix/​config/​zabbix_agentd|parameter]].
  
 Possible frontend messages and log entries for failed commands/​scripts:​ Possible frontend messages and log entries for failed commands/​scripts:​
   * Contents of standard error and standard output for failed executions (if any).   * Contents of standard error and standard output for failed executions (if any).
-  * Process exited with code: N.” (for empty output, and exit code not equal to 0). +  * %%"%%Process exited with code: N.%%"​%% ​(for empty output, and exit code not equal to 0). 
-  * Process killed by signal: N.” (for process terminated by a signal, on Linux only). +  * %%"%%Process killed by signal: N.%%"​%% ​(for process terminated by a signal, on Linux only). 
-  * Process terminated unexpectedly.” (for process terminated for unknown reasons).+  * %%"%%Process terminated unexpectedly.%%"​%% ​(for process terminated for unknown reasons).
  
 ---- ----
  
-Read more about [[manual:config:items:​userparameters|user parameters]][[manual:​config:​notifications:​action:​operation:remote_command|remote ​commands]][[manual:​config:notifications:​media:​script|alert scripts]].+Read more about
 + 
 +  * [[:manual/config/items/​itemtypes/​external#​external_check_result|External checks]] 
 +  * [[:manual/​config/​items/​userparameters|User parameters]] 
 +  * [[:manual/config/​items/​itemtypes/​zabbix_agent|system.run]] items 
 +  * [[:manual/​config/​notifications/​media/​script|Custom alert scripts]] 
 +  * [[:manual/​config/​notifications/​action:​operation/remote_command|Remote ​commands]] 
 +  * [[:manual/​web_interface/​frontend_sections/​administration/​scripts|Global ​scripts]]