For programmers to need to analyze syslog of RFC3164 or RFC5424 by python,this tested source code is useful.
Output is python dictionary format as followings:
- RFC3164
[{‘datetime’: ‘Oct 28 11:46:20’}, {‘hostname’: ‘swata-VF-AD4S’}, {‘message’: ‘systemd[1]: NetworkManager-dispatcher.service: Succeeded.’}], [{‘datetime’: ‘Oct 28 11:47:35’}, {‘hostname’: ‘swata-VF-AD4S’}, {‘message’: ‘kernel: [ 2565.200606] perf: interrupt took too long (4946 > 4943), lowering kernel.perf_event_max_sample_rate to 40250’}]
- RFC5424
[{‘priority’: ’34’}, {‘version’: ‘1’}, {‘datetime’: ‘2021-08-16T22:10:01.000Z’}, {‘hostname’: ‘mymachine’}, {‘message’: ‘myapplication 2017 ID11 BOMmyapplication has started’}]
Specification
ID | STCD_0000000011 |
Language | Python |
Steps | 77 |
Purpose | Analyze syslog . |
Function | Analyze syslog of RFC3164. Analyze syslog of RFC5424. |
Environment | Ubuntu 20.04.4 LTS Anaconda3(Python 3.9.7) IDE : Visual Studio Code |
Restriction | free license You can use source code copy as owner . You can customize and distribute it freely. |
Price | 7 dollars or 700 yen (Pay with PayPal) |
References | https://tex2e.github.io/rfc-translater/html/rfc3164.html https://tex2e.github.io/rfc-translater/html/rfc5424.html https://www.oresamalabo.net/entry/2020/07/19/200717 |
Source Code
Test Result
NO | test case | result |
01 | syslog file of RFC3164 | OK |
02 | syslog file of RFC5424 | OK |
Test Code
*) Modify “path” along your PC environment.
History
10/3/2023 created
Provider Profile
Nick name is “Dead Fish” employed as an engineer in Japan.
I am grad if you need my code.
Thanks !
Download
Get download passwordSTCD_0000000011
1 file(s) 0.18 KB
Following files and data are zipped.
├── SysLogClass.py ├── syslog_RFC3164.txt └── syslog_RFC5424.txt
Remarks
None
Comments