# 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)