--- - name: Investigate High CPU hosts: all become: true tasks: - name: Gather information on top CPU consuming processes ansible.builtin.command: cmd: 'ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%cpu' register: processes_cpu changed_when: false - name: Gather information on top Memory consuming processes ansible.builtin.command: cmd: 'ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%mem' register: processes_mem changed_when: false - name: Open Incident hosts: all tasks: - name: Create Problem Template # noqa: no-relative-paths ansible.builtin.template: mode: '0644' src: 'cpuhog_ticket.j2' dest: /tmp/cpuhog_details.txt delegate_to: localhost - name: Create SNow Incident servicenow.itsm.incident: instance: '{{ snow_instance }}' state: new caller: "admin" short_description: "CPUHog event detected on: {{ ansible_eda.event.alert.labels.instance }}" description: "A CPUHog was detected on: {{ ansible_eda.event.alert.labels.instance }} that needs to be investigated." impact: high urgency: high delegate_to: localhost register: incident_result - name: Create SNow Problem servicenow.itsm.problem: instance: '{{ snow_instance }}' state: new short_description: "{{ alertmanager_annotations.summary }}" description: "Generator URL: {{ alertmanager_generator_url }}" impact: high urgency: high attachments: - path: /tmp/cpuhog_details.txt name: cpuhog_details.txt type: 'text/plain' register: problem_result delegate_to: localhost - name: Update Incident servicenow.itsm.incident: instance: '{{ snow_instance }}' state: in_progress number: "{{ incident_result.record.number }}" other: problem_id: "{{ problem_result.record.number }}" delegate_to: localhost