pangolin_exporter

Форк
0
/
postgres-metrics-get-changes.sh 
40 строк · 1.1 Кб
1
#!/bin/bash
2
# Script to parse a text exposition format file into a unique list of metrics
3
# output by the exporter and then build lists of added/removed metrics.
4

5
old_src="$1"
6
if [ ! -d "$old_src" ] ; then
7
    mkdir -p "$old_src"
8
fi
9

10
function generate_add_removed() {
11
    type="$1"
12
    pg_version="$2"
13
    old_version="$3"
14
    new_version="$4"
15
    
16
    if [ ! -e "$old_version" ] ; then
17
        touch "$old_version"
18
    fi
19

20
    comm -23 "$old_version" "$new_version" > ".metrics.${type}.${pg_version}.removed"
21
    comm -13 "$old_version" "$new_version" > ".metrics.${type}.${pg_version}.added"   
22
}
23

24
for raw_prom in $(echo .*.prom) ; do
25
    # Get the type and version
26
    type=$(echo "$raw_prom" | cut -d'.' -f3)
27
    pg_version=$(echo "$raw_prom" | cut -d'.' -f4- | sed 's/\.prom$//g')
28

29
    unique_file="${raw_prom}.unique"
30
    old_unique_file="$old_src/$unique_file"
31

32
    # Strip, sort and deduplicate the label names
33
    grep -v '#' "$raw_prom" | \
34
        rev | cut -d' ' -f2- | \
35
        rev | cut -d'{' -f1 | \
36
        sort | \
37
        uniq > "$unique_file"
38
    
39
    generate_add_removed "$type" "$pg_version" "$old_unique_file" "$unique_file"
40
done
41

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.