Skip to content

Instantly share code, notes, and snippets.

@CHERTS
Last active September 19, 2021 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CHERTS/b40485efbdf2bd426b4dcfc5a56821ae to your computer and use it in GitHub Desktop.
Save CHERTS/b40485efbdf2bd426b4dcfc5a56821ae to your computer and use it in GitHub Desktop.
Template CPU and Memory by User (required Zabbix v5.4)
zabbix_export:
version: '5.4'
date: '2021-09-19T18:59:11Z'
groups:
-
uuid: 7df96b18c230490a9a0a9e2307226338
name: Templates
templates:
-
uuid: ddfbae14f57f4aa09733fba5de867ce3
template: 'Template CPU and Memory by User'
name: 'CPU and Memory usage by User'
description: |
Created by Mikhail Grigorev
Version: 0.1
groups:
-
name: Templates
items:
-
uuid: 147edb7d60f34fbd82ae468c1ef955fd
name: 'Get linux user list'
type: ZABBIX_ACTIVE
key: 'vfs.file.contents[/etc/passwd]'
delay: 10m
history: '0'
trends: '0'
value_type: TEXT
preprocessing:
-
type: CSV_TO_JSON
parameters:
- ':'
- ''
- '0'
tags:
-
tag: Application
value: 'Zabbix raw data'
discovery_rules:
-
uuid: 7baff8295d0344a8b9a2becdbbc67434
name: 'Users discovery'
type: DEPENDENT
key: users.discovery
delay: '0'
filter:
evaltype: AND
conditions:
-
macro: '{#USER}'
value: '{$USERS.NAME.MATCHES}'
formulaid: A
-
macro: '{#USER}'
value: '{$USERS.NAME.NOT_MATCHES}'
operator: NOT_MATCHES_REGEX
formulaid: B
item_prototypes:
-
uuid: 0f8bb2e9504f4efaaaec400500afcce4
name: 'CPU usage for user ''{#USER}'''
type: ZABBIX_ACTIVE
key: 'proc.cpu.util[,{#USER}]'
history: 30d
value_type: FLOAT
tags:
-
tag: Application
value: 'CPU by User'
-
uuid: c16fafcabf2649499594198b9112e4eb
name: 'Memory usage for user ''{#USER}'' (pmem)'
type: ZABBIX_ACTIVE
key: 'proc.mem[,{#USER},,,pmem]'
history: 30d
value_type: FLOAT
units: percent
tags:
-
tag: Application
value: 'Memory by User'
-
uuid: d6923bb05cce426cba626f5049fa5034
name: 'Memory usage for user ''{#USER}'' (rss)'
type: ZABBIX_ACTIVE
key: 'proc.mem[,{#USER},,,rss]'
history: 30d
units: B
tags:
-
tag: Application
value: 'Memory by User'
-
uuid: 0f97b628a05b4cb49c3aee23d104f4cb
name: 'Memory usage for user ''{#USER}'' (swap)'
type: ZABBIX_ACTIVE
key: 'proc.mem[,{#USER},,,swap]'
history: 30d
units: B
tags:
-
tag: Application
value: 'Memory by User'
-
uuid: 9ff6d23832164b7ebd552122db6a0bed
name: 'Memory usage for user ''{#USER}'' (vsize)'
type: ZABBIX_ACTIVE
key: 'proc.mem[,{#USER},,,vsize]'
history: 30d
units: B
tags:
-
tag: Application
value: 'Memory by User'
graph_prototypes:
-
uuid: 2ebe19c9fb864382a121db8714ec429f
name: 'CPU usage for user ''{#USER}'''
graph_items:
-
sortorder: '1'
color: 1A7C11
item:
host: 'Template CPU and Memory by User'
key: 'proc.cpu.util[,{#USER}]'
-
uuid: 7b33376813d24db8a2538426e8e4d0d7
name: 'Memory usage for user ''{#USER}'' (bytes)'
graph_items:
-
sortorder: '1'
color: F63100
item:
host: 'Template CPU and Memory by User'
key: 'proc.mem[,{#USER},,,rss]'
-
sortorder: '2'
color: 2774A4
item:
host: 'Template CPU and Memory by User'
key: 'proc.mem[,{#USER},,,swap]'
-
sortorder: '3'
color: A54F10
item:
host: 'Template CPU and Memory by User'
key: 'proc.mem[,{#USER},,,vsize]'
-
uuid: de86679a587d447182d39d45b3c4b25c
name: 'Memory usage for user ''{#USER}'' (percent)'
graph_items:
-
sortorder: '1'
color: 1A7C11
item:
host: 'Template CPU and Memory by User'
key: 'proc.mem[,{#USER},,,pmem]'
master_item:
key: 'vfs.file.contents[/etc/passwd]'
lld_macro_paths:
-
lld_macro: '{#USER}'
path: $.1
macros:
-
macro: '{$USERS.NAME.MATCHES}'
value: .+
-
macro: '{$USERS.NAME.NOT_MATCHES}'
value: '^(_apt|bin|backup|daemon|games|gnats|irc|list|lp|man|messagebus|news|ntp|proxy|sync|sys|systemd-.*|uucp)$'
dashboards:
-
uuid: dfb378aa8ce6437b99a41f8ece35e03d
name: 'Resource usage by user'
pages:
-
name: 'CPU usage by user'
display_period: '60'
widgets:
-
type: GRAPH_PROTOTYPE
name: 'CPU usage by user'
width: '24'
height: '5'
fields:
-
type: INTEGER
name: columns
value: '1'
-
type: GRAPH_PROTOTYPE
name: graphid
value:
name: 'CPU usage for user ''{#USER}'''
host: 'Template CPU and Memory by User'
-
name: 'Memory usage by user (bytes)'
display_period: '60'
widgets:
-
type: GRAPH_PROTOTYPE
name: 'Memory usage by user (bytes)'
width: '24'
height: '5'
fields:
-
type: INTEGER
name: columns
value: '1'
-
type: GRAPH_PROTOTYPE
name: graphid
value:
name: 'Memory usage for user ''{#USER}'' (bytes)'
host: 'Template CPU and Memory by User'
-
name: 'Memory usage by user (percent)'
display_period: '60'
widgets:
-
type: GRAPH_PROTOTYPE
name: 'Memory usage by user (percent)'
width: '24'
height: '5'
fields:
-
type: INTEGER
name: columns
value: '1'
-
type: INTEGER
name: source_type
value: '3'
-
type: ITEM_PROTOTYPE
name: itemid
value:
key: 'proc.mem[,{#USER},,,pmem]'
host: 'Template CPU and Memory by User'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment