Giter VIP home page Giter VIP logo

syslog's Introduction

Syslog Server

This Python script implements a simple Syslog server that listens to incoming Syslog messages on port 514 and logs them to a MongoDB database. In addition, the script sends a notification to a Discord channel for Syslog messages with a severity level of 0-3 (Emergency, Alert, Critical, and Error). This server is part of a larger project, which includes several microservices and other components that collectively provide tools to manage on-premise networking devices. The view the cluster architecture and the CI/CD pipeline for deployment, refer to the Cluster Manifest Repository.

Prerequisites

  • Python 3.7 or later
  • A MongoDB database
  • A Discord channel

Getting Started

To run this application, follow these steps:

  • Clone this repository
  • Install the required packages using pip install -r requirements.txt
  • Run the application using python server.py
  • The application will listen on port 514 for syslog messages

Usage

Send a Syslog message to the server by running the following command in a separate terminal window:

echo "<13>Feb  5 17:32:18 mymachine myproc[10]: %% It's time to make the do-nuts." | nc -w 1 -u localhost 514

Signal Handling

The server is designed to handle SIGTERM signals. When the server receives a SIGTERM signal, it will shut down gracefully.

MongoDB Storage

Each incoming syslog message is stored in its own collection within the syslogs database, with the following format:

{
  "level": <severity_level>,
  "severity":  <trap_severity>,
  "message": <trap_message>,
  "client_ip": <client_ip>,
  "created_at": datetime.utcnow(),
}

Discord Alerting

If the severity level of an incoming message is critical (severity <= 3), an alert will be sent to the Discord channel specified in the DISCORDURL environment variable. The alert will include the device IP address, severity level, and the message.

Environmental Variables

Create a .env file in the root directory of the project and set the following environment variables:

MONGOURL=<MongoDB URL>
DISCORDURL=https://discord.com/api/webhooks/<Webhook URL>

syslog's People

Contributors

steffensenchyna avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.