forked from roidelapluie/icinga-to-graphite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform_perfdata.awk
More file actions
56 lines (48 loc) · 1.33 KB
/
transform_perfdata.awk
File metadata and controls
56 lines (48 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
BEGIN {
FS="\t"
}
# emptying the prefix for each line
prefix_string=""
$8 ~ /[0-9]/ {
#Replace ponctuation marks
gsub(/ /,"_",$3);
gsub(/ /,"_",$4);
gsub(/-/,"_",$3);
gsub(/-/,"_",$4);
gsub(/\./,"_",$3);
gsub(/\./,"_",$4);
split($8, perfdatas, " ");
old_string="";
# We want to trasform 'foo bar=5 bar foo=6' in:
# foo_bar 5
# bar_foo 6
for (i=1; i<=length(perfdatas); i++)
{
# if the prefix is not empty, we add the current perfdata to it
if (prefix_string != "")
{
perfdata=prefix_string "_" perfdatas [i]
}
else
{
perfdata=perfdatas[i]
}
# We check if the perfdata has =
# because some check scripts are using 'foo bar=5 bar foo=6' as perfdatas
if (perfdata ~ /=/)
{
name=gensub(/(.+)=.*/, "\\1", "g", perfdata)
value=gensub(/[^=]*=([0-9.]+).*/, "\\1", "g", perfdata)
if (value != perfdata){
# This is the actual value sent to graphite
print "monitoring.nagios."$3"."$4"."name" "value" "$2
}
# We found actual data, so we can empty the prefix string
prefix_string=""
}
else
{
prefix_string=perfdata
}
}
}