Created
October 19, 2012 16:58
-
-
Save hcooper/3919323 to your computer and use it in GitHub Desktop.
syslog priority converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Convert encoded syslog values into human-friendly facility and level names | |
| severity_map = { | |
| 0: 'emergency', 1: 'alert', 2: 'critical', 3: 'error', | |
| 4: 'warning', 5: 'notice', 6: 'informational', 7: 'debug' | |
| } | |
| facility_map = { | |
| 0: 'kernel', 1: 'user', 2: 'mail', 3: 'daemon', | |
| 4: 'auth', 5: 'syslog', 6: 'lpr', 7: 'news', 8: 'uucp', | |
| 9: 'clock', 10: 'authpriv', 11: 'ftp', 12: 'ntp', | |
| 13: 'logaudit', 14: 'logalert', 15: 'cron', 16: 'local0', | |
| 17: 'local1', 18: 'local2', 19: 'local3', 20: 'local4', | |
| 21: 'local5', 22: 'local6', 23: 'local7' | |
| } | |
| def convert_syslog_pri(priority): | |
| """ divide by 8 to get facility, calculate the remainder to get severity """ | |
| return (priority/8, priority%8) | |
| facility, severity = convert_syslog_pri(input("Enter encoded syslog value: ")) | |
| print "Facility: %s\nLevel: %s" % (facility_map[facility], severity_map[severity]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment