class Fluent::DiskUsage

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_diskusage.rb, line 14
def configure(conf)
        super
        require 'sys/filesystem'
end
output() click to toggle source
# File lib/fluent/plugin/in_diskusage.rb, line 31
def output
        filestats = Sys::Filesystem.stat(@mountpoint)
        total_bytes = filestats.block_size * filestats.blocks
        free_bytes = filestats.block_size * filestats.blocks_available
        used_bytes = total_bytes - free_bytes
        used_percent = 0
        free_percent = 0
        if total_bytes.nonzero?       
                used_percent = used_bytes / total_bytes.to_f
                free_percent = free_bytes / total_bytes.to_f
        end
        record = {"label"=>@label,"total_bytes"=>total_bytes,"free_bytes"=>free_bytes,"used_bytes"=>used_bytes,"used_percent"=>used_percent,"free_percent"=>free_percent}

        time = Fluent::Engine.now
        router.emit(tag,time,record)
end
run() click to toggle source
# File lib/fluent/plugin/in_diskusage.rb, line 24
def run
        while true
                output
        sleep @refresh_interval
        end
end
shutdown() click to toggle source
# File lib/fluent/plugin/in_diskusage.rb, line 48
def shutdown
        @watcher.terminate
        @watcher.join

end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_diskusage.rb, line 19
def start
        super
        @watcher = Thread.new(&method(:run))
end