Bug 31352 - Netsaint check_by_ssh: fcntl(0, F_SETFL, O_NONBLOCK): Inappropriate ioctl for device
Summary: Netsaint check_by_ssh: fcntl(0, F_SETFL, O_NONBLOCK): Inappropriate ioctl for...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-18 12:40 UTC by dl
Modified: 2002-06-11 09:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dl 2001-10-18 12:40:01 UTC
 This could be more related to ssh, than to netsaint, but it seems to
 occur only if check_by_ssh is used. Unfortunately it is not really
 reproducable. Sometimes (like once a day) all remote checks that use
 ssh fail with that error message:
 
   fcntl(0, F_SETFL, O_NONBLOCK): Inappropriate ioctl for device

 They produce a warning, but fail 3 times, so no more checks are done, and
 I have to reschedule each check by hand, to get the state changed
 again. Then it works fine again for some hours.
 The problem did not occur before my update to 4.4-STABLE, and OpenSSH 2.9.
 I have to say, that there was ssh 2.9 installed on this system already
 (from the ports) before, but I guess there are differences to the one
 now included in the system.

Fix: 

sorry, no idea. Not beeing able to reproduce this problem in a defined
  environment, doesn't help. :(
How-To-Repeat:   Tricky: install netsaint and plugins, define a service which is checked
  on a remote machine, it doesn't seem to make difference which ssh 
  is used on the remote machine (I've had FreeBSD boxes and Solaris
  with different versions of OpenSSH). Start netsaint and wait until
  you get warnings about the checks failing with the error message above.
Comment 1 dl 2001-10-18 13:44:52 UTC
Hi again,

I can come up with some more info:

- if netsaint reports the problem described, I can definitely
  do the check by hand, so even if I can submit something like

  /usr/local/libexec/netsaint/check_by_ssh -H some.host /usr/local/libexec/netsaint/check_disk 90 95 /

  it always works, by netsaint reports this problem.


- A restart sometimes helps to solve the problem, but not for long

- since fd 0 is stdin, I have the impression the I/O redirection
  between netsaint and it commands must try to set the pipe to
  O_NONBLOCK, but I couldn't find a piece of code, that does it.
  But I feel it, the problem must be somewhere within that, and
  maybe how ssh handles redirected i/o ?

Best regards,
 Daniel
-- 
IRCnet: Mr-Spock   - signs of absurd developments in the net community: 
#42:   - "Wurstbrot gehoert m.E. zum Fruehstuecks-botnet von Cartoon" -  
*Daniel Lang * dl@leo.org * +49 89 289 25735 * http://www.leo.org/~dl/*
Comment 2 blaz 2002-06-11 08:38:37 UTC
Here is a patch for both the netsaint and nagios ports. Please report back
if it fixes your problems.
Fix has been pointed out to me by Stanley Hopcroft
<Stanley.Hopcroft@IPAustralia.Gov.AU> (see PR 39018).

diff -urN netsaint.old/Makefile netsaint/Makefile
--- netsaint.old/Makefile Thu Mar 14 06:41:17 2002
+++ netsaint/Makefile Tue Jun 11 09:25:40 2002
@@ -7,6 +7,7 @@

 PORTNAME= netsaint
 PORTVERSION= 0.0.7
+PORTREVISION= 1
 PORTEPOCH= 1
 CATEGORIES= net
 MASTER_SITES= http://netsaint.sourceforge.net/download/ \
diff -urN netsaint.old/files/patch-ba netsaint/files/patch-ba
--- netsaint.old/files/patch-ba Thu Jan  1 01:00:00 1970
+++ netsaint/files/patch-ba Tue Jun 11 09:22:21 2002
@@ -0,0 +1,20 @@
+--- base/utils.c.orig Thu Feb 21 02:47:12 2002
++++ base/utils.c Tue Jun 11 09:21:53 2002
+@@ -1884,6 +1884,17 @@
+  val|=FD_CLOEXEC;
+  fcntl(lockfile,F_SETFD,val);
+
++ /* close existing stdin, stdout, stderr */
++ close(0);
++ close(1);
++ close(2);
++
++ /* THIS HAS TO BE DONE TO AVOID PROBLEMS WITH STDERR BEING REDIRECTED TO
SERVICE MESSAGE PIPE! */
++ /* re-open stdin, stdout, stderr with known values */
++ open("/dev/null",O_RDONLY);
++ open("/dev/null",O_WRONLY);
++ open("/dev/null",O_WRONLY);
++
+  return OK;
+  }
+

diff -urN nagios.old/Makefile nagios/Makefile
--- nagios.old/Makefile Tue Jun  4 04:52:36 2002
+++ nagios/Makefile Tue Jun 11 09:10:31 2002
@@ -6,11 +6,11 @@
 #

 PORTNAME= nagios
-PORTVERSION= 1.0.b2
+PORTVERSION= 1.0.b3
 CATEGORIES= net
 MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=nagios
-DISTNAME= nagios-1.0b2
+DISTNAME= nagios-1.0b3

 MAINTAINER= blaz@si.FreeBSD.org

diff -urN nagios.old/distinfo nagios/distinfo
--- nagios.old/distinfo Tue Jun  4 04:52:36 2002
+++ nagios/distinfo Tue Jun 11 09:10:47 2002
@@ -1 +1 @@
-MD5 (nagios-1.0b2.tar.gz) = beb6349b4ce46cd19e27a12ab1c79f70
+MD5 (nagios-1.0b3.tar.gz) = 2bef463bedf547321d7eb6155355a389
Comment 3 Jun Kuriyama freebsd_committer freebsd_triage 2002-06-11 09:17:49 UTC
State Changed
From-To: open->closed

Committed, thanks!