Add scan queue execution and listing endpoint.
Run scans in background with progress/status updates and store scan metrics in memory or PostgreSQL. Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed sql/001_init.sql
|
||||
var initSQL string
|
||||
|
||||
func RunMigrations(db *sql.DB) error {
|
||||
_, err := db.Exec(initSQL)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
create table if not exists scan_jobs (
|
||||
id text primary key,
|
||||
name text not null,
|
||||
status text not null check (status in ('queued','running','done','failed','canceled')),
|
||||
cidrs jsonb not null,
|
||||
exclude_ips jsonb not null default '[]'::jsonb,
|
||||
options jsonb not null,
|
||||
progress int not null default 0,
|
||||
stats jsonb not null default '{}'::jsonb,
|
||||
snmp_credentials_id text null,
|
||||
created_at timestamptz not null default now(),
|
||||
started_at timestamptz null,
|
||||
finished_at timestamptz null
|
||||
);
|
||||
|
||||
create index if not exists idx_scan_jobs_created_at on scan_jobs (created_at desc);
|
||||
|
||||
alter table scan_jobs add column if not exists progress int not null default 0;
|
||||
alter table scan_jobs add column if not exists stats jsonb not null default '{}'::jsonb;
|
||||
Reference in New Issue
Block a user