cloudstore-uncached
Changes
distributed-jmeter/cloudscale/aws_distributed_jmeter.py 224(+113 -111)
distributed-jmeter/cloudscale/tasks.py 54(+42 -12)
distributed-jmeter/conf/celeryd.conf 16(+8 -8)
distributed-jmeter/conf/config.ini 15(+10 -5)
distributed-jmeter/conf/nginx.conf 98(+15 -83)
distributed-jmeter/conf/supervisor.conf 10(+5 -5)
distributed-jmeter/db.sqlite3 0(+0 -0)
distributed-jmeter/fabfile.py 12(+6 -6)
distributed-jmeter/requirements.txt 2(+1 -1)
distributed-jmeter/scripts/meet_sla_req.py 65(+65 -0)
distributed-jmeter/static/js/Chart.min.js 11(+11 -0)
distributed-jmeter/templates/home.html 24(+19 -5)
distributed-jmeter/templates/report.html 22(+17 -5)
distributed-jmeter/webapp/local_settings.py 32(+32 -0)
Details
distributed-jmeter/cloudscale/aws_distributed_jmeter.py 224(+113 -111)
diff --git a/distributed-jmeter/cloudscale/aws_distributed_jmeter.py b/distributed-jmeter/cloudscale/aws_distributed_jmeter.py
index 15e45ce..8d6c465 100644
--- a/distributed-jmeter/cloudscale/aws_distributed_jmeter.py
+++ b/distributed-jmeter/cloudscale/aws_distributed_jmeter.py
@@ -1,20 +1,23 @@
import boto, boto.ec2
+
import sys, os, time
import paramiko
import subprocess
+import select
import logging
-from cloudscale.common.distributed_jmeter import DistributedJmeter
-
+import thread
+from threading import Thread
+from .common.distributed_jmeter import DistributedJmeter
+from scripts.meet_sla_req import check
logger = logging.getLogger(__name__)
class CreateInstance(DistributedJmeter):
- def __init__(self, config_path, cfg, key_pair, key_name, scenario_path, num_slaves):
+ def __init__(self, cfg, scenario_path):
super(CreateInstance, self).__init__(scenario_path)
self.scenario_path = scenario_path
- self.num_slaves = num_slaves
- self.key_pair = key_pair
- self.key_name = key_name
+ self.key_pair = cfg.get('EC2', 'key_pair')
+ self.key_name = cfg.get('EC2', 'key_name')
self.cfg = cfg
self.pid = str(scenario_path.split('/')[-1][:-4])
self.conn = boto.ec2.connect_to_region(self.cfg.get('EC2', 'region'),
@@ -22,99 +25,132 @@ class CreateInstance(DistributedJmeter):
aws_secret_access_key=self.cfg.get('EC2', 'aws_secret_access_key'))
self.create_security_groups()
- slaves = []
+ masters = []
for i in xrange(int(self.cfg.get('EC2', 'num_jmeter_slaves'))):
- instance = self.create_instance("Creating slave instance {0} ...".format(i+1))
- slaves.append(instance)
-
- self.log("Please wait one minute for status checks ...")
- time.sleep(60) # wait for status checks
- self.log("Setting up slaves ...")
- self.setup_slaves(slaves)
- instance = self.create_instance("Creating master instance ... ")
- self.log("Please wait one minute for status checks ...")
- time.sleep(60) # wait for status checks
- self.log("Setting up master ...")
- self.setup_master(slaves, instance)
- #self.write_config(config_path, instance)
+ instance = self.create_instance("Creating master instance {0} ...".format(i+1))
+ time.sleep(30)
+ self.log(instance.ip_address)
+ self.setup_master(instance)
+ masters.append(instance)
+ self.run_masters(masters)
-
- def setup_master(self, slaves, instance):
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-
- #ip_addr = '54.194.221.83'
+ def setup_master(self, instance):
ip_addr = instance.ip_address
- if self.key_pair:
- ssh.connect(ip_addr, username="ubuntu", key_filename=os.path.abspath(self.key_pair))
- else:
- ssh.connect(ip_addr, username="ubuntu", password="root")
+ ssh = self.ssh_to_instance(ip_addr)
scp = paramiko.SFTPClient.from_transport(ssh.get_transport())
dirname = os.path.abspath(os.path.dirname(__file__))
+ _, stdout, _ = ssh.exec_command('rm -rf /home/ubuntu/*')
+ stdout.readlines()
self.log("Transfering jmeter_master.tar.gz ...")
- scp.put( dirname + '/../scripts/jmeter_master.tar.gz', 'jmeter.tar.gz')
+ scp.put( dirname + '/../scripts/jmeter_master.tar.gz', '/home/ubuntu/jmeter.tar.gz')
+
self.log("Transfering JMeter scenario ...")
scp.put( self.scenario_path, 'scenario.jmx')
- self.log("Installing Java 7 on master ...")
- _, stdout, _ = ssh.exec_command("sudo apt-get -y install openjdk-7-jdk; tar xvf jmeter.tar.gz")
+ self.log("Unpacking JMeter ...")
+ _, stdout, _ = ssh.exec_command("tar xvf jmeter.tar.gz")
stdout.readlines()
- ip_addresses = [instance.private_ip_address for instance in slaves]
- # ip_addresses = ['172.31.31.9', '172.31.26.205']
- cmd = "~/jmeter/bin/jmeter -n -t ~/scenario.jmx -R %s -l scenario.jtl -j scenario.log" % ",".join(ip_addresses)
- self.log("Executing your JMeter scenario. This can take a while. Please wait ...")
- stdin, stdout, stderr = ssh.exec_command(cmd)
- # wait for JMeter to execute
+ _, stdout, _ = ssh.exec_command("find . -iname '._*' -exec rm -rf {} \;")
stdout.readlines()
- # get reports
- resultspath = "{0}/../static/results/".format(dirname)
+ def ssh_to_instance(self, ip_addr):
+ ssh = paramiko.SSHClient()
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ if self.key_pair:
+ ssh.connect(ip_addr, username="ubuntu", key_filename=os.path.abspath(self.key_pair))
+ else:
+ ssh.connect(ip_addr, username="ubuntu", password="")
+ return ssh
+
+ def run_masters(self, instances):
tmp_userpath = "/tmp/{0}".format(os.path.basename(self.scenario_path)[:-4])
- os.makedirs(tmp_userpath, 0777)
- scp.get("/home/ubuntu/scenario.log", "{0}/{1}".format(tmp_userpath, "scenario.log"))
- scp.get("/home/ubuntu/scenario.jtl", "{0}/{1}".format(tmp_userpath, "scenario.jtl"))
+
+ dirname = os.path.abspath(os.path.dirname(__file__))
+ resultspath = "{0}/../static/results/".format(dirname)
+
+ if not os.path.exists(tmp_userpath):
+ os.makedirs(tmp_userpath, 0777)
+
+ self.log(resultspath)
+ for instance in instances:
+ self.log("Running JMeter on instance %s" % instance.ip_address)
+ ssh = self.ssh_to_instance(instance.ip_address)
+ cmd = "(~/jmeter/bin/jmeter -n -t ~/scenario.jmx -l scenario.jtl -j scenario.log -Jstartup_threads=%s -Jrest_threads=%s -Jhost=%s;touch finish)" % (self.cfg.get('EC2', 'startup_threads'), self.cfg.get('EC2', 'rest_threads'), self.cfg.get('EC2', 'host'))
+ self.log(cmd)
+ self.log("Executing your JMeter scenario. This can take a while. Please wait ...")
+ stdin, stdout, stderr = ssh.exec_command(cmd)
+
+ i = 1
+ threads = []
+ for instance in instances:
+ t = Thread(target=self.check_instance, args=(i, tmp_userpath, resultspath, instance))
+ t.start()
+ threads.append(t)
+ i+=1
+
+ for t in threads:
+ t.join()
+
+ for instance in instances:
+ self.conn.terminate_instances(instance_ids=[instance.id])
+
+
cmd = "cp -r {0} {1}".format(tmp_userpath, resultspath)
+ self.log(cmd)
p = subprocess.check_output(cmd.split())
+
+ resultspath = resultspath + os.path.basename(self.scenario_path)[:-4]
+ filenames = ["{0}/scenario{1}.log".format(resultspath, j) for j in xrange(1,i)]
+ self.log(filenames)
+ with open("{0}/scenario.log".format(resultspath), 'w') as outfile:
+ for fname in filenames:
+ with open(fname) as infile:
+ for line in infile:
+ outfile.write(line)
+
+ filenames = ["{0}/response-times-over-time{1}.csv".format(resultspath, j) for j in xrange(1, i)]
+ self.log(filenames)
+ with open("{0}/response-times-over-time.csv".format(resultspath), 'w') as outfile:
+ for fname in filenames:
+ with open(fname) as infile:
+ for line in infile:
+ outfile.write(line)
+
+ self.log("<br>".join(check("{0}/response-times-over-time.csv".format(resultspath)).split('\n')))
+
+ self.log("Finished!", fin=True)
+
+
+ def check_instance(self, i, tmp_userpath, resultspath, instance):
+ cmd = "cat finish"
+
+ ssh = self.ssh_to_instance(instance.ip_address)
+ _, _, stderr = ssh.exec_command(cmd)
+
+ while len(stderr.readlines()) > 0:
+ time.sleep(30)
+ ssh.close()
+ ssh = self.ssh_to_instance(instance.ip_address)
+ _, _, stderr = ssh.exec_command(cmd)
+
+ self.log("Finishing thread " + str(i))
+ scp = paramiko.SFTPClient.from_transport(ssh.get_transport())
+ self.log("JMeter scenario finished. Collecting results")
+ scp.get("/home/ubuntu/scenario.log", "{0}/{1}".format(tmp_userpath, "scenario" + str(i) + ".log"))
+ scp.get("/home/ubuntu/scenario.jtl", "{0}/{1}".format(tmp_userpath, "scenario" + str(i) + ".jtl"))
+ scp.get("/home/ubuntu/response-times-over-time.csv", "{0}/{1}".format(tmp_userpath, "response-times-over-time" + str(i) + ".csv"))
scp.close()
ssh.close()
-
- self.log("Finished! You can now download report files.", 1)
- instance_ids = [inst.id for inst in slaves] + [instance.id]
- self.conn.terminate_instances(instance_ids=instance_ids)
-
- def setup_slaves(self, instances):
- for instance in instances:
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-
- if self.key_pair:
- ssh.connect(instance.ip_address, username="ubuntu", key_filename=os.path.abspath(self.key_pair))
- else:
- ssh.connect(instance.ip_address, username="ubuntu", password="root")
-
- scp = paramiko.SFTPClient.from_transport(ssh.get_transport())
- dirname = os.path.abspath(os.path.dirname(__file__))
- self.log("Transfering jmeter_slave.tar.gz ...")
- scp.put( dirname + '/../scripts/jmeter_slave.tar.gz', 'jmeter.tar.gz')
-
- self.log( "Installing Java 7 on slave ..." )
- _, stdout, _ = ssh.exec_command("sudo apt-get -y install openjdk-7-jdk; tar xvf jmeter.tar.gz")
- stdout.readlines()
-
- self.log("Starting jmeter-server ...")
- ssh.exec_command("~/jmeter/bin/jmeter-server &")
- ssh.close()
- scp.close()
-
+
def create_security_groups(self):
self.log( "Creating security groups ..." )
self.create_security_group('cs-jmeter', 'Security group for JMeter', '8557', '0.0.0.0/0')
@@ -141,7 +177,8 @@ class CreateInstance(DistributedJmeter):
def create_instance(self, msg = "Creating EC2 instance"):
self.log(msg)
- res = self.conn.run_instances(self.cfg.get('EC2', 'ami_id'), key_name=self.key_name, instance_type=self.cfg.get('EC2','instance_type'),security_groups=['cs-jmeter', 'ssh'])
+ res = self.conn.run_instances(self.cfg.get('EC2', 'ami_id'), key_name=self.key_name, instance_type=self.cfg.get('EC2','instance_type'),security_groups=['cs-jmeter', 'ssh', 'flask'])
+ time.sleep(30)
self.wait_available(res.instances[0])
instance = self.conn.get_all_instances([res.instances[0].id])[0].instances[0]
return instance
@@ -149,12 +186,12 @@ class CreateInstance(DistributedJmeter):
def wait_available(self, instance):
self.log( "Waiting for instance to become available" )
self.log( "Please wait ..." )
- status = self.conn.get_all_instances([instance.id])[0].instances[0].state
+ status = self.conn.get_all_instances(instance_ids=[instance.id])[0].instances[0].state
i=1
while status != 'running':
if i%10 == 0:
self.log( "Please wait ..." )
- status = self.conn.get_all_instances([instance.id])[0].instances[0].state
+ status = self.conn.get_all_instances(instance_ids=[instance.id])[0].instances[0].state
time.sleep(3)
i=i+1
self.log( "Instance is up and running" )
@@ -163,44 +200,9 @@ class CreateInstance(DistributedJmeter):
def write_config(self, config_path, instance):
self.cfg.save_option(config_path, 'infrastructure', 'remote_user', 'ubuntu')
self.cfg.save_option(config_path, 'infrastructure', 'ip_address', instance.ip_address)
- # f = open(os.path.abspath('../infrastructure.ini'), 'w')
- # f.write('[EC2]\n')
- # f.write('remote_user=ubuntu\n')
- # f.write('ip_address=' + instance.ip_address + '\n')
- # f.close()
def read_config(config_file):
cfg = boto.Config()
cfg.load_from_path(os.path.abspath(config_file))
return cfg
-
-def usage(args):
- print 'Usage:\n $ python %s %s' % (sys.argv[0].split("/")[-1], args)
-
-def check_args(num_args, args_desc):
- if len(sys.argv) < num_args+1:
- usage(args_desc)
- exit(0)
-
-def parse_args():
- config_file = sys.argv[1]
-
- if not os.path.isfile(config_file):
- print config_file + ' doesn\'t exist!'
- exit(0)
-
- cfg = read_config(config_file)
- key_name = cfg.get('EC2', 'key_name')
- key_pair = os.path.abspath(cfg.get('EC2', 'key_pair'))
- if not os.path.isfile(key_pair):
- print key_pair + ' doesn\'t exist!'
- exit(0)
-
- return config_file, cfg, key_name, key_pair
-
-
-if __name__ == "__main__":
- check_args(4, "<config_path> <scenario_path> <num_virtual_users> <num_slaves>")
- config_path, cfg, key_name, key_pair = parse_args()
- CreateInstance(config_path, cfg, key_pair, key_name, sys.argv[2], sys.argv[3], sys.argv[4])
diff --git a/distributed-jmeter/cloudscale/common/distributed_jmeter.py b/distributed-jmeter/cloudscale/common/distributed_jmeter.py
index 22ce26d..71f993c 100644
--- a/distributed-jmeter/cloudscale/common/distributed_jmeter.py
+++ b/distributed-jmeter/cloudscale/common/distributed_jmeter.py
@@ -1,8 +1,6 @@
import logging
from cloudscale import models
-
-logger = logging.getLogger(__name__)
-
+import time
class DistributedJmeter(object):
@@ -10,14 +8,13 @@ class DistributedJmeter(object):
self.pid = str(scenario_path.split('/')[-1][:-4])
def log(self, msg, fin=0):
- logger.info(msg)
db_log = models.Log()
db_log.process_id = self.pid
- db_log.log = msg
+ db_log.log = "[%s] %s" % (time.strftime("%H:%M:%S"), msg)
db_log.finished = fin
db_log.save()
def clear(self):
msgs = models.Log.objects.filter(process_id=self.pid)
for obj in msgs:
- obj.delete()
\ No newline at end of file
+ obj.delete()
diff --git a/distributed-jmeter/cloudscale/forms.py b/distributed-jmeter/cloudscale/forms.py
index cca38fa..df0d1f0 100644
--- a/distributed-jmeter/cloudscale/forms.py
+++ b/distributed-jmeter/cloudscale/forms.py
@@ -2,3 +2,6 @@ from django import forms
class UploadScenarioForm(forms.Form):
scenario = forms.FileField()
+ instance_type = forms.ChoiceField(choices=(('t2.medium', 't2.medium'),))
+ num_threads = forms.IntegerField()
+ host = forms.CharField(max_length=255)
diff --git a/distributed-jmeter/cloudscale/openstack_distributed_jmeter.py b/distributed-jmeter/cloudscale/openstack_distributed_jmeter.py
new file mode 100644
index 0000000..979657f
--- /dev/null
+++ b/distributed-jmeter/cloudscale/openstack_distributed_jmeter.py
@@ -0,0 +1,68 @@
+import paramiko
+import os
+import subprocess
+from .common.distributed_jmeter import DistributedJmeter
+import novaclient.v1_1 as novaclient
+
+class OpenStackDistributedJmeter(DistributedJmeter):
+
+ def __init__(self, scenario_path, cfg):
+ super(OpenStackDistributedJmeter, self).__init__(scenario_path)
+ self.cfg = cfg
+
+ self.host = self.cfg.get('OPENSTACK', 'host')
+ self.startup_threads = self.cfg.get('OPENSTACK', 'startup_threads')
+ self.rest_threads = self.cfg.get('OPENSTACK', 'rest_threads')
+ self.num_jmeter_slaves = self.cfg.get('OPENSTACK', 'num_jmeter_slaves')
+
+ master_ip = self.create_instance('jmeter-master')
+ slaves_ips = [self.create_instance('jmeter-slave-%s' % i) for i in range(self.num_jmeter_slaves) ]
+ self.run_jmeter(master_ip, slaves_ips, scenario_path)
+
+ def create_instance(self, name):
+ nc = novaclient.Client(
+ self.cfg.get('OPENSTACK', 'user'),
+ self.cfg.get('OPENSTACK', 'pwd'),
+ self.cfg.get('OPENSTACK', 'tenant'),
+ auth_url=self.cfg.get('OPENSTACK', 'url'))
+
+ nc.servers.create(name, self.cfg.get('OPENSTACK', 'image'), self.cfg.get('OPENSTACK', 'flavor'))
+ for server in nc.servers.list():
+ if server._info['name'] == name:
+ return server
+
+ def run_jmeter(self, master_ip, slave_ips, scenario_path):
+
+ self.log(scenario_path)
+ username = "distributedjmeter"
+ ssh = paramiko.SSHClient()
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+
+ ssh.connect(master_ip, username=username, password='password')
+ scp = paramiko.SFTPClient.from_transport(ssh.get_transport())
+
+ self.log("Transfering scenario to OpenStack ...")
+
+ dirname = os.path.abspath(os.path.dirname(__file__))
+ scp.put( scenario_path, 'scenario.jmx')
+
+ self.log("Executing JMeter scenario on OpenStack ...")
+
+ cmd = "~/jmeter/bin/jmeter -n -t ~/scenario.jmx -j scenario.log -R %s -Ghost=%s -Gstartup_threads=%s -Grest_threads=%s" % (",".join(slave_ips), self.host, self.startup_threads, self.rest_threads)
+ _, stdout, _ = ssh.exec_command(cmd)
+ stdout.readlines()
+
+ resultspath = "{0}/../static/results/".format(dirname)
+
+ tmp_userpath = "/tmp/{0}".format(os.path.basename(scenario_path)[:-4])
+ os.makedirs(tmp_userpath, 0777)
+ scp.get("/home/{2}/scenario.log", "{0}/{1}".format(tmp_userpath, "scenario.log", username))
+ scp.get("/home/{2}/response-times-over-time.csv", "{0}/{1}".format(tmp_userpath, "response-times-over-time.csv", username))
+
+ cmd = "cp -r {0} {1}".format(tmp_userpath, resultspath)
+ p = subprocess.check_output(cmd.split())
+
+ scp.close()
+ ssh.close()
+
+ self.log("Finished! You can now download report files.", 1)
distributed-jmeter/cloudscale/tasks.py 54(+42 -12)
diff --git a/distributed-jmeter/cloudscale/tasks.py b/distributed-jmeter/cloudscale/tasks.py
index 5e03039..8c92f92 100644
--- a/distributed-jmeter/cloudscale/tasks.py
+++ b/distributed-jmeter/cloudscale/tasks.py
@@ -2,23 +2,53 @@ from __future__ import absolute_import
from celery import shared_task, task
import os, subprocess
import logging
-from cloudscale.aws_distributed_jmeter import CreateInstance
-from cloudscale.aws_distributed_jmeter import read_config
-from cloudscale.openstack_distributed_jmeter import OpenStackDistributedJmeter
+from .aws_distributed_jmeter import CreateInstance
+from .aws_distributed_jmeter import read_config
+from .openstack_distributed_jmeter import OpenStackDistributedJmeter
+from math import floor, ceil
+import novaclient.v1_1 as novaclient
+
logger = logging.getLogger(__name__)
@shared_task
-def run_tests(scenario_path):
-# run_aws_test(scenario_path)
- run_openstack_test(scenario_path)
+def run_tests(scenario_path, instance_type, num_threads, host):
+ num_jmeter_slaves, startup_threads, rest_threads = calculate(num_threads)
+
+ cfg = write_config('EC2', instance_type, num_jmeter_slaves, startup_threads, rest_threads, host)
+ run_aws_test(scenario_path, cfg)
+
+# cfg = write_config('OPENSTACK', instance_type, num_jmeter_slaves, startup_threads, rest_threads, host)
+# run_openstack_test(scenario_path, cfg)
+
+def calculate(num_threads):
+ num_users_per_jmeter_instance = 300
+ num_threads = int(num_threads)
+ num_jmeter_slaves = int(ceil(num_threads/(num_users_per_jmeter_instance*1.0)))
+
+ startup_threads = int((num_threads/10)/num_jmeter_slaves)
+ threads_per_slave = int(num_threads/num_jmeter_slaves)
-def run_openstack_test(scenario_path):
- OpenStackDistributedJmeter('10.32.11.102', ['10.32.11.103:8557', '10.32.11.104:8557'], scenario_path)
+ if (num_jmeter_slaves*num_users_per_jmeter_instance) - num_threads > 0:
+ rest_threads = int(threads_per_slave - startup_threads)
+ else:
+ rest_threads = int(num_users_per_jmeter_instance-startup_threads)
+ return num_jmeter_slaves, startup_threads, rest_threads
-def run_aws_test(scenario_path):
+def write_config(section, instance_type, num_jmeter_slaves, startup_threads, rest_threads, host):
basedir = os.path.abspath(os.path.dirname(__file__))
config_path = '%s/../conf/config.ini' % basedir
cfg = read_config(config_path)
- key_name = cfg.get('EC2', 'key_name')
- key_pair = cfg.get('EC2', 'key_pair')
- CreateInstance(config_path, cfg, key_pair, key_name, scenario_path, 2)
+
+ cfg.save_option(config_path, section, 'instance_type', instance_type)
+ cfg.save_option(config_path, section, 'num_jmeter_slaves', str(num_jmeter_slaves))
+ cfg.save_option(config_path, section, 'startup_threads', str(startup_threads))
+ cfg.save_option(config_path, section, 'rest_threads', str(rest_threads))
+ cfg.save_option(config_path, section, 'host', str(host))
+
+ return cfg
+
+def run_openstack_test(scenario_path, cfg):
+ OpenStackDistributedJmeter(scenario_path, cfg)
+
+def run_aws_test(scenario_path, cfg):
+ CreateInstance(cfg, scenario_path)
diff --git a/distributed-jmeter/cloudscale/views.py b/distributed-jmeter/cloudscale/views.py
index 9451d79..cf9038b 100644
--- a/distributed-jmeter/cloudscale/views.py
+++ b/distributed-jmeter/cloudscale/views.py
@@ -31,7 +31,7 @@ def upload(request):
errors = True
else:
filename = handle_uploaded_file(request.FILES['scenario'])
- start_test(filename)
+ start_test(filename, request.POST['instance_type'], request.POST['num_threads'], request.POST['host'])
else:
messages.error(request, "You didn't fill in the form!")
errors = True
@@ -51,7 +51,7 @@ def handle_uploaded_file(file):
destination.close()
return scenario_path
-def start_test(scenario_path):
+def start_test(scenario_path, instance_type, num_threads, host):
from tasks import run_tests
userpath = "{0}/../static/results/{1}".format(os.path.abspath(os.path.dirname(__file__)), os.path.basename(scenario_path)[:-4])
try:
@@ -60,7 +60,7 @@ def start_test(scenario_path):
if e.errno != 17:
raise
pass
- run_tests.delay(scenario_path)
+ run_tests.delay(scenario_path, instance_type, num_threads, host)
def report(request, id):
dir = "{0}/../static/results/{1}".format(os.path.abspath(os.path.dirname(__file__)), id)
@@ -99,4 +99,4 @@ def contact(request):
send_mail("[CloudScale] Query for distributed JMeter", request.POST['message'], request.POST['your_email'],
['simon.ivansek@xlab.si'])
messages.success(request, "Email was successfully sent")
- return render(request, 'contact.html')
\ No newline at end of file
+ return render(request, 'contact.html')
distributed-jmeter/conf/celeryd.conf 16(+8 -8)
diff --git a/distributed-jmeter/conf/celeryd.conf b/distributed-jmeter/conf/celeryd.conf
index d3e8d84..d446f69 100644
--- a/distributed-jmeter/conf/celeryd.conf
+++ b/distributed-jmeter/conf/celeryd.conf
@@ -2,16 +2,16 @@
; celery worker supervisor example
; ==================================
-[program:celery]
+[program:celery-worker1]
; Set full path to celery program if using virtualenv
-command=/home/distributedjmeter/webapp/env/bin/celery worker -A webapp --loglevel=INFO
+command=/home/<user>/webapp/env/bin/celery worker -A webapp --concurrency=10 -n worker1 --loglevel=INFO
-directory=/home/distributedjmeter/webapp/releases/current/webapp
-user=distributedjmeter
-group=distributedjmeter
-numprocs=1
-stdout_logfile=/var/log/celery/distributedjmeter.log
-stderr_logfile=/var/log/celery/distributedjmeter.log
+directory=/home/<user>/webapp/releases/current/webapp
+user=<user>
+group=<user>
+;numprocs=2
+stdout_logfile=/var/log/celery/distributedjmeter-worker1.log
+stderr_logfile=/var/log/celery/distributedjmeter-worker1.log
autostart=true
autorestart=true
startsecs=10
distributed-jmeter/conf/config.ini 15(+10 -5)
diff --git a/distributed-jmeter/conf/config.ini b/distributed-jmeter/conf/config.ini
index 88cd19d..a15af91 100644
--- a/distributed-jmeter/conf/config.ini
+++ b/distributed-jmeter/conf/config.ini
@@ -3,9 +3,14 @@ aws_access_key_id =
aws_secret_access_key =
region = eu-west-1
availability_zones = eu-west-1a
-ami_id = ami-480bea3f
-instance_type = t1.micro
-key_name = key-pair
-key_pair = /path/to/key-pair.pem
-num_jmeter_slaves = 2
+ami_id = ami-6c53881b
+instance_type = t2.medium
+key_name = example-keypair
+key_pair = /path/to/example-keypair.pem
+
+[OPENSTACK]
+user = <user>
+pwd = <password>
+tenant = <tenant>
+url = http://127.0.0.1:5000/v2.0
diff --git a/distributed-jmeter/conf/config.ini.production b/distributed-jmeter/conf/config.ini.production
index 88cd19d..e0d80c0 100644
--- a/distributed-jmeter/conf/config.ini.production
+++ b/distributed-jmeter/conf/config.ini.production
@@ -1,11 +1,15 @@
[EC2]
-aws_access_key_id =
-aws_secret_access_key =
-region = eu-west-1
-availability_zones = eu-west-1a
-ami_id = ami-480bea3f
-instance_type = t1.micro
-key_name = key-pair
-key_pair = /path/to/key-pair.pem
-num_jmeter_slaves = 2
+aws_access_key_id=
+aws_secret_access_key=
+region=eu-west-1
+availability_zones=eu-west-1a
+ami_id=ami-6c53881b
+instance_type=t2.medium
+key_name=example-keypair
+key_pair=/path/to/example-keypair.pem
+[OPENSTACK]
+user = <user>
+pwd = <password>
+tenant = <tenant>
+url = http://127.0.0.1:5000/v2.0
diff --git a/distributed-jmeter/conf/gunicorn.conf b/distributed-jmeter/conf/gunicorn.conf
index 9f71acb..52b4d8f 100644
--- a/distributed-jmeter/conf/gunicorn.conf
+++ b/distributed-jmeter/conf/gunicorn.conf
@@ -8,8 +8,8 @@ worker_connections = 1000
timeout = 30
keepalive = 2
-user='distributedjmeter'
-group='distributedjmeter'
+user='user'
+group='group'
debug = False
spew = False
distributed-jmeter/conf/nginx.conf 98(+15 -83)
diff --git a/distributed-jmeter/conf/nginx.conf b/distributed-jmeter/conf/nginx.conf
index 0ebe29d..e9ff1ec 100644
--- a/distributed-jmeter/conf/nginx.conf
+++ b/distributed-jmeter/conf/nginx.conf
@@ -2,20 +2,15 @@ upstream class_app_server {
server 127.0.0.1:8001 fail_timeout=0;
}
-#server {
-# server_name cloudconference;
-# rewrite ^(.*) http://www.cloudconference.eu$1 permanent;
-#}
-
server {
listen 80;
client_max_body_size 4G;
- server_name cloudscale.xlab.si
+ server_name dummy-host.com
keepalive_timeout 5;
access_log /var/log/nginx/distributedjmeter.access.log;
- error_log /var/log/nginx/distributedjmeter.error.log;
+ error_log /var/log/nginx/distributedjmeter.error.log;
root /var/www;
@@ -27,82 +22,19 @@ server {
gzip_types text/plain text/xml text/css application/xhtml+xml application/xml application/rss+xml application/javascript application/x-javascript;
gzip_disable "MSIE [1-6]\.";
}
-
- location ~ /showcase/ {
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_pass 127.0.0.1:9001;
- fastcgi_index index.php;
- }
-
- location /wiki {
- proxy_pass http://127.0.0.1:81;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
location /distributed-jmeter/static {
- alias /home/distributedjmeter/webapp/releases/current/webapp/static;
- }
-
- location /distributed-jmeter {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header REMOTE_HOST $remote_addr;
- proxy_set_header X-FORWARDED-PROTOCOL $scheme;
- proxy_set_header SCRIPT_NAME /distributed-jmeter;
- proxy_redirect off;
- proxy_pass http://127.0.0.1:8001;
- }
-
- location /showcase-0 {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header REMOTE_HOST $remote_addr;
- proxy_set_header X-FORWARDED-PROTOCOL $scheme;
- proxy_redirect off;
- proxy_pass http://openstack.cloudscale.xlab.si/showcase-0;
- }
- location /showcase-1-a {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header REMOTE_HOST $remote_addr;
- proxy_set_header X-FORWARDED-PROTOCOL $scheme;
- proxy_redirect off;
- proxy_pass http://openstack.cloudscale.xlab.si/showcase-1-a;
- }
- location /showcase-1-b {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header REMOTE_HOST $remote_addr;
- proxy_set_header X-FORWARDED-PROTOCOL $scheme;
- proxy_redirect off;
- proxy_pass http://openstack.cloudscale.xlab.si/showcase-1-b;
- }
- location /jenkins {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header REMOTE_HOST $remote_addr;
- proxy_set_header X-FORWARDED-PROTOCOL $scheme;
- proxy_redirect off;
- proxy_pass http://localhost:8080;
-
- }
- location /sonar{
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header REMOTE_HOST $remote_addr;
- proxy_set_header X-FORWARDED-PROTOCOL $scheme;
- proxy_redirect off;
- proxy_pass http://localhost:9000;
-
- }
-
+ alias /home/<user>/webapp/releases/current/webapp/static;
+ }
+
+ location /distributed-jmeter {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header REMOTE_HOST $remote_addr;
+ proxy_set_header X-FORWARDED-PROTOCOL $scheme;
+ proxy_set_header SCRIPT_NAME /distributed-jmeter;
+ proxy_redirect off;
+ proxy_pass http://127.0.0.1:8001;
+ }
}
distributed-jmeter/conf/supervisor.conf 10(+5 -5)
diff --git a/distributed-jmeter/conf/supervisor.conf b/distributed-jmeter/conf/supervisor.conf
index a024879..d9154de 100644
--- a/distributed-jmeter/conf/supervisor.conf
+++ b/distributed-jmeter/conf/supervisor.conf
@@ -1,12 +1,12 @@
[program:distributed_jmeter]
-user=distributedjmeter
-group=distributedjmeter
-directory=/home/distributedjmeter/webapp/releases/current/webapp
-command=/home/distributedjmeter/webapp/env/bin/python /home/distributedjmeter/webapp/releases/current/webapp/manage.py run_gunicorn -c /home/distributedjmeter/webapp/releases/current/webapp/conf/gunicorn.conf --error-logfile /var/log/gunicorn/distributedjmeter.log
+user=<user>
+group=<group>
+directory=/home/<user>/webapp/releases/current/webapp
+command=/home/<user>/webapp/env/bin/python /home/<user>/webapp/releases/current/webapp/manage.py run_gunicorn -c /home/<user>/webapp/releases/current/webapp/conf/gunicorn.conf --error-logfile /var/log/gunicorn/distributedjmeter.log
stderr_logfile=/var/log/supervisor/distributedjmeter.err.log
stdout_logfile=/var/log/supervisor/distributedjmeter.log
autostart=true
autorestart=true
redirect_stderr=True
-environment=HOME='/home/distributedjmeter/webapp/releases/current/webapp'
+environment=HOME='/home/<user>/webapp/releases/current/webapp'
distributed-jmeter/db.sqlite3 0(+0 -0)
diff --git a/distributed-jmeter/db.sqlite3 b/distributed-jmeter/db.sqlite3
new file mode 100644
index 0000000..392ed0b
Binary files /dev/null and b/distributed-jmeter/db.sqlite3 differ
distributed-jmeter/fabfile.py 12(+6 -6)
diff --git a/distributed-jmeter/fabfile.py b/distributed-jmeter/fabfile.py
index 3e5b563..2f6123d 100644
--- a/distributed-jmeter/fabfile.py
+++ b/distributed-jmeter/fabfile.py
@@ -2,15 +2,15 @@ from __future__ import with_statement
from fabric.api import sudo, cd, run, settings, require, env, put, local, prefix, task
from fabric.contrib.files import exists
-env.hosts = ['host']
-env.user = 'distributedjmeter'
+env.hosts = ['0.0.0.0']
+env.user = '<user>'
env.django_app = 'webapp'
# tasks
@task
def new():
env.process_name = 'distributed_jmeter'
- env.celery_process_name = 'celery'
- env.user = 'distributedjmeter'
+ env.celery_process_name = 'celery-worker1'
+ env.user = '<user>'
env.project_name = 'webapp'
env.postfix=''
env.path = '/home/%(user)s/%(project_name)s' % env
@@ -127,8 +127,8 @@ def migrate(install=False):
with cd('%(path)s/releases/current/%(project_name)s' % env):
with prefix('source %(virtualhost_path)s/bin/activate' % env):
if install:
- run('%(virtualhost_path)s/bin/python manage.py syncdb --all' % env)
- run('%(virtualhost_path)s/bin/python manage.py migrate --fake' % env)
+ run('%(virtualhost_path)s/bin/python manage.py syncdb' % env)
+ #run('%(virtualhost_path)s/bin/python manage.py migrate --fake' % env)
else:
run('%(virtualhost_path)s/bin/python manage.py syncdb --all' % env)
run('%(virtualhost_path)s/bin/python manage.py migrate' % env)
distributed-jmeter/requirements.txt 2(+1 -1)
diff --git a/distributed-jmeter/requirements.txt b/distributed-jmeter/requirements.txt
index 14cd8c3..998181b 100644
--- a/distributed-jmeter/requirements.txt
+++ b/distributed-jmeter/requirements.txt
@@ -3,7 +3,7 @@ MySQL-python==1.2.5
amqp==1.4.3
anyjson==0.3.3
billiard==3.3.0.16
-boto==2.25.0
+boto==2.32.1
celery==3.1.9
ecdsa==0.10
gunicorn==18.0
diff --git a/distributed-jmeter/scripts/__init__.py b/distributed-jmeter/scripts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/distributed-jmeter/scripts/__init__.py
distributed-jmeter/scripts/meet_sla_req.py 65(+65 -0)
diff --git a/distributed-jmeter/scripts/meet_sla_req.py b/distributed-jmeter/scripts/meet_sla_req.py
new file mode 100644
index 0000000..64d2c15
--- /dev/null
+++ b/distributed-jmeter/scripts/meet_sla_req.py
@@ -0,0 +1,65 @@
+import time as t
+import sys
+
+max_time = {}
+max_time['/'] = 3000
+max_time['/?SHOPPING_ID'] = 3000
+max_time['/best-sellers'] = 5000
+max_time['/new-products'] = 5000
+max_time['/product-detail'] = 3000
+max_time['/search?searchField=&keyword=&C_ID='] = 10000
+max_time['/search?C_ID'] = 3000
+max_time['/search'] = 3000
+max_time['/shopping-cart?ADD_FLAG=N'] = 3000
+max_time['/shopping-cart?I_ID=&QTY=1&ADD_FLAG=Y'] = 3000
+max_time['/customer-registration?SHOPPING_ID='] = 3000
+max_time['/buy-confirm'] = 5000
+max_time['/buy?RETURNING_FLAG=Y'] = 3000
+max_time['/buy?RETURNING_FLAG=N'] = 3000
+max_time['/order-inquiry'] = 3000
+
+def check(file_path):
+ output = ""
+ urls = {}
+ unsuccessfull = 0
+ all_requests = 0
+ fp = open(file_path)
+ for line in fp:
+ all_requests+=1
+ try:
+ timestamp, estimated_time, url, response_code, _, _, _ = line.split(",")
+ if not urls.has_key(url):
+ urls[url] = {}
+ urls[url]['times'] = []
+
+ urls[url]['times'].append([estimated_time, response_code])
+
+ if response_code != "200":
+ unsuccessfull += 1
+ except Exception as e:
+ output += "Exception occured\n"
+ output += e.message + "\n"
+ pass
+
+ for k in urls:
+ count_succ = 0
+ all = len(urls[k]['times'])
+
+ for time, response_code in urls[k]['times']:
+ if int(time) <= max_time[k] and response_code == "200":
+ count_succ += 1
+
+ if count_succ >= (all * 90) / 100:
+ output += "%-50s VREDU\n" % k
+ else:
+ p = (count_succ*100)/all
+ output += "%-50s NI VREDU [all = %s, succ = %s (%s%%) ]\n" % (k, all, count_succ, p)
+ fp.close()
+ output += "--------------------------------------------------\n"
+ output += "ALL = %s, UNSUCCESSFULL = %s\n" % (all_requests, unsuccessfull)
+
+ return output
+
+if __name__ == "__main__":
+ print check(sys.argv[1])
+
distributed-jmeter/static/js/Chart.min.js 11(+11 -0)
diff --git a/distributed-jmeter/static/js/Chart.min.js b/distributed-jmeter/static/js/Chart.min.js
new file mode 100644
index 0000000..626e6c3
--- /dev/null
+++ b/distributed-jmeter/static/js/Chart.min.js
@@ -0,0 +1,11 @@
+/*!
+ * Chart.js
+ * http://chartjs.org/
+ * Version: 1.0.1-beta.4
+ *
+ * Copyright 2014 Nick Downie
+ * Released under the MIT license
+ * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
+ */
+(function(){"use strict";var t=this,i=t.Chart,e=function(t){this.canvas=t.canvas,this.ctx=t;this.width=t.canvas.width,this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this};e.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,maintainAspectRatio:!0,showTooltips:!0,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},e.types={};var s=e.helpers={},n=s.each=function(t,i,e){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n<t.length;n++)i.apply(e,[t[n],n].concat(s))}else for(var o in t)i.apply(e,[t[o],o].concat(s))},o=s.clone=function(t){var i={};return n(t,function(e,s){t.hasOwnProperty(s)&&(i[s]=e)}),i},a=s.extend=function(t){return n(Array.prototype.slice.call(arguments,1),function(i){n(i,function(e,s){i.hasOwnProperty(s)&&(t[s]=e)})}),t},h=s.merge=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift({}),a.apply(null,t)},l=s.indexOf=function(t,i){if(Array.prototype.indexOf)return t.indexOf(i);for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1},r=(s.where=function(t,i){var e=[];return s.each(t,function(t){i(t)&&e.push(t)}),e},s.findNextWhere=function(t,i,e){e||(e=-1);for(var s=e+1;s<t.length;s++){var n=t[s];if(i(n))return n}},s.findPreviousWhere=function(t,i,e){e||(e=t.length);for(var s=e-1;s>=0;s--){var n=t[s];if(i(n))return n}},s.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},s=function(){this.constructor=e};return s.prototype=i.prototype,e.prototype=new s,e.extend=r,t&&a(e.prototype,t),e.__super__=i.prototype,e}),c=s.noop=function(){},u=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof t.define&&t.define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,i,e){if(f(i)){if(t>i)return i}else if(f(e)&&e>t)return e;return t},s.getDecimalPlaces=function(t){return t%1!==0&&f(t)?t.toString().split(".")[1].length:0}),x=s.radians=function(t){return t*(Math.PI/180)},S=(s.getAngleFromPoint=function(t,i){var e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s),o=2*Math.PI+Math.atan2(s,e);return 0>e&&0>s&&(o+=2*Math.PI),{angle:o,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),y=(s.splineCurve=function(t,i,e,s){var n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=s*n/(n+o),h=s*o/(n+o);return{inner:{x:i.x-a*(e.x-t.x),y:i.y-a*(e.y-t.y)},outer:{x:i.x+h*(e.x-t.x),y:i.y+h*(e.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),C=(s.calculateScaleRange=function(t,i,e,s,n){var o=2,a=Math.floor(i/(1.5*e)),h=o>=a,l=g(t),r=m(t);l===r&&(l+=.5,r>=.5&&!s?r-=.5:l+=.5);for(var c=Math.abs(l-r),u=y(c),d=Math.ceil(l/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(r/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,v=Math.pow(10,u),x=Math.round(f/v);(x>a||a>2*x)&&!h;)if(x>a)v*=2,x=Math.round(f/v),x%1!==0&&(h=!0);else if(n&&u>=0){if(v/2%1!==0)break;v/=2,x=Math.round(f/v)}else v/=2,x=Math.round(f/v);return h&&(x=o,v=f/x),{steps:x,stepValue:v,min:p,max:p+x*v}},s.template=function(t,i){function e(t,i){var e=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return i?e(i):e}if(t instanceof Function)return t(i);var s={};return e(t,i)}),b=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=C(t,{value:e+s*(n+1)})}),o},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)))},easeOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin(2*(1*t-i)*Math.PI/e)+1)},easeInOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:2==(t/=.5)?1:(e||(e=.3*1.5),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),1>t?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)*.5+1)},easeInBack:function(t){var i=1.70158;return 1*(t/=1)*t*((i+1)*t-i)},easeOutBack:function(t){var i=1.70158;return 1*((t=t/1-1)*t*((i+1)*t+i)+1)},easeInOutBack:function(t){var i=1.70158;return(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},easeInBounce:function(t){return 1-b.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*b.easeInBounce(2*t):.5*b.easeOutBounce(2*t-1)+.5}}),w=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),P=(s.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),s.animationLoop=function(t,i,e,s,n,o){var a=0,h=b[e]||b.linear,l=function(){a++;var e=a/i,r=h(e);t.call(o,r,e,a),s.call(o,r,e),i>a?o.animationFrame=w(l):n.apply(o)};w(l)},s.getRelativePosition=function(t){var i,e,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect();return s.touches?(i=s.touches[0].clientX-o.left,e=s.touches[0].clientY-o.top):(i=s.clientX-o.left,e=s.clientY-o.top),{x:i,y:e}},s.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),L=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},k=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},P(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){L(t.chart.canvas,e,i)})}),F=s.getMaximumWidth=function(t){var i=t.parentNode;return i.clientWidth},R=s.getMaximumHeight=function(t){var i=t.parentNode;return i.clientHeight},A=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=s+"px",i.canvas.height=s*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},M=s.fontString=function(t,i,e){return i+" "+t+"px "+e},W=s.longestText=function(t,i,e){t.font=i;var s=0;return n(e,function(i){var e=t.measureText(i).width;s=e>s?e:s}),s},z=s.drawRoundedRectangle=function(t,i,e,s,n,o){t.beginPath(),t.moveTo(i+o,e),t.lineTo(i+s-o,e),t.quadraticCurveTo(i+s,e,i+s,e+o),t.lineTo(i+s,e+n-o),t.quadraticCurveTo(i+s,e+n,i+s-o,e+n),t.lineTo(i+o,e+n),t.quadraticCurveTo(i,e+n,i,e+n-o),t.lineTo(i,e+o),t.quadraticCurveTo(i,e,i+o,e),t.closePath()};e.instances={},e.Type=function(t,i,s){this.options=i,this.chart=s,this.id=u(),e.instances[this.id]=this,i.responsive&&this.resize(),this.initialize.call(this,t)},a(e.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return s.cancelAnimFrame.call(t,this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=F(this.chart.canvas),s=this.options.maintainAspectRatio?e/this.chart.aspectRatio:R(this.chart.canvas);return i.width=this.chart.width=e,i.height=this.chart.height=s,A(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return C(this.options.legendTemplate,this)},destroy:function(){this.clear(),k(this,this.events),delete e.instances[this.id]},showTooltip:function(t,i){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var o=function(t){var i=!1;return t.length!==this.activeElements.length?i=!0:(n(t,function(t,e){t!==this.activeElements[e]&&(i=!0)},this),i)}.call(this,t);if(o||i){if(this.activeElements=t,this.draw(),t.length>0)if(this.datasets&&this.datasets.length>1){for(var a,h,r=this.datasets.length-1;r>=0&&(a=this.datasets[r].points||this.datasets[r].bars||this.datasets[r].segments,h=l(a,t[0]),-1===h);r--);var c=[],u=[],d=function(){var t,i,e,n,o,a=[],l=[],r=[];return s.each(this.datasets,function(i){t=i.points||i.bars||i.segments,t[h]&&t[h].hasValue()&&a.push(t[h])}),s.each(a,function(t){l.push(t.x),r.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(r),e=g(r),n=m(l),i=g(l),{x:n>this.chart.width/2?n:i,y:(o+e)/2}}.call(this,h);new e.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:u,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx}).draw()}else n(t,function(t){var i=t.tooltipPosition();new e.Tooltip({x:Math.round(i.x),y:Math.round(i.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:C(this.options.tooltipTemplate,t),chart:this.chart}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),e.Type.extend=function(t){var i=this,s=function(){return i.apply(this,arguments)};if(s.prototype=o(i.prototype),a(s.prototype,t),s.extend=e.Type.extend,t.name||i.prototype.name){var n=t.name||i.prototype.name,l=e.defaults[i.prototype.name]?o(e.defaults[i.prototype.name]):{};e.defaults[n]=a(l,t.defaults),e.types[n]=s,e.prototype[n]=function(t,i){var o=h(e.defaults.global,e.defaults[n],i||{});return new s(t,o,this)}}else d("Name not provided for this chart, so it hasn't been registered");return i},e.Element=function(t){a(this,t),this.initialize.apply(this,arguments),this.save()},a(e.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):a(this,this._saved),this},save:function(){return this._saved=o(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,i){this._saved[i]=this[i],this[i]=t},this),this},transition:function(t,i){return n(t,function(t,e){this[e]=(t-this._saved[e])*i+this._saved[e]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return f(this.value)}}),e.Element.extend=r,e.Point=e.Element.extend({display:!0,inRange:function(t,i){var e=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(i-this.y,2)<Math.pow(e,2)},draw:function(){if(this.display){var t=this.ctx;t.beginPath(),t.arc(this.x,this.y,this.radius,0,2*Math.PI),t.closePath(),t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.fillStyle=this.fillColor,t.fill(),t.stroke()}}}),e.Arc=e.Element.extend({inRange:function(t,i){var e=s.getAngleFromPoint(this,{x:t,y:i}),n=e.angle>=this.startAngle&&e.angle<=this.endAngle,o=e.distance>=this.innerRadius&&e.distance<=this.outerRadius;return n&&o},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,i=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*i,y:this.y+Math.sin(t)*i}},draw:function(t){var i=this.ctx;i.beginPath(),i.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),i.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),i.closePath(),i.strokeStyle=this.strokeColor,i.lineWidth=this.strokeWidth,i.fillStyle=this.fillColor,i.fill(),i.lineJoin="bevel",this.showStroke&&i.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this.ctx,i=this.width/2,e=this.x-i,s=this.x+i,n=this.base-(this.base-this.y),o=this.strokeWidth/2;this.showStroke&&(e+=o,s-=o,n+=o),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(e,this.base),t.lineTo(e,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,i){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&i>=this.y&&i<=this.base}}),e.Tooltip=e.Element.extend({draw:function(){var t=this.chart.ctx;t.font=M(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=2,e=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+i;this.x+e/2>this.chart.width?this.xAlign="left":this.x-e/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var o=this.x-e/2,a=this.y-n;switch(t.fillStyle=this.fillColor,this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-i),t.lineTo(this.x+this.caretHeight,this.y-(i+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(i+this.caretHeight)),t.closePath(),t.fill();break;case"below":a=this.y+i+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+i),t.lineTo(this.x+this.caretHeight,this.y+i+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+i+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":o=this.x-e+(this.cornerRadius+this.caretHeight);break;case"right":o=this.x-(this.cornerRadius+this.caretHeight)}z(t,o,a,e,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,o+e/2,a+s/2)}}),e.MultiTooltip=e.Element.extend({initialize:function(){this.font=M(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=M(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,i=W(this.ctx,this.font,this.labels)+this.fontSize+3,e=g([i,t]);this.width=e+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var i=this.y-this.height/2+this.yPadding,e=t-1;return 0===t?i+this.titleFontSize/2:i+(1.5*this.fontSize*e+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){z(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(i,e){t.fillStyle=this.textColor,t.fillText(i,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(e+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[e].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}),e.Scale=e.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(C(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?W(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,i=this.endPoint-this.startPoint;for(this.calculateYRange(i),this.buildYLabels(),this.calculateXLabelRotation();i>this.endPoint-this.startPoint;)i=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(i),this.buildYLabels(),t<this.yLabelWidth&&this.calculateXLabelRotation()},calculateXLabelRotation:function(){this.ctx.font=this.font;var t,i,e=this.ctx.measureText(this.xLabels[0]).width,s=this.ctx.measureText(this.xLabels[this.xLabels.length-1]).width;if(this.xScalePaddingRight=s/2+3,this.xScalePaddingLeft=e/2>this.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=W(this.ctx,this.font,this.xLabels);this.xLabelWidth=o;for(var a=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>a&&0===this.xLabelRotation||this.xLabelWidth>a&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(x(this.xLabelRotation)),t=n*e,i=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*o;this.xLabelRotation>0&&(this.endPoint-=Math.sin(x(this.xLabelRotation))*o+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var i=this.drawingArea()/(this.min-this.max);return this.endPoint-i*(t-this.min)},calculateX:function(t){var i=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),e=i/(this.valuesCount-(this.offsetGridLines?0:1)),s=e*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=e/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,i=(this.endPoint-this.startPoint)/this.steps,e=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,o){var a=this.endPoint-i*o,h=Math.round(a);t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),t.moveTo(e,h),t.lineTo(this.width,h),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(e-5,h),t.lineTo(e,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(i,e){var s=this.calculateX(e)+S(this.lineWidth),n=this.calculateX(e-(this.offsetGridLines?.5:0))+S(this.lineWidth),o=this.xLabelRotation>0;t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(-1*x(this.xLabelRotation)),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(i,0,0),t.restore()},this))}}),e.RadialScale=e.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(C(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,e,s,n,o,a,h,l,r,c,u,d=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=M(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;i<this.valuesCount;i++)t=this.getPointPosition(i,d),e=this.ctx.measureText(C(this.templateString,{value:this.labels[i]})).width+5,0===i||i===this.valuesCount/2?(s=e/2,t.x+s>p&&(p=t.x+s,n=i),t.x-s<g&&(g=t.x-s,a=i)):i<this.valuesCount/2?t.x+e>p&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e<g&&(g=t.x-e,a=i);l=g,r=Math.ceil(p-this.width),o=this.getIndexAngle(n),h=this.getIndexAngle(a),c=r/Math.sin(o+Math.PI/2),u=l/Math.sin(h+Math.PI/2),c=f(c)?c:0,u=f(u)?u:0,this.drawingArea=d-(u+c)/2,this.setCenterPoint(u,c)},setCenterPoint:function(t,i){var e=this.width-i-this.drawingArea,s=t+this.drawingArea;this.xCenter=(s+e)/2,this.yCenter=this.height/2},getIndexAngle:function(t){var i=2*Math.PI/this.valuesCount;return t*i-Math.PI/2},getPointPosition:function(t,i){var e=this.getIndexAngle(t);return{x:Math.cos(e)*i+this.xCenter,y:Math.sin(e)*i+this.yCenter}},draw:function(){if(this.display){var t=this.ctx;if(n(this.yLabels,function(i,e){if(e>0){var s,n=e*(this.drawingArea/this.steps),o=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var a=0;a<this.valuesCount;a++)s=this.getPointPosition(a,this.calculateCenterOffset(this.min+e*this.stepValue)),0===a?t.moveTo(s.x,s.y):t.lineTo(s.x,s.y);t.closePath(),t.stroke()}if(this.showLabels){if(t.font=M(this.fontSize,this.fontStyle,this.fontFamily),this.showLabelBackdrop){var h=t.measureText(i).width;t.fillStyle=this.backdropColor,t.fillRect(this.xCenter-h/2-this.backdropPaddingX,o-this.fontSize/2-this.backdropPaddingY,h+2*this.backdropPaddingX,this.fontSize+2*this.backdropPaddingY)}t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.fontColor,t.fillText(i,this.xCenter,o)}}},this),!this.lineArc){t.lineWidth=this.angleLineWidth,t.strokeStyle=this.angleLineColor;for(var i=this.valuesCount-1;i>=0;i--){if(this.angleLineWidth>0){var e=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(e.x,e.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=M(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var o=this.labels.length,a=this.labels.length/2,h=a/2,l=h>i||i>o-h,r=i===h||i===o-h;t.textAlign=0===i?"center":i===a?"center":a>i?"left":"right",t.textBaseline=r?"middle":l?"bottom":"top",t.fillText(this.labels[i],s.x,s.y)}}}}}),s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(e.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return e}):"object"==typeof module&&module.exports&&(module.exports=e),t.Chart=e,e.noConflict=function(){return t.Chart=i,e}}).call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Bar",defaults:s,initialize:function(t){var s=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,i,e){var n=this.calculateBaseWidth(),o=this.calculateX(e)-n/2,a=this.calculateBarWidth(t);return o+a*i+i*s.barDatasetSpacing+a/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return i/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(s),e.each(i.data,function(e,n){s.bars.push(new this.BarClass({value:e,label:t.labels[n],datasetLabel:i.label,strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,i,s){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,s,i),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(i,s){e.each(i.bars,t,this,s)},this)},getBarsAtEvent:function(t){for(var i,s=[],n=e.getRelativePosition(t),o=function(t){s.push(t.bars[i])},a=0;a<this.datasets.length;a++)for(i=0;i<this.datasets[a].bars.length;i++)if(this.datasets[a].bars[i].inRange(n.x,n.y))return e.each(this.datasets,o),s;return s},buildScale:function(t){var i=this,s=function(){var t=[];return i.eachBars(function(i){t.push(i.value)}),t},n={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(s(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.barShowStroke?this.options.barStrokeWidth:0,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(n,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new this.ScaleClass(n)},addData:function(t,i){e.each(t,function(t,e){this.datasets[e].bars.push(new this.BarClass({value:t,label:i,x:this.scale.calculateBarX(this.datasets.length,e,this.scale.valuesCount+1),y:this.scale.endPoint,width:this.scale.calculateBarWidth(this.datasets.length),base:this.scale.endPoint,strokeColor:this.datasets[e].strokeColor,fillColor:this.datasets[e].fillColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.bars.shift()},this),this.update()},reflow:function(){e.extend(this.BarClass.prototype,{y:this.scale.endPoint,base:this.scale.endPoint});var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t,s){e.each(t.bars,function(t,e){t.hasValue()&&(t.base=this.scale.endPoint,t.transition({x:this.scale.calculateBarX(this.datasets.length,s,e),y:this.scale.calculateY(t.value),width:this.scale.calculateBarWidth(this.datasets.length)},i).draw())},this)},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,percentageInnerCutout:50,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};
+i.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.segments=[],this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.calculateTotal(t),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({value:t.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(t.value),label:t.label})),e||(this.reflow(),this.update())},calculateCircumference:function(t){return 2*Math.PI*(t/this.total)},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this)},update:function(){this.calculateTotal(this.segments),e.each(this.activeElements,function(t){t.restore(["fillColor"])}),e.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,e.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var i=t?t:1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},i),t.endAngle=t.startAngle+t.circumference,t.draw(),0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle)},this)}}),i.types.Doughnut.extend({name:"Pie",defaults:e.merge(s,{percentageInnerCutout:0})})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,bezierCurve:!0,bezierCurveTension:.4,pointDot:!0,pointDotRadius:4,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Line",defaults:s,initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(t){return Math.pow(t-this.x,2)<Math.pow(this.radius+this.hitDetectionRadius,2)}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(e,n){s.points.push(new this.PointClass({value:e,label:t.labels[n],datasetLabel:i.label,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))},this),this.buildScale(t.labels),this.eachPoints(function(t,i){e.extend(t,{x:this.scale.calculateX(i),y:this.scale.endPoint}),t.save()},this)},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachPoints(function(t){t.save()}),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.datasets,function(t){e.each(t.points,function(t){t.inRange(s.x,s.y)&&i.push(t)})},this),i},buildScale:function(t){var s=this,n=function(){var t=[];return s.eachPoints(function(i){t.push(i.value)}),t},o={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(n(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.pointDotRadius+this.options.pointDotStrokeWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(o,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new i.Scale(o)},addData:function(t,i){e.each(t,function(t,e){this.datasets[e].points.push(new this.PointClass({value:t,label:i,x:this.scale.calculateX(this.scale.valuesCount+1),y:this.scale.endPoint,strokeColor:this.datasets[e].pointStrokeColor,fillColor:this.datasets[e].pointColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.points.shift()},this),this.update()},reflow:function(){var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();var s=this.chart.ctx,n=function(t){return null!==t.value},o=function(t,i,s){return e.findNextWhere(i,n,s)||t},a=function(t,i,s){return e.findPreviousWhere(i,n,s)||t};this.scale.draw(i),e.each(this.datasets,function(t){var h=e.where(t.points,n);e.each(t.points,function(t,e){t.hasValue()&&t.transition({y:this.scale.calculateY(t.value),x:this.scale.calculateX(e)},i)},this),this.options.bezierCurve&&e.each(h,function(t,i){var s=i>0&&i<h.length-1?this.options.bezierCurveTension:0;t.controlPoints=e.splineCurve(a(t,h,i),t,o(t,h,i),s),t.controlPoints.outer.y>this.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.y<this.scale.startPoint&&(t.controlPoints.outer.y=this.scale.startPoint),t.controlPoints.inner.y>this.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y<this.scale.startPoint&&(t.controlPoints.inner.y=this.scale.startPoint)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(h,function(t,i){if(0===i)s.moveTo(t.x,t.y);else if(this.options.bezierCurve){var e=a(t,h,i);s.bezierCurveTo(e.controlPoints.outer.x,e.controlPoints.outer.y,t.controlPoints.inner.x,t.controlPoints.inner.y,t.x,t.y)}else s.lineTo(t.x,t.y)},this),s.stroke(),this.options.datasetFill&&h.length>0&&(s.lineTo(h[h.length-1].x,this.scale.endPoint),s.lineTo(h[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),e.each(h,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBeginAtZero:!0,scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,scaleShowLine:!0,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.segments=[],this.SegmentArc=i.Arc.extend({showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,ctx:this.chart.ctx,innerRadius:0,x:this.chart.width/2,y:this.chart.height/2}),this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,valuesCount:t.length}),this.updateScaleRange(t),this.scale.update(),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value,outerRadius:this.options.animateScale?0:this.scale.calculateCenterOffset(t.value),circumference:this.options.animateRotate?0:this.scale.getCircumference(),startAngle:1.5*Math.PI})),e||(this.reflow(),this.update())},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var i=[];e.each(t,function(t){i.push(t.value)});var s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s,{size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.calculateTotal(this.segments),e.each(this.segments,function(t){t.save()}),this.render()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),e.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),e.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var i=t||1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},i),t.endAngle=t.startAngle+t.circumference,0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle),t.draw()},this),this.scale.draw()}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers;i.Type.extend({name:"Radar",defaults:{scaleShowLine:!0,angleShowLineOut:!0,scaleShowLabels:!1,scaleBeginAtZero:!0,angleLineColor:"rgba(0,0,0,.1)",angleLineWidth:1,pointLabelFontFamily:"'Arial'",pointLabelFontStyle:"normal",pointLabelFontSize:10,pointLabelFontColor:"#666",pointDot:!0,pointDotRadius:3,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'},initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx}),this.datasets=[],this.buildScale(t),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(e,n){var o;this.scale.animation||(o=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(e))),s.points.push(new this.PointClass({value:e,label:t.labels[n],datasetLabel:i.label,x:this.options.animation?this.scale.xCenter:o.x,y:this.options.animation?this.scale.yCenter:o.y,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=e.getRelativePosition(t),s=e.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},i),n=2*Math.PI/this.scale.valuesCount,o=Math.round((s.angle-1.5*Math.PI)/n),a=[];return(o>=this.scale.valuesCount||0>o)&&(o=0),s.distance<=this.scale.drawingArea&&e.each(this.datasets,function(t){a.push(t.points[o])}),a},buildScale:function(t){this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,angleLineColor:this.options.angleLineColor,angleLineWidth:this.options.angleShowLineOut?this.options.angleLineWidth:0,pointLabelFontColor:this.options.pointLabelFontColor,pointLabelFontSize:this.options.pointLabelFontSize,pointLabelFontFamily:this.options.pointLabelFontFamily,pointLabelFontStyle:this.options.pointLabelFontStyle,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,labels:t.labels,valuesCount:t.datasets[0].data.length}),this.scale.setScaleSize(),this.updateScaleRange(t.datasets),this.scale.buildYLabels()},updateScaleRange:function(t){var i=function(){var i=[];return e.each(t,function(t){t.data?i=i.concat(t.data):e.each(t.points,function(t){i.push(t.value)})}),i}(),s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s)},addData:function(t,i){this.scale.valuesCount++,e.each(t,function(t,e){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[e].points.push(new this.PointClass({value:t,label:i,x:s.x,y:s.y,strokeColor:this.datasets[e].pointStrokeColor,fillColor:this.datasets[e].pointColor}))},this),this.scale.labels.push(i),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),e.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){e.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2}),this.updateScaleRange(this.datasets),this.scale.setScaleSize(),this.scale.buildYLabels()},draw:function(t){var i=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.hasValue()&&t.transition(this.scale.getPointPosition(e,this.scale.calculateCenterOffset(t.value)),i)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(t,i){0===i?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),e.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this);
\ No newline at end of file
distributed-jmeter/templates/home.html 24(+19 -5)
diff --git a/distributed-jmeter/templates/home.html b/distributed-jmeter/templates/home.html
index df2743c..bb32ec1 100644
--- a/distributed-jmeter/templates/home.html
+++ b/distributed-jmeter/templates/home.html
@@ -13,7 +13,8 @@
</p>
</div>
-
+ <form action="{{ url_prefix }}/upload" method="post" name="upload-form" {% if form.is_multipart %} enctype="multipart/form-data" {% endif %} >
+ {% csrf_token %}
<div class="row marketing">
{% if errors %}
{% for message in messages %}
@@ -34,13 +35,26 @@
{% endif %}
{% endfor %}
{% endif %}
- <form action="{{ url_prefix }}/upload" method="post" name="upload-form"
- {% if form.is_multipart %} enctype="multipart/form-data" {% endif %} >
- {% csrf_token %}
+
+
<div class="form-group form-scenario-upload">
- <label for="id_scenario">Scenario</label>
+ <label>Scenario</label>
<input type="file" id="scenarioUploadInput" class="form-control" name="scenario" />
</div>
+ <div class="form-group">
+ <label>Instance type</label>
+ <select class="form-control" name="instance_type">
+ <option value="t2.medium">t2.medium</option>
+ </select>
+ </div>
+ <div class="form-group">
+ <label>Number of threads:</label>
+ <input type="text" name="num_threads" class="form-control"/>
+ </div>
+ <div class="form-group">
+ <label>Host</label>
+ <input type="text" name="host" class="form-control"/>
+ </div>
<div class="clearfix"></div>
<input type="submit" class="btn btn-success" value="Submit" />
</form>
distributed-jmeter/templates/report.html 22(+17 -5)
diff --git a/distributed-jmeter/templates/report.html b/distributed-jmeter/templates/report.html
index 58bb394..bc3a642 100644
--- a/distributed-jmeter/templates/report.html
+++ b/distributed-jmeter/templates/report.html
@@ -13,19 +13,24 @@
<div class="row marketing">
<div class="log">
</div>
+ <canvas id="myChart" width="400" height="400"></canvas>
<div class="download-buttons">
- <a href="{{ url_prefix }}/static/results/{{ id }}/scenario.jtl" id="download-jtl" class="btn disabled btn-success">
+ <a href="{{ url_prefix }}/static/results/{{ id }}/scenario.jtl" id="download-btn" class="btn disabled btn-success">
Download JTL file</a>
- <a href="{{ url_prefix }}/static/results/{{ id }}/scenario.log" id="download-log" class="btn disabled btn-success">
+ <a href="{{ url_prefix }}/static/results/{{ id }}/scenario.log" id="download-btn" class="btn disabled btn-success">
Download LOG file
</a>
+ <a href="{{ url_prefix }}/static/results/{{ id }}/response-times-over-time.csv" id="download-btn" class="btn disabled btn-success">
+ Download response-times-over-time.csv file
+ </a>
</div>
</div>
{% endif %}
{% endblock %}
{% block javascript %}
<script src="https://code.jquery.com/jquery.js"></script>
-<script src="{% static "js/bootstrap.min.js" %}"></script>
+<script src="{% static 'js/bootstrap.min.js' %}"></script>
+<script src="{% static 'js/Chart.min.js' %}"></script>
<script type="text/javascript">
timer = null
function doPoll(finish) {
@@ -48,8 +53,9 @@
}
if (data['finished'] == 1) {
- $('#download-jtl').removeClass('disabled')
- $('#download-log').removeClass('disabled')
+ $('.download-buttons #download-btn').each(function() {
+ $(this).removeClass('disabled')
+ });
}
$('.log').html('')
@@ -61,6 +67,12 @@
$(document).ready(function () {
doPoll()
+
+ // Get context with jQuery - using jQuery's .get() method.
+ var ctx = $("#myChart").get(0).getContext("2d");
+ // This will get the first returned node in the jQuery collection.
+ var myNewChart = new Chart(ctx);
+
})
</script>
{% endblock %}
distributed-jmeter/webapp/local_settings.py 32(+32 -0)
diff --git a/distributed-jmeter/webapp/local_settings.py b/distributed-jmeter/webapp/local_settings.py
new file mode 100644
index 0000000..ecdf743
--- /dev/null
+++ b/distributed-jmeter/webapp/local_settings.py
@@ -0,0 +1,32 @@
+import os
+from settings import BASE_DIR
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': 'distributedjmeter',
+ 'USER': 'user',
+ 'PASSWORD': 'password',
+ 'HOST': 'localhost',
+ 'PORT': '3306',
+ }
+}
+
+INSTALLED_APPS = (
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'cloudscale',
+ 'gunicorn',
+)
+FORCE_SCRIPT_NAME=''
+URL_PREFIX = '/distributed-jmeter'
+MEDIA_ROOT = '{0}/../media/'.format(BASE_DIR)
+STATIC_ROOT = '{0}/../static/'.format(BASE_DIR)
+STATIC_URL = '{0}/static/'.format(URL_PREFIX)
+
+CELERY_ALWAYS_EAGER = False
+
diff --git a/distributed-jmeter/webapp/local_settings.py.production b/distributed-jmeter/webapp/local_settings.py.production
index 3842808..ecdf743 100644
--- a/distributed-jmeter/webapp/local_settings.py.production
+++ b/distributed-jmeter/webapp/local_settings.py.production
@@ -4,9 +4,9 @@ from settings import BASE_DIR
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
- 'NAME': 'load_test',
+ 'NAME': 'distributedjmeter',
'USER': 'user',
- 'PASSWORD': 'pass',
+ 'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '3306',
}
@@ -23,10 +23,10 @@ INSTALLED_APPS = (
'gunicorn',
)
FORCE_SCRIPT_NAME=''
-URL_PREFIX = ''
+URL_PREFIX = '/distributed-jmeter'
MEDIA_ROOT = '{0}/../media/'.format(BASE_DIR)
STATIC_ROOT = '{0}/../static/'.format(BASE_DIR)
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
-
+CELERY_ALWAYS_EAGER = False
diff --git a/distributed-jmeter/webapp/settings.py b/distributed-jmeter/webapp/settings.py
index 04bdd5e..2db2498 100644
--- a/distributed-jmeter/webapp/settings.py
+++ b/distributed-jmeter/webapp/settings.py
@@ -68,7 +68,7 @@ DATABASES = {
LANGUAGE_CODE = 'en-us'
-TIME_ZONE = 'UTC'
+TIME_ZONE = 'Europe/Ljubljana'
USE_I18N = True
@@ -97,13 +97,13 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
)
-EMAIL_HOST = 'mx.xlab.si'
+EMAIL_HOST = 'dummy-host.com'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
-# CELERY_ALWAYS_EAGER = True
+CELERY_ALWAYS_EAGER = True
CELERYD_HIJACK_ROOT_LOGGER = False
LOGGING = {