- Description:
- Imports OpenBSD httpd forwarded-style logs into an SQLite DB
- Last Change:
- Clone URL:
ssh://anonymous@git.linskey.org/import-httpd-logs
- ECDSA:
SHA256:NGp9Hbafw+cmfseVXcP9q9zBAU0tLvvzRYQEsJdAJDg
- ED25519:
SHA256:Wr25Bc8kREsGVjh7OY+yNRx6hUDD68qr2eKsvPc0y6w
- RSA:
SHA256:egEdHfpk8FWAExkycQm+RmqcfrTovy/joYsa2GDGDt4
Commit Briefs
Delete logs older than one month on each run (main)
This is a quick fix for a ballooning database size.
Improve readme
Fixed a typo and clarified dash character usage.
Fix a test
The test_mixed_stdin_and_file_import test was seemingly half-finished.
Improve indexes
To clean out old junk: drop index if exists log_ua; drop index if exists log_remote_addr_ua; drop idnex if exists log_req_time; drop index if exists log_req; vacuum;
Branches
Tree
| .gitignore | commits | blame |
| LICENSE | commits | blame |
| Makefile | commits | blame |
| README.md | commits | blame |
| import_httpd_logs/ | |
| requirements.txt | commits | blame |
README.md
# OpenBSD httpd log importer This is a simple Python script that imports OpenBSD httpd log files in the "forwarded" format into an SQLite database. It has no dependencies, can handle both plaintext and gzipped files, and is idempotent with respect to individual log records. ## Requirements and installation The script requires the optional Python 3 `sqlite3` module but otherwise has no requirements. You can copy `import_httpd_logs/import_httpd_logs.py` to the location of your choice and invoke it directly as `./import_httpd_logs.py`. ## Usage usage: import_httpd_logs.py [-h] [-f DB_PATH] [-q] [log_path ...] positional arguments: log_path log file path (plaintext or gzipped) (default: None) options: -h, --help show this help message and exit -f DB_PATH database file path (default: logs.db) -q quiet mode: Don't print error message on invalid log line (default: False) If no `log_path` arguments are provided or the dash character (`-`) is provided as a `log_path` argument, log data will be read from stdin. The SQLite database specified by `DB_PATH` (defaulting to `logs.db`) will be updated or created if it does not already exist. When run repeatedly with the same log files, the script will import only those log records whose timestamps are more recent than the most recently imported record in the database. ## Development Run `make` to create a virtual environment with the required development tools. Run `make test` to run the tests and `make lint` to run `flake8` and `mypy`. ## References [httpd.conf(5)](https://man.openbsd.org/httpd.conf.5)
