How do I find out if there is a difference between 10% or more between one of these numbers ? I am trying to do this in Bash.. but no luck so far.. Does anyone have an Idea ??
I am trying to create a script for Icinga (Monitoring). I am getting these values from Graphite function. These numbers represent the traffic an application is getting divided on 8 nodes. I just want to make sure the traffic is equally dived on the 8 nodes.. sure I can watch on the LB, but I want to make sure the numbers from the application side are comparebly with the these from the LB.. Does someone know how to compare them ?? I tried already with awk.. didnt work so far..
I guess I didn't ask clearly enough.
Could you please provide a desired output based on the sample input provided.
Also, please show what you've tried so far.
awk '
NR == 1 {
m = M = $1
mn = NR
}
{ if($1 < m) {
m = $1
mn = NR
}
else if($1 > M) M = $1
v[NR] = $1
}
END { printf("minimum: %d, maximum: %d, difference: %.2f%%\n",
m, M, M * 100 / m - 100)
for(i = 1; i <= NR; i++)
if(v / m > 1.1)
printf("Node %d(%d) is %.2f%% of node %d(%d)\n",
i, v, v * 100 / m, mn, m)
}' file
With your sample input, it produces the output:
minimum: 6065, maximum: 6377, difference: 5.14%
If we add the value 6800 to the end of your sample input, it produces:
minimum: 6065, maximum: 6800, difference: 12.12%
Node 9(6800) is 112.12% of node 1(6065)
If we change the 6800 to 5000, it produces the output:
minimum: 5000, maximum: 6377, difference: 27.54%
Node 1(6065) is 121.30% of node 9(5000)
Node 2(6094) is 121.88% of node 9(5000)
Node 3(6348) is 126.96% of node 9(5000)
Node 4(6297) is 125.94% of node 9(5000)
Node 5(6161) is 123.22% of node 9(5000)
Node 6(6377) is 127.54% of node 9(5000)
Node 7(6338) is 126.76% of node 9(5000)
Node 8(6290) is 125.80% of node 9(5000)
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk .
Average is a generic term that, depending on context, can refer to a mean, the median, or the mode of a set of numbers. In some contexts, average and arithmetic mean are synonymous (referring to the sum of a set of numbers divided by the number of elements in the set). In addition to arithmetic mean, there are lots of other means (including, but not limited to, geometric mean, harmonic mean, interquartile mean, quadratic mean, truncated mean).