#!/bin/sh

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

if systemctl --quiet is-active identityman ; then
   echo -e "${GREEN}identity manager${NC}"
else
   echo -e "${RED}identity manager${NC}"
fi
#if systemctl --quiet is-active cloudmon ; then
#   echo -e "${GREEN}cloud monitor${NC}"
#else
#   echo -e "${RED}cloud monitor${NC}"
#fi
if systemctl --quiet is-active tunnelmon ; then
   echo -e "${GREEN}tunnel monitor${NC}"
else
   echo -e "${RED}tunnel monitor${NC}"
fi
if systemctl --quiet is-active probemon ; then
   echo -e "${GREEN}probe monitor${NC}"
else
   echo -e "${RED}probe monitor${NC}"
fi
if systemctl --quiet is-active submit-server ; then
   echo -e "${GREEN}submit server${NC}"
else
   echo -e "${RED}submit server${NC}"
fi
if [ -e /etc/systemd/system/jobmon.service ] ; then
   if systemctl --quiet is-active jobmon ; then
      echo -e "${GREEN}job monitor${NC}"
   else
      echo -e "${RED}job monitor${NC}"
   fi
   if systemctl --quiet is-active jobpro ; then
      echo -e "${GREEN}job processor${NC}"
   else
      echo -e "${RED}job processor${NC}"
   fi
   if systemctl --quiet is-active jobstageinput ; then
      echo -e "${GREEN}job input stager${NC}"
   else
      echo -e "${RED}job input stager${NC}"
   fi
   if systemctl --quiet is-active jobexe ; then
      echo -e "${GREEN}job executer${NC}"
   else
      echo -e "${RED}job executer${NC}"
   fi
   if systemctl --quiet is-active jobmetrics ; then
      echo -e "${GREEN}job metrics${NC}"
   else
      echo -e "${RED}job metrics${NC}"
   fi
   if systemctl --quiet is-active jobcachesimtools ; then
      echo -e "${GREEN}job simtool caching${NC}"
   else
      echo -e "${RED}job simtool caching${NC}"
   fi
else
   if systemctl --quiet is-active jobmon ; then
      echo -e "${GREEN}job monitor${NC}"
   else
      echo -e "${RED}job monitor${NC}"
   fi
fi

if [ -e /etc/init.d/condor_grid ] ; then
   if systemctl --quiet is-active condor_grid ; then
      echo -e "${GREEN}condor grid${NC}"
   else
      echo -e "${RED}condor grid${NC}"
   fi
fi
if [ -e /etc/init.d/condor_osg ] ; then
   if systemctl --quiet is-active condor_osg ; then
      echo -e "${GREEN}condor osg${NC}"
   else
      echo -e "${RED}condor osg${NC}"
   fi
fi
