Skip to content

Instantly share code, notes, and snippets.

@vi

vi/Makefile

Last active Aug 29, 2015
Embed
What would you like to do?
I2P daily graph extraction framework
Save I2P-generated bandwidth and other statistics to a set of PNG files.
Each file is a png graph of some I2P stat for the given day.
I2P stat can be useful for monitoring networking reliability on host
(assuming that I2P itself is stable).
Usage:
* set parameters in the beginning of Makefile
* chmod +x auxilary scripts
* `make` will start downloading the pictures
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: get_date_range_from_until date_1 date_2" >&2
echo "Example: get_date_range_from_until 2014-02-27 2013-03-04" >&2
echo " should output 2014-02-27, 2014-02-28, 2014-03-01, 2014-03-02 and 2014-03-03" >&2
exit 1
fi
DATE_FROM=$(date -u --date="$1" +%s)
DATE_TO=$(date -u --date="$2" +%s)
I=$DATE_FROM
while [ $I -lt $DATE_TO ]; do
date -u +'%Y-%m-%d' --date @$I
I=$(expr $I + 3600 \* 24 )
done
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: get_seconds_before_now utc_date" >&2
exit 1
fi
DATE_SPECIFIED=$(date -u --date="$1" +%s )
DATE_NOW=$(date -u +%s)
expr \( $DATE_NOW - $DATE_SPECIFIED \) / 60 - 1440 - 30
#wget 'http://127.0.0.1:7657/viewstat.jsp?stat=tunnel.participatingTunnels&showEvents=false&period=60000&periodCount=1500&end=1744&width=2400&height=600' -O 2014-03-01.png
INITIAL_DAY=2014-01-28
WIDTH=1200
HEIGHT=600
ADDR=http://127.0.0.1:7657
DATE_NOW=$(date -u +'%Y-%m-%d')
DATES=$(shell ./get_date_range_from_until ${INITIAL_DAY} ${DATE_NOW})
TARGETS=$(shell for i in ${DATES}; do \
echo $${i}.pt.png; \
echo $${i}.pe.png; \
echo $${i}.bw.png; \
done)
PT_COMMAND=wget "${ADDR}/viewstat.jsp?stat=tunnel.participatingTunnels&showEvents=false&period=60000&periodCount=1500&width=${WIDTH}&height=${HEIGHT}"
PE_COMMAND=wget "${ADDR}/viewstat.jsp?stat=router.activePeers&showEvents=false&period=60000&periodCount=1500&width=${WIDTH}&height=${HEIGHT}"
BW_COMMAND=wget "${ADDR}/viewstat.jsp?stat=bw.combined&showEvents=false&period=60000&periodCount=1500&width=${WIDTH}&height=${HEIGHT}"
all: ${TARGETS}
%.pt.png:
${PT_COMMAND}"&end=$(shell ./get_number_of_minutes_since_end_of_this_day $(subst .pt.png, '', $@))" -O $@
%.pe.png:
${PE_COMMAND}"&end=$(shell ./get_number_of_minutes_since_end_of_this_day $(subst .pe.png, '', $@))" -O $@
%.bw.png:
${BW_COMMAND}"&end=$(shell ./get_number_of_minutes_since_end_of_this_day $(subst .bw.png, '', $@))" -O $@
print:
@echo ${TARGETS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.