{% extends "base.html" %} {% block title %}Data server settings · NEXXVU{% endblock %} {% block head %}{# A1: while root reads the certificate, or applies the approval and restarts the Portal, the page reloads by itself (the stopping process may serve it without its stylesheet; this reload needs neither). #} {% if admin and data and data.server and not data.server.approved and data.server.destination.pending %}{% set dp = data.server.destination %} {% if dp.pending.status != 'requested' %}{% elif not dp.observed %}{% endif %}{% endif %}{% endblock %} {% macro key_panel(k, role) %}
{% if k.get('id') %}
Key ID
{{ k.get('id') }}
Key
{{ k.get('hint') }} (first and last four characters; the key itself is never shown)
Created
{{ (k.get('created') or '')|replace('T',' ')|replace('Z',' UTC') }}
Valid until
{% if k.get('expires') %}{{ k.get('expires')|replace('T',' ')|replace('Z',' UTC') }}{% if k.get('days_left') is not none %} ({{ k.get('days_left') }} days){% endif %}{% else %}no expiry (set up before keys had one){% endif %} {% if k.get('state') == 'expired' %}Expired{% elif k.get('state') in ('renew', 'no-expiry') %}Renew{% else %}Valid{% endif %}

On the data server the same key ID is in /etc/nexxvu/data-server-key.json (root only), and the device's Tools → Data server check compares the two. To renew the key, run that check and apply: a new key is generated on the server and stored in this Portal.

{% else %}

No key recorded yet: use Generate a new key above.

{% endif %}

A notice appears {{ 14 }} days before a key expires; once expired, PostgreSQL refuses it and readings wait on this Portal until it is renewed.

{% endmacro %} {% block content %}

Settings

Data server

This Portal's own PostgreSQL server for monitoring history and logs, so pages stay fast, the history can grow, and updates stay small. Inventory and settings stay on the Portal.

All settings
{% include "_settings_navigation.html" %}
{% if notice %}
{{ notice }}
{% endif %} {% if error %}{% endif %} {% if not admin %}

Only Portal administrators manage the data server.

{% else %}{% set d0 = data %} {% set tab = tab if tab in ('overview', 'connection', 'history', 'logs', 'key') else 'overview' %} {% if tab == 'overview' %}
Connection {% if not d0.server %}Not set up History stays on this Portal. {% elif d0.connected %}Connected {{ d0.server_name }} · TLS · last check {{ (d0.last_check_at or '')[:16]|replace('T',' ') }} {% elif not d0.server.approved %}Approve its address {{ d0.server_name }} {% else %}Not connected {{ d0.last_check_detail or 'Run Check connection.' }}{% endif %} Monitoring history {% if history and history.mode == 'data_server' %}On the data server{% if history.remote %} {{ '{:,}'.format(history.remote.readings_estimate) }} readings · {{ history.remote.days }} days · {{ (history.remote.monitoring_bytes / 1073741824)|round(1) }} GB{% endif %} · {{ '{:,}'.format(history.backlog) }} waiting{% if history.error %} · {{ history.error }}{% endif %} {% elif history and history.mode in ('moving', 'returning') %}{{ 'Moving' if history.mode == 'moving' else 'Coming back' }}{% if history.progress is not none %} {{ history.progress }} %{% endif %} {% else %}On this Portal{% endif %} {% set k = d0.get('key') or {} %}Connection key {% if not d0.server %}No data server. {% elif not k.get('id') %}Generate one open this card, then Generate a new key {% else %}{% if k.get('state') == 'expired' %}Expired{% elif k.get('state') in ('renew', 'no-expiry') %}Renew{% else %}Valid{% endif %} {{ k.get('id') }}{% if k.get('expires') %} · until {{ k.get('expires')[:10] }}{% if k.get('days_left') is not none %} ({{ k.get('days_left') }} days){% endif %}{% endif %}{% endif %} Logs {% if logs_server and logs_server.server %}{% if logs_server.connected %}Logs data server{% else %}Logs data server not connected{% endif %} {{ logs_server.server_name }}{% else %}On the {{ 'data server' if d0.server else 'Portal' }}{% endif %}{% if history %} · kept {{ history.logs_retention_days }} days{% endif %}{% if history and history.remote %} · {{ (history.remote.logs_bytes / 1048576)|round(1) }} MB{% endif %}
{% endif %} {% if tab == 'connection' %}

Status

{% if not d0.server %}

Not set up The Portal keeps its monitoring history in its own database, as before.

    {{ fresh_tag("data:order") }}
  1. Install Ubuntu Server on its own machine, and let this Portal reach it on SSH (22) and PostgreSQL (5432).
  2. Add it as a device: Inventory › Add device › Ubuntu, with an account that may use sudo.
  3. Make this a data server: on that device, Tools › Data server. NEXXVU sets PostgreSQL, TLS, the account and the firewall, and fills in this page.
  4. Approve its certificate here, test the connection and move the monitoring history.

Step by step, with the network rules: Installation guide › Data server.

{% elif d0.connected %}

Connected {{ d0.server_name }} · {{ d0.server.address }}:{{ d0.server.port }} as {{ d0.server.username }}.

{% else %}

Not connected yet {{ d0.last_check_detail or ('Approved: press Check connection.' if d0.server.approved else 'Approve the address below first.') }}

{% endif %} {% if d0.server %}
Last check
{{ (d0.last_check_at or 'never')|replace('T',' ')|replace('Z',' UTC') }}{% if d0.last_check_at %} · {{ 'passed' if d0.last_check_ok else 'failed' }}{% endif %}
Last connected
{{ (d0.last_success_at or 'never')|replace('T',' ')|replace('Z',' UTC') }}
Monitoring history
{% if history and history.mode == 'data_server' %}On the data server (this Portal keeps the last {{ history.local_hours }} hours){% elif history and history.mode == 'moving' %}Moving to the data server{% else %}On this Portal{% endif %}
{% endif %} {% if check %}
{{ check.detail }}
{% endif %} {% set dbs = (check.details.databases if check else (d0.last_check.get('databases') or {})) %} {% if dbs %}
{% for name, r in dbs.items() %}{% endfor %}
DatabaseResultPostgreSQLTLSSizeTime
{{ name }}{% if r.ok %}Ready{% else %}Not ready {{ r.get('error') or 'this account may not create tables here' }}{% endif %}{{ r.get('version') or '–' }}{{ r.get('tls') or '–' }}{% if r.get('bytes') is not none %}{{ (r.bytes / 1048576)|round(1) }} MB{% else %}–{% endif %}{% if r.get('milliseconds') is not none %}{{ r.milliseconds }} ms{% else %}–{% endif %}
{% endif %} {% if d0.server and d0.server.approved %}
{{ fresh_tag("data:check-here") }}Connects with the saved account and the approved certificate, then shows the result here. Nothing is written; no password needed.
{% endif %}
{% if d0.server %}{% set d = d0.server.destination %}

Data server address

{{ d0.server_name }} · {{ d0.server.address }}:{{ d0.server.port }}

{% if d0.server.approved %}

Approved Only this Portal's own account may connect to this address, and only to this certificate.

{% if d.fingerprint %}
Server certificate (SHA-256)
{{ d.fingerprint }}
{% endif %} {% elif d.enabled is defined and not d.enabled %}

This Portal does not use approved addresses, so the data server cannot be approved here.

{% elif d.pending and d.pending.status == 'requested' and d.observed %}

Step 2 of 3 Compare the certificate with the data server, then approve the address.

Server certificate (SHA-256)
{{ d.fingerprint }}

On the data server: sudo openssl x509 -in /etc/ssl/certs/ssl-cert-snakeoil.pem -outform der | sha256sum

The password you sign in to this Portal with, not the database password. The Portal restarts once to apply the address.

{% elif d.pending and d.pending.status == 'requested' %}

NEXXVU is reading the data server's certificate; this page refreshes by itself.

{% elif d.pending %}

Approved. The Portal applies the address and restarts once; this page continues by itself.

{% else %}{% if d.latest and d.latest.status == 'failed' %}

The data server could not be reached: {{ d.latest.failure }}. {% if d.latest.failure == 'connection_refused' %}{{ fresh_tag("data:order") }}The server answered, but nothing accepts connections on port {{ d0.server.port if d0.server else 5432 }} from this Portal: usually it was never made a data server, and its PostgreSQL listens only on the server itself. Add it as a device (Inventory › Add device › Ubuntu), then on that device choose Tools › Data server › Make this a data server; it sets PostgreSQL, TLS and the firewall and fills in this page.{% else %}Check the address, the port, that PostgreSQL has TLS on, and that your router lets this Portal reach it; then save again.{% endif %}

{{ fresh_tag("data:read-again") }}Fixed it on the server? Read it again: NEXXVU connects once more and shows its certificate to approve.

{% endif %}{% endif %}
{% endif %} {% if not d0.server %}
Enter a data server prepared by hand (without Make this a data server) {% else %}
Change the address, account or password

Only when the data server changed. The account and its password are already saved; Check connection above uses them.

{% endif %}

{{ 'Data server' if d0.server else 'Data server prepared by hand' }}

The password is in /root/nexxvu-db-credentials on the data server (sudo cat /root/nexxvu-db-credentials). It is write-only here: stored in the Portal's protected credential store, never shown or logged. Databases used: {{ d0.databases|join(', ') }}.

{% endif %} {% if tab == 'history' %}{% if history and d0.server and d0.server.approved %}{% set hs = history %}

Monitoring history

{% if hs.mode == 'local' %} {% if cost and cost.large %}
{{ fresh_tag("data:move-back-guard") }}This Portal's database is {{ (cost.database_bytes / 1e9)|round(1) }} GB{% if cost.growth_bytes_per_day %} and grows by about {{ (cost.growth_bytes_per_day / 1e9)|round(1) }} GB a day ({{ '{:,}'.format(cost.readings_per_day) }} readings){% endif %}. Every update copies it: an update takes about {{ cost.update_minutes }} minutes now and about {{ cost.update_minutes_week }} in a week. Move the history to the data server to keep only the last {{ hs.local_hours }} hours here.
{% endif %}

The monitoring history is on this Portal. Moving it copies every reading and hourly summary to the data server, oldest first, while monitoring continues. When everything is copied and the counts match, the data server keeps the history and this Portal keeps only the last {{ hs.local_hours }} hours for its live pages; older readings are removed from the Portal only after the data server has them.

{% if d0.connected %}
{% else %}

Run Check connection first; the move starts only on a connected data server.

{% endif %} {% if hs.returned_at %}

The history came back to this Portal on {{ hs.returned_at|replace('T',' ')|replace('Z',' UTC') }} ({{ '{:,}'.format(hs.returned_rows) }} readings).

{% endif %}
Disconnect this data server

NEXXVU forgets the data server: its approved address is revoked (the Portal restarts once) and its registration removed. Its databases stay on the server; remove its device from the inventory and the virtual machine yourself when you no longer need them.

{% elif hs.mode == 'returning' %}

Coming back Bringing readings back to this Portal{% if hs.progress is not none %}: {{ hs.progress }} %{% endif %} ({{ '{:,}'.format(hs.returned_rows) }}{% if hs.return_total %} of {{ '{:,}'.format(hs.return_total) }}{% endif %} readings since {{ (hs.return_cutoff or '')[:10] }}). Monitoring continues; this page refreshes by itself.

{% if hs.progress is not none %}{{ hs.progress }} %{% endif %} {% if hs.error %}

Waiting for the data server: {{ hs.error }}

{% endif %}
{% elif hs.mode == 'moving' %}

Moving Copying readings to the data server{% if hs.progress is not none %}: {{ hs.progress }} %{% endif %}. Monitoring continues; this page refreshes by itself.

{% if hs.progress is not none %}{{ hs.progress }} %{% endif %}
Started
{{ (hs.started_at or '')|replace('T',' ')|replace('Z',' UTC') }}
Still to copy
{{ '{:,}'.format(hs.backlog) }} readings
Last copied
{{ (hs.last_ship_at or 'not yet')|replace('T',' ')|replace('Z',' UTC') }}
{% if hs.error %}

Waiting for the data server: {{ hs.error }}. Readings stay on this Portal and are copied when it answers again.

{% endif %} {% if hs.verification and not hs.verification.get('ok', True) %}

Counts did not match yet ({{ '{:,}'.format(hs.verification.readings_on_data_server) }} of {{ '{:,}'.format(hs.verification.readings_on_portal) }}); copying continues.

{% endif %}
{% else %}

On the data server since {{ (hs.moved_at or '')|replace('T',' ')|replace('Z',' UTC') }}. This Portal keeps the last {{ hs.local_hours }} hours of readings for its live pages; longer periods are read from the data server.

{% if hs.remote %}
On the data server
about {{ '{:,}'.format(hs.remote.readings_estimate) }} readings, {{ hs.remote.days }} days ({{ hs.remote.oldest_day }} to {{ hs.remote.newest_day }}), {{ (hs.remote.monitoring_bytes / 1048576)|round(1) }} MB
{% endif %} {% if hs.remote and hs.remote.get('kinds') %}
What uses the space
{{ fresh_tag("data:runs") }}{% for label, size in hs.remote.kinds %}{{ label }} {{ (size / 1048576)|round(1) }} MB{% if not loop.last %} · {% endif %}{% endfor %}
{% endif %}
Waiting to be sent
{{ '{:,}'.format(hs.backlog) }} readings{% if hs.last_ship_at %} · last sent {{ hs.last_ship_at|replace('T',' ')|replace('Z',' UTC') }}{% endif %}
{% if hs.verification %}
Move verified
{{ '{:,}'.format(hs.verification.get('readings_on_data_server', 0)) }} readings on the data server for {{ '{:,}'.format(hs.verification.get('readings_on_portal', 0)) }} on the Portal; {{ '{:,}'.format(hs.verification.get('summaries_on_data_server', 0)) }} hourly summaries
{% endif %}
Retention
set on the Capacity tab; applied on the data server{% if hs.last_maintenance_at %} (last {{ hs.last_maintenance_at|replace('T',' ')|replace('Z',' UTC') }}){% endif %}
{% if catch_up %}{% set cu = catch_up %}
{{ fresh_tag("data:move-now") }}

The Portal sends new readings every few seconds and keeps the last {{ hs.local_hours }} hours. Waiting now: {{ '{:,}'.format(cu.to_send) }} readings to send, about {{ '{:,}'.format(cu.to_trim) }} older readings to remove from this Portal, {{ (cu.free_bytes / 1e9)|round(1) }} GB to give back to the disk.

{% if cu.running %}

Moving now, without pauses, until nothing is left (at most until {{ (cu.until or '')|replace('T',' ')|replace('Z',' UTC') }}). Monitoring continues; this page refreshes by itself.

{% elif cu.to_send or cu.to_trim or cu.free_bytes %}
Sends, trims and gives the space back at once instead of in the regular rounds, for example before an update.
{% else %}

Nothing waiting: everything older than {{ hs.local_hours }} hours is on the data server.

{% endif %}
{% endif %} {% if hs.error %}

The data server is not answering: {{ hs.error }}. Readings stay on this Portal and are sent when it is back.

{% endif %} {% if hs.remote_error %}

The data server's figures are not available now: {{ hs.remote_error }}

{% endif %}
Keep the history on this Portal again

Brings the last days of readings and every hourly summary back to this Portal; then the history is kept here again and the data server can be disconnected. Monitoring continues meanwhile.

{% if room %}

{{ '{:,}'.format(room.readings) }} readings ({{ room.days }} days) need about {{ (room.bytes / 1e9)|round(1) }} GB on this Portal; {{ (room.free / 1e9)|round(1) }} GB is free{% if not room.enough %}: not enough with the reserve for updates. Choose fewer days or add disk first{% endif %}.

{% endif %}
{% if cost %}

{{ fresh_tag("data:move-back-guard") }}While the history is on this Portal, copying to the data server stops{% if cost.growth_if_local %} and the Portal grows by about {{ (cost.growth_if_local / 1e9)|round(1) }} GB a day ({{ '{:,}'.format(cost.readings_per_day) }} readings){% endif %}. Every update copies the whole database: an update takes about {{ cost.update_minutes }} minutes now and about {{ cost.update_minutes_week }} after a week. Use it only to stop using the data server; to look at older readings, the graphs already read them from the data server.

{% endif %}
{% endif %}
{% else %}

Connect and approve a data server first (Connection tab); the history stays on this Portal until you move it.

{% endif %}{% endif %} {% if tab == 'logs' %}{% if keep %}{% set life_names = {'attack': 'Attack', 'expected': 'Expected', 'unknown': 'Unknown', 'device': 'Device', 'earlier': 'Stored before classes'} %}

{{ fresh_tag("logs:class-retention") }}{{ fresh_tag("data:tabs-fast") }}What is kept

Each class of log line has its own period, removed a whole day at a time, never longer than Keep logs for below or a device's own period on this Portal (Tools › Logs). A held device keeps everything. Lines and space: the last 30 days, all devices.

{% if keep.counting %}

Counting the lines of the last 30 days; open this tab again in a minute to see them. The periods can be changed meanwhile.

{% endif %}
{% for u in keep.usage %}{% endfor %}
ClassKeptLinesSpaceExport
{{ life_names.get(u.life, u.life) }} {% if u.life in keep.days %}{% elif u.life == 'attack' %}{% else %}{% endif %} {{ '{:,}'.format(u.lines) }} {% if u.bytes is not none %}{{ (u.bytes / 1048576)|round(1) }} MB · {% endif %}{{ u.share }} % {% if u.life != 'earlier' %}Download{% endif %}

{{ fresh_tag("logs:hold") }}Hold

For an investigation: a held device loses no log line - no class period, no release of attack lines, and on the data server its lines are kept aside when their day is dropped. When the hold ends, the normal periods apply again.

{% if keep.holds %}
{% for h in keep.holds %}{% endfor %}
DeviceHeld untilReasonByActions
{{ h.name }}{{ h.until|replace('T', ' ')|replace('Z', ' UTC') }}{{ h.reason or '—' }}{{ h.held_by }} Download{% if history and history.mode != 'local' %} · Lines kept aside{% endif %}
{% else %}

No device is held.

{% endif %}
{% endif %}{% if history and d0.server and d0.server.approved %}{% set hs = history %}

Logs

The nexxvu_logs database is ready for device logs (syslog arrives in a coming release){% if logs_server and logs_server.connected %}, on the logs data server {{ logs_server.server_name }}{% endif %}. To keep the logs on a second data server, add it as a device and choose Tools → Data server → Logs only. {% if hs.remote %}It holds {{ hs.remote.log_days }} days, {{ (hs.remote.logs_bytes / 1048576)|round(1) }} MB.{% endif %} Logs older than the period below are removed a whole day at a time.

{% endif %} {% if logs_server and logs_server.server %}{% set ls = logs_server %}{% set ld = ls.server.destination %}

Logs data server

{{ ls.server_name }} · {{ ls.server.address }}:{{ ls.server.port }} keeps this Portal's logs; the monitoring history stays {{ 'on the main data server' if d0.server else 'on this Portal' }}. {% if ls.connected %}Connected{% elif ls.server.approved %}Check the connection{% else %}Approve its address{% endif %}

{% if not ls.server.approved and ld.pending and ld.pending.status == 'requested' and ld.observed %}
Server certificate (SHA-256)
{{ ld.fingerprint }}
{% elif not ls.server.approved and ld.pending %}

NEXXVU is reading or applying the address; this page refreshes by itself.

{% endif %} {% if ls.server.approved %}
{% endif %}

Its connection key

{{ key_panel(ls.get('key') or {}, 'logs') }}
Keep the logs on the main data server again

New logs go to {{ 'the main data server' if d0.server else 'this Portal' }}; the logs already on this server stay there. Its approved address is revoked (the Portal restarts once) and it is no longer protected from removal.

{% endif %} {% if not (logs_server and logs_server.server) %}

For large log volumes, add another Ubuntu server as a device and choose Tools → Data server → Logs only.

{% endif %}{% endif %} {% if tab == 'key' %} {% if ds_device and ds_device.asset %}

Generate a new key on {{ ds_device.asset.name }} with its root or sudo account, in the device's Tools → Data server

{% elif d0.server %}

To generate a key, add the data server ({{ d0.server.address }}) as a device (Inventory → Add device → Ubuntu); its Tools → Data server then has a Generate button.

{% endif %} {% if d0.server %}

Connection key

{{ key_panel(d0.get('key') or {}, 'main') }}{% endif %} {% if not d0.server %}

Set up a data server first.

{% endif %}{% endif %} {% endif %}
{% endblock %} {% block scripts %}{% endblock %}