tons of updates, should have checked in sooner
[buildscripts] / prometheus
diff --git a/prometheus b/prometheus
new file mode 100755 (executable)
index 0000000..e7e3233
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# I initially was using these
+# https://github.com/cloudalchemy/ansible-prometheus
+# https://github.com/cloudalchemy/ansible-alertmanager
+# https://github.com/cloudalchemy/ansible-node-exporter
+# https://github.com/cloudalchemy/ansible-grafana
+
+# As of trisquel 11, get upstream prom because it has the react ui,
+# which has localtime, and general better usability. alertmanager,
+# changelog seems to show good changes and surely things will just work
+# better with a matching prometheus.
+
+if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
+
+#rsync --delete consoles console_libraries /etc/prometheus
+
+
+while read -r prog tool; do
+  cd /a/opt/${prog}dl
+  url=$(curl -s https://api.github.com/repos/prometheus/$prog/releases/latest | jq -r '.assets[].browser_download_url | match(".*linux-amd64.tar.gz$").string')
+  f=${url##*/}
+  if [[ -e $f ]]; then
+    timestamp=$(stat -c %Y $f)
+  else
+    timestamp=0
+  fi
+  m wget -nv -N $url
+  new_timestamp=$(stat -c %Y $f)
+  if [[ $timestamp != $new_timestamp || ! -e /usr/local/bin/$prog ]]; then
+    ngset
+    to_rm=( !($f) )
+    ngreset
+    if (( ${#to_rm[@]} )); then
+      rm -rf ${to_rm[@]}
+    fi
+    m ex $f
+    dir=${f%.tar.gz}
+    m sudo install $dir/$prog $dir/$tool /usr/local/bin
+    m sudo systemctl restart $prog
+  fi
+done <<'EOF'
+prometheus promtool
+alertmanager amtool
+EOF