#!/bin/bash
#Version History:
#1.0.00 Added Basic MyWave Monitoring

function Version(){
echo 1.0.00
}


function mywaverunning() {
if lsof -i :8080 | grep -q "java"; then
  echo "mywave running"
 else
  echo "mywave not running"
fi
}

function integrationservicerunning() {
if lsof -i :8081 | grep -q "java"; then
  echo "integration service running"
 else
  echo "integration service not running"
fi
}


function kafkarunning(){
if docker ps |grep -q "mywave-kafka"; then
  echo "Kafka running"
 else
  echo "Kafka not running"
fi
}

function postgresrunning(){
if docker ps |grep -q "mywave-postgres-multi"; then
  echo "Postgres running"
 else
  echo "Postgres not running"
fi
}

function zookeeperrunning(){
if docker ps |grep -q "mywave-zookeeper"; then
  echo "zookeeper running"
 else
  echo "zookeeper not running"
fi
}



case "$1" in
    mywaverunning)
        mywaverunning
        ;;
    integrationservicerunning)
        integrationservicerunning
        ;;
	kafkarunning)
        kafkarunning
        ;;
	postgresrunning)
        postgresrunning
        ;;
	zookeeperrunning)
        zookeeperrunning
        ;;
	Version)
        Version
        ;;
	*)
        echo "Usage: $0 {Version|mywaverunning|integrationservicerunning|kafkarunning|postgresrunning|zookeeperrunning}"
        exit 1
        ;;
esac