blob: 05ac6bfbe821c2dc1a4f4ca5bb9787050af55073 (
plain) (
blame)
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
|
#!/bin/bash
INST="$1"
if [ -z "$1" ]; then
echo "Usage: $0 <gitolite-instance>"
exit 1
fi
REPOS_D="{{ gitolite_base_path }}/$INST/repositories"
if [ ! -d "$REPOS_D" ]; then
echo "instance $INST not found."
exit 2
fi
repos=$(find $REPOS_D -type d -name '*.git')
declare -A results
for repo in $repos; do
echo "*** $repo ***"
git --bare --git-dir "$repo" fsck --full --strict --root
results[$repo]=$?
echo ""
done
if [ -d "/var/lib/prometheus-node-exporter/textfile-collector/" ]; then
echo "reporting results to prometheus"
{
echo "# HELP git_fsck_run Last time git-fsck has been run."
echo "# TYPE git_fsck_run gauge"
echo "git_fsck_run{gitolite_instance=\"$INST\"} $(date +"%s")"
echo ""
echo "# HELP git_fsck_failed Result of git-fsck (0 means OK)."
echo "# TYPE git_fsck_failed gauge"
for repo in "${!results[@]}"; do
repo_name=$(realpath --relative-to "$REPOS_D" "$repo")
echo "git_fsck_failed{repository=\"$repo_name\",gitolite_instance=\"$INST\"} ${results[$repo]}"
done
} | sponge "/var/lib/prometheus-node-exporter/textfile-collector/git-fsck-$INST.prom"
fi
|