Piat Project
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:
- Cisco.
- Arista.:
- Juniper.
- Huawei.
- HP.
- F5.
- Fortinet.
Features:
- you can pass as many callback as you want, all callbacks will be running concurrently in separate threads.
- both syslog and trap will be running as an independent process.
- you can add more mib dir to be used by the trap server, use
add_mib_dirkwarg to pass the mib dir location. - Piat uses
pysnmpfor trap listening, so if you want to extend the mib support you need to combile the mib files usingmibdump.pycommand provided bypysnmpto combile the new mibs, then add the compiled mibs dir to piat server usingadd_mib_dir. - we only support Syslog parsing described by rfc3164.
Release files for piat 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| piat-0.0.15.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| piat-0.0.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.3 kB
Release files / piat-0.0.15.tar.gz
| Download URL | piat-0.0.15.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8eeb06d865ddc272b4267c2a61dc1af3f26b33d1ba13124c6c469e8718f2d5f4
|
|
BLAKE2b-256 checksum How to use checksums |
4d8d1b5c4a08386102bc1cf31c451677140bfae8f5810f1449c54849a41df51e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / piat-0.0.15-py3-none-any.whl
| Download URL | piat-0.0.15-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d53052e79048140198442fcab0126b1d463363bee34c370e64bd8958737b46b0
|
|
BLAKE2b-256 checksum How to use checksums |
0fc7b347d2188dda64c194f94c6a212a7ddfb175540bfe36ffe2124efa67c840
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|