Skip to content

Instantly share code, notes, and snippets.

@zoran
zoran / iota.partners-iri-env-auto-updater.sh
Last active May 27, 2020 19:06
iota.partners-iri-env-auto-updater.sh
#!/usr/bin/env bash
set -euo pipefail
readonly NODE_PATH="/home/iota/node"
readonly IOTA_ENV_FILE="$NODE_PATH/iota.env"
readonly SCRIPT_NAME=$(basename $0)
function get_latest_github_release {
curl -s https://api.github.com/repos/iotaledger/iri/releases/latest | jq "[.assets][0][2].name" --raw-output
@zoran
zoran / jvm_opts.sh
Last active April 11, 2019 09:47
Return reasonable JVM options
#!/usr/bin/env bash
CGROUPS_MEM=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
MEMINFO_MEM=$(($(awk '/MemTotal/ {print $2}' /proc/meminfo)*1024))
MEM=$(($MEMINFO_MEM>$CGROUPS_MEM?$CGROUPS_MEM:$MEMINFO_MEM))
JVM_HEAP_RATIO=${JVM_HEAP_RATIO:-0.5}
XMX=$(awk '{printf("%d",$1*$2/1024^2)}' <<<" ${MEM} ${JVM_HEAP_RATIO} ")
echo "-Xmx${XMX}m"
@zoran
zoran / field-dashboard.json
Created August 31, 2018 14:27
field-dashboard.json
{"dashboard":{"__inputs":[{"name":"Prometheus","label":"Prometheus","description":"","type":"datasource","pluginId":"prometheus","pluginName":"Prometheus"}],"__requires":[{"type":"grafana","id":"grafana","name":"Grafana","version":"5.2.3"},{"type":"panel","id":"graph","name":"Graph","version":"5.0.0"},{"type":"datasource","id":"prometheus","name":"Prometheus","version":"5.0.0"},{"type":"panel","id":"singlestat","name":"Singlestat","version":"5.0.0"}],"annotations":{"list":[{"builtIn":1,"datasource":"Prometheus","enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","limit":100,"name":"Annotations & Alerts","showIn":0,"type":"dashboard"}]},"editable":false,"gnetId":null,"graphTooltip":1,"id":null,"links":[],"panels":[{"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":128,"title":"Common Field Stats","type":"row"},{"cacheTimeout":null,"colorBackground":false,"colorValue":true,"colors":["#299c46","rgba(237, 129, 40, 0.89)","#d44a3a"],"datasource":"Prometheus","decimals":2,"format":"none","gauge":{"maxValue":100,"m
@zoran
zoran / prometheus-dashboard-node.json
Last active November 18, 2018 16:16
prometheus-dashboard-node.json
{"dashboard":{"__inputs":[{"name":"Prometheus","label":"Prometheus","description":"","type":"datasource","pluginId":"prometheus","pluginName":"Prometheus"}],"__requires":[{"type":"grafana","id":"grafana","name":"Grafana","version":"5.2.2"},{"type":"panel","id":"graph","name":"Graph","version":"5.0.0"},{"type":"datasource","id":"prometheus","name":"Prometheus","version":"5.0.0"},{"type":"panel","id":"singlestat","name":"Singlestat","version":"5.0.0"}],"annotations":{"list":[{"builtIn":1,"datasource":"Prometheus","enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"description":"Nearly all default values exported by Prometheus node exporter graphed.","editable":false,"gnetId":1860,"graphTooltip":0,"id":null,"iteration":1535500384018,"links":[],"panels":[{"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":261,"panels":[],"repeat":null,"title":"Basic CPU / Mem / Disk Gauge","type":"row"},{"cacheTimeout":null,"colorBackground":false,"colorValue"
@zoran
zoran / prometheus-dashboard-iota
Last active January 6, 2019 12:10
prometheus-dashboard-iota
{"dashboard":{"__inputs":[{"name":"Prometheus","label":"Prometheus","description":"","type":"datasource","pluginId":"prometheus","pluginName":"Prometheus"},{"name":"127.0.0.1:9100","type":"constant","label":"Node","value":"127.0.0.1:9100","description":""}],"__requires":[{"type":"grafana","id":"grafana","name":"Grafana","version":"5.2.2"},{"type":"panel","id":"graph","name":"Graph","version":"5.0.0"},{"type":"datasource","id":"prometheus","name":"Prometheus","version":"5.0.0"},{"type":"panel","id":"singlestat","name":"Singlestat","version":"5.0.0"}],"annotations":{"list":[{"builtIn":1,"datasource":"-- Grafana --","enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"description":"","editable":false,"gnetId":null,"graphTooltip":1,"id":null,"iteration":null,"links":[],"panels":[{"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":93,"panels":[],"repeat":null,"title":"IRI Node Stats","type":"row"},{"cacheTimeout":null,"colorBackground":false,"co
04e5f962a0d64dfba97cb19871d171bfc9cc472c49d373a121a1b37f5466d6b133574d6c87ecda8d0d9a75e8ee6efdfefca8ca0fca2a10bffb85a24a156e709b2a;pkshankle
@zoran
zoran / iota.partners-iri-auto-updater.sh
Last active January 11, 2019 21:39
IOTA IRI Auto Update
#!/usr/bin/env bash
set -euo pipefail
readonly SYSTEMD_CONFIG="/lib/systemd/system/iota.service"
readonly SCRIPT_NAME=$(basename $0)
function get_latest_github_release {
curl -s https://api.github.com/repos/iotaledger/iri/releases/latest | jq "[.assets][0][0].name" --raw-output
}
@zoran
zoran / .dockerrc.sh
Created September 22, 2016 14:22
docker start/stop script
function docker-start {
typeset vm=${1:-default} sts
case $vm in
-h|--help)
echo $'usage: docker-start [<vm>]\n\nEnsures that the specified/default Docker VM is started\nand the environment is initialized.'
return 0
;;
esac
sts=$(docker-machine status "$vm") || return
[[ $sts == 'Running' ]] && echo "(Docker VM '$vm' is already running.)" || {