Ad Widget

Collapse

Monitoring CPU without zabbix agent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gert
    Junior Member
    • Jan 2013
    • 4

    #1

    Monitoring CPU without zabbix agent

    I'd like to monitor the CPU usage on a server where I can not install a zabbix agent. However, I can login to that server with SSH.
    So I thought I had found a solution: create an SSH-agent item which connects to that host and executes the 'sar' command.
    And indeed, it does work - except that, several times a day the item becomes 'not supported'. The log file shows errors such as 'Cannot read data from SSH server'.

    Seems like, whenever the system is heavily used the ssh command times out, causing Zabbix to give up - and hence no values are measured until the item is re-enabled. And of course, it's exactly when the server is heavily used that I'd need to monitor and possibly send alerts.

    Is there a better way to retrieve this information? Is there a way to avoid the time-out, or to avoid zabbix from setting the item not-supported?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    There're several ways that come to my mind.
    One work-around could be to define items of type 'Zabbix trapper' and run a similar command like the following one via cron on Zabbix-Proxy/-Server (Not tested. Just to show the idea):
    Code:
    ssh example.com vmstat | awk '$1~/[0-9]/{p="- custom.cpu.";printf p"us "$13"\n"p"sy "$14"\n"p"id "$15"\n"p"wa "$16"\n"p"st "$17"\n"}' | zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -s example.com -i -
    The output of awk should look like:
    Code:
    - custom.cpu.us 7
    - custom.cpu.sy 1
    - custom.cpu.id 89
    - custom.cpu.wa 4
    - custom.cpu.st 0
    which gets finally send in a bulk to Zabbix-Proxy/-Server via zabbix_sender.
    Last edited by BDiE8VNy; 29-04-2013, 13:38. Reason: Removed useless while loop from command

    Comment

    • gert
      Junior Member
      • Jan 2013
      • 4

      #3
      Thanks for that idea, it seems to work.
      I'll have to finetune it still a bit - vmstat without further arguments gives the average since boot, which doesn't necessarily tell a lot about the current state.

      Comment

      • BDiE8VNy
        Senior Member
        • Apr 2010
        • 680

        #4
        I'm sure you already noticed that but I want to be sure.
        I accidentally left 'while read i; do echo $i; done' within the command, what is useless in this context.

        Comment

        Working...