File tree 6 files changed +107
-0
lines changed
6 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Deployed by ansible
3
+ # See roles/node_exporter/files/db_replication_mon_active
4
+ # active database --> standby
5
+ #
6
+ # Errors are reported as RTT=0
7
+
8
+ set -u
9
+ FN=/run/nodeexp/db_replication_socket.prom
10
+ while true ; do
11
+ socket_rtt=$( ss -ntpi state established ' dst 37.218.242.175' | tr -s " " " \n" | grep ^rtt: | cut -c5- | cut -d' /' -f1)
12
+ socket_rtt=${socket_rtt:- 0}
13
+ ping_rtt=$( ping -w 1 -c 1 10.1.0.1 | tail -n1 | cut -d' /' -f5)
14
+ ping_rtt=${ping_rtt:- 0}
15
+
16
+ cat << EOF > $FN .tmp
17
+ db_replication_rtt{role="active"} $socket_rtt
18
+ ping_rtt{role="active"} $ping_rtt
19
+ EOF
20
+ mv $FN .tmp $FN
21
+ sleep 1
22
+ done
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Deployed by ansible
3
+ # See roles/node_exporter/files/db_replication_mon_standby
4
+ # standby database --> active
5
+ #
6
+ # Errors are reported as RTT=0
7
+
8
+ set -u
9
+ FN=/run/nodeexp/db_replication_socket.prom
10
+ while true ; do
11
+ socket_rtt=$( ss -ntpi state established ' dst 37.218.240.56 dport = 5432' | tr -s " " " \n" | grep ^rtt: | cut -c5- | cut -d' /' -f1)
12
+ socket_rtt=${socket_rtt:- 0}
13
+ ping_rtt=$( ping -w 1 -c 1 10.1.0.2 | tail -n1 | cut -d' /' -f5)
14
+ ping_rtt=${ping_rtt:- 0}
15
+
16
+ cat << EOF > $FN .tmp
17
+ db_replication_rtt{role="standby"} $socket_rtt
18
+ ping_rtt{role="standby"} $ping_rtt
19
+ EOF
20
+ mv $FN .tmp $FN
21
+ sleep 1
22
+ done
Original file line number Diff line number Diff line change 3
3
service :
4
4
name : node_exporter
5
5
state : restarted
6
+
6
7
- name : restart seeksample
7
8
service :
8
9
name : seeksample
9
10
state : restarted
11
+
10
12
- name : restart tcpmetrics
11
13
service :
12
14
name : tcpmetrics
13
15
state : restarted
16
+
17
+ - name : restart db_replication_mon
18
+ service :
19
+ name : db_replication_mon
20
+ state : restarted
21
+
14
22
- name : restart collector-metrics
15
23
service :
16
24
name : collector-metrics
Original file line number Diff line number Diff line change 89
89
dest : /etc/systemd/system/tcpmetrics.service
90
90
when : " 'have_tcpmetrics' in group_names"
91
91
92
+ - name : Install db_replication_mon on active DB
93
+ copy : src=db_replication_mon_active dest=/srv/db_replication_mon mode=0555
94
+ when : " 'db_active' in group_names"
95
+ tags : db_replication_mon
96
+
97
+ - name : Install db_replication_mon on standby DB
98
+ copy : src=db_replication_mon_standby dest=/srv/db_replication_mon mode=0555
99
+ when : " 'db_standby' in group_names"
100
+ tags : db_replication_mon
101
+
102
+ - name : Install db_replication_mon systemd service file
103
+ notify :
104
+ - systemctl daemon-reload
105
+ - restart db_replication_mon
106
+ template :
107
+ src : db_replication_mon.service
108
+ dest : /etc/systemd/system/db_replication_mon.service
109
+ when : " 'db_active' in group_names or 'db_standby' in group_names"
110
+ tags : db_replication_mon
111
+
92
112
- name : Install collector-metrics systemd service file
93
113
notify :
94
114
- restart collector-metrics
Original file line number Diff line number Diff line change
1
+ # Deployed by ansible
2
+ # see roles/node_exporter/templates/db_replication_mon.service
3
+ [Unit]
4
+ Description =DB replication monitor
5
+
6
+ [Service]
7
+ User =root
8
+ Group =root
9
+
10
+ ExecStartPre =/usr/bin/install --owner root --group root --mode 0755 --directory {{ node_exporter_textfiles_path }}
11
+ ExecStart =/srv/db_replication_mon
12
+ KillMode =process
13
+ Restart =always
14
+
15
+ # Hardening
16
+ CapabilityBoundingSet =CAP_SETUID CAP_SETGID CAP_NET_RAW
17
+ SystemCallFilter =~@clock @debug @cpu-emulation @keyring @module @mount @obsolete @raw-io @reboot @swap
18
+ NoNewPrivileges =yes
19
+ PrivateDevices =yes
20
+ PrivateTmp =yes
21
+ ProtectHome =yes
22
+ ProtectSystem =full
23
+ ProtectKernelModules =yes
24
+ ProtectKernelTunables =yes
25
+
26
+ [Install]
27
+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ PostgreSQL metadb database
2
+
3
+ Deploys a temporary traffic forwarder using A VPN
4
+ HKG -> mia-ps-test.ooni.nu -> AMS
5
+
6
+ Runs db_replication_mon.service on HKG and AMS db to monitor the replication
7
+ sudo systemctl status db_replication_mon.service
8
+ sudo journalctl -f -u db_replication_mon
You can’t perform that action at this time.
0 commit comments