summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--awx/main/management/commands/stats.py43
-rw-r--r--config/awx_munin_tower_jobs3
-rwxr-xr-xsetup.py8
-rw-r--r--tools/scripts/tower_jobs27
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
+
diff --git a/setup.py b/setup.py
index 296428ea3b..900f7d3779 100755
--- a/setup.py
+++ b/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 = {
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