[ZBX-9095] Ruby script sometimes fails as External check Created: 2014 Dec 01  Updated: 2017 May 30  Resolved: 2014 Dec 20

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 2.2.7, 2.4.2
Fix Version/s: None

Type: Incident report Priority: Blocker
Reporter: Alexey Pustovalov Assignee: Unassigned
Resolution: Won't fix Votes: 0
Labels: externalchecks, scripts
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ruby script as external script.



 Description   

Sometimes Ruby script fails because of FD = 0 (stdin) is closed by Zabbix server/proxy before script execution.

The problem is described in https://redmine.ruby-lang.org/issues/5723 issue:

[BUG] rb_update_max_fd: invalid fd (0) given.
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]

-- Control frame information -----------------------------------------------
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP

-- C level backtrace information -------------------------------------------
-e [0x8173762]
-e [0x81b7de8]
-e(rb_bug+0x35) [0x81b7e85]
-e [0x8073427]
-e [0x8079be0]
-e [0x806da5a]
-e(ruby_init+0x97) [0x805b317]
-e [0x8058887]
/lib/libc.so.6(__libc_start_main+0xdc) [0x3cedec]
-e [0x8058781]

-- Other runtime information -----------------------------------------------

0: can't convert false into String (TypeError)

The trace above is stored as item value.

Zabbix closed FD = 0 to decrease usage of files and avoid situations when max opened files option are reached. I suppose we need to document that Zabbix can use huge amount of opened FDs (files).



 Comments   
Comment by Igors Homjakovs (Inactive) [ 2014 Dec 16 ]

At startup Zabbix server closes STDIN and then redirects it to /dev/null:

         const char	default_file[] = "/dev/null";

	close(STDIN_FILENO);
	open(default_file, O_RDONLY);	/* stdin, normally fd==0 */

The file descriptor you are mentioning (FD = 0), is closed by "close(fd[0]);" when external script is being executed. However, this descriptor is the read end of a pipe and it is not related to STDIN. Therefore, it this situation there is no fault with Zabbix.

In https://redmine.ruby-lang.org/issues/5723 it is mentioned that this is a known Ruby issue for which the work-around has been added in the new Ruby version.
The problem will disappear after upgrade.

Comment by Alexander Vladishev [ 2014 Dec 20 ]

I close the issue.

Generated at Fri Mar 29 15:52:11 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.