Browse Source

Gather different port status on different hosts

Knowing what ports are open, it helps to debug network issues.

Change-Id: Idc777231e85d60fb794ba3905cb2fe5077b87951
Chandan Kumar 2 months ago
parent
commit
6223a72d18
3 changed files with 49 additions and 0 deletions
  1. 43
    0
      listening-port-report.yml
  2. 3
    0
      test-log-collect.sh
  3. 3
    0
      tests/test.yml

+ 43
- 0
listening-port-report.yml View File

@@ -0,0 +1,43 @@
1
+# Copyright 2018, BBC
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+- name: Gather listening ports report
16
+  hosts: all
17
+  become: true
18
+  gather_facts: no
19
+  tasks:
20
+    - name: netstat package is installed
21
+      package:
22
+        name: net-tools
23
+        state: present
24
+
25
+    - name: Gather listening ports
26
+      command: netstat -ln --inet --program
27
+      register: listening_ports
28
+      changed_when: false
29
+
30
+    - name: create report
31
+      copy:
32
+        content: |
33
+          {% for host in ansible_play_hosts %}
34
+          hostname: {{ host }}
35
+          listening_ports:
36
+          {% for port in hostvars[host].listening_ports['stdout_lines'] %}
37
+          {{ port }}
38
+          {% endfor %}
39
+
40
+          {% endfor %}
41
+        dest: /tmp/listening_port_report.txt
42
+      delegate_to: localhost
43
+      run_once: true

+ 3
- 0
test-log-collect.sh View File

@@ -197,6 +197,9 @@ store_artifacts /var/log/ "${WORKING_DIR}/logs/host"
197 197
 # Store the ara sqlite database in the openstack-ci expected path
198 198
 store_artifacts "${TESTING_HOME}/.ara/ansible.sqlite" "${WORKING_DIR}/logs/ara-report/"
199 199
 
200
+# Store netstat report
201
+store_artifacts /tmp/listening_port_report.txt "${WORKING_DIR}/logs/host"
202
+
200 203
 # Verify the integrity of the journal files but do not fail if one of them is not usable
201 204
 echo "Verifying journal files consistency..."
202 205
 find /var/log/journal/ -type f -name "*.journal" -exec bash -c 'sudo journalctl --file={} --verify || true' \;

+ 3
- 0
tests/test.yml View File

@@ -30,3 +30,6 @@
30 30
 
31 31
 # Install Tempest
32 32
 - import_playbook: common/test-install-tempest.yml
33
+
34
+# Gather port status
35
+- import_playbook: common/listening-port-report.yml

Loading…
Cancel
Save