I'm trying to get a JSON document with the top 5 processes by memory.
This JSON I want to send to Zabbix and draw the top 5 processes by memory.
I get the top 5 processes by memory by the following command:
ps axho comm --sort -rss | head -5
node
mongod
kubelet
dockerd
systemd-journal
How to convert the output of ps+head to JSON with key {#PROCNAME} to get this structure:
{
"data": [
{
"{#PROCNAME}": "node"
},
{
"{#PROCNAME}": "mongod"
},
{
"{#PROCNAME}": "kubelet"
},
{
"{#PROCNAME}": "dockerd"
},
{
"{#PROCNAME}": "systemd-journal"
}
]
}
https://www.zabbix.com/documentation/current/manual/config/macros/lld_macros
There is a type of macro used within the low-level discovery (LLD) function:
{#MACRO}