Ad Widget

Collapse

Monitoring output of long running scripts, e.g. vmstat

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrbox
    Junior Member
    • Aug 2009
    • 6

    #1

    Monitoring output of long running scripts, e.g. vmstat

    How do you do this in Zabbix?

    Official/unofficial documentation seems to suggest that you need to periodically run your script and send the output of each instance to Zabbix for entry in the database. I want to run one script that sends multiple values, each new line being record in the database.

    For instance, how would I monitor the "api" column in a long running vmstat:

    root@cactimel1:[/]# vmstat -p 5
    memory page executable anonymous filesystem
    swap free re mf fr de sr epi epo epf api apo apf fpi fpo fpf
    109279344 51177344 24 133 0 0 0 0 0 0 2 0 0 1 0 0
    107555872 49561024 4 8 0 0 0 0 0 0 0 0 0 0 0 0
    107548408 49552632 3 3 0 0 0 0 0 0 0 0 0 0 0 0
    107555856 49561008 3 3 0 0 0 0 0 0 0 0 0 0 0 0
    107555856 49561008 3 3 0 0 0 0 0 0 0 0 0 0 0 0
    107555856 49561008 3 3 0 0 0 0 0 0 0 0 0 0 0 0


    My eventual goal is to have Solaris DTrace scripts outputing very specific statistics to monitor within Zabbix. If this is not possible with Zabbix, perhaps someone is familiar with how this is done in Cacti/rrdtool?
  • igor
    ZABBIX Support Specialist
    • Mar 2009
    • 40

    #2
    Hi! I think that you can use such command to get values from the "api" column:
    vmstat 1 2|tail -n 1|awk '{print $ 11}'

    where

    1 --> is interval 1 sec
    2 --> is how many rows display with vmstat results (2)
    tail -n 1 -->output last n lines
    awk '{print $ 11}' -display value from the 11 column (column "api" in your case)

    So, the full syntax of the command that you should use can be:

    ./zabbix_sender -z <host_IP> -p 10051 -s H1 -k key1 -o `vmstat 1 5|tail -n 1|awk '{print $ 11}'`

    Comment

    • mrbox
      Junior Member
      • Aug 2009
      • 6

      #3
      Hi Igor

      Thanks for your suggestion.

      I can see how this would work for the vmstat example, but there a couple of problems:

      First, placing this command in a while loop means running the vmstat/tail/awk pipe every <interval> seconds. This will create very many fork/execs, especially if the interval is small.

      Second, some of the commands that I want to monitor take greater than <interval> seconds to initialise (i.e. start producing output), so this would not work at all (these are the DTrace scripts I talked about in my initial post).

      One way I could workaround the above, is to output my stats to a file every <interval> seconds and scrape the last line at the same interval from another script. However this would still require sending to Zabbix every <interval> seconds, unless I bulk sent a series of values with a date stamp generated for each line to graph on.

      Does this like it would work to you, I'm not sure if it's possible to send a time stamp to plot the metrics against, rather than at the time they are received by Zabbix?

      Comment

      • igor
        ZABBIX Support Specialist
        • Mar 2009
        • 40

        #4
        Hi!
        Unfortunately there is no such possibility to send timestamps to Zabbix server using zabbix_sender in order to show these timestamps then on the graph, on the graph always will be displayed timestamp when these data has been received by zabbix_server.
        I do not see any problems here to use "vmstat 1 2|tail -n 1|awk '{print $ 11}'" command (you can execute it even each 1-2 seconds) and then send this data to zabbix_server, it will NOT consume many resources.

        Comment

        Working...