Ad Widget

Collapse

Suggestion about listen,bind and close

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • limo
    Senior Member
    • Dec 2004
    • 192

    #1

    Suggestion about listen,bind and close

    Hello all,

    It would be great if zabbix_server and agent do better start with tcp_listen. Now it is started, zabbix_* will try to bind and if there is error, it dies. My suggestion is that it would be better to wait some time or do better checking. Sometime agent or server dies and leaves many connections in TIME_WAIT state. It takes some time before this connections are dropped and in this time, I have to wait before I try to run zabbix_* again. I have two suggestions, one of them is enaught:

    - when try to listen, do some loop and try it 60 seconds. It should be enaught, each second try to bind again. After that time, die. I know this can do init script but we need exact return code for this scenario.

    - better connection management when killing agent. I think there is some problem inside zabbix_agentd that when I kill it, it does not properly close connections. If it does this, there could not be TIME_WAIT connections after kill. Am I wrong?

    Thanx to all!
  • abi
    Member
    • Jun 2006
    • 81

    #2
    hi limo,

    Originally posted by limo
    - better connection management when killing agent. I think there is some problem inside zabbix_agentd that when I kill it, it does not properly close connections. If it does this, there could not be TIME_WAIT connections after kill. Am I wrong?
    no, the agent daemon should care about closing its open sockets
    on SIGTERM. I have had a short look at the code and it seems the
    agent does, when receiving SIGTERM call uninit() which then sends
    the SIGTERM to all childs, but doesnt bother about closing open
    sockets. Im not sure how to solve this in a propper way, i dont
    know the code well enough.

    We have received and bugreport in the Debian BTS about this
    too, and its indeed an annoying problem
    (http://bugs.debian.org/374758)
    Last edited by abi; 21-06-2006, 09:43.

    Comment

    • Alexei
      Founder, CEO
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2004
      • 5654

      #3
      Fixed in CVS tree. This is patch for server.c and zabbix_agentd.c.

      When the patch is applied the process will bind to port even if there are sockets in TIME_WAIT state.

      int on;

      ...

      if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
      {
      zabbix_log( LOG_LEVEL_CRIT, "Cannot create socket");
      exit(1);
      }

      /* New code */
      on = 1;
      if( -1 == setsockopt( sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on) ))
      {
      zabbix_log(LOG_LEVEL_WARNING, "Cannot setsockopt SO_REUSEADDR [%s]", strerror(errno));
      }
      Alexei Vladishev
      Creator of Zabbix, Product manager
      New York | Tokyo | Riga
      My Twitter

      Comment

      Working...