Heka同一个文件滚动读取rolling read FilePollingInput

针对一个文件,周期性质的去读取内容,无buffer的读取,典型应用

1,内存使用情况读取

[hekad]
maxprocs = 2

[MemStats]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/proc/meminfo"
decoder = "MemStatsDecoder"


[MemStatsDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/linux_memstats.lua"


[RstEncoder]

[LogOutput]
message_matcher = "TRUE"
encoder = "RstEncoder"

结果如下,

:Timestamp: 2016-07-22 10:29:48 +0000 UTC
:Type: stats.memstats
:Hostname: master
:Pid: 0
:Uuid: 977fd381-43d8-424a-a410-8d230b85ab46
:Logger: MemStats
:Payload: 
:EnvVersion: 
:Severity: 7
:Fields:
    | name:"Hugepagesize" type:double value:2048 representation:"kB"
    | name:"Buffers" type:double value:183108 representation:"kB"
    | name:"Active" type:double value:696196 representation:"kB"
    | name:"Bounce" type:double value:0 representation:"kB"
    | name:"SUnreclaim" type:double value:31416 representation:"kB"
    | name:"HugePages_Total" type:double value:0
    | name:"Active(anon)" type:double value:454064 representation:"kB"
    | name:"Mlocked" type:double value:0 representation:"kB"
    | name:"AnonPages" type:double value:981512 representation:"kB"
    | name:"Active(file)" type:double value:242132 representation:"kB"
    | name:"Committed_AS" type:double value:3.152928e+06 representation:"kB"
    | name:"VmallocUsed" type:double value:149148 representation:"kB"
    | name:"SwapFree" type:double value:2.009828e+06 representation:"kB"
    | name:"Inactive(file)" type:double value:313540 representation:"kB"
    | name:"CommitLimit" type:double value:2.988856e+06 representation:"kB"
    | name:"Slab" type:double value:164308 representation:"kB"
    | name:"PageTables" type:double value:16888 representation:"kB"
    | name:"HugePages_Free" type:double value:0
    | name:"SwapTotal" type:double value:2.031608e+06 representation:"kB"
    | name:"NFS_Unstable" type:double value:0 representation:"kB"
    | name:"VmallocChunk" type:double value:3.4359583224e+10 representation:"kB"
    | name:"HugePages_Surp" type:double value:0
    | name:"DirectMap1G" type:double value:0 representation:"kB"
    | name:"DirectMap2M" type:double value:2.091008e+06 representation:"kB"
    | name:"DirectMap4k" type:double value:6144 representation:"kB"
    | name:"HugePages_Rsvd" type:double value:0
    | name:"Shmem" type:double value:1164 representation:"kB"
    | name:"SReclaimable" type:double value:132892 representation:"kB"
    | name:"Mapped" type:double value:57724 representation:"kB"
    | name:"HardwareCorrupted" type:double value:0 representation:"kB"
    | name:"FilePath" type:string value:"/proc/meminfo"
    | name:"MemFree" type:double value:159100 representation:"kB"
    | name:"Writeback" type:double value:0 representation:"kB"
    | name:"SwapCached" type:double value:3240 representation:"kB"
    | name:"WritebackTmp" type:double value:0 representation:"kB"
    | name:"Dirty" type:double value:164 representation:"kB"
    | name:"VmallocTotal" type:double value:3.4359738367e+10 representation:"kB"
    | name:"Inactive" type:double value:844780 representation:"kB"
    | name:"AnonHugePages" type:double value:706560 representation:"kB"
    | name:"Unevictable" type:double value:0 representation:"kB"
    | name:"Inactive(anon)" type:double value:531240 representation:"kB"
    | name:"KernelStack" type:double value:3128 representation:"kB"
    | name:"Cached" type:double value:373728 representation:"kB"
    | name:"MemTotal" type:double value:1.914496e+06 representation:"kB"

fileds中的值会随着每次读取发生变化的。

 

应用二,系统负载读取

[LoadAvg]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/proc/loadavg"
decoder = "LoadAvgDecoder"

[LoadAvgDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/linux_loadavg.lua"

 

应用三,磁盘情况读取

[DiskStats]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/sys/block/sda1/stat"
decoder = "DiskStatsDecoder"

[DiskStatsDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/linux_diskstats.lua"

 

应用四,cpu情况读取

[ProcStats]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/proc/stat"
decoder = "ProcStatDecoder"

[ProcStatDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/linux_procstat.lua"

 

应用五,设备情况读取

[Netdev]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/proc/net/dev"
decoder = "NetdevDecoder"

[NetdevDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/linux_netdev.lua"

 

应用六,网络情况读取

[NetNetstat]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/proc/net/netstat"
decoder = "NetstatDecoder"

[NetSnmp]
type = "FilePollingInput"
ticker_interval = 1
file_path = "/proc/net/snmp"
decoder = "NetstatDecoder"

[NetstatDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/linux_netstat.lua"

转载于:https://my.oschina.net/weikan/blog/716362

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值