1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
Chl 6956971a89 nagios/check_gitea_version.sh: quick and dirty fix scraper 2020-05-14 02:55:35 +02:00
Chl 4e915e750e récup. oldies rrd-resize-double 2020-05-14 02:55:30 +02:00
2 changed files with 46 additions and 1 deletions

View File

@ -8,7 +8,7 @@ set -e
# note: some local problems with IPv4, the quickest way was to force IPv6.
LOCAL_VERSION="$( wget -6 -O - -q "https://$( hostname -f )/api/v1/version" | sed -n 's/{"version":"\([^"]\+\)"}/\1/p' )"
UPSTREAM_VERSION="$( wget -q -O - "https://dl.gitea.io/gitea/" | egrep -o -- '<a href="/gitea/[0-9]+\.[0-9]+\.[0-9]+/"' | egrep -o "[0-9]+\.[0-9]+\.[0-9]+" | sort --version-sort | tail -n 1 )"
UPSTREAM_VERSION="$( wget -q -O - "https://dl.gitea.io/gitea/" | egrep -- '<a href="/gitea/[0-9]+\.[0-9]+\.[0-9]+/?"' | egrep -o "[0-9]+\.[0-9]+\.[0-9]+" | sort --version-sort | tail -n 1 )"
if [ "$UPSTREAM_VERSION" = "$LOCAL_VERSION" ]; then
echo "OK ($LOCAL_VERSION / $UPSTREAM_VERSION)"

45
oldies/rrd-resize-double.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
# This script simply takes a rrd file and doubles the rows of all its RRA
#
# Result in tmp.rrd
#
# Make backups before any important use !
RESULT_FILENAME="result.rrd"
set -e
if [ ! -f "$1" ]; then
echo "ERROR: no file specified." >&2
exit 1
fi
SRC="$1"
DST="$( dirname "$SRC" )/$RESULT_FILENAME"
# rrdtool seems to always create in current directory
RRD_SPECIAL_FILE="resize.rrd"
if [ -f "$RRD_SPECIAL_FILE" ] || [ -f "$DST" ]; then
echo "ERROR: files with names '$RRD_SPECIAL_FILE' or '$DST' already exist. Trouble ?" >&2
exit 1
fi
# Initial copy
cp -ai "$SRC" "$DST"
# Only use the SRC for enumeration : all the work after that is done on DST
rrdtool info "$SRC" | grep rows | while read LINE; do
RRANUM="$( echo "$LINE" | sed 's/.*\[\([0-9]\+\)\].rows.*/\1/' )"
ROWS="$( echo "$LINE" | sed 's/.* = //' )"
if [ -z "$RRANUM" ] || [ -z "$ROWS" ]; then
echo "Trouble at the mill." >&2
exit 2
fi
rrdtool resize "$DST" $RRANUM GROW $ROWS && mv "$RRD_SPECIAL_FILE" "$DST"
done
# I often forget this one...
chmod "--reference=$SRC" "$DST"
chown "--reference=$SRC" "$DST"