influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.59k stars 5.56k forks source link

[inputs.mem] Error in plugin: error getting virtual memory info: strconv.ParseUint: parsing "": invalid syntax #8622

Closed iStone188 closed 3 years ago

iStone188 commented 3 years ago

Telegraf Configuration

Telegraf is entirely plugin driven. All metrics are gathered from the declared inputs, and sent to the declared outputs.

[global_tags]
   user = "ad-east"

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  debug = false
  quiet = false
  hostname = "deviceID"
  omit_hostname = false

[[outputs.kafka]]
  brokers = ["192.168.1.122:9092","192.168.1.123:9092","192.168.1.124:9092"]
  topic = "tg_device_data"
  routing_tag = "test"
  max_retry = 3
  data_format = "json"

# Read metrics about cpu usage
[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false

# Read metrics about disk usage by mount point
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"]

# Read metrics about disk IO by device
[[inputs.diskio]]
  # no configuration

# Get kernel statistics from /proc/stat
[[inputs.kernel]]
  # no configuration

# Read metrics about memory usage
[[inputs.mem]]
  # no configuration

# Get the number of processes and group them by status
[[inputs.processes]]
  # no configuration

# Read metrics about swap memory usage
[[inputs.swap]]
  # no configuration

# Read metrics about system load & uptime
# [[inputs.system]]
  # no configuration

System info:

Telegraf v1.17.0 AndroidVersion:7.0 Hardware:MStar AArch64

Steps to reproduce:

  1. Copy telegraf and telegraf.conf to /data/local/tmp
  2. excute ./telegraf -config=telegraf.conf

Expected behavior:

Actual behavior:

service input plugins

[inputs.mem] Error in plugin: error getting virtual memory info: strconv.ParseUint: parsing "": invalid syntax

but inputs.cpu、inputs.disk、inputs.diskio、inputs.kernel、inputs.processes 、inputs.swap output data is normal and true. I look at the "cat /proc/meminfo" data : MemTotal: 916484 kB MemFree: 84576 kB Buffers: 668 kB Cached: 323892 kB SwapCached: 1844 kB Active: 240312 kB Inactive: 271632 kB Active(anon): 127556 kB Inactive(anon): 158360 kB Active(file): 112756 kB Inactive(file): 113272 kB Unevictable: 5040 kB Mlocked: 0 kB SwapTotal: 393212 kB SwapFree: 366308 kB Dirty: 36 kB Writeback: 0 kB AnonPages: 190888 kB Mapped: 147708 kB Shmem: 93408 kB Slab: 33420 kB SReclaimable: 13916 kB SUnreclaim: 19504 kB KernelStack: 10096 kB PageTables: 12396 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 851452 kB Committed_AS: 16274040 kB VmallocTotal: 251658176 kB VmallocUsed: 75164 kB VmallocChunk: 251485952 kB CMA Free: 63052 kB CMA heap info(name,alloc,in cache,fail,total free): DEFAULT_CMA_BUFFER (856kb 0kb 0kb 15528kb) OTHERS (32768kb 0kb 0kb 0kb) VDEC_XC_STR_MBOOT (0kb 0kb 0kb 49152kb) RETURN_ENUM0 (25600kb 0kb 0kb 31744kb) RETURN_ENUM2 (8192kb 0kb 0kb 36864kb) VDEC1 (49152kb 0kb 0kb 0kb)

I find the result:

// ErrRange indicates that a value is out of range for the target type.
var ErrRange = errors.New("value out of range")

// ErrSyntax indicates that a value does not have the right syntax for the target type.
var ErrSyntax = errors.New("invalid syntax")

func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *VirtualMemoryExStat, error) {
    filename := common.HostProc("meminfo")
    lines, _ := common.ReadLines(filename)

    // flag if MemAvailable is in /proc/meminfo (kernel 3.14+)
    memavail := false
    activeFile := false   // "Active(file)" not available: 2.6.28 / Dec 2008
    inactiveFile := false // "Inactive(file)" not available: 2.6.28 / Dec 2008
    sReclaimable := false // "SReclaimable:" not available: 2.6.19 / Nov 2006

    ret := &VirtualMemoryStat{}
    retEx := &VirtualMemoryExStat{}
        .....
       ......
        .....
 }

But it still hasn't solved the problem。

ssoroka commented 3 years ago

This looks like an upstream issue with gopsutil and support for the platform you're using. You may want to open an issue there instead, it looks like the issue is this line CMA heap info(name,alloc,in cache,fail,total free): doesn't have a value after it, and gopsutil tries to parse it as a float.

iStone188 commented 3 years ago

yes, CMA heap info value pattern not matching. I give up heap info value .