docs: Add 16, update 2 and remove 2 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 9s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 9s
This commit is contained in:
43
graylog/status.sh
Executable file
43
graylog/status.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# STATUS SCRIPT
|
||||
# The status script is REQUIRED.
|
||||
# It is used to return the status of the service.
|
||||
# Must output exactly one of: Running, Stopped, Error, Unknown
|
||||
|
||||
# Check if main graylog container exists
|
||||
if ! docker ps -a --format "{{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
|
||||
echo "Unknown"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check all container states
|
||||
GRAYLOG_STATE=$(docker inspect -f '{{.State.Status}}' "$CONTAINER_NAME" 2>/dev/null)
|
||||
MONGODB_STATE=$(docker inspect -f '{{.State.Status}}' "${CONTAINER_NAME}_mongodb" 2>/dev/null)
|
||||
OPENSEARCH_STATE=$(docker inspect -f '{{.State.Status}}' "${CONTAINER_NAME}_opensearch" 2>/dev/null)
|
||||
|
||||
# All must be running for "Running" status
|
||||
if [ "$GRAYLOG_STATE" = "running" ] && [ "$MONGODB_STATE" = "running" ] && [ "$OPENSEARCH_STATE" = "running" ]; then
|
||||
echo "Running"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Any stopped means "Stopped"
|
||||
if [ "$GRAYLOG_STATE" = "exited" ] || [ "$GRAYLOG_STATE" = "stopped" ] || \
|
||||
[ "$MONGODB_STATE" = "exited" ] || [ "$MONGODB_STATE" = "stopped" ] || \
|
||||
[ "$OPENSEARCH_STATE" = "exited" ] || [ "$OPENSEARCH_STATE" = "stopped" ]; then
|
||||
echo "Stopped"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Any restarting or paused means "Error"
|
||||
if [ "$GRAYLOG_STATE" = "restarting" ] || [ "$GRAYLOG_STATE" = "paused" ] || \
|
||||
[ "$MONGODB_STATE" = "restarting" ] || [ "$MONGODB_STATE" = "paused" ] || \
|
||||
[ "$OPENSEARCH_STATE" = "restarting" ] || [ "$OPENSEARCH_STATE" = "paused" ]; then
|
||||
echo "Error"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Unknown"
|
||||
Reference in New Issue
Block a user