Skip to main content

Syslog and Trap service API

Project description

Piat Project

PyPI - Python Version PyPI PyPI - Status PyPI - License Codacy Badge

Piat is a syslog and trap listeners APIs which are easy to use, it support syslog parsing for multiple vendors

Installing

pip install piat

Getting Started

Example 1:

to run both listeners/servers use the PiatServer API:

from piat.servers import PiatServer

def syslog_cb(syslog_msg):
    """ callback to be executed on received syslog msg """
    data = syslog_msg.get_dictionary()
    # do something with syslog data
    print(data)

def trap_cb(trap_msg):
    """ callback to be executed on received trap msg """
    data = trap_msg.get_dictionary()
    # do something with trap data
    print(data)

if __name__ == '__main__':
    server = PiatServer(traps_callbacks=[trap_cb],
                        syslog_callbacks=[syslog_cb],
                        trap_community='my_community')
    server.start()

syslog data example :

{'ip': '192.168.1.1',
 'timestamp': 
 '2019-04-28 21:26:40.809271',
 'tag': 'LSD-4-LABEL_RESOURCE',
 'severity': 'warning',
 'facility': 'syslogd',
  'msg': 'label range 100-150 exhausted'}

{'ip': '192.168.1.9',
 'timestamp': '2019-04-28 21:26:41.741839',
 'tag': 'SYS-6-LOGGINGHOST_STARTSTOP',
 'severity': 'informational',
 'facility': 'syslogd',
 'msg': 'Logging to host 192.1.1.8 port 514 started - CLI initiated'}

trap data example :

{'ip': '192.168.1.1',
 'timestamp': '2019-04-28 21:30:11.536344',
 'sysUpTime': '88847929',
 'snmpTrapOID': 'CISCO-SMI::cisco.0.1',
 'snmpTrapAddress': '192.168.1.1',
 'snmpTrapCommunity': 'public',
 'snmpTrapEnterprise': 'CISCO-SMI::cisco',
 'local': 'root',
 'tcpConnState': 'finWait2'}

{'ip': '192.168.1.9',
 'timestamp': '2019-04-28 21:30:11.544577',
 'sysUpTime': '88847996',
 'snmpTrapOID': 'CISCO-SYSLOG-MIB::clogMessageGenerated',
 'snmpTrapAddress': '192.168.1.9',
 'snmpTrapCommunity': 'public',
 'snmpTrapEnterprise': 'CISCO-SYSLOG-MIB::ciscoSyslogMIBNotificationPrefix',
 'clogHistFacility': 'LSD',
 'clogHistSeverity': 'warning',
 'clogHistMsgName': 'LABEL_RESOURCE',
 'clogHistMsgText': 'label range 100-150 exhausted',
 'clogHistTimestamp': '88847996'}

Example 2:

to run only syslog server:

from piat.servers import SyslogServer

def syslog_cb(syslog_msg):
    data = syslog_msg.get_dictionary()
    print(data)
    # do something with syslog data

if __name__ == '__main__':
    server = SyslogServer(callbacks=[syslog_cb])
    server.start()

also you can run only trap server:

from piat.servers import SnmpTrapServer

def trap_cb(trap_msg):
    data = trap_msg.get_dictionary()
    # do something with trap data
    print(data)

if __name__ == '__main__':
    server = SnmpTrapServer(callbacks=[trap_cb],community='my_comm')
    server.start()

Supported Vendors:

  1. Cisco.
  2. Arista.
  3. Juniper.
  4. Huawei.
  5. HP.
  6. F5.
  7. Fortinet.

Features:

  1. you can pass as many callback as you want, all callbacks will be running concurrently in separate threads.
  2. both syslog and trap will be running as an independent process.
  3. you can add more mib dir to be used by the trap server, use add_mib_dir kwarg to pass the mib dir location.
  4. Piat uses pysnmp for trap listening, so if you want to extend the mib support you need to combile the mib files using mibdump.py command provided by pysnmp to combile the new mibs, then add the compiled mibs dir to piat server using add_mib_dir.
  5. we only support Syslog parsing described by rfc3164.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piat-0.0.14.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piat-0.0.14-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file piat-0.0.14.tar.gz.

File metadata

  • Download URL: piat-0.0.14.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15rc1

File hashes

Hashes for piat-0.0.14.tar.gz
Algorithm Hash digest
SHA256 14ad280c99b4a3508324ca34f039e4aab72baa54f74364038ed0bc18ffd59db5
MD5 d4b601bd0912398984a8fa0dc28f1873
BLAKE2b-256 a74196f915c15346ab2759f8cf622ddbaa0f0713c7e152cb3b7614ff5fa45e82

See more details on using hashes here.

File details

Details for the file piat-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: piat-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15rc1

File hashes

Hashes for piat-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 86944cac17cba34894e2d56ee63dd707a2b5dd7b42b8f9f31229b4cc438a1181
MD5 7adc423dea432a80ca4b803abc339fd7
BLAKE2b-256 267549110bf92aee06dba9c4a31d3c134e57dee3d9553372506cf404cb699014

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page