-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install script for network size metric
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
LoadPlugin exec | ||
|
||
<Plugin exec> | ||
Exec "__USER_GROUP__" "__SCRAPERSCRIPT__" | ||
</Plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "[*] Network Size Monitoring installation script" | ||
|
||
##### change paths if necessary for your system | ||
|
||
ROOT_USER=root | ||
|
||
SCRAPER_HOME=/journalreader | ||
SCRAPER_USER=journalreader | ||
SCRAPER_GROUP=systemd-journal | ||
|
||
##### | ||
echo "[*] Checking environment..." | ||
if [ ! -f "/etc/collectd/collectd.conf" ]; then | ||
echo 'Collectd is not installed. Did you do the install_monitoring_debian.sh?' | ||
echo 'Exiting...' | ||
exit | ||
fi | ||
|
||
echo "[*] Creating journal reader user" | ||
sudo -H -i -u "${ROOT_USER}" useradd -d "${SCRAPER_HOME}" -G "${SCRAPER_GROUP}" "${SCRAPER_USER}" | ||
sudo -H -i -u "${ROOT_USER}" mkdir -p "${SCRAPER_HOME}" | ||
sudo -H -i -u "${ROOT_USER}" chown "${SCRAPER_USER}":"${SCRAPER_GROUP}" ${SCRAPER_HOME} | ||
|
||
echo "[*] Installing journal parser script" | ||
curl -s https://raw.githubusercontent.com/bisq-network/bisq/master/pricenode/journalscraper.sh > /tmp/journalscraper.sh | ||
sudo -H -i -u "${ROOT_USER}" install -c -o "${SCRAPER_USER}" -g "${SCRAPER_GROUP}" -m 744 /tmp/journalscraper.sh "${SCRAPER_HOME}/scraperscript.sh" | ||
|
||
echo "[*] Installing collectd config" | ||
curl -s https://raw.githubusercontent.com/bisq-network/bisq/master/pricenode/collectd.conf.snippet > /tmp/collectd.conf.snippet | ||
sudo -H -i -u "${ROOT_USER}" tee -a /etc/collectd/collectd.conf < /tmp/collectd.conf.snippet | ||
sudo -H -i -u "${ROOT_USER}" sed -i -e "s/__USER_GROUP__/${SCRAPER_USER}:${SCRAPER_GROUP}/" /etc/collectd/collectd.conf | ||
sudo -H -i -u "${ROOT_USER}" sed -i -e "s!__SCRAPERSCRIPT__!${SCRAPER_HOME}/scraperscript.sh!" /etc/collectd/collectd.conf | ||
|
||
sudo -H -i -u "${ROOT_USER}" systemctl enable collectd.service | ||
|
||
echo "[*] Restarting services" | ||
sudo -H -i -u "${ROOT_USER}" systemctl restart collectd.service | ||
|
||
echo '[*] Done!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}" | ||
INTERVAL=750 | ||
|
||
last=$(date +"%F %T" -d "$INTERVAL seconds ago") | ||
while true; | ||
do | ||
now=$(date +"%F %T") | ||
|
||
journalctl -u bisq --since="$last" --until="$now" | grep -Eo "getAllMarketPrices.*bisq/[0-9].[0-9].[0-9]" | cut -d / -f 2 | sort | uniq -c | while read -r line; do | ||
number=$(echo "${line}" | cut -d ' ' -f 1); | ||
version=$(echo "${line}" | cut -d \ -f 2); | ||
version=${version//./_}; | ||
echo "PUTVAL $HOSTNAME/requestsPer750Seconds/gauge-v$version interval=$INTERVAL N:$number"; | ||
done | ||
last=$now | ||
|
||
sleep $INTERVAL | ||
done |