Quantcast
Channel: User Michael Mol - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 14

Deriving an item value from a structured file in Zabbix

$
0
0

Zabbix's builtin items for monitoring system parameters are reasonably rich, but there are occasionally things it doesn't seem to make trivial to obtain, such as how many dirty cache pages there are.

For example, consider /proc/meminfo on your typical Linux system:

Inactive(file):  1348288 kBUnevictable:       18876 kBMlocked:           18876 kBSwapTotal:       8388604 kBSwapFree:        8388604 kBDirty:             39620 kBWriteback:           948 kBAnonPages:       6184596 kBMapped:          5319216 kBShmem:            427020 kBSlab:             741476 kBSReclaimable:     633088 kBSUnreclaim:       108388 kBKernelStack:       14528 kBPageTables:       118816 kBNFS_Unstable:          0 kBBounce:                0 kBWritebackTmp:          0 kBCommitLimit:    16575460 kBCommitted_AS:   19184632 kBVmallocTotal:   34359738367 kBVmallocUsed:           0 kBVmallocChunk:          0 kBAnonHugePages:         0 kBShmemHugePages:        0 kBShmemPmdMapped:        0 kBCmaTotal:              0 kBCmaFree:               0 kBHugePages_Total:       0HugePages_Free:        0HugePages_Rsvd:        0HugePages_Surp:        0Hugepagesize:       2048 kBDirectMap4k:     9692684 kBDirectMap2M:     7049216 kB

What I want is 39620, from the Dirty line. With a combination of sed and grep, this would be as simple as export field=Dirty; grep -e "$field:" /proc/meminfo | sed -e "s/^$field: \+\([0-9]\)\+.*$/\1/"; fairly straightforward.

I could do this with a UserParameter:

UserParameter=proc.meminfo[*], grep -e "$1:" /proc/meminfo | sed -e "s/^$1: \+\([0-9]\)\+.*$/\1/"

and then access the value with the item key proc.meminfo[Dirty].

I'd prefer not to use a UserParameter for this, though, as UserParameter require me to deploy additional configuration to each node, and also the process spawns consume system entropy. Both are things I generally prefer to avoid.


Viewing all articles
Browse latest Browse all 14

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>