Skip to content

tools: Machine audit - backend scripts to run on Nagios server#4357

Open
Haroon-Khel wants to merge 19 commits into
adoptium:masterfrom
Haroon-Khel:machine.audit.server
Open

tools: Machine audit - backend scripts to run on Nagios server#4357
Haroon-Khel wants to merge 19 commits into
adoptium:masterfrom
Haroon-Khel:machine.audit.server

Conversation

@Haroon-Khel

@Haroon-Khel Haroon-Khel commented May 21, 2026

Copy link
Copy Markdown
Contributor
  • commit message has one of the standard prefixes
  • faq.md updated if appropriate
  • other documentation is changed or added (if applicable)
  • playbook changes run through VPC or QPC (if you have access)
  • VPC/QPC not applicable for this PR
  • for inventory.yml changes, bastillion/nagios/jenkins updated accordingly

Re #4334

Backend scripts to run on the Nagios server.

  • machine.list generated by getNodeList.py, pulls machines from jenkins, saves hostname ip and port
  • main.py performs scp onto the machines to pull machines_info.json file, stores in collecedInfo/{node_name}_machine_info.json
  • url username and token provided as command line arguments for now. pass in via .env file

linux_aix_audit.yml executes platforms/linux.py and aix.py on linux and aix nodes
static_docker_audit.yml executes platforms/linux.py on static containers running on dockerhost nodes.
Both playbooks will run in scheduled jobs in AWX

Things i need to do to test this pr:

  • run the scripts in machine_audit/platform on each of our machines (including static docker containers) to generate machine_info.json on each machine
    • Non windows machines
    • Static docker containers
    • Windows - make a playbook for this too
  • Create nagios user on static docker machines
  • Ensure nagios key is on static docker nodes

