This commit is contained in:
2026-02-20 09:42:55 +02:00
parent c9b0f6f6b4
commit 254802ef95
2 changed files with 74 additions and 0 deletions

View File

@@ -822,6 +822,78 @@
{%- elif (wd_version_clean | default('') | length) > 0 -%}v{{ wd_version_clean }}
{%- else -%}n/a{%- endif -%}
# ----------------------- Dev1 connstats.sh check & publish -----------------------
- name: Dev1 | Check connstats.sh presence
delegate_to: localhost
shell: |
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
"test -f /root/connstats.sh && echo present || echo missing"
register: cs_present
changed_when: false
failed_when: false
ignore_errors: true
- name: Dev1 | Set connstats presence fact
delegate_to: localhost
set_fact:
connstats_present: "{{ (cs_present.stdout | default('') | trim) == 'present' }}"
- name: Dev1 | Read connstats.sh version (SCRIPTVERSION)
when: connstats_present | default(false)
delegate_to: localhost
shell: |
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
"grep -m1 'SCRIPTVERSION' /root/connstats.sh 2>/dev/null | awk -F'=' '{print \$2}' | tr -d '[:space:]' | sed -E 's/^v?([0-9].*)$/\1/'"
register: cs_version_raw
changed_when: false
failed_when: false
ignore_errors: true
- name: Dev1 | Normalize connstats version
delegate_to: localhost
set_fact:
cs_version_clean: "{{ cs_version_raw.stdout | default('') | trim }}"
- name: Dev1 | Compute connstats value
delegate_to: localhost
set_fact:
connstats_value: >-
{%- if not (connstats_present | default(false)) -%}missing
{%- elif (cs_version_clean | default('') | length) > 0 -%}v{{ cs_version_clean }}
{%- else -%}n/a{%- endif -%}
# ----------------------- Scan tracking: Dev1 connstats -----------------------
- name: Scan tracking | Dev1 connstats outcome
delegate_to: localhost
set_fact:
scan_ok: "{{ scan_ok + ['connstats'] }}"
changed_when: false
- name: Publish Dev1 connstats custom field
delegate_to: localhost
uri:
url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost|urlencode }}/{{ rmq_exchange|urlencode }}/publish"
method: POST
user: "{{ rmq_user }}"
password: "{{ rmq_pass }}"
force_basic_auth: true
status_code: 200
headers: { content-type: "application/json" }
body_format: json
body:
properties: { content_type: "application/json" }
routing_key: "{{ control_queue }}"
payload: "{{ {
'inscope_device': (ansible_hostname|default(inventory_hostname)),
'task_name': 'custom_field_set',
'task_add1': 'connstats',
'task_result': connstats_value
} | to_json }}"
payload_encoding: "string"
changed_when: false
# ----------------------- Scan tracking: Dev1 wifidebug -----------------------
- name: Scan tracking | Dev1 wifidebug outcome
delegate_to: localhost

View File

@@ -6,6 +6,8 @@
# Optional: --always-find-offset to calibrate syslog header time via a logger marker
# and (on fresh start / rotation / truncation) build a true last-10-min slice.
SCRIPTVERSION=v1
LOG_SRC="/var/log/messages"
OUT_LOG="/root/connstats.log"
STATE="/tmp/connstats.state"