#!/bin/bash

# This script monitors the status of a service and sends a metric to Netdata via statsd
# if the service is not active.

service="__SERVICE__"

status=$(systemctl is-active $service)

if [ "$status" != "active" ]; then
  change_flag=1
else
  change_flag=0
fi

echo "__METRIC_NAME__:$change_flag|g" | nc -u -w 1 localhost 8125
