A C application that monitors Docker containers and sends notifications when they stop running. The application checks a list of specified containers and sends alerts to a Rocket.Chat channel when any container is found to be stopped.
- Monitors multiple Docker containers simultaneously
- Configurable container list via TOML configuration
- Sends notifications to Rocket.Chat with container name and server IP
- Environment variable support for API authentication
- Automatic retry mechanism with configurable intervals
- C compiler (GCC recommended)
- CMake (version 3.10 or higher)
- libcurl
- Docker
- Linux/Unix environment (for Docker commands)
The project uses the following external libraries:
- libcurl: For making HTTP requests
- tomlc99: For parsing TOML configuration files
- dotenv: For loading environment variables
- Clone the repository:
git clone [repository-url]
cd [repository-name]- Create a build directory and build the project:
mkdir build
cd build
cmake ..
makeThe executable will be created in build/bin/notifica-rabbit
Create a .env file in the project root with the following variables:
XAUTH=your_rocket_chat_auth_token
XUSER=your_rocket_chat_user_id
Create a config.toml file in the project root with the following structure:
[list]
enabled = true
processes = ["container1", "container2", "container3"]enabled: Set totrueto enable monitoringprocesses: Array of container names to monitor
- Set up your environment variables and configuration files
- Run the executable:
./build/bin/notifica-rabbitThe program will:
- Check the status of configured containers every 100 seconds
- Send a notification to the specified Rocket.Chat channel when a container is found stopped
- Include the container name and server IP in the notification
Notifications are sent to the Rocket.Chat channel in the following format:
Container [container_name] PARADO @pedro.afonso (IP: [server_ip])
- The program will retry every 5 seconds if it fails to check container status
- Failed API requests are logged to stderr
- Invalid configurations will cause the program to exit with an error message
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
MIT License
Pedro Afonso