#! /bin/sh
sys="cron ssh rsyslog" # rsyslog shows as syslog, so after ssh
cumulus="arp_refresh clagd lldpd mstpd poed portwd ptmd pwmd smond switchd vxrd vxsnd"
routing="rdnbrd quagga"

systemctl show -p Names,ActiveState,UnitFileState ${sys} ${cumulus} ${routing} | \
  awk 'BEGIN { FS="[=.]" }
/^Names/ {service=$2 }
/^ActiveState/ { active=$2 }
/^UnitFileState/ {
  state=$2
  printf "Service %-12s %-10s %-9s\n", service, state, active
  }
'

[ -f /etc/quagga/daemons -a -r /etc/quagga/daemons ] || exit 0

for srvc in bgpd isisd ospf6d ospfd ripd ripngd zebra; do
  if grep -q "^$srvc=yes" /etc/quagga/daemons
    then state=enabled
    else state=disabled
  fi
  if pidof $srvc > /dev/null
    then active=active
    else active=inactive
  fi
  echo $srvc $state $active
done | awk '{printf "Service %-12s %-10s %-9s\n", $1, $2, $3}'
