Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use telegraf for collecting (some) of the SQL stats, thanks to a prot…
…ip from @erasche
- Loading branch information
Showing
7 changed files
with
171 additions
and
78 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
dbservers_group_templates: | ||
- src: templates/stats/galaxy_db_slurp.sh.j2 | ||
dest: /usr/local/bin/galaxy_db_slurp.sh | ||
owner: root | ||
group: root | ||
mode: '0755' | ||
|
||
telegraf_plugins_extra: | ||
galaxy_db_slurp: | ||
plugin: "exec" | ||
config: | ||
- commands = ["/usr/local/bin/galaxy_db_slurp.sh"] | ||
- timeout = "120s" | ||
- data_format = "influx" | ||
- interval = "1m" | ||
- '[inputs.exec.tags]' | ||
- ' influxdb_database = "{{ galaxy_instance_codename }}_sql"' |
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,28 @@ | ||
--- | ||
|
||
galaxy_instance_codename: main | ||
|
||
stats_slurp: | ||
db_name: galaxy_main | ||
galaxy_handlers: | ||
- main_w3_handler0 | ||
- main_w3_handler1 | ||
- main_w3_handler2 | ||
- main_w4_handler0 | ||
- main_w4_handler1 | ||
- main_w4_handler2 | ||
|
||
telegraf_agent_output: | ||
- type: influxdb | ||
config: | ||
- urls = ["http://stats.galaxyproject.org:8086"] | ||
- database = "system" | ||
- '[outputs.influxdb.tagdrop]' | ||
- ' influxdb_database = ["*"]' | ||
- type: influxdb | ||
config: | ||
- urls = ["http://stats.galaxyproject.org:8086"] | ||
- database = "{{ galaxy_instance_codename }}_sql" | ||
- 'tagexclude = ["influxdb_database"]' | ||
- '[outputs.influxdb.tagpass]' | ||
- ' influxdb_database = ["{{ galaxy_instance_codename }}_sql"]' |
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,13 @@ | ||
--- | ||
|
||
galaxy_instance_codename: test | ||
|
||
stats_slurp: | ||
db_name: galaxy_test | ||
galaxy_handlers: | ||
- test_handler0 | ||
- test_handler1 | ||
- test_handler2 | ||
- test_handler3 | ||
|
||
# test's telegraf output config is in galaxyservers.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
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,93 @@ | ||
#!/bin/bash | ||
## | ||
## This file is maintained by Ansible - CHANGES WILL BE OVERWRITTEN | ||
## | ||
#set -xv | ||
set -e | ||
|
||
function arr2awk() { | ||
t=$(declare -p $1) | ||
eval "declare -A t="${t#*=} | ||
s= | ||
for k in "${!t[@]}"; do | ||
s+="$k=\"\$${t[$k]}\"," | ||
done | ||
echo -n ${s:0:-2} | ||
} | ||
|
||
function query() { | ||
if [ -n "$4" ]; then | ||
psql {{ stats_slurp.db_name }} -c "COPY ($1) TO STDOUT WITH CSV" | awk -F, "{print \"${2},$(arr2awk $4)\" $(arr2awk $3)}" | ||
else | ||
psql {{ stats_slurp.db_name }} -c "COPY ($1) TO STDOUT WITH CSV" | awk -F, "{print \"${2} $(arr2awk $3)}" | ||
fi | ||
} | ||
|
||
|
||
function jobs_queued_internal_by_handler() { | ||
sql=" | ||
SELECT | ||
t.handler AS handler, | ||
coalesce(j.ct, 0) AS ct | ||
FROM | ||
( | ||
SELECT | ||
unnest( | ||
ARRAY['{{ stats_slurp.galaxy_handlers | join("', '") }}'] | ||
) AS handler | ||
) AS t | ||
LEFT OUTER JOIN | ||
( | ||
SELECT | ||
handler AS handler, | ||
count(handler) AS ct | ||
FROM | ||
job | ||
WHERE | ||
state = 'queued' | ||
AND job_runner_external_id IS null | ||
GROUP BY | ||
handler | ||
) AS j | ||
ON | ||
t.handler = j.handler | ||
" | ||
declare -A fields=( [count]=2 ) | ||
declare -A tags=( [handler]=1 ) | ||
query "$sql" "${FUNCNAME[0]}" fields tags | ||
} | ||
|
||
function jobs_queued() { | ||
sql=" | ||
SELECT | ||
sum(CASE WHEN job_runner_external_id IS NOT null THEN 1 ELSE 0 END), | ||
sum(CASE WHEN job_runner_external_id IS null THEN 1 ELSE 0 END) | ||
FROM | ||
job | ||
WHERE | ||
state = 'queued' | ||
" | ||
declare -A fields=( [internal]=2 [external]=1 ) | ||
query "$sql" "${FUNCNAME[0]}" fields | ||
} | ||
|
||
function disk_usage_sum() { | ||
sql=" | ||
SELECT | ||
sum(total_size) | ||
FROM | ||
dataset | ||
WHERE | ||
NOT purged | ||
" | ||
declare -A fields=( [value]=1 ) | ||
query "$sql" "${FUNCNAME[0]}" fields | ||
} | ||
|
||
#for f in "$@"; do | ||
# $f | ||
#done | ||
|
||
jobs_queued_internal_by_handler | ||
jobs_queued | ||
disk_usage_sum |
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