diff options
author | Matthew Jones <mat@matburt.net> | 2014-07-29 17:44:36 +0200 |
---|---|---|
committer | Luke Sneeringer <luke@sneeringer.com> | 2014-07-29 20:17:42 +0200 |
commit | beece8d4444f58a6ffac71e5348f685ec9698ab3 (patch) | |
tree | 801954e6431b85a927e85b8da3dd590b8088c7a5 | |
parent | Websocket Help (diff) | |
download | awx-beece8d4444f58a6ffac71e5348f685ec9698ab3.tar.xz awx-beece8d4444f58a6ffac71e5348f685ec9698ab3.zip |
Add some munin tower monitoring tasks
-rw-r--r-- | awx/main/management/commands/stats.py | 43 | ||||
-rw-r--r-- | config/awx_munin_tower_jobs | 3 | ||||
-rwxr-xr-x | setup.py | 8 | ||||
-rw-r--r-- | tools/scripts/tower_jobs | 27 |
4 files changed, 80 insertions, 1 deletions
diff --git a/awx/main/management/commands/stats.py b/awx/main/management/commands/stats.py new file mode 100644 index 0000000000..a56797f020 --- /dev/null +++ b/awx/main/management/commands/stats.py @@ -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}") + + diff --git a/config/awx_munin_tower_jobs b/config/awx_munin_tower_jobs new file mode 100644 index 0000000000..ff2cc225f8 --- /dev/null +++ b/config/awx_munin_tower_jobs @@ -0,0 +1,3 @@ +[tower_jobs] +user awx + @@ -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 = { diff --git a/tools/scripts/tower_jobs b/tools/scripts/tower_jobs new file mode 100644 index 0000000000..0632b628dc --- /dev/null +++ b/tools/scripts/tower_jobs @@ -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 |