-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shifted ldl-pusher out of stat-pusher
- Loading branch information
1 parent
acb323a
commit cd8479e
Showing
11 changed files
with
158 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
#!/usr/bin/env bash | ||
#### Swarm environment also determined in script, from hostname, for settings | ||
DEBUG= | ||
|
||
# get argument if provided | ||
if [[ $1 ]]; then | ||
if [[ $1 == 'debug' ]]; then | ||
DEBUG=1 | ||
fi | ||
fi | ||
|
||
# setup venv | ||
export PYTHONPATH=/home/monitor/github/ukwa-monitor/h3exporter | ||
export PYTHONPATH=~/github/ukwa-monitor/h3exporter | ||
source ${PYTHONPATH}/venv/bin/activate | ||
|
||
# ensure log directory exists | ||
[[ -d ${PYTHONPATH}/logs/ ]] || mkdir ${PYTHONPATH}/logs | ||
|
||
# ensure python libraries installed | ||
cd ${PYTHONPATH} | ||
cd ${PYTHONPATH}/ | ||
pip install -r requirements.txt | ||
|
||
# run h3exporter script | ||
${PYTHONPATH}/h3exporter.py & | ||
exit 0 | ||
|
||
if [[ ${DEBUG} -eq 1 ]]; then | ||
${PYTHONPATH}/h3exporter.py & # if debug argument given, don't push to /dev/null (for live service debugging) | ||
|
||
# ------ | ||
if [[ $(hostname -s) =~ ^(prod|monitor) ]]; then | ||
elif [[ ${HOSTNAME} =~ ^(monitor|prod) ]]; then | ||
${PYTHONPATH}/h3exporter.py > /dev/null & # disable generation of large logs over time | ||
else | ||
${PYTHONPATH}/h3exporter.py & | ||
${PYTHONPATH}/h3exporter.py & | ||
fi |
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,34 @@ | ||
Requirements | ||
============ | ||
|
||
``` | ||
$ python3 -m venv venv | ||
``` | ||
|
||
|
||
LDL VM Monitoring Pusher | ||
======================== | ||
|
||
We've always had difficulties tracking the status of DLS LDL VMs, especially their network connectivity. | ||
|
||
Each LDL VM has a root cronjob that curls "http://ld02:8983/wa/monitor?host=$(hostname -f)" (NLS and NLW going via 'dls-(bsp|lon)-wb02' instead of directly to 'ld02:8983'). (ld02 being 'lduwka-proxy', our WA infrastructure server that routes all LDL requests onwards to our WA services via Apache httpd proxypasses.) | ||
|
||
To set up as a systemctl daemon, as the root user: | ||
* Copy ldl-pusher service file to systemctl directory | ||
* cp ldl-pusher.service /usr/lib/systemd/system/ | ||
|
||
* Reload systemctl | ||
* systemctl daemon-reload | ||
|
||
* Enable and start ldl pusher service | ||
* systemctl enable --now ldl-pusher.service | ||
|
||
|
||
Development and Testing | ||
======================= | ||
|
||
The service can also be ran manually. It is best to do this as the monitor/dev user and from the user account home directory as this most simulates the production systemctl service operation. | ||
|
||
``` | ||
~$ /home/<user account>/github/ukwa-monitor/ldl-pusher/run_ldl_pusher.sh | ||
``` |
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,20 @@ | ||
''' | ||
Common/non-script specific functions | ||
''' | ||
|
||
import logging | ||
|
||
def configure(lvl='INFO'): | ||
logging.basicConfig(format='[%(asctime)s %(funcName)s %(levelname)s] %(message)s', level=lvl) | ||
|
||
def configure_file(eset): | ||
scriptHandler = logging.FileHandler(eset['logfpfn']) | ||
formatter = logging.Formatter("[%(asctime)s %(funcName)s %(levelname)s] %(message)s") | ||
scriptHandler.setFormatter(formatter) | ||
logging.root.addHandler(scriptHandler) | ||
logging.root.setLevel(logging.WARNING) | ||
if eset['loglevel'] == 'ERROR': logging.getLogger().setLevel(logging.ERROR) | ||
elif eset['loglevel'] == 'WARNING': logging.getLogger().setLevel(logging.WARNING) | ||
elif eset['loglevel'] == 'DEBUG': logging.getLogger().setLevel(logging.DEBUG) | ||
else: logging.getLogger().setLevel(logging.INFO) | ||
logger = logging.getLogger('__main__') |
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
2 changes: 0 additions & 2 deletions
2
stat-pusher/ldl-requirements.txt → ldl-pusher/requirements.txt
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 |
---|---|---|
@@ -1,4 +1,2 @@ | ||
python-daemon | ||
lockfile | ||
datetime | ||
prometheus_client |
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,30 @@ | ||
#!/usr/bin/env bash | ||
DEBUG= | ||
|
||
# get argument if provided | ||
if [[ $1 ]]; then | ||
if [[ $1 == 'debug' ]]; then | ||
DEBUG=1 | ||
fi | ||
fi | ||
|
||
# setup venv | ||
export PYTHONPATH=~/github/ukwa-monitor/ldl-pusher | ||
source ${PYTHONPATH}/venv/bin/activate | ||
|
||
# ensure log directory exists | ||
[[ -d ${PYTHONPATH}/logs/ ]] || mkdir ${PYTHONPATH}/logs | ||
|
||
# ensure python libraries installed | ||
cd ${PYTHONPATH}/ | ||
pip install -r requirements.txt | ||
|
||
# run ldl-pusher script | ||
if [[ ${DEBUG} -eq 1 ]]; then | ||
${PYTHONPATH}/ldl-pusher.py & # if debug argument given, don't push to /dev/null (for live service debugging) | ||
|
||
elif [[ ${HOSTNAME} =~ ^(monitor|prod) ]]; then | ||
${PYTHONPATH}/ldl-pusher.py > /dev/null & # disable generation of large logs over time | ||
else | ||
${PYTHONPATH}/ldl-pusher.py & | ||
fi |
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,57 @@ | ||
[dev] | ||
# common | ||
pushgtw = http://monitor-pushgateway.dapi.wa.bl.uk | ||
|
||
# ldl server connection testing | ||
logfpfn = /home/gilh/github/ukwa-monitor/ldl-pusher/logs/ldl-pusher.log | ||
output = /home/gilh/github/ukwa-monitor/ldl-pusher/logs/ldl-pusher.out | ||
loglevel = DEBUG | ||
uid = 1004 | ||
gid = 1004 | ||
hostname = 0.0.0.0 | ||
port = 9119 | ||
# prometheus settings | ||
schedule = 10 | ||
job = ldl_rr | ||
metric = recent_connections | ||
desc = Curl requests from LDL VMs, indicating LDL to WA connectivity | ||
|
||
|
||
|
||
[beta] | ||
# common | ||
pushgtw = http://monitor-pushgateway.bapi.wa.bl.uk | ||
|
||
# ldl server connection testing | ||
logfpfn = /home/monitor/github/ukwa-monitor/ldl-pusher/logs/ldl-pusher.log | ||
output = /home/monitor/github/ukwa-monitor/ldl-pusher/logs/ldl-pusher.out | ||
loglevel = DEBUG | ||
uid = 1000 | ||
gid = 1000 | ||
hostname = 0.0.0.0 | ||
port = 9119 | ||
# prometheus settings | ||
schedule = 20 | ||
job = ldl_rr | ||
metric = recent_connections | ||
desc = Curl requests from LDL VMs, indicating LDL to WA connectivity | ||
|
||
|
||
|
||
[prod] | ||
# common | ||
pushgtw = http://monitor-pushgateway.api.wa.bl.uk | ||
|
||
# ldl server connection testing | ||
logfpfn = /home/monitor/github/ukwa-monitor/ldl-pusher/logs/ldl-pusher.log | ||
output = /home/monitor/github/ukwa-monitor/ldl-pusher/logs/ldl-pusher.out | ||
loglevel = INFO | ||
uid = 1000 | ||
gid = 1000 | ||
hostname = 0.0.0.0 | ||
port = 9119 | ||
# prometheus settings | ||
schedule = 20 | ||
job = ldl_rr | ||
metric = recent_connections | ||
desc = Curl requests from LDL VMs, indicating LDL to WA connectivity |
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 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