@karianna karianna requested review from steelhead31 and sxa May 22, 2026 09:34
Comment thread ansible/machine_audit/backend/main.py Outdated
scp_command = [
"scp",
"-P", port,
"-o", "StrictHostKeyChecking=no",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep will likely flag this as an issue, might be worth trying it without this flag.

@Haroon-Khel

Copy link
Copy Markdown
Contributor Author

The nagios server was able to collect the machine_info.json file from 46 of our machines (static nodes included, windows machine excluded for now). Some connection issues, on other failing machines the machine_info.json file wasnt present. Still good progress. All thats left with this pr is the windows machines

============================================================
Collection Summary:
  Successful: 46
  Failed: 67
============================================================
nagios@nagios:~/machine_audit/infrastructure/ansible/machine_audit$ ls -la backend/collectedInfo/
total 200
drwxrwxr-x 2 nagios nagios 4096 Jun  4 17:44 .
drwxrwxr-x 4 nagios nagios 4096 Jun  4 17:39 ..
-rw-r--r-- 1 nagios nagios 2088 Jun  4 17:39 build-marist-rhel8-s390x-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2159 Jun  4 17:39 build-marist-rhel8-s390x-2_machine_info.json
-rw-r--r-- 1 nagios nagios 2296 Jun  4 17:39 build-osuosl-aix72-ppc64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2946 Jun  4 17:39 build-osuosl-aix72-ppc64-2_machine_info.json
-rw-r--r-- 1 nagios nagios 2296 Jun  4 17:39 build-osuosl-aix72-ppc64-3_machine_info.json
-rw-rw-r-- 1 nagios nagios 5239 Jun  4 17:39 machine.list
-rw-r--r-- 1 nagios nagios 2099 Jun  4 17:40 test-aws-rhel8-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2080 Jun  4 17:40 test-azure-rhel10-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2139 Jun  4 17:40 test-azure-ubuntu2404-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 1880 Jun  4 17:41 test-docker-fedora42-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 1875 Jun  4 17:41 test-docker-ubi9-armv8-2_machine_info.json
-rw-r--r-- 1 nagios nagios 1874 Jun  4 17:41 test-docker-ubi9-s390x-1_machine_info.json
-rw-r--r-- 1 nagios nagios 1874 Jun  4 17:41 test-docker-ubi9-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 1867 Jun  4 17:42 test-docker-ubuntu2204-ppc64le-3_machine_info.json
-rw-r--r-- 1 nagios nagios 1866 Jun  4 17:42 test-docker-ubuntu2204-x64-2_machine_info.json
-rw-r--r-- 1 nagios nagios 1864 Jun  4 17:42 test-docker-ubuntu2404-armv7-10_machine_info.json
-rw-r--r-- 1 nagios nagios 1865 Jun  4 17:42 test-docker-ubuntu2404-armv7-1_machine_info.json
-rw-r--r-- 1 nagios nagios 1864 Jun  4 17:42 test-docker-ubuntu2404-armv7-9_machine_info.json
-rw-r--r-- 1 nagios nagios 1864 Jun  4 17:42 test-docker-ubuntu2404-armv8-5_machine_info.json
-rw-r--r-- 1 nagios nagios 1864 Jun  4 17:42 test-docker-ubuntu2404-armv8-6_machine_info.json
-rw-r--r-- 1 nagios nagios 1864 Jun  4 17:42 test-docker-ubuntu2404-ppc64le-2_machine_info.json
-rw-r--r-- 1 nagios nagios 1863 Jun  4 17:42 test-docker-ubuntu2404-s390x-1_machine_info.json
-rw-r--r-- 1 nagios nagios 1863 Jun  4 17:42 test-docker-ubuntu2404-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2092 Jun  4 17:42 test-ibmcloud-rhel8-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2132 Jun  4 17:42 test-marist-rhel7-s390x-2_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:42 test-marist-rhel8-s390x-2_machine_info.json
-rw-r--r-- 1 nagios nagios 1973 Jun  4 17:42 test-marist-sles15-s390x-2_machine_info.json
-rw-r--r-- 1 nagios nagios 2075 Jun  4 17:42 test-marist-sles15-s390x-3_machine_info.json
-rw-r--r-- 1 nagios nagios 2145 Jun  4 17:42 test-marist-ubuntu2204-s390x-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2118 Jun  4 17:42 test-marist-ubuntu2404-s390x-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2304 Jun  4 17:43 test-osuosl-aix72-ppc64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2286 Jun  4 17:43 test-osuosl-aix72-ppc64-2_machine_info.json
-rw-r--r-- 1 nagios nagios 2296 Jun  4 17:43 test-osuosl-aix72-ppc64-5_machine_info.json
-rw-r--r-- 1 nagios nagios 2296 Jun  4 17:43 test-osuosl-aix72-ppc64-6_machine_info.json
-rw-r--r-- 1 nagios nagios 2145 Jun  4 17:43 test-osuosl-ubuntu2404-aarch64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2145 Jun  4 17:43 test-osuosl-ubuntu2404-ppc64le-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2144 Jun  4 17:43 test-osuosl-ubuntu2404-ppc64le-2_machine_info.json
-rw-r--r-- 1 nagios nagios 2145 Jun  4 17:43 test-osuosl-ubuntu2404-ppc64le-3_machine_info.json
-rw-r--r-- 1 nagios nagios 2144 Jun  4 17:43 test-osuosl-ubuntu2404-ppc64le-4_machine_info.json
-rw-r--r-- 1 nagios nagios 2144 Jun  4 17:44 test-osuosl-ubuntu2404-ppc64le-5_machine_info.json
-rw-r--r-- 1 nagios nagios 2089 Jun  4 17:44 test-rhibmcloud-rhel9-x64-1_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:44 test-rise-ubuntu2404-riscv64-3_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:44 test-rise-ubuntu2404-riscv64-4_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:44 test-rise-ubuntu2404-riscv64-6_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:44 test-rise-ubuntu2404-riscv64-7_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:44 test-rise-ubuntu2404-riscv64-8_machine_info.json
-rw-r--r-- 1 nagios nagios 2090 Jun  4 17:44 test-rise-ubuntu2404-riscv64-9_machine_info.json

karianna
karianna previously approved these changes Jun 4, 2026
@Haroon-Khel

Haroon-Khel commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

For windows, copying the machine_info.json file from the remote windows nodes onto the nagios server will be tricky since it wont respond to scp. Can be solved with a playbook which first runs the platform/windows.ps1 script on the windows nodes, and then at the end of the playbook copies the output machine_info.json file to the local host to forward it onto the nagios server's backend/collectedInfo directory

@Haroon-Khel

Copy link
Copy Markdown
Contributor Author

The windows playbook needs these connection variables to run (found in the adoptium windows playbook vars file)

ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants