mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Add some munin tower monitoring tasks
This commit is contained in:
parent
945e6d468f
commit
beece8d444
43
awx/main/management/commands/stats.py
Normal file
43
awx/main/management/commands/stats.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2014 Ansible, Inc.
|
||||
# All Rights Reserved
|
||||
|
||||
from optparse import make_option
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import transaction, DatabaseError
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.dateparse import parse_datetime
|
||||
from django.utils.timezone import now, is_aware, make_aware
|
||||
from django.utils.tzinfo import FixedOffset
|
||||
|
||||
# AWX
|
||||
from awx.main.models import *
|
||||
|
||||
class Command(BaseCommand):
|
||||
'''
|
||||
Emits some simple statistics suitable for external monitoring
|
||||
'''
|
||||
|
||||
help = 'Display some simple statistics'
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--stat',
|
||||
action='store',
|
||||
dest='stat',
|
||||
type="string",
|
||||
default="jobs_running",
|
||||
help='Select which stat to get information for'),
|
||||
)
|
||||
|
||||
def job_stats(self, state):
|
||||
return UnifiedJob.objects.filter(status=state).count()
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if options['stat'].startswith("jobs_"):
|
||||
self.stdout.write(str(self.job_stats(options['stat'][5:])))
|
||||
else:
|
||||
self.stdout.write("Supported stats: jobs_{state}")
|
||||
|
||||
|
||||
3
config/awx_munin_tower_jobs
Normal file
3
config/awx_munin_tower_jobs
Normal file
@ -0,0 +1,3 @@
|
||||
[tower_jobs]
|
||||
user awx
|
||||
|
||||
8
setup.py
8
setup.py
@ -16,6 +16,9 @@ build_timestamp = os.getenv("BUILD",datetime.datetime.now().strftime('-%Y%m%d%H%
|
||||
etcpath = "/etc/awx"
|
||||
homedir = "/var/lib/awx"
|
||||
sharedir = "/usr/share/awx"
|
||||
munin_plugin_path = "/etc/munin/plugins/"
|
||||
munin_plugin_conf_path = "/etc/munin/plugin-conf.d"
|
||||
|
||||
if os.path.exists("/etc/debian_version"):
|
||||
webconfig = "/etc/apache2/conf.d"
|
||||
shutil.copy("config/awx-munin-ubuntu.conf", "config/awx-munin.conf")
|
||||
@ -198,7 +201,10 @@ setup(
|
||||
"config/awx-httpd-443.conf",
|
||||
"config/awx-munin.conf",
|
||||
]),
|
||||
("%s" % sharedir, ["tools/scripts/request_tower_configuration.sh"]),
|
||||
("%s" % sharedir, ["tools/scripts/request_tower_configuration.sh",
|
||||
"tools/scripts/tower_jobs"]),
|
||||
("%s" % munin_plugin_path, ["tools/scripts/tower_jobs"]),
|
||||
("%s" % munin_plugin_conf_path, ["config/awx_munin_tower_jobs"]),
|
||||
]
|
||||
),
|
||||
options = {
|
||||
|
||||
27
tools/scripts/tower_jobs
Normal file
27
tools/scripts/tower_jobs
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
multigraph jobs
|
||||
graph_title Running Jobs breakdown
|
||||
graph_vlabel job count
|
||||
graph_category tower
|
||||
running.label Running jobs
|
||||
running.type DERIVE
|
||||
waiting.label Waiting jobs
|
||||
waiting.type DERIVE
|
||||
pending.label Pending jobs
|
||||
pending.type DERIVE
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "running.value "
|
||||
awx-manage stats --stat jobs_running
|
||||
|
||||
printf "waiting.value "
|
||||
awx-manage stats --stat jobs_waiting
|
||||
|
||||
printf "pending.value "
|
||||
awx-manage stats --stat jobs_pending
|
||||
Loading…
x
Reference in New Issue
Block a user