Skip to content

About

A microservice that ingests, persists, and exposes device fault events via REST APIs, WebSockets, and SNMP traps, with RabbitMQ-driven consumption and MSSQL storage. Supports RMA workflows, CSV exports, audit logging, and file server integration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🚨 FMS - Fault Management Service

A microservice developed by Nybsys Inc for managing device fault data. The service supports REST and gRPC interfaces, consumes fault events from RabbitMQ, persists data to MongoDB, and sends SNMP traps.


📁 Project Structure

fms/
├── app/
│   ├── cli-test/                      # CLI tools for manual testing/debugging
│   │   └── test.py
│   ├── consumers/
│   │   └── fault_consumer.py          # RabbitMQ consumer for fault events
│   ├── data_source/
│   │   └── mongo_service.py           # MongoDB connection and access logic
│   ├── models/
│   │   └── model.py                   # Pydantic/ORM models for fault data
│   ├── repository/
│   │   ├── abstract/
│   │   │   └── abstract_fault.py      # Abstract base class for fault repos
│   │   └── fault_repository.py        # Implementation of fault data repo
│   ├── routes/
│   │   ├── grpc/
│   │   │   ├── protos/
│   │   │   │   ├── fault_service.proto      # Proto file for gRPC service
│   │   │   │   ├── fault_service_pb2.py     # Auto-generated (DO NOT EDIT)
│   │   │   │   └── fault_service_pb2_grpc.py# Auto-generated (DO NOT EDIT)
│   │   │   └── grpc_devices.py              # gRPC server logic
│   │   └── rest/
│   │       └── fault_router.py              # FastAPI REST API endpoints
│   ├── services/
│   │   └── [Coming soon or internal logic]
│   ├── utils/
│   │   └── snmp_sender.py             # SNMP trap sender utility
│   ├── docs/                          # Documentation files
│
├── tests/
│   └── test_fault_routes.py          # Unit tests for REST APIs
│
├── .env                              # Environment variables
├── main.py                           # Main entry point
├── requirements.txt                  # Python dependencies
├── README.md                         # This file
├── .gitignore

🚀 Features

  • RabbitMQ Consumer: Listens to fault_queue and processes real-time device fault messages.
  • SNMP Trap Sender: Sends alerts to SNMP managers.
  • REST API (FastAPI): Exposes fault information and endpoints.
  • gRPC Server: Supports high-performance protocol-based communication.
  • MongoDB Integration: Persists structured fault data for querying and analytics.

⚙️ Setup & Installation

1. Clone the Repository

git clone https://github.com/nybsys/fms.git
cd fms

2. Set Up Virtual Environment

python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

3. Install Dependencies

pip install -r requirements.txt

4. Add a .env File

DEVICE_ALARM_REPORT="./device_backups/alarm_reports/"
GRPC_HOST=localhost:50051
SNMP_TRAP_TARGET=192.168.1.1
SNMP_COMMUNITY=public

# RabbitMQ
RABBITMQ_URL=amqp://guest:guest@localhost:5672/
RABBITMQ_QUEUE=fault_queue

# MongoDB
MONGO_URI=mongodb://localhost:27018/
MONGO_DB_NAME=genieacsif
MONGO_FAULTS_COLLECTION=devices

▶️ Running the App

python main.py

Services Started:

  • REST API at http://localhost:8000
  • gRPC server at localhost:50051
  • RabbitMQ consumer (background)
  • SNMP trap sender (background)

📡 REST API Endpoints

Method Endpoint Description
GET / Health check / welcome
GET /faults/... Fault data operations

Swagger UI: http://localhost:8000/docs


🧬 gRPC API

  • Proto: app/routes/grpc/protos/fault_service.proto
  • Server: grpc_devices.py
  • Compiled with: grpcio-tools
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. fault_service.proto

📬 SNMP Integration

  • SNMP trap sent via pysnmp
  • Target & community configured in .env
  • Sent automatically upon critical fault detection

📦 MongoDB Schema

  • Database: genieacsif
  • Collection: devices
  • Fields: Defined in model.py

🧪 Testing

pytest tests/

Tests are located in tests/, currently covering REST routes.


✨ Authors & Credits

  • Developer: Saad Md Minhaz
  • Company: Nybsys Inc
  • Copyright: © 2025

🛡 License

This is a private repository. All rights reserved by Nybsys Inc.


📌 Notes

  • Regenerate gRPC bindings when modifying *.proto files.
  • For production, consider using uvicorn or Docker for deployment.

About

A microservice that ingests, persists, and exposes device fault events via REST APIs, WebSockets, and SNMP traps, with RabbitMQ-driven consumption and MSSQL storage. Supports RMA workflows, CSV exports, audit logging, and file server integration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages