X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=sysd-prom-fail-install;h=f25510ef094ce28df9d5cba7e0633bad961aac32;hb=bc712f26afdccd6ecea609edc3705ae719c55b8d;hp=244e0a51f09f1fac594e255848d1f3c24d9f5a7e;hpb=c95baa6003490dcbbda39f5b6340ab68ba121224;p=log-quiet diff --git a/sysd-prom-fail-install b/sysd-prom-fail-install index 244e0a5..f25510e 100755 --- a/sysd-prom-fail-install +++ b/sysd-prom-fail-install @@ -13,17 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -source /a/bin/errhandle/err +# usage: since this is a counter, in prometheus alert manager you will +# need to test something like: rate(node_systemd_unit_result_fail_count[30m]) > 0 + +source /a/bin/bash-bear-trap/bash-bear [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" ser_name=$1 mkdir -p /var/lib/prometheus/node-exporter -f=/var/local/sysd-prom-fail/${ser_name}-result-fail.prom +f=/var/local/sysd-prom-fail/${ser_name}-result.prom -if [[ ! -s /var/lib/prometheus/node-exporter/${ser_name}-result-fail.premerge ]]; then +if [[ ! -s $f ]]; then SERVICE_RESULT=success /usr/local/bin/sysd-prom-fail $ser_name fi @@ -45,3 +48,5 @@ if [[ $out ]]; then systemctl restart $ser_name ||: fi fi + +# todo: make uninstall script