2015-03-15 21:04:06 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-03-15 21:53:34 +01:00
|
|
|
load_reporter_with_prefix () {
|
2015-03-15 21:04:06 +01:00
|
|
|
local prefix=$1
|
|
|
|
local file=$2
|
2015-03-15 21:53:34 +01:00
|
|
|
# dash will error if this variable is defined as `local`
|
|
|
|
content=$(sed \
|
2015-03-15 21:48:46 +01:00
|
|
|
-e 's/^[[:space:]]*\(init[ ]*()[ ]*{\)/'"$prefix"'\1/' \
|
2015-03-15 21:53:34 +01:00
|
|
|
-e 's/^[[:space:]]*\(report[ ]*()[ ]*{\)/'"$prefix"'\1/' \
|
2015-03-15 21:48:46 +01:00
|
|
|
-e 's/^[[:space:]]*\(terminate[ ]*()[ ]*{\)/'"$prefix"'\1/' \
|
|
|
|
-e 's/^[[:space:]]*\(docs[ ]*()[ ]*{\)/'"$prefix"'\1/' $file)
|
2015-03-15 21:04:06 +01:00
|
|
|
|
|
|
|
eval "$content"
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:53:34 +01:00
|
|
|
load_metric_with_prefix () {
|
2015-03-15 21:04:06 +01:00
|
|
|
local prefix=$1
|
|
|
|
local file=$2
|
2015-03-15 21:53:34 +01:00
|
|
|
|
|
|
|
# dash will error if this variable is defined as `local`
|
|
|
|
content=$(sed \
|
2015-03-15 21:48:46 +01:00
|
|
|
-e 's/^[[:space:]]*\(init[ ]*()[ ]*{\)/'"$prefix"'\1/' \
|
2015-03-15 21:53:34 +01:00
|
|
|
-e 's/^[[:space:]]*\(collect[ ]*()[ ]*{\)/'"$prefix"'\1/' \
|
2015-03-15 21:48:46 +01:00
|
|
|
-e 's/^[[:space:]]*\(terminate[ ]*()[ ]*{\)/'"$prefix"'\1/' \
|
|
|
|
-e 's/^[[:space:]]*\(docs[ ]*()[ ]*{\)/'"$prefix"'\1/' $file)
|
2015-03-15 21:04:06 +01:00
|
|
|
|
|
|
|
eval "$content"
|
2015-03-15 21:53:34 +01:00
|
|
|
}
|