0

I am trying to graph how many ms a REST command is taking. The command is issued many times a minute. Here is the plugin that I wrote:

#!/bin/bash

#
# Collect stats for the timing of recommendations.
#
logs="/var/www/custhome/logs/play.log"

# CONFIG

if [ "$#" -eq "1" ] && [ "$1" = "config" ]; then
        echo "graph_title Post Recommendation Times"
        echo "graph_category apache"
        echo "graph_info Data is pooled from all sites."
        echo "graph_vlabel ms"
        echo "graph_period ms"
        echo "graph_data_size huge"
        echo "precs.label PostRecommending"
        echo "precs.type GAUGE"
        echo "precs.min 0"
        echo "precs.draw AREA"
        exit
fi

# DATA

precs=(`grep :Post.Recommending /var/www/custhome/logs/play.log | awk '{print $7}'`)

for i in "${precs[@]}"
do
        [ $i -eq 0 ] && continue
        echo "precs.value $i"
done

This is what a typical bunch of lines looks like in the log file:

4:59:17,422 DEBUG ~ colorado:45870:Post Recommending took 1925 millis
15:02:22,588 DEBUG ~ michigan:417550:Post Recommending took 1306 millis
15:02:23,753 DEBUG ~ michigan:417550:Post Recommending took 276 millis
15:02:23,754 DEBUG ~ michigan:417550:Post Recommending took 277 millis
15:05:21,047 DEBUG ~ chicago:1105784:Post Recommending took 2484 millis
15:07:02,275 DEBUG ~ colorado:66199:Post Recommending took 3303 millis

The problem is, the graph is showing the same exact data every time it refreshes - 1.53k ms. This number appears to be an average. What I want to see is a graph that shows all of the values, and it needs to change over time as new data comes in.

Is there a better way to do this in munin? Or some preprocessing that I should do on the data first? Or a different tool entirely to see the results that I need? I'm used to using munin to graph things like the total number of REST calls per second. But I'm having difficulty wrapping my head around how to represent this data.

1 Answer 1

0

I ended up doing this by averaging for each read:

for i in "${recs[@]}"
do
    ((total+=$i))
done

echo "recs.value $((total/${#recs[@]}))"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .