11 lines
639 B
Python
11 lines
639 B
Python
#!/usr/bin/env python3
|
|
import pathlib, sqlite3, sys
|
|
p=pathlib.Path(sys.argv[1])
|
|
if not p.is_file():
|
|
print('No database scans yet.'); sys.exit(0)
|
|
with sqlite3.connect(f'file:{p}?mode=ro', uri=True) as db:
|
|
print('Total scans:', db.execute('SELECT count(*) FROM scans').fetchone()[0])
|
|
print('Unique assets:', db.execute('SELECT count(DISTINCT asset_id) FROM scans').fetchone()[0])
|
|
for asset, model, gate, timestamp in db.execute('SELECT asset_id, model, health_gate, scanned_at_unix FROM scans ORDER BY scan_id DESC LIMIT 15'):
|
|
print(f'{asset:14} | {(model or "unknown")[:28]:28} | {gate or "UNKNOWN"} | {timestamp}')
|