-
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.
Report HS version to pricenode (#4027)
* Report HS version to pricenode In order to evaluate progress on bisq-network/projects#23, the Bisq app reports its hiddenservice version. This change is going to be undone as soon as we do not need the info anymore. * Added hsversion scraper script * Added installer/uninstaller * Cleanup * Fix unit name
- Loading branch information
Showing
5 changed files
with
104 additions
and
2 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
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
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,41 @@ | ||
#!/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 | ||
if ! grep -q "journalreader" /etc/passwd; then | ||
echo 'User not found. Did you run the install_networksize_debian.sh?' | ||
echo 'Exiting...' | ||
exit | ||
fi | ||
|
||
echo "[*] Installing journal parser script" | ||
curl -s https://raw.githubusercontent.com/bisq-network/bisq/master/pricenode/journalscraper_hsversion.sh > /tmp/journalscraper_hsversion.sh | ||
sudo -H -i -u "${ROOT_USER}" install -c -o "${SCRAPER_USER}" -g "${SCRAPER_GROUP}" -m 744 /tmp/journalscraper_hsversion.sh "${SCRAPER_HOME}/scraperscript_hsversion.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}" sed -i -e "s/LoadPlugin exec//" /tmp/collectd.conf.snippet | ||
sudo -H -i -u "${ROOT_USER}" /bin/sh -c "cat /tmp/collectd.conf.snippet >> /etc/collectd/collectd.conf" | ||
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_hsversion.sh!" /etc/collectd/collectd.conf | ||
|
||
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/bash | ||
|
||
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}" | ||
INTERVAL=750 | ||
|
||
last=$(date +"%F %T" -d "$INTERVAL seconds ago") | ||
while true; | ||
do | ||
now=$(date +"%F %T") | ||
|
||
journalctl -u bisq-pricenode --since="$last" --until="$now" | grep -Eo "getAllMarketPrices.*HSv[0-9]" | grep -o "HSv[0-9]" | 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/hsversionStats/gauge-$version interval=$INTERVAL N:$number"; | ||
done | ||
last=$now | ||
|
||
sleep $INTERVAL | ||
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,29 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "[*] Network Size Monitoring removal script" | ||
|
||
##### change paths if necessary for your system | ||
|
||
ROOT_USER=root | ||
|
||
SCRAPER_HOME=/journalreader | ||
|
||
##### | ||
echo "[*] Checking environment..." | ||
if [ ! -f "${SCRAPER_HOME}/scraperscript_hsversion.sh" ]; then | ||
echo 'There is nothing to be removed.' | ||
echo 'Exiting...' | ||
exit | ||
fi | ||
|
||
echo "[*] Removing journal parser script" | ||
sudo -H -i -u "${ROOT_USER}" rm "${SCRAPER_HOME}/scraperscript_hsversion.sh" | ||
|
||
echo "[*] Reverting collectd config" | ||
sudo -H -i -u "${ROOT_USER}" sed -i '/<Plugin exec>.*/ {N;N; s/<Plugin exec>.*scraperscript_hsversion.sh.*<.Plugin>//g}' /etc/collectd/collectd.conf | ||
|
||
echo "[*] Restarting services" | ||
sudo -H -i -u "${ROOT_USER}" systemctl restart collectd.service | ||
|
||
echo '[*] Done!' |