Sha256: dd7ee3c2bf4f06d1d395f5a3cdfd2b4c6517e474de97f76e1d95335afa4c12d0

Contents?: true

Size: 1.59 KB

Versions: 50

Compression:

Stored size: 1.59 KB

Contents

module MCollective
  module Data
    class Fstat_data<Base
      query do |file|
        result[:name] = file
        result[:output] = "not present"
        result[:type] = "unknown"
        result[:mode] = "0000"
        result[:present] = 0
        result[:size] = 0
        result[:mtime] = 0
        result[:ctime] = 0
        result[:atime] = 0
        result[:mtime_seconds] = 0
        result[:ctime_seconds] = 0
        result[:atime_seconds] = 0
        result[:md5] = 0
        result[:uid] = 0
        result[:gid] = 0


        if File.exists?(file)
          result[:output] = "present"
          result[:present] = 1

          if File.symlink?(file)
            stat = File.lstat(file)
          else
            stat = File.stat(file)
          end

          [:size, :uid, :gid].each do |item|
            result[item] = stat.send(item)
          end

          [:mtime, :ctime, :atime].each do |item|
            result[item] = stat.send(item).strftime("%F %T")
            result["#{item}_seconds".to_sym] = stat.send(item).to_i
            result["#{item}_age".to_sym] = Time.now.to_i - stat.send(item).to_i
          end

          result[:mode] = "%o" % [stat.mode]
          result[:md5] = Digest::MD5.hexdigest(File.read(file)) if stat.file?

          result[:type] = "directory" if stat.directory?
          result[:type] = "file" if stat.file?
          result[:type] = "symlink" if stat.symlink?
          result[:type] = "socket" if stat.socket?
          result[:type] = "chardev" if stat.chardev?
          result[:type] = "blockdev" if stat.blockdev?
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 3 rubygems

Version Path
choria-mcorpc-support-2.22.1 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.22.0 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.21.1 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.21.0 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.8 lib/mcollective/data/fstat_data.rb
mcollective-client-2.12.5 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.7 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.6 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.5 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.4 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.3 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.2 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-2.20.0 lib/mcollective/data/fstat_data.rb
choria-mcorpc-support-0.0.1 lib/mcollective/data/fstat_data.rb
mcollective-client-2.12.4 lib/mcollective/data/fstat_data.rb
mcollective-client-2.12.3 lib/mcollective/data/fstat_data.rb
mcollective-client-2.12.1 lib/mcollective/data/fstat_data.rb
mcollective-client-2.12.0 lib/mcollective/data/fstat_data.rb
mcollective-client-2.10.6 lib/mcollective/data/fstat_data.rb
mcollective-client-2.11.4 lib/mcollective/data/fstat_data.rb