-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nomis: DSOS-2359: fixngo connected refactor (#398)
* Renamed fixngo connectivity role * fix * fix * Commit changes made by code formatters --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1ab67f6
commit 74ccf87
Showing
21 changed files
with
119 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Check connectivity with a remote host/port using netcat. | ||
|
||
Define a `collectd-connectivity-tests` tag on the AWS instance. In format "hostname1:port1 hostname2:port2 ...". | ||
A collectd_connectivity_test.sh script is spawned to periodically check each hostname:port using netcat. | ||
|
||
The hostname:port will be used as a dimension in cloudwatch: | ||
|
||
Metric type type_instance | ||
collectd_connectivity_test_value exitcode hostname1:port1 | ||
collectd_connectivity_test_value exitcode hostname2:port2 | ||
|
||
The metric value is the netcat exitcode, i.e. 0 if connected, non-zero if not. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
collectd_script_path: /usr/local/bin | ||
collectd_script_name: collectd_connectivity_test | ||
collectd_script_user: ec2-user | ||
collectd_script_interval: 60 | ||
connectivity_test_connect_timeout: 2 |
10 changes: 10 additions & 0 deletions
10
ansible/roles/collectd-connectivity-test/handlers/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: restart collectd | ||
ansible.builtin.service: | ||
name: collectd | ||
state: restarted | ||
|
||
- name: restart plugin script | ||
ansible.builtin.shell: | | ||
pkill -u {{ collectd_script_user }} -f {{ collectd_script_path }}/{{ collectd_script_name }}.sh | ||
failed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
dependencies: | ||
- role: get-ec2-facts | ||
- role: amazon-cloudwatch-agent-collectd |
18 changes: 18 additions & 0 deletions
18
ansible/roles/collectd-connectivity-test/tasks/configure_collectd.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
- name: copy collectd config | ||
ansible.builtin.template: | ||
src: "{{ collectd_script_name }}.conf.j2" | ||
dest: "/etc/collectd.d/{{ collectd_script_name }}.conf" | ||
owner: root | ||
mode: 0644 | ||
notify: | ||
- restart collectd | ||
|
||
- name: copy collectd plugin script | ||
ansible.builtin.template: | ||
src: "{{ collectd_script_name }}.sh.j2" | ||
dest: "{{ collectd_script_path }}/{{ collectd_script_name }}.sh" | ||
owner: root | ||
mode: 0755 | ||
notify: | ||
- restart plugin script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- import_tasks: configure_collectd.yml | ||
tags: | ||
- ec2provision | ||
- ec2patch | ||
when: | ||
- ansible_distribution in ['RedHat', 'OracleLinux'] | ||
- ec2.tags['connectivity-tests'] is defined |
4 changes: 4 additions & 0 deletions
4
ansible/roles/collectd-connectivity-test/templates/collectd_connectivity_test.conf.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LoadPlugin exec | ||
<Plugin exec> | ||
Exec "{{ collectd_script_user }}" "{{ collectd_script_path }}/{{ collectd_script_name }}.sh" | ||
</Plugin> |
28 changes: 28 additions & 0 deletions
28
ansible/roles/collectd-connectivity-test/templates/collectd_connectivity_test.sh.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
# Managed by collectd-connectivity-test ansible role | ||
# If manually editing, just kill script and collectd will respawn | ||
# e.g. pkill -u {{ collectd_script_user }} -f {{ collectd_script_path }}/{{ collectd_script_name }}.sh | ||
|
||
HOSTNAME="${HOSTNAME:-localhost}" | ||
INTERVAL="${INTERVAL:-{{ collectd_script_interval }}}" | ||
CONNECTIVITY_TIMEOUT={{ connectivity_test_connect_timeout }} | ||
|
||
get_targets() { | ||
aws ec2 describe-tags --filters "Name=resource-id,Values={{ ansible_ec2_instance_id }}" "Name=key,Values=connectivity-tests" --query Tags[0].Value --output=text | ||
} | ||
|
||
connectivity_test() { | ||
ip=$(echo $1 | cut -d: -f1) | ||
port=$(echo $1 | cut -d: -f2) | ||
ncat -vzw "$CONNECTIVITY_TIMEOUT" $ip $port | ||
} | ||
|
||
while sleep "$INTERVAL"; do | ||
targets=$(get_targets) | ||
if [[ "$targets" != "None" ]]; then | ||
for target in $targets; do | ||
connectivity_test $target >/dev/null 2>&1 | ||
echo "PUTVAL $HOSTNAME/connectivity_test/exitcode-$target interval=$INTERVAL N:$?" | ||
done | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
ansible/roles/fixngo-connected-metric/tasks/fixngo-connected-metric.yml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
ansible/roles/fixngo-connected-metric/templates/fixngo_connected_metrics.sh.j2
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.