Ad Widget

Collapse

multiple line string in an item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Franky
    Junior Member
    • Sep 2004
    • 1

    #1

    multiple line string in an item

    Dear all,

    is it possible to monitor top 10 process with their CPU Usage and with a multi line format for put the values in history.

    For example, i Want to log this type of information with a trapperd item
    ps wwagux |grep -v wait | head -10

    USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND
    sreop 195632 0.4 0.0 27696 16248 - A 10:53:51 8:00 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    sreop 33036 0.3 0.0 27532 16084 - A 10:51:26 6:22 ora_snp5_DSREP2
    sreop 209716 0.3 0.0 1476 1504 - A 10:54:54 6:12 /bin/ksh
    sreop 202808 0.3 0.0 1736 1768 - A 10:54:55 5:39 /bin/ksh
    sreop 195422 0.2 0.0 27696 16248 - A 10:53:51 5:22 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    cft 90576 0.2 0.0 1964 1492 - A Jan 11 28:58 CFTMAIN
    sreop 182478 0.2 0.0 8728 9772 pts/10 A 10:53:51 3:49 /e/d/g/sre/sre_aix/exe/gprtsorac /e/d/g/sre/sre_aix/exe/gdfxm060.gnt
    sreop 179980 0.1 0.0 27700 16252 - A 10:53:51 3:14 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    sreop 174064 0.1 0.0 27552 16096 - A 10:53:51 3:11 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
  • cooper
    Senior Member
    • Sep 2004
    • 110

    #2
    Originally posted by Franky
    Dear all,

    is it possible to monitor top 10 process with their CPU Usage and with a multi line format for put the values in history.

    For example, i Want to log this type of information with a trapperd item
    ps wwagux |grep -v wait | head -10

    USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND
    sreop 195632 0.4 0.0 27696 16248 - A 10:53:51 8:00 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    sreop 33036 0.3 0.0 27532 16084 - A 10:51:26 6:22 ora_snp5_DSREP2
    sreop 209716 0.3 0.0 1476 1504 - A 10:54:54 6:12 /bin/ksh
    sreop 202808 0.3 0.0 1736 1768 - A 10:54:55 5:39 /bin/ksh
    sreop 195422 0.2 0.0 27696 16248 - A 10:53:51 5:22 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    cft 90576 0.2 0.0 1964 1492 - A Jan 11 28:58 CFTMAIN
    sreop 182478 0.2 0.0 8728 9772 pts/10 A 10:53:51 3:49 /e/d/g/sre/sre_aix/exe/gprtsorac /e/d/g/sre/sre_aix/exe/gdfxm060.gnt
    sreop 179980 0.1 0.0 27700 16252 - A 10:53:51 3:14 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    sreop 174064 0.1 0.0 27552 16096 - A 10:53:51 3:11 oracleDSREP2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    I see 2 possible ways of doing this.

    The first would be to add to your ps statement, and make it something like:
    ps wwagux |grep -v wait | head -10|awk '{print $11" " $3}'
    This would produce the command name and cpu%. You could set this up as a user defined value in zabbix_agentd.conf, and Configure the server to collect this as a text value. Only problem I see here is that I dont think zabbix will handle the multi-line return (I could be wrong, Alexei, please advise)

    The other option would be to create a trapperd monitored item for the server. Call it something like top10[*], and use 1-10 for the *. Again, store it as text. Then use a similar one-liner above to feed the values in via zabbix_sender.
    ps wwagux |grep -v wait | head -n 10 |awk '{s+=1; print "zabbix_server port hostname top["s"]" $11 $3"\n"}'|xargs zabbix_sender

    I am not sure of the order zabbix_sender needs info, but the preceeding one-liner will produce output similar to

    zabbix_sender zabbix_server port hostname top[7] command 3.2

    I know this message seems a little disconnected, but I know the second would work. Its just not that pretty.

    HTH

    cooper

    Comment

    Working...