Ad Widget

Collapse

How to print the list of TOP resource consuming processes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soumya
    Junior Member
    • Nov 2013
    • 21

    #1

    How to print the list of TOP resource consuming processes

    Hi,

    I'm getting Memory & CPU utilization alerts very frequently. While logging into the server I'm seeing all have come back to normal (most of the time). Is there any way I can print the utilization stats for TOP 10 resource consuming processes in Trigger description, so that I can see which are the processes consumes resources on that time. kindly help


    Thank You.

  • brunohl
    Senior Member
    Zabbix Certified Specialist
    • Mar 2019
    • 215

    #2
    You could create a UserParameter to monitor it in JSON. Something like

    In this case, ordered by CPU usage:
    Code:
     ps aux | sort -nrk 3,3 | head -n 10 | awk '
    BEGIN { ORS = ""; print " [ "}
    { printf "%s{\"user\": \"%s\", \"pid\": \"%s\", \"cpu\": \"%s\", \"mem\": \"%s\", \"cmd\": \"%s\"}",
          separator, $1, $2, $3, $4, $11
      separator = ", "
    }
    END { print " ] " }';
    (Ps aux to json thanks to https://stackoverflow.com/questions/...ps-aux-to-json)

    Or you can monitor processes individually, creating an item to each one of them.
    Last edited by brunohl; 27-08-2019, 14:27. Reason: Changed from 5 to 10 processes

    Comment


    • soumya
      soumya commented
      Editing a comment
      Thank You brunohl for your suggestion. How can i do this for windows systems as well ?

    • brunohl
      brunohl commented
      Editing a comment
      Well, if you run Powershell you can use ps aux command as well, but you would have to parse it some way.
Working...