Commit Briefs

e51f05d667 Benjamin Linskey

Delete logs older than one month on each run (main)

This is a quick fix for a ballooning database size.


7e1573cf8c Benjamin Linskey

Fix handling of escaped double quotation mark


d371ce751d Benjamin Linskey

Improve readme

Fixed a typo and clarified dash character usage.


a34bcb6152 Benjamin Linskey

Fix a test

The test_mixed_stdin_and_file_import test was seemingly half-finished.


0191e89378 Benjamin Linskey

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;


fc7d416e19 Benjamin Linskey

Improve -q option handling


983a3692b2 Benjamin Linskey

Add readme


b0205a0d70 Benjamin Linskey

Add makefile dependencies


63645393a3 Benjamin Linskey

Improve usage text


6581fb3e7f Benjamin Linskey

Add license


Branches

Tags

This repository contains no tags

Tree

.gitignorecommits | blame
LICENSEcommits | blame
Makefilecommits | blame
README.mdcommits | blame
import_httpd_logs/
requirements.txtcommits | 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)