zoukankan      html  css  js  c++  java
  • logstash 监控日志文件时应对日志文件名改变的原理

    开门见山先说结论:基于inode实现。

    分析很简单,logstash是用一个filewatch去监视文件的。在logstash目录里搜索filewatch即可找到该目录

    logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.7/lib/filewatch

    其中的watch.rb文件是我们所关注的重点

        public
        def inode(path,stat)
          if @iswindows
            fileId = Winhelper.GetWindowsUniqueFileIdentifier(path)
            inode = [fileId, 0, 0] # dev_* doesn't make sense on Windows
          else
            inode = [stat.ino.to_s, stat.dev_major, stat.dev_minor]
          end
          return inode
        end

    修改文件名并不会改变inode与文件的对应关系,并且打开一个文件以后,系统就以inode号码来识别这个文件,不再考虑文件名。

    inode具体原理参考下文:

    http://www.cnblogs.com/itech/archive/2012/05/15/2502284.html

  • 相关阅读:
    SQL补充
    SQL练习题
    HDU 2907
    Codeforces 814D
    Codeforces 814C
    Codeforces 1004D
    Codeforces 1004E
    CodeForces 909F
    CodeForces 909E
    CodeForces 909D
  • 原文地址:https://www.cnblogs.com/oceanking/p/5740153.html
Copyright © 2011-2022 走看看