├── CREDITS
├── LICENSE-2.0.txt
├── README.md
├── client
├── Makefile
├── README
├── game_cron
│ ├── README
│ ├── count_page_load_time.py
│ ├── global_preset_paths.py
│ ├── movenbzip.sh
│ ├── perfaggregate.py
│ ├── pullconfig.py
│ ├── pyjson.py
│ ├── timetail.py
│ └── zperfmon_config.py
├── zperfmon-client-apache.conf
├── zperfmon-client.spec
├── zperfmon.ini
└── zxhprof
│ ├── extension
│ ├── xhprof.ini
│ └── zperfmon.inc.php
├── props
├── counts_tab.jpg
├── counts_tab_small.jpg
├── overview.jpg
├── overview_small.jpg
├── profile_page.jpg
├── profile_page_small.jpg
├── top_5.jpg
├── top_5_small.jpg
├── unaggregated.jpg
├── unaggregated_small.jpg
└── zperfmon.png
├── server
├── Makefile
├── README
├── db_cron
│ ├── add_game_automation
│ │ └── add-game-worker
│ ├── aggregate.php
│ ├── array_wise_split.php
│ ├── clean.php
│ ├── clean.sh
│ ├── compress.php
│ ├── create_array_games.php
│ ├── create_hostgroupsyml.php
│ ├── daily_aggregate.py
│ ├── daily_game_metrics.php
│ ├── daily_instance_report_job.php
│ ├── daily_job.php
│ ├── daily_job.sh
│ ├── deregister_node.php
│ ├── etc
│ │ ├── common_config.yml
│ │ ├── common_config_zcloud.yml
│ │ ├── conf.d
│ │ │ └── game.cfg
│ │ ├── eu.ini
│ │ ├── report.ini
│ │ ├── rs.ini
│ │ └── server.cfg
│ ├── fetch_rs.py
│ ├── generate_instance_report.php
│ ├── generate_report.php
│ ├── get_apache_metrics.php
│ ├── get_array_ids.php
│ ├── get_conf_vars.php
│ ├── get_db_details.php
│ ├── get_game_metrics.php
│ ├── get_game_metrics.sh
│ ├── get_pdt.php
│ ├── get_pdt_parallel.php
│ ├── get_rightscale_data.php
│ ├── get_rightscale_data.sh
│ ├── get_splunk_metrics.php
│ ├── get_top5_functions.php
│ ├── get_yml_conf.php
│ ├── include
│ │ ├── game_deploy_map.php
│ │ ├── insort.php
│ │ ├── lib
│ │ │ └── S3.class.php
│ │ ├── logger.inc.php
│ │ ├── profilepie.inc.php
│ │ ├── run_in_background.php
│ │ ├── spyc.php
│ │ ├── yml_conf.inc.php
│ │ └── zpm_util.inc.php
│ ├── insert_bd_metrics.php
│ ├── insert_zmonitor_data.php
│ ├── json.py
│ ├── massage_profiles.py
│ ├── massage_profiles_unzip.py
│ ├── monit.conf
│ ├── monitor.php
│ ├── move_slowpages.php
│ ├── parallelcurl.py
│ ├── pdt.py
│ ├── process_uploads.php
│ ├── process_uploads.sh
│ ├── register_node.php
│ ├── report.php
│ ├── rightscale.php
│ ├── slack_reduction.php
│ ├── slowpage.php
│ ├── update_game_map.php
│ ├── update_report_hostgroup.php
│ ├── vertica_table_add_column.php
│ ├── xhprof_update.php
│ ├── xhprof_update.sh
│ ├── zperfmon-report-games-test.php
│ ├── zperfmon-server.cron
│ ├── zperfmon_partition_dynamics.php
│ └── zperfmon_set_p_tag.php
├── schemas
│ ├── apache_stats_30min.sql
│ ├── config.sql
│ ├── eu_schema.sql
│ ├── events.sql
│ ├── fn_details_table_schema
│ ├── game_config.sql
│ ├── insert_to_daily_table.sql
│ ├── log.sql
│ ├── report.sql
│ ├── rs_schema.sql
│ ├── slow_page.sql
│ ├── splunk_stats.sql
│ ├── stats_30min.sql
│ ├── top5_functions_30min.sql
│ ├── tracked_functions_30min.sql
│ ├── vertica_stats_30min.sql
│ └── xhprof_blob_30min.sql
├── scripts
│ └── Readme
├── web_ui
│ ├── README.txt
│ ├── admin
│ │ ├── admin.php
│ │ ├── dump_file.php
│ │ ├── fetch_hosts.php
│ │ └── images
│ │ │ ├── delete.jpg
│ │ │ └── download_sprite.png
│ ├── apis
│ │ ├── add-game-worker.php
│ │ ├── get_candidates.php
│ │ ├── get_events.php
│ │ ├── get_ini.php
│ │ ├── get_sketchy.php
│ │ ├── index.php
│ │ └── zPerfmonAPI.class.php
│ ├── bd-view
│ │ ├── bd-view.html
│ │ └── get_bd_data.php
│ ├── css
│ │ ├── bx_styles-3.0.css
│ │ ├── demo_table.prime.css
│ │ ├── gauges.css
│ │ ├── images
│ │ │ ├── close_icon.png
│ │ │ ├── gauge-green.png
│ │ │ ├── gauge-orange.png
│ │ │ ├── gauge-red.png
│ │ │ ├── gray_pager.png
│ │ │ ├── nav_bg.png
│ │ │ ├── zoom-in.png
│ │ │ └── zoom-out.png
│ │ ├── jquery.autocomplete.css
│ │ ├── main.css
│ │ ├── meters.css
│ │ ├── overview.css
│ │ ├── smoothness
│ │ │ ├── images
│ │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png
│ │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png
│ │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png
│ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png
│ │ │ │ ├── ui-bg_glass_75_dadada_1x400.png
│ │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png
│ │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png
│ │ │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png
│ │ │ │ ├── ui-icons_222222_256x240.png
│ │ │ │ ├── ui-icons_2e83ff_256x240.png
│ │ │ │ ├── ui-icons_454545_256x240.png
│ │ │ │ ├── ui-icons_888888_256x240.png
│ │ │ │ └── ui-icons_cd0a0a_256x240.png
│ │ │ ├── jquery-ui-1.8.15.custom.css
│ │ │ └── jquery-ui-1.8.5.custom.css
│ │ ├── style.css
│ │ └── twocolumn.css
│ ├── cto-view
│ │ ├── cto-view.php
│ │ └── cto_query.php
│ ├── dau
│ │ └── index.php
│ ├── eu-view
│ │ ├── eu-query.php
│ │ ├── eu-view.html
│ │ └── eu-view.php
│ ├── eu
│ │ └── index.php
│ ├── fetch.php
│ ├── get_yaml_config.php
│ ├── help
│ │ ├── bd_help.pdf
│ │ ├── cto_help.pdf
│ │ ├── eu_help.pdf
│ │ ├── profile_help.pdf
│ │ ├── slow_page_help.pdf
│ │ └── top5_help.pdf
│ ├── images
│ │ ├── loader.gif
│ │ └── spinner.gif
│ ├── include
│ │ ├── PDOAdapter.php
│ │ ├── XhProfDAO.php
│ │ ├── XhProfJSONView.php
│ │ ├── XhProfModel.php
│ │ ├── XhProfView_Interface.php
│ │ ├── ZPerfmonDAO_Interface.php
│ │ ├── curl_prefetch.php
│ │ ├── dau-collector.php
│ │ ├── eu-collector.php
│ │ ├── game_config.php
│ │ ├── gameidMap.php
│ │ ├── overview-adapter.php
│ │ ├── overview-data.php
│ │ ├── prof_summary.php
│ │ ├── profilepie.inc.php
│ │ ├── query_cfg.php
│ │ ├── setup_page.php
│ │ ├── slack_api.php
│ │ └── splunk-collector.php
│ ├── index.php
│ ├── js
│ │ ├── autoheight.js
│ │ ├── chartcontrol.js
│ │ ├── charts.js
│ │ ├── datatables.1.9.4
│ │ │ ├── README.using.datatables
│ │ │ └── link_datatable
│ │ ├── filteredtable.js
│ │ ├── jquery-1.4.2.min.js
│ │ ├── jquery-1.5.2.min.js
│ │ ├── jquery-ui-1.8.15.custom.min.js
│ │ ├── jquery-ui-1.8.5.custom.min.js
│ │ ├── jquery.autocomplete.js
│ │ ├── jquery.bxSlider-3.0.min.js
│ │ ├── jquery.cookie.js
│ │ ├── jquery.dataTables.js
│ │ ├── jquery.flot-0.7.js
│ │ ├── jquery.flot.axislabels-0.1.js
│ │ ├── jquery.flot.stack-0.7.js
│ │ ├── jquery.lightbox_me.js
│ │ ├── jquery.sparkline.min-1.6.js
│ │ ├── jquery.tooltip.js
│ │ ├── log-view.js
│ │ ├── main.js
│ │ ├── sprintf-0.6.js
│ │ └── top5table.js
│ ├── log-view
│ │ └── log-view.php
│ ├── overview
│ │ ├── index.php
│ │ └── overview.php
│ ├── profile-view
│ │ ├── ExtractProfileFilename.php
│ │ ├── dailyview.php
│ │ ├── dev-view.css
│ │ ├── dev-view.js
│ │ ├── dev-view.php
│ │ ├── getLastProfile.php
│ │ ├── getProfileList.php
│ │ ├── getReleaseList.php
│ │ └── ipview.php
│ ├── report
│ │ ├── index.php
│ │ ├── instance-detail-report.php
│ │ ├── instance-eu-adapter.php
│ │ ├── instance-summary-report.php
│ │ ├── instance-util-adapter.php
│ │ ├── report-adapter.php
│ │ ├── report-collector.php
│ │ ├── report-css.php
│ │ ├── report-markup.php
│ │ └── report.php
│ ├── slow-page
│ │ └── slow-page.php
│ ├── status
│ │ └── index.php
│ ├── top5-view
│ │ └── top5-view.php
│ ├── uploader.php
│ ├── xhprof_html
│ ├── xhprof_lib
│ └── zperfmon-server.ini
├── zperfmon-server.conf
└── zperfmon-server.spec
├── xhprof
├── CHANGELOG
├── CREDITS
├── LICENSE
├── README
├── examples
│ └── sample.php
├── extension
│ ├── config.m4
│ ├── php_xhprof.h
│ ├── tests
│ │ ├── xhprof_001.phpt
│ │ ├── xhprof_002.phpt
│ │ ├── xhprof_003.phpt
│ │ ├── xhprof_004.phpt
│ │ ├── xhprof_005.phpt
│ │ ├── xhprof_006.phpt
│ │ ├── xhprof_007.phpt
│ │ └── xhprof_008.phpt
│ └── xhprof.c
├── xhprof_html
│ ├── callgraph.php
│ ├── css
│ │ ├── base-context-min.css
│ │ ├── container.css
│ │ ├── datatable.css
│ │ ├── datatablegrouper.css
│ │ ├── dt-group-arrow-down.png
│ │ ├── dt-group-arrow-up.png
│ │ ├── jquery-ui-1.8.15.custom.css
│ │ ├── xhprof.css
│ │ └── xhprof_yui.css
│ ├── index.php
│ ├── index_json.php
│ ├── jquery
│ │ ├── indicator.gif
│ │ ├── jquery-1.2.6.js
│ │ ├── jquery.autocomplete.css
│ │ ├── jquery.autocomplete.js
│ │ ├── jquery.tooltip.css
│ │ └── jquery.tooltip.js
│ ├── js
│ │ ├── combo.js
│ │ ├── groupdatatable.js
│ │ ├── xhprof_report.js
│ │ └── yui-min.js
│ ├── piechart.php
│ └── typeahead.php
└── xhprof_lib
│ ├── display
│ ├── get_latest_release.php
│ ├── typeahead_common.php
│ ├── xhprof.php
│ └── xhprof_json.php
│ └── utils
│ ├── callgraph_utils.php
│ ├── xhprof_lib.php
│ └── xhprof_runs.php
└── zperfmon_arch.html
/CREDITS:
--------------------------------------------------------------------------------
1 | Contributors:
2 | Binu Jose Philip
3 | Debashish Bose
4 | Gaurav
5 | Gopal Vijayaraghavan
6 | Korath Paul
7 | Mahesh Gattani
8 | Nasrudheen Kakkadavath
9 | Nuruddin Alam
10 | Rajeev Bakshi
11 | Saurabh Odhyan
12 | Shankara K Seethappa
13 | Ujwalendu Prakash
14 |
15 | Additional Contributors:
16 | Prakash Ramachandran
17 | Prashun Purkayastha
18 |
19 |
20 | PHP profiling is completely based on xhprof extension by Facebook. Thank you
21 | FB for the wonderfully practical xhprof.
22 |
23 | There are a host of other technology pieces which went into the cauldron to
24 | make this possible. jquery, YUI, google widgets, Datatables, MySQL nd more.
25 | You could put in highcharts or D3 instead and get a much prettier interface.
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **Please note:** This project is deprecated at Zynga and is no longer maintained.
2 |
3 | ---
4 |
5 | zPerfmon - ***Grok Production Profiles***
6 | ========
7 |
8 |
9 | zPerfmon is an app performance analysis suite. It collects production
10 | profiles, systems metrics and other data on a periodic basis. It has
11 | data visualization and data correlation capabilities which lets you
12 | answer questions about performance, health and behavior trends as
13 | well.
14 |
15 | ![App state Overview Page][overview_image]
16 |
17 | ### There are two distinct pieces in it:
18 |
19 | [Server][server-code] - which takes care of ETL-ing, storing and presenting
20 | collected data. Data streams can consist of profiles, page hits,
21 | system metrics, unqiue user counts or even arbitrary events
22 | with timestamps.
23 |
24 | [Client][client-code] - is like an agent. It goes into the application being monitored and at
25 | a minimum triggers profile collection. As long as the client generates
26 | PHP serialized or igbinary serialized xhprof formatted data, server
27 | can pick it up. There is a schema mandated for the profile name.
28 |
29 | Server and Client are connected by a [configuration file][client-config]. The PHP client uses
30 | xhprof extension for profile collection. For another language or platform to
31 | deliver profiles into zPerfmon, you will need a profile generation solution
32 | in that language which can dump xhprof formatted profiles.
33 |
34 | The most intersting view for a developer from a performance or behavior
35 | perspective is the [profile browser][profile-view] tab. It shows an average profile for each
36 | distinct page hit at half hour granularity.
37 | ![profile_page_image]
38 |
39 | If however, you want to browse individual profiles, maybe to see the one
40 | errant hit which took 10 times the average, or look at the hit which consumed
41 | the most CPU, there is the [un-aggregated view][profile-view-unagg]
42 |
43 | ![unaggregated_image]
44 |
45 | Data mined from profiles are surfaced in different ways.
46 | [Top-5 functions][top-5-functions] is one of them. It provides visual clues
47 | when top function distribution according to wall time change.
48 |
49 | ![top_5_image]
50 |
51 | High altitude overviews which answer questions like "Did my web instance count
52 | go up without user count increasing?" is answered by the [business tab][bd-dash]
53 |
54 | ![counts_tab_image]
55 |
56 | [overview_image]: props/overview_small.jpg "Overview Dashboard"
57 | [profile_page_image]: props/profile_page_small.jpg "Profile Tab"
58 | [top_5_image]: props/top_5_small.jpg "Top5 functions Tab"
59 | [unaggregated_image]: props/unaggregated_small.jpg "Unaggregated Profiles Page"
60 | [counts_tab_image]: props/counts_tab_small.jpg "Instance and user count Tab"
61 | [server-code]: server
62 | [client-code]: client
63 | [client-config]: client/zperfmon.ini.sample
64 | [profile-view]: server/web_ui/profile-view
65 | [profile-view-unagg]: server/web_ui/profile-view/ipview.php
66 | [top-5-functions]: server/web_ui/top5-view/top5-view.php
67 | [bd-dash]: server/web_ui/bd-view/bd-view.html
68 |
--------------------------------------------------------------------------------
/client/Makefile:
--------------------------------------------------------------------------------
1 | FILES=Makefile \
2 | game_cron/ \
3 | zxhprof/ \
4 | ../CREDITS \
5 | README \
6 | zperfmon-client-apache.conf \
7 | zperfmon-client.spec \
8 | zperfmon.ini
9 |
10 | DIRS=/var/opt/zperfmon/xhprof_tbz \
11 | /usr/share/php/zperfmon \
12 | /usr/local/zperfmon/bin \
13 | /etc/cron.d \
14 | /var/run/zperfmon \
15 | /etc/php.d \
16 | /mnt/logs/httpd/xhprof \
17 | /etc/httpd/conf.d \
18 | /etc/zperfmon/ \
19 | /var/log/zperfmon \
20 | /usr/local/zperfmon/etc
21 |
22 | BUILDROOT=.
23 | #svn info | grep "Revision" | sed "s/Revision: /r/"
24 |
25 | all:
26 | @@true # do nothing
27 |
28 |
29 | tarball:
30 | tar -czv --exclude=.svn --dereference -f $(BUILDROOT)/zperfmon-client.tgz $(FILES)
31 |
32 | rpm: tarball
33 | rpmbuild -ta $(BUILDROOT)/zperfmon-client.tgz
34 |
35 | install: $(INSTALL_ROOT) xhprof crons profiler apache_conf zperfmon_ini htpasswd
36 |
37 |
38 | makedirs: $(INSTALL_ROOT)
39 | test -d $(INSTALL_ROOT) || echo "Invalid build root specified - $(INSTALL_ROOT)"
40 | for dir in $(DIRS); do mkdir -p $(INSTALL_ROOT)/$$dir; done
41 |
42 | xhprof: makedirs
43 | cd zxhprof/extension && make install INSTALL_ROOT=$(INSTALL_ROOT)
44 | cp zxhprof/xhprof.ini $(INSTALL_ROOT)/etc/php.d/
45 |
46 | crons: makedirs
47 | cp -v game_cron/*.py $(INSTALL_ROOT)/usr/local/zperfmon/bin/
48 | cp -v game_cron/*.sh $(INSTALL_ROOT)/usr/local/zperfmon/bin/
49 | chmod a+x $(INSTALL_ROOT)/usr/local/zperfmon/bin/*
50 |
51 | profiler: makedirs
52 | cp -v zxhprof/zperfmon.inc.php $(INSTALL_ROOT)/usr/share/php/
53 |
54 | apache_conf: makedirs
55 | cp -v zperfmon-client-apache.conf ${INSTALL_ROOT}/etc/httpd/conf.d/zperfmon-client.conf
56 |
57 | zperfmon_ini: makedirs
58 | cp -v zperfmon.ini ${INSTALL_ROOT}/etc/zperfmon/zperfmon.ini
59 |
60 | htpasswd: makedirs
61 | /usr/bin/htpasswd -bc ${INSTALL_ROOT}/usr/local/zperfmon/etc/zperfmon.htpasswd "3.141592653" "2.718281823"
62 |
--------------------------------------------------------------------------------
/client/README:
--------------------------------------------------------------------------------
1 | This is the client package for zPerfmon which delivers an automated
2 | php profile collection framework.
3 |
--------------------------------------------------------------------------------
/client/game_cron/README:
--------------------------------------------------------------------------------
1 | We keep only a day worth of failed uploads on the host.
2 |
3 | --
4 |
5 | The profile upload cron job runs 4 times every hour. Once each at 55th
6 | and 25th minute, and once each at a 5 minute boundary between 55-25
7 | and 25-55 minutes.
8 |
9 | --
10 |
11 | PROFILE_CLI_BY_DEFAULT
12 | - Ignored by non-CLI invocations. For CLI invocations, if set
13 | profile on/off check will be done at app init and app exit. If
14 | set to false, profiling on/off check will be done on calls to
15 | zperfmon_enable() and zperfmon_disable().
16 |
17 | DISABLE_APC
18 | - Don't use APC even if loaded. Use case of CLI app profiling
19 | and multiple processes involved in profile collection.
20 |
--------------------------------------------------------------------------------
/client/game_cron/global_preset_paths.py:
--------------------------------------------------------------------------------
1 | """
2 | Global configuration file
3 | """
4 |
5 | global_preset_paths = {
6 | "ZPERFMON_CONFIG_PATH" : "/var/run/zperfmon/zperfmon-conf",
7 | "ZPERFMON_TBZ_TARGET_PATH" : "/var/opt/zperfmon/xhprof_tbz",
8 | "ZPERFMON_XHPROF_CONFIG_FILE" : "/etc/php.d/xhprof.ini",
9 | "ZPERFMON_APACHE_STAT_FILE" : "/var/log/zperfmon/apache-page.stats",
10 | "ZPERFMON_APACHE_MON_PID" : "/var/run/apache_mon_pid",
11 | "ZPERFMON_ZID_COUNT_FILE" : "/var/log/zperfmon/zidstuff.csv",
12 | "ZPERFMON_AUTH_HASH_FILE" : "/var/log/zperfmon/auth_hash.csv",
13 | "ZPERFMON_PDT_FILE" : "/var/log/zperfmon/pdt.json",
14 | "ZPERFMON_MEM_FILE" : "/var/log/zperfmon/zidmem.csv",
15 |
16 | #
17 | # URL parameter extraction
18 | #
19 | "ZPERFMON_URL_PARAMS" : "",
20 | "ZRUNTIME_LIVE_REV" : "/var/tmp/prod-liveRev",
21 | "ZPERFMON_INI_FILE" : "/etc/zperfmon/zperfmon.ini",
22 | "ZPERFMON_CONF_URL" : "http:/xxxxx/zperfmon/get_ini.php",
23 | "ZPERFMON_CONF_URL_EC2" : "http://xxxxx/zperfmon/get_ini.php"
24 | }
25 |
--------------------------------------------------------------------------------
/client/game_cron/movenbzip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | TSLOT=$((`date +\%s`/1800))
4 |
5 | for FNAME in zidstuff.csv pdt.json auth_hash.csv zidmem.csv
6 | do
7 | /bin/mv /var/log/zperfmon/${FNAME} /var/log/zperfmon/${TSLOT}.${FNAME}
8 | done
9 |
10 | for FNAME in zidstuff.csv pdt.json auth_hash.csv zidmem.csv
11 | do
12 | /usr/bin/bzip2 /var/log/zperfmon/${TSLOT}.${FNAME}
13 | done
14 |
--------------------------------------------------------------------------------
/client/game_cron/pyjson.py:
--------------------------------------------------------------------------------
1 | ../../server/db_cron/json.py
--------------------------------------------------------------------------------
/client/game_cron/zperfmon_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | """
4 | Configuration Manager for zperfmon game clients.
5 | Currently used by perfaggregate.py and count_page_load_time.py
6 | """
7 |
8 | import re
9 | import os
10 |
11 | #
12 | # Do nothing class for trapping clean exit paths, were we needn't log
13 | # errors or stack of the resulting exception
14 | #
15 | class CleanExit(Exception):
16 | pass
17 |
18 | class GameSetup:
19 |
20 | def __init__(self, preset_paths):
21 |
22 | # Load base configs
23 | self.set_base_params(preset_paths)
24 |
25 | # Last conf-file read time
26 | self.last_modification = -1
27 |
28 | # Load params delivered via zrt
29 | self.read_zrt_config()
30 |
31 | # Pickup configuration from built-ins
32 | def set_base_params(self, preset_paths):
33 | for key, value in preset_paths.items():
34 | setattr(self, key, value)
35 |
36 | # Read ZRT config and set corresponding parameters
37 | def read_zrt_config(self):
38 |
39 | try:
40 | zrt_config = open(self.ZPERFMON_CONFIG_PATH).read()
41 | except:
42 | #
43 | # If zperfmon.inc.php did not dump the config pulled from
44 | # zRT, we are most likely not profiling on this machine. We
45 | # will do a clean exit.
46 | #
47 | raise CleanExit()
48 |
49 | # The file is in this format:
50 | # key1:=value1,key2:=value2,key3:=......
51 | #
52 | values = [re.split(":=", x) for x in zrt_config.split("\n") if x]
53 |
54 | # set the attribute in the class corresponding to key
55 | # The consumers will use it directly as 'conf.key => value'
56 |
57 | for key, value in values:
58 | setattr(self, key, value)
59 |
60 | self.last_modification = os.path.getmtime(self.ZPERFMON_CONFIG_PATH)
61 |
62 | #
63 | # Check and re-read the configuration dumped by zperfmon.inc.php
64 | def refresh(self):
65 | if (os.path.exists(self.ZPERFMON_CONFIG_PATH) and
66 | self.last_modification != os.path.getmtime(self.ZPERFMON_CONFIG_PATH)):
67 | #
68 | # Re-read the configuration, it was dumped again
69 | #
70 | self.read_zrt_config()
71 |
--------------------------------------------------------------------------------
/client/zperfmon-client-apache.conf:
--------------------------------------------------------------------------------
1 | # zPerfmon specific page access time log
2 | CustomLog logs/zperfmon.log "%m%f%D%{%s}t%>s%U%q%{pparam}n%{zid}n%{hash}n%{mpk}n%{muse}n"
3 |
4 | Alias /zplog /var/log/zperfmon
5 |
6 |
7 | AuthType Basic
8 | AuthName "Restricted Files"
9 | AuthUserFile /usr/local/zperfmon/etc/zperfmon.htpasswd
10 | Require valid-user
11 | Options Indexes
12 |
13 |
--------------------------------------------------------------------------------
/client/zperfmon.ini:
--------------------------------------------------------------------------------
1 | ; How often to dump profile, default is every 60 seconds
2 | XHPROF_PROBE_INTERVAL=60;
3 |
4 | ; The ID assigned to the game for tracking
5 | ZPERFMON_GAME_ID=42;
6 |
7 | ; Name of the game as understood by zperfmon server
8 | ZPERFMON_GAME_NAME="fluid";
9 |
10 | ; The URL at which zperfmon server is installed
11 | ZPERFMON_UPLOAD_URL="http://hostname.not.set/zperfmon/uploader.php";
12 |
13 | ; A list of URL parameters, values of which will be prepended to the page name
14 | ; Keep this empty if not used
15 | ; ZPERFMON_URL_PARAMS="UPARAM1,UPARAM2";
16 |
17 | ; The constants below are meant for dev setup only
18 |
19 | ; A list of time slots for which memory profilling will be set on
20 | ; ZPERFMON_MEM_SLOTS=48;
21 |
22 | ; Time by which we start profiling before the memory profiling enabled time slot.
23 | ; ZPERFMON_SLOW_PAGE_THRESHOLD=5;
24 |
25 | ; Variable to figure out if we have to append Hostname to profiles
26 | ; Useful for virtual host tagging
27 | ; ZPERFMON_APPEND_HOSTNAME=false;
28 |
29 | ; Per page defined constant which is to be appended to file name
30 | ; ZPERFMON_PAGE_PARAMS="PPARAM1,PPARAM2"
31 |
32 | ; If we dont need the hash data collected, set this to false
33 | ; ZPERFMON_HASH_DATA = true;
34 |
35 | ; Set to true to use file caching instead of APC caching
36 | ; DISABLE_APC=false
37 |
38 | ; A list of pages that must be profiled in a half-hour timeslot
39 | ; Format is: :,:,...
40 | ; page name can include url parameter(s) used to key the profile dump.
41 | ;
42 | ; This works as a guarantee and throttle. Within a fuzziness range, a page
43 | ; appearing in the list will not occur more times than specified and will occur
44 | ; as many times as specified.
45 | ;
46 | ; ZPERFMON_PROFILE_CONF="one.php:1,two.php:2"
47 |
--------------------------------------------------------------------------------
/client/zxhprof/extension:
--------------------------------------------------------------------------------
1 | ../../xhprof/extension/
--------------------------------------------------------------------------------
/client/zxhprof/xhprof.ini:
--------------------------------------------------------------------------------
1 | ; Enable xhprof extension module
2 | extension=xhprof.so
3 | xhprof.output_dir="/mnt/logs/httpd/xhprof/"
4 |
5 |
--------------------------------------------------------------------------------
/props/counts_tab.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/counts_tab.jpg
--------------------------------------------------------------------------------
/props/counts_tab_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/counts_tab_small.jpg
--------------------------------------------------------------------------------
/props/overview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/overview.jpg
--------------------------------------------------------------------------------
/props/overview_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/overview_small.jpg
--------------------------------------------------------------------------------
/props/profile_page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/profile_page.jpg
--------------------------------------------------------------------------------
/props/profile_page_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/profile_page_small.jpg
--------------------------------------------------------------------------------
/props/top_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/top_5.jpg
--------------------------------------------------------------------------------
/props/top_5_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/top_5_small.jpg
--------------------------------------------------------------------------------
/props/unaggregated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/unaggregated.jpg
--------------------------------------------------------------------------------
/props/unaggregated_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/unaggregated_small.jpg
--------------------------------------------------------------------------------
/props/zperfmon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/props/zperfmon.png
--------------------------------------------------------------------------------
/server/Makefile:
--------------------------------------------------------------------------------
1 | export SHELL := /bin/bash
2 |
3 | FILES=Makefile \
4 | db_cron/ \
5 | web_ui/ \
6 | schemas/ \
7 | scripts/ \
8 | ../CREDITS \
9 | README \
10 | zperfmon-server.conf \
11 | zperfmon-server.spec
12 |
13 | DIRS=/var/www/html/zperfmon/blobs \
14 | /etc/zperfmon/conf.d \
15 | /usr/local/zperfmon/bin \
16 | /usr/local/zperfmon/include \
17 | /usr/local/bin \
18 | /usr/local/zperfmon/etc/schemas \
19 | /usr/share/php/zperfmon \
20 | /etc/cron.d \
21 | /var/run/zperfmon \
22 | /var/log/zperfmon \
23 | /etc/php.d \
24 | /etc/httpd/conf.d
25 |
26 | BUILDROOT=.
27 | #svn info | grep "Revision" | sed "s/Revision: /r/"
28 |
29 | all:
30 | @@true # do nothing
31 |
32 |
33 | tarball:
34 | tar -czv --exclude=.svn --dereference -f $(BUILDROOT)/zperfmon-server.tgz $(FILES)
35 |
36 | rpm: tarball
37 | rpmbuild -ta $(BUILDROOT)/zperfmon-server.tgz
38 |
39 | install: $(INSTALL_ROOT) crons configs schemas webui symlinks scripts
40 |
41 | makedirs: $(INSTALL_ROOT)
42 | test -d $(INSTALL_ROOT) || echo "Invalid build root specified - $(INSTALL_ROOT)"
43 | for dir in $(DIRS); do mkdir -p $(INSTALL_ROOT)/$$dir; done
44 |
45 | crons: makedirs
46 | cp -v db_cron/*.{php,py,sh} $(INSTALL_ROOT)/usr/local/zperfmon/bin/
47 | cp -rv db_cron/include/ $(INSTALL_ROOT)/usr/local/zperfmon/
48 | chmod a+x $(INSTALL_ROOT)/usr/local/zperfmon/bin/*
49 | cp -v db_cron/zperfmon-server.cron $(INSTALL_ROOT)/etc/cron.d/zperfmon-server
50 |
51 | configs: makedirs
52 | cp -rvf db_cron/etc/* $(INSTALL_ROOT)/etc/zperfmon/
53 | cp -v web_ui/zperfmon-server.ini $(INSTALL_ROOT)/etc/php.d/
54 | cp -v zperfmon-server.conf $(INSTALL_ROOT)/etc/httpd/conf.d/
55 |
56 | schemas: makedirs
57 | cp -rvf schemas/* $(INSTALL_ROOT)/usr/local/zperfmon/etc/schemas
58 |
59 | webui: makedirs
60 | cp -rvf web_ui/* $(INSTALL_ROOT)/var/www/html/zperfmon/
61 | rm $(INSTALL_ROOT)/var/www/html/zperfmon/README.txt
62 | rm $(INSTALL_ROOT)/var/www/html/zperfmon/zperfmon-server.ini
63 |
64 | symlinks: makedirs
65 | for each in aggregate_runs.php extract_functions.php combine_files.php; do \
66 | ln -svf /usr/local/zperfmon/bin/aggregate.php $(INSTALL_ROOT)/usr/local/zperfmon/bin/$$each;\
67 | done
68 |
69 | scripts: makedirs
70 | cp -avf scripts/* $(INSTALL_ROOT)/usr/local/bin/
71 | chmod a+x $(INSTALL_ROOT)/usr/local/bin/*
72 |
--------------------------------------------------------------------------------
/server/README:
--------------------------------------------------------------------------------
1 | Collection of ETL and processing scripts to manipulate various data
2 | streams send to zPerfmon server. It also delivers the web UI to view
3 | the data in a timestamp keyed manner.
4 |
--------------------------------------------------------------------------------
/server/db_cron/add_game_automation/add-game-worker:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2013 Zynga Inc.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | #
20 | # description: add-game-worker
21 | #
22 | # Get function from functions library
23 | . /etc/init.d/functions
24 |
25 | pidfile="/var/run/add-game-worker.pid"
26 | script="php /var/www/html/zperfmon/apis/add-game-worker.php"
27 | lockfile="/var/lock/subsys/add-game-worker"
28 | prog="add-game-worker"
29 |
30 | # Start the service add-game-worker
31 | start() {
32 | echo -n "Starting add-game-worker: "
33 | #daemon $script --pidfile $pidfile &
34 | daemon $script -P $pidfile &
35 | retval=$?
36 | if [ $retval -eq 0 ]
37 | then
38 | touch $lockfile
39 | success $"add-game-worker startup"
40 | echo_success
41 | echo
42 | else
43 | echo_failure
44 | echo
45 | fi
46 |
47 | return $retval
48 | }
49 |
50 | # Stop the service add-game-worker
51 | stop() {
52 | echo -n "Stopping add-game-worker: "
53 | #pid=$(<$pidfile)i
54 | killproc -p $pidfile $prog
55 | retval=$?
56 | if [ ! $retval -eq 0 ]
57 | then
58 | echo failure
59 | echo
60 | return
61 | fi
62 |
63 | test -e $pidfile && rm -f $pidfile
64 | echo_success
65 | echo
66 | return
67 | }
68 |
69 | ### main logic ###
70 | case "$1" in
71 | start)
72 | start
73 | ;;
74 | stop)
75 | stop
76 | ;;
77 | status)
78 | status $prog
79 | ;;
80 | restart|reload|condrestart)
81 | stop
82 | start
83 | ;;
84 | *)
85 | echo $"Usage: $0 {start|stop|restart|reload|status}"
86 | exit 1
87 | esac
88 | exit 0
89 |
--------------------------------------------------------------------------------
/server/db_cron/clean.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | /dev/null ";
55 | $output = system($cleanup, $retval);
56 | if($retval != 0){
57 | error_log("Couldn`t cleanup game $game", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
58 | continue;
59 | }
60 |
61 | $arrays_to_id = get_array_id_map($server_cfg, $game_cfg);
62 | foreach($arrays_to_id as $array=>$id){
63 | $game_cfg = load_game_config($game, $id);
64 | $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null ";
65 | $output = system($cleanup, $retval);
66 | if($retval != 0){
67 | error_log("Couldn`t cleanup game $game", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
68 | continue;
69 | }
70 |
71 | }
72 |
73 | zpm_postamble($game);
74 | }
75 | }
76 |
77 | main($server_cfg);
78 |
79 | ?>
80 |
--------------------------------------------------------------------------------
/server/db_cron/create_array_games.php:
--------------------------------------------------------------------------------
1 | server_cfg = $server_cfg;
52 | }
53 |
54 |
55 | //function to make sudo games for each array id. The array ids are fetched from rightscale database.
56 | public function make_array_games($game_name, $deploy_id) {
57 |
58 | $query = "select distinct(array_id) from instances where deploy_id = (:deploy_id) and array_name like '%web%'";
59 |
60 | $parameters = array(
61 | "deploy_id" => array($deploy_id, PDO::PARAM_INT),
62 | );
63 |
64 | $stmt = $this->prepare($query);
65 |
66 | $rows = $this->fetchAll($stmt, $parameters);
67 |
68 | $arrays = array();
69 | foreach ($rows as $array)
70 | {
71 | $retval = null;
72 |
73 | if ( $array["array_id"] != "" ) {
74 | $cmd = "echo 'yes' | /usr/local/bin/zperfmon-add-game ".$game_name." ".$array["array_id"] . " 2>&1 > /tmp/split-log &";
75 | }
76 | $output = system($cmd, $retval);
77 |
78 | array_push($arrays, $array["array_id"]);
79 | if($retval != 0){
80 | error_log("Couldn`t make game with $cmd\n$retval\n$output\n", 3, sprintf($this->server_cfg['log_file'], $game_name));
81 | continue;
82 | }
83 | }
84 | }
85 | }
86 |
87 | ?>
88 |
--------------------------------------------------------------------------------
/server/db_cron/daily_instance_report_job.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
3 |
107 |
--------------------------------------------------------------------------------
/server/db_cron/daily_job.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
3 |
107 |
--------------------------------------------------------------------------------
/server/db_cron/daily_job.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2013 Zynga Inc.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | # run this script to update the report db to have any new classes
20 | taskset -c 13-15 /usr/bin/php /usr/local/zperfmon/bin/update_report_hostgroup.php
21 |
22 | # generate instance email reports
23 | taskset -c 13-15 /usr/bin/php /usr/local/zperfmon/bin/daily_instance_report_job.php -j report
24 |
25 | # generate aggregate and email reports
26 | /usr/local/zperfmon/bin/get_conf_vars.php -s game_list | xargs -n1 -P8 taskset -c 13-15 /usr/bin/php /usr/local/zperfmon/bin/daily_job.php -g
27 |
28 | # cleanup zperfmon old data
29 | /usr/local/zperfmon/bin/get_conf_vars.php -s game_list | xargs -n1 -P8 taskset -c 13-15 /usr/bin/php /usr/local/zperfmon/bin/clean.php -g
30 |
31 | # rebuild the deployment to game map file
32 | /usr/local/zperfmon/bin/update_game_map.php
33 |
34 | # update the vertica_stats_30min table
35 | php -r "include 'server.cfg'; echo implode(' ',\$server_cfg['game_list']);" | xargs -n1 -P8 taskset -c 1-8 /usr/bin/php /usr/local/zperfmon/bin/vertica_table_add_column.php -g
36 |
--------------------------------------------------------------------------------
/server/db_cron/etc/eu.ini:
--------------------------------------------------------------------------------
1 |
2 | [DB]
3 | user =
4 | password =
5 | host =
6 | database = eu
7 | eu_table = common_eu
8 |
--------------------------------------------------------------------------------
/server/db_cron/etc/report.ini:
--------------------------------------------------------------------------------
1 |
2 | [DB]
3 | user =
4 | password =
5 | host =
6 | database = report
7 |
--------------------------------------------------------------------------------
/server/db_cron/etc/rs.ini:
--------------------------------------------------------------------------------
1 |
2 | [DB]
3 | user =
4 | password =
5 | host =
6 | database = rightscale
7 | table = instances
8 | deployments= 55859,67956,21550,27510,36763,35533,24524
9 |
--------------------------------------------------------------------------------
/server/db_cron/generate_report.php:
--------------------------------------------------------------------------------
1 | parseString($message);
88 | $tidy->cleanRepair();
89 | mail($to, $subject, $tidy, $headers);
90 | }
91 |
92 |
93 | function generate_report($server_cfg, $game_cfg, $timestamp, $period)
94 | {
95 | $report = build_report($server_cfg, $game_cfg, $period, $timestamp);
96 | if ($report === null) {
97 | return null;
98 | }
99 |
100 | send_mail($server_cfg, $game_cfg, $report);
101 | }
102 |
103 | ?>
104 |
--------------------------------------------------------------------------------
/server/db_cron/get_array_ids.php:
--------------------------------------------------------------------------------
1 | connect();
53 | $array_id = $XhProfDAO->prepare_and_query('select distinct array_id from instances where deploy_id ='.$deploy_id.';');
54 | $ids = Array();
55 | foreach ( $array_id as $id)
56 | {
57 | array_push($ids,$id['array_id']);
58 | }
59 | foreach ( $ids as $id) {
60 | echo $id."\n";
61 | }
62 | $XhProfDAO->disconnect();
63 |
--------------------------------------------------------------------------------
/server/db_cron/get_conf_vars.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | value.
28 | //
29 |
30 | include_once 'server.cfg';
31 | include_once 'zpm_util.inc.php';
32 | zpm_preamble("");
33 |
34 | function getValue($value,$quote,$space_seperated){
35 |
36 | if (!is_string($value)) {
37 | if($space_seperated == true){
38 | $value = implode(' ', $value);
39 | }
40 | else{
41 | $value = json_encode($value);
42 | }
43 | } elseif($quote) {
44 |
45 | $value = "\"$value\"";
46 | }
47 | return $value;
48 | }
49 |
50 | function main($server_cfg, $argv) {
51 |
52 | $space_seperated = false;
53 |
54 | array_shift($argv);
55 |
56 | if ($argv[0] == "-s") {
57 | $space_seperated = true;
58 | array_shift($argv);
59 | }
60 |
61 | $var_string = implode("", $argv);
62 |
63 | if (empty($var_string)) {
64 | return;
65 | }
66 |
67 | $conf_vars = explode(",", $var_string);
68 |
69 | if (count($conf_vars) == 0) {
70 | // ignore
71 | } else if (count($conf_vars) == 1) {
72 | if (isset($server_cfg[$conf_vars[0]])) {
73 | $value = $server_cfg[$conf_vars[0]];
74 | $value = getValue($value,false,$space_seperated);
75 | echo $value;
76 | }
77 | } else {
78 |
79 | $need_comma = False;
80 |
81 | echo "{";
82 |
83 | foreach($conf_vars as $var) {
84 |
85 | $value = $server_cfg[$var];
86 | $value = getValue($value,true,$space_seperated);
87 |
88 | if ($need_comma) {
89 | echo ",";
90 | } else {
91 | $need_comma = True;
92 | }
93 |
94 | echo "\"$var\":$value";
95 | }
96 |
97 | echo "}";
98 | }
99 | }
100 |
101 | main($server_cfg, $argv);
102 | zpm_postamble("");
103 |
--------------------------------------------------------------------------------
/server/db_cron/get_db_details.php:
--------------------------------------------------------------------------------
1 |
37 |
--------------------------------------------------------------------------------
/server/db_cron/get_pdt_parallel.php:
--------------------------------------------------------------------------------
1 |
97 |
--------------------------------------------------------------------------------
/server/db_cron/get_rightscale_data.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2013 Zynga Inc.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | php -r "include 'server.cfg'; echo implode(' ',\$server_cfg['game_list']);" | xargs -n1 -P4 /usr/bin/php /usr/local/zperfmon/bin/get_rightscale_data.php -g
20 |
--------------------------------------------------------------------------------
/server/db_cron/get_splunk_metrics.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
3 | $query) {
69 | $results = $splunk_collector->run_query($query, $query_period);
70 | if(is_array($results)) {
71 | $count = $results[0]["count"];
72 | $splunk_store->store_splunk_count($now, $query_name, $count);
73 | } else {
74 | echo "Could not fetch $query_name for $game_name\n";
75 | }
76 | }
77 | }
78 | }
79 | catch(Exception $e) {
80 | }
81 |
82 | zpm_postamble($game_name);
83 |
84 | }
85 | }
86 |
87 | main($server_cfg);
88 |
--------------------------------------------------------------------------------
/server/db_cron/get_yml_conf.php:
--------------------------------------------------------------------------------
1 |
52 |
--------------------------------------------------------------------------------
/server/db_cron/include/game_deploy_map.php:
--------------------------------------------------------------------------------
1 | name = $name;
27 | $this->metric = $metric;
28 | }
29 |
30 | public function getName() {
31 | return $this->name;
32 | }
33 |
34 | public function getValue() {
35 | return $this->metric;
36 | }
37 |
38 | public static function compare($ob1, $ob2) {
39 | $m1 = $ob1->metric;
40 | $m2 = $ob2->metric;
41 |
42 | $r = ($m1 > $m2) ? 1 : (($m1 < $m2) ? -1 : 0);
43 | return $r;
44 | }
45 | }
46 |
47 |
48 | class TopX implements ArrayAccess {
49 | protected $size;
50 | public $elements;
51 |
52 | public function __construct($size=5) {
53 | $this->size = $size;
54 | $low = new Symbol("_", 0);
55 | $this->elements = array_fill(0, $size, $low);
56 | }
57 |
58 | public function peek() {
59 | return $this->elements[$this->size]->metric;
60 | }
61 |
62 | public function compareMin($metric) {
63 | $value = $this->elements[$this->size]->metric;
64 |
65 | return ($value > $metric ? 1 :
66 | $value < $metric ? -1 : 0);
67 | }
68 |
69 | public function insert($name, $value) {
70 | /*
71 | * Push items smaller than item being inserted to slot below.
72 | * If largest item is smaller than item being inserted, that
73 | * is handled outside the loop.
74 | */
75 | $index = $this->size - 1;
76 | while ($index > 0 && $value > $this->elements[$index]->metric) {
77 | $this->elements[$index] = $this->elements[$index-1];
78 | $index--;
79 | }
80 |
81 | if ($index == $this->size-1) {
82 | return;
83 | }
84 |
85 | if ($index != 0 || $value <= $this->elements[$index]->metric) {
86 | $index++;
87 | }
88 |
89 | $this->elements[$index] = new Symbol($name, $value);
90 | }
91 |
92 | public function offsetGet($offset) {
93 | return $this->elements[$offset];
94 | }
95 | public function offsetSet($offset, $value) {
96 | $this->elements[$offset] = $value;
97 | }
98 | public function offsetExists($offset) {
99 | return isset($this->elements[$offset]);
100 | }
101 | public function offsetUnset($offset) {
102 | return NULL;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/server/db_cron/include/run_in_background.php:
--------------------------------------------------------------------------------
1 | $target & echo $!");
25 | chmod($target, 0777);
26 | }
27 | else
28 | $PID = shell_exec("nohup nice -n $Priority $Command > /dev/null & echo $!");
29 | }
30 | else{
31 | if($target){
32 | $PID = shell_exec("nohup $Command > $target & echo $!");
33 | chmod($target, 0777);
34 | }
35 | else
36 | $PID = shell_exec("nohup $Command > /dev/null & echo $!");
37 | }
38 | return($PID);
39 | }
40 |
41 | function is_process_running($PID)
42 | {
43 | exec("ps $PID", $ProcessState);
44 | return(count($ProcessState) >= 2);
45 | }
46 |
47 | ?>
48 |
--------------------------------------------------------------------------------
/server/db_cron/include/zpm_util.inc.php:
--------------------------------------------------------------------------------
1 | get_array_id_name();
57 | $game_name = $game_cfg['parent'];
58 |
59 | if (!empty($array_id_name)) {
60 | $array_name = $array_id_name[$array_id];
61 | }
62 | }
63 |
64 | // Fetch curent eu from eu database
65 | $euObj = new EUAdapter($server_cfg);
66 | $data_array = $euObj->get_current_eu($game_name, $array_name);
67 |
68 | $query = createQuery($table, $data_array);
69 | echo "$query\n";
70 | $query_res = execute_queries($server_cfg, $game_cfg, array($query));
71 |
72 | if ($query_res == 0) {
73 | $game_cfg['logger']->log("insert_zmonitor_data","zmonitor data for ".
74 | $game_cfg['name']." successfully inserted", Logger::INFO);
75 | } else {
76 | $game_cfg['logger']->log("insert_zmonitor_data","zmonitor data for ".
77 | $game_cfg['name']." not inserted", Logger::ERR);
78 | }
79 | }
80 |
81 | ?>
82 |
--------------------------------------------------------------------------------
/server/db_cron/pdt.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | #
4 | # Copyright 2013 Zynga Inc.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | #
20 | # Reads one or more bucketed PDT time files and prints it out in a
21 | # format readable by most humans
22 | #
23 | # bphilip@zynga.com
24 | #
25 |
26 | import sys
27 |
28 | def print_page(page, buckets, detail=False):
29 | if not detail:
30 | c = buckets['0']['count']
31 | if not c: c = 0.0000001
32 | t = buckets['0']['time']
33 | print "%s,%i,%i,%i" % (page,c,t,t/c)
34 | return
35 |
36 | head = "-" * 10 + page + "-" * 10
37 | print head
38 | # print "-" * len(head)
39 |
40 | bkts = [int(x) for x in buckets.keys()]
41 | bkts.sort()
42 | for b in [str(x) for x in bkts][:]:
43 | entry = buckets[b]
44 | c = int(entry["count"])
45 | if not c: c = 0.000001
46 | t = int(entry["time"])
47 | print "%8s %8i %12i %8i" % (b, c, t, round(t/c, 3))
48 | print
49 |
50 |
51 | def print_pages(buckets, page_list, detail=False):
52 | if not page_list:
53 | page_list = buckets.keys()
54 |
55 | if type(page_list) != list:
56 | page_list = [page_list]
57 | for page in page_list:
58 | print_page(page, buckets[page], detail)
59 |
60 |
61 | def load_apache_stats(file_list):
62 | buckets = {}
63 | stat_count = 0
64 |
65 | for fname in file_list:
66 | stat_count += 1
67 | # print "Opening", fname
68 | buf = open(fname).read()
69 | if buf[0] != "{":
70 | buf = buf[8:]
71 | stats = eval(buf)
72 |
73 | for page in stats.keys():
74 | merge(buckets, stats, page)
75 |
76 | print "opened %d stat files" % stat_count
77 | return buckets
78 |
79 |
80 | def merge(buckets, page_data, page_name):
81 |
82 | page = page_data[page_name]
83 | if not buckets.has_key(page_name):
84 | buckets[page_name] = page
85 | return
86 |
87 | for x in buckets[page_name].keys():
88 | buckets[page_name][x]['time'] += page[x]['time']
89 | buckets[page_name][x]['count'] += page[x]['count']
90 |
91 | return
92 |
93 | import getopt
94 |
95 | def main():
96 |
97 | opts, file_list = getopt.getopt(sys.argv[1:], "p:d")
98 |
99 | pages = None
100 | detail = False
101 |
102 | for i,j in opts:
103 | if i == "-p":
104 | pages = j
105 | if i == "-d":
106 | detail = True
107 |
108 | buckets = load_apache_stats(file_list)
109 | print_pages(buckets, pages, detail)
110 |
111 |
112 | if __name__ == '__main__':
113 | main()
114 |
--------------------------------------------------------------------------------
/server/db_cron/process_uploads.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2013 Zynga Inc.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | php -r "include 'server.cfg'; echo implode(' ',\$server_cfg['game_list']);" | xargs -n1 -P8 taskset -c 1-8 /usr/bin/php /usr/local/zperfmon/bin/process_uploads.php -g
20 |
--------------------------------------------------------------------------------
/server/db_cron/update_game_map.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | $config["DB"]["host"],
45 | "db_user" => $config["DB"]["user"],
46 | "db_pass" => $config["DB"]["password"],
47 | "db_name" => $config['DB']["database"],
48 | );
49 | }
50 |
51 | $report_cfg = get_report_cfg($server_cfg['report_conf_file']);
52 | $xhprofModelObject = new XhProfModel($server_cfg, $report_cfg ,false ,false);
53 | $result = $xhprofModelObject->generic_execute_get_query("get_instance_class_name", array());
54 |
55 | foreach ( $result as $value) {
56 | $db_class[$value['class_id']] = $value['class_name'];
57 | }
58 |
59 |
60 | /*
61 | * load config for all the games
62 | */
63 | $games = $server_cfg['game_list'];
64 | $class = Array();
65 |
66 | /*
67 | * cycle through all games and find all class name by reading hostgroup
68 | */
69 | foreach ( $games as $game){
70 | $hostgroup = new HostgroupConfig($server_cfg, $game);
71 | $class = array_merge($class, $hostgroup->get_class_name());
72 | }
73 |
74 | /*
75 | * find diff between these two array and insert into database if any new class is found in hostgroup files of any game
76 | */
77 | $diff = (array_diff(array_unique($class),$db_class));
78 | $max = count($db_class);
79 |
80 | if ( count($diff) > 0 )
81 | {
82 | foreach ($diff as $name=>$value){
83 | $max +=1;
84 | $xhprofModelObject->generic_execute_get_query("insert_instance_class_name",
85 | array('table' => 'instance_class_name',
86 | 'max' => $max,
87 | 'value' => $value
88 | )
89 | );
90 | }
91 | }
92 | zpm_postamble("");
93 | ?>
94 |
--------------------------------------------------------------------------------
/server/db_cron/xhprof_update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2013 Zynga Inc.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | /usr/local/zperfmon/bin/get_conf_vars.php -s auto_updated_games | xargs -n 1 /usr/local/zperfmon/bin/xhprof_update.php -g
20 | /usr/local/zperfmon/bin/get_conf_vars.php -s auto_ini_games | xargs -n 1 /usr/local/zperfmon/bin/xhprof_update.php -g
21 |
--------------------------------------------------------------------------------
/server/db_cron/zperfmon-server.cron:
--------------------------------------------------------------------------------
1 | 29,59 * * * * root /bin/nice -n 10 /usr/local/zperfmon/bin/get_game_metrics.sh > /dev/null 2>&1
2 | */5 * * * * root /bin/nice -n 10 /usr/local/zperfmon/bin/process_uploads.sh > /dev/null 2>&1
3 | # 25,55 * * * * root /bin/nice -n 10 /usr/local/zperfmon/bin/get_rightscale_data.sh > /dev/null 2>&1
4 | */5 * * * * root /bin/nice -n 10 /usr/local/zperfmon/bin/get_splunk_metrics.php > /dev/null 2>&1
5 | 10 6 * * * root /usr/local/zperfmon/bin/daily_job.sh > /dev/null 2>&1
6 | 25,55 * * * * root /usr/local/zperfmon/bin/fetch_rs.py -y instance > /dev/null 2>&1
7 | 0 */12 * * * root /usr/local/zperfmon/bin/fetch_rs.py -y deployment > /dev/null 2>&1
8 | 0 1 * * * root /usr/local/zperfmon/bin/fetch_rs.py -y template > /dev/null 2>&1
9 | 1 0 */3 * * root /usr/local/zperfmon/bin/xhprof_update.sh > /dev/null 2>&1
10 | 0 23 1 * * root /bin/nice php /usr/local/zperfmon/bin/zperfmon_partition_dynamics.php > /dev/null 2>&1
11 | 0 3 * * * root /bin/nice php /usr/local/zperfmon/bin/zperfmon-report-games-test.php >/dev/null 2>&1
12 |
--------------------------------------------------------------------------------
/server/db_cron/zperfmon_set_p_tag.php:
--------------------------------------------------------------------------------
1 |
81 |
--------------------------------------------------------------------------------
/server/schemas/config.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE DATABASE IF NOT EXISTS config;
18 |
19 | CREATE TABLE IF NOT EXISTS config.gameidmap
20 | (
21 | `id` int(6) default NULL,
22 | `name` varchar(255) NOT NULL,
23 | PRIMARY KEY (`id`)
24 | );
25 |
26 |
27 | LOCK TABLES config.gameidmap WRITE;
28 | INSERT IGNORE INTO config.gameidmap VALUES('88','adventure_prod');
29 | INSERT IGNORE INTO config.gameidmap VALUES('61','cafe');
30 | INSERT IGNORE INTO config.gameidmap VALUES('223','castle_prod');
31 | INSERT IGNORE INTO config.gameidmap VALUES('75','city');
32 | INSERT IGNORE INTO config.gameidmap VALUES('81','empire');
33 | INSERT IGNORE INTO config.gameidmap VALUES('90','familyville');
34 | INSERT IGNORE INTO config.gameidmap VALUES('63','farm');
35 | INSERT IGNORE INTO config.gameidmap VALUES('66','fish');
36 | INSERT IGNORE INTO config.gameidmap VALUES('119','forestville');
37 | INSERT IGNORE INTO config.gameidmap VALUES('67','frontier');
38 | INSERT IGNORE INTO config.gameidmap VALUES('115','hidden_chronicles');
39 | INSERT IGNORE INTO config.gameidmap VALUES('237','towerville');
40 | INSERT IGNORE INTO config.gameidmap VALUES('69','treasure');
41 | INSERT IGNORE INTO config.gameidmap VALUES('46','vampires');
42 | INSERT IGNORE INTO config.gameidmap VALUES('45','yoville');
43 | INSERT IGNORE INTO config.gameidmap VALUES('232','zoomobile');
44 | UNLOCK TABLES;
--------------------------------------------------------------------------------
/server/schemas/eu_schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE DATABASE IF NOT EXISTS eu;
18 |
19 | CREATE TABLE IF NOT EXISTS eu.common_eu (
20 | `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
21 | `game` varchar(30) NOT NULL,
22 | `class` varchar(20) NOT NULL,
23 | `hostgroup` varchar(80) NOT NULL,
24 | `plugin` varchar(60) NOT NULL,
25 | `metric` varchar(50) NOT NULL,
26 | `value` double default NULL,
27 | `stddev` float NOT NULL,
28 | PRIMARY KEY (timestamp, game, class, hostgroup, plugin, metric)
29 | );
30 |
31 |
--------------------------------------------------------------------------------
/server/schemas/events.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS `events` (
18 | `start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
19 | `end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
20 | `type` enum('tag','experiment','release') DEFAULT NULL,
21 | `text` varchar(252),
22 | PRIMARY KEY (start, type, text)
23 | );
24 |
25 | ALTER TABLE `events`
26 | ADD PRIMARY KEY(start, type, text(252)),
27 | DROP PRIMARY KEY;
28 |
29 | drop procedure if exists create_events_table;
30 |
31 | delimiter //
32 | create procedure create_events_table() begin
33 | /* delete columns if they exist */
34 | if exists (select * from information_schema.columns where table_schema = DATABASE() and table_name = 'stats_30min' and column_name = 'tag') then
35 | replace into events (start, type, text) select MIN(timestamp), 'tag', tag from stats_30min group by tag;
36 | replace into events (start, type, text) select MIN(timestamp), 'release', release_id from stats_30min group by release_id;
37 | alter table stats_30min drop column `tag`, drop column `release_id`;
38 | end if;
39 | end//
40 |
41 | delimiter ';'
42 | call create_events_table();
43 |
44 | drop procedure if exists create_events_table;
45 |
--------------------------------------------------------------------------------
/server/schemas/fn_details_table_schema:
--------------------------------------------------------------------------------
1 | top5_functions_30min;
2 |
3 | timestamp TIMESTAMP
4 | function VARCHAR(256)
5 | page VARCHAR(256)
6 | count INT
7 | incl_time INT
8 | excl_time INT
9 |
10 |
11 | #-------##-------##-------##-------#
12 |
13 | Top 5 functions by count for all pages at 123689
14 |
15 | SELECT function, count
16 | FROM fn_detail_table
17 | WHERE timestamp = 123689 AND page = "all"
18 | ORDER BY count DESC
19 | LIMIT 5;
20 |
21 | Top 5 functions by exclusive wall time for gateway.php pages at 777777
22 |
23 | SELECT function, count
24 | FROM fn_detail_table
25 | WHERE timestamp = 777777 AND page = "gateway.php"
26 | ORDER BY excl_time DESC
27 | LIMIT 5;
28 |
29 |
30 | 123124235 MC::Get gateway.php 4 230 150.48484
31 | 123124235 MC::Get gateway.php 4 230 150.48484
32 |
33 |
34 | tracked_functions_30min;
35 |
36 | timestamp TIMESTAMP
37 | function VARCHAR(256)
38 | page VARCHAR(256)
39 | count INT
40 | incl_time INT
41 | excl_time INT
42 |
--------------------------------------------------------------------------------
/server/schemas/game_config.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS game_config
18 | (
19 | name VARCHAR(64),
20 | value TEXT,
21 | gameid SMALLINT,
22 | timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
23 | PRIMARY KEY (name)
24 | );
25 |
--------------------------------------------------------------------------------
/server/schemas/insert_to_daily_table.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | delimiter //
18 |
19 | DROP PROCEDURE IF EXISTS insert_to_daily_table//
20 |
21 | CREATE PROCEDURE insert_to_daily_table(IN tbl TEXT, IN start_ts INT, IN end_ts INT)
22 | BEGIN
23 | DECLARE end_loop INT DEFAULT 0;
24 | DECLARE query TEXT;
25 | DECLARE col TEXT ;
26 | DECLARE cols CURSOR FOR
27 | SELECT column_name FROM information_schema.columns WHERE table_name=tbl and column_name!='timestamp' and table_schema=DATABASE();
28 |
29 | DECLARE CONTINUE HANDLER FOR NOT FOUND SET end_loop=1;
30 |
31 | SET @daily_table := REPLACE(tbl, "30min", "daily");
32 |
33 | OPEN cols;
34 |
35 | SET @query := CONCAT("REPLACE INTO ", @daily_table ," ( `timestamp` ");
36 |
37 | cols_loop: loop
38 | FETCH cols INTO col;
39 | IF end_loop = 1 THEN
40 | leave cols_loop;
41 | END IF;
42 | SET @query := CONCAT(@query, ", `", col, "`");
43 | END LOOP cols_loop;
44 | SET @query := CONCAT(@query, ")");
45 | CLOSE cols;
46 |
47 | OPEN cols;
48 |
49 | SET end_loop := 0;
50 | SET @query := CONCAT(@query, " SELECT FROM_UNIXTIME(", end_ts, ") ");
51 |
52 | cols_loop: loop
53 | FETCH cols INTO col;
54 | IF end_loop = 1 THEN
55 | leave cols_loop;
56 | END IF;
57 | SET @query := CONCAT(@query, ", AVG(", col, ") ", col);
58 | END LOOP cols_loop;
59 |
60 | SET @query := CONCAT(@query, " FROM ", tbl, " WHERE timestamp BETWEEN FROM_UNIXTIME(", start_ts, ") AND FROM_UNIXTIME(", end_ts, ")");
61 | CLOSE cols;
62 |
63 | call run_query(@query);
64 | END//
65 |
66 | delimiter ;
67 |
--------------------------------------------------------------------------------
/server/schemas/log.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | DROP PROCEDURE IF EXISTS drop_old_logs_table;
18 |
19 | DELIMITER //
20 | CREATE PROCEDURE drop_old_logs_table() BEGIN
21 | /* delete columns if they exist */
22 | IF (EXISTS (SELECT * FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'log')) AND (NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'log' AND column_name = 'log_id')) THEN
23 | DROP TABLE `log`;
24 | END IF;
25 | END//
26 |
27 | DELIMITER ';'
28 | CALL drop_old_logs_table();
29 |
30 | DROP PROCEDURE IF EXISTS drop_old_logs_table;
31 |
32 |
33 |
34 | CREATE TABLE IF NOT EXISTS log
35 | (
36 | log_id int NOT NULL AUTO_INCREMENT,
37 | timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- logging time
38 | log_level ENUM(
39 | 'EMERG', /* system is unusable */
40 | 'ALERT', /* action must be taken immediately */
41 | 'CRIT', /* critical conditions */
42 | 'ERR', /* error conditions */
43 | 'WARNING', /* warning conditions */
44 | 'NOTICE', /* normal but significant condition */
45 | 'INFO', /* informational */
46 | 'DEBUG' /* debug-level messages */
47 | ) NOT NULL DEFAULT 'INFO',
48 | module_name varchar(64) NOT NULL, -- name of the module (e.g. uploader, blob processor etc)
49 | message varchar(1024) NOT NULL, -- log message
50 | PRIMARY KEY(log_id,timestamp)
51 | );
52 |
--------------------------------------------------------------------------------
/server/schemas/report.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE DATABASE IF NOT EXISTS report;
18 |
19 | CREATE TABLE IF NOT EXISTS report.instance_utilization
20 | (
21 | `date` DATE NOT NULL ,
22 | `game` varchar(255) NOT NULL,
23 | `total_instance` int(6) default NULL,
24 | `DAU` int(11) default NULL,
25 | `DAU_per_instance` int(11) default NULL,
26 | `optimal_instance_count` int(11) default NULL,
27 | `slack_per` decimal(4,2) default NULL,
28 | `cloud_id` int(11) default NULL,
29 | PRIMARY KEY (`game`,`date`)
30 | );
31 |
32 | CREATE TABLE IF NOT EXISTS report.instance_class_summary
33 | (
34 | `date` DATE NOT NULL ,
35 | `game` varchar(255) NOT NULL,
36 | `class_id` TINYINT(2) NOT NULL,
37 | `total_instance` int(11) default NULL,
38 | `DAU_per_instance` int(11) default NULL,
39 | `optimal_instance_count` int(11) default NULL,
40 | `slack_per` decimal(4,2) default NULL,
41 | PRIMARY KEY (`game`,`date`,`class_id`)
42 | );
43 |
44 | CREATE TABLE IF NOT EXISTS report.instance_pool_summary
45 | (
46 | `date` DATE NOT NULL ,
47 | `game` varchar(255) NOT NULL,
48 | `class_id` TINYINT(2) NOT NULL,
49 | `pool_name` varchar(255) NOT NULL,
50 | `type_id` TINYINT(2) default NULL,
51 | `total_instance` int(11) default NULL,
52 | `DAU_per_instance` int(11) default NULL,
53 | `utilization_per` decimal(4,2) default NULL,
54 | `optimal_instance_count` int(11) default NULL,
55 | `slack_per` decimal(4,2) default NULL,
56 | `bottleneck` varchar(255) default NULL,
57 | `underutilized` varchar(255) default NULL,
58 | `headroom_per` decimal(4,2) default NULL,
59 | PRIMARY KEY (`game`,`date`, `pool_name`)
60 | );
61 |
62 |
63 | DROP TABLE IF EXISTS report.instance_class_name;
64 | CREATE TABLE report.instance_class_name
65 | (
66 | `class_id` TINYINT(2) NOT NULL,
67 | `class_name` varchar(255) NOT NULL,
68 | PRIMARY KEY (`class_id`,`class_name`)
69 | );
70 |
71 | LOCK TABLES report.instance_class_name WRITE;
72 | INSERT INTO report.instance_class_name VALUES('1','mqueue');
73 | INSERT INTO report.instance_class_name VALUES('2','consumer');
74 | INSERT INTO report.instance_class_name VALUES('3','msched');
75 | INSERT INTO report.instance_class_name VALUES('4','mc');
76 | INSERT INTO report.instance_class_name VALUES('5','proxy');
77 | INSERT INTO report.instance_class_name VALUES('6','web');
78 | INSERT INTO report.instance_class_name VALUES('7','db');
79 | INSERT INTO report.instance_class_name VALUES('8','mb');
80 | UNLOCK TABLES;
81 |
--------------------------------------------------------------------------------
/server/schemas/slow_page.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS slow_page
18 | (
19 | id MEDIUMINT NOT NULL AUTO_INCREMENT,
20 | page VARCHAR(256)NOT NULL,
21 | ip CHAR(16) NOT NULL,
22 | timestamp timestamp NOT NULL,
23 | page_time INT NOT NULL,
24 | top_excl_wt_1 VARCHAR(512),
25 | top_excl_wt_2 VARCHAR(512),
26 | top_excl_wt_3 VARCHAR(512),
27 | top_excl_wt_4 VARCHAR(512),
28 | top_excl_wt_5 VARCHAR(512),
29 | `profile` mediumblob,
30 | KEY (ID),
31 | INDEX slow_page_index (page, page_time)
32 | );
33 |
--------------------------------------------------------------------------------
/server/schemas/splunk_stats.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS `splunk_stats` (
18 | `timestamp` timestamp NOT NULL default '0000-00-00 00:00:00',
19 | `query_name` VARCHAR(255),
20 | `value` bigint(20) default '0',
21 | PRIMARY KEY (`timestamp`, `query_name`),
22 | KEY `timestamp` USING BTREE (`timestamp`)
23 | );
24 |
--------------------------------------------------------------------------------
/server/schemas/stats_30min.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS stats_30min
18 | (
19 | timestamp timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
20 | gameid smallint(6) NOT NULL DEFAULT -1,
21 | DAU int(11) NOT NULL DEFAULT -1,
22 | web_count int(11) NOT NULL DEFAULT -1,
23 | db_count int(11) NOT NULL DEFAULT -1,
24 | mc_count int(11) NOT NULL DEFAULT -1,
25 | mb_count int(11) NOT NULL DEFAULT -1,
26 | admin_count int(11) NOT NULL DEFAULT -1,
27 | proxy_count int(11) NOT NULL DEFAULT -1,
28 | queue_count int(11) NOT NULL DEFAULT -1,
29 | PRIMARY KEY (timestamp),
30 | INDEX USING BTREE(timestamp)
31 | );
32 |
33 |
34 | -- daily aggregated table
35 |
36 | CREATE TABLE IF NOT EXISTS stats_daily LIKE stats_30min;
37 |
38 |
--------------------------------------------------------------------------------
/server/schemas/vertica_stats_30min.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS `vertica_stats_30min` (
18 | `web_cpu_idle` float default '100',
19 | `web_cpu_iowait` float default '0',
20 | `web_mem_used` bigint(20) default '0',
21 | `web_mem_free` bigint(20) default '0',
22 | `web_nw_rx_pkts` int(11) default '0',
23 | `web_nw_rx_bytes` bigint(20) default '0',
24 | `web_nw_tx_pkts` int(11) default '0',
25 | `web_nw_tx_bytes` bigint(20) default '0',
26 | `web_rps` float default '0',
27 | `db_cpu_idle` float default '100',
28 | `db_cpu_iowait` float default '0',
29 | `db_mem_free` bigint(20) default '0',
30 | `db_nw_rx_pkts` int(11) default '0',
31 | `db_nw_rx_bytes` bigint(20) default '0',
32 | `db_nw_tx_pkts` int(11) default '0',
33 | `db_nw_tx_bytes` bigint(20) default '0',
34 | `mc_cpu_idle` float default '100',
35 | `mc_cpu_iowait` float default '0',
36 | `mc_mem_free` bigint(20) default '0',
37 | `mc_nw_rx_pkts` int(11) default '0',
38 | `mc_nw_rx_bytes` bigint(20) default '0',
39 | `mc_nw_tx_pkts` int(11) default '0',
40 | `mc_nw_tx_bytes` bigint(20) default '0',
41 | `timestamp` timestamp NOT NULL default '0000-00-00 00:00:00',
42 | `web_cpu_system` float default '0',
43 | `web_cpu_user` float default '0',
44 | PRIMARY KEY (`timestamp`),
45 | KEY `timestamp` USING BTREE (`timestamp`)
46 | );
47 |
48 |
49 | -- daily aggregated table
50 |
51 | CREATE TABLE IF NOT EXISTS `vertica_stats_daily` LIKE vertica_stats_30min;
52 |
53 |
--------------------------------------------------------------------------------
/server/schemas/xhprof_blob_30min.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2013 Zynga Inc.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE IF NOT EXISTS xhprof_blob_30min
18 | (
19 | `timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
20 | xhprof_blob mediumblob,
21 | `flags` SET('MemDisabled',
22 | 'MemEnabled',
23 | 'MemPartial') default 'MemDisabled',
24 | `p_tag` smallint DEFAULT 0,
25 |
26 | PRIMARY KEY (timestamp, p_tag),
27 | INDEX USING BTREE(timestamp)
28 | ) partition by list(p_tag) (
29 | partition p000 values in (0),
30 | partition p001 values in (1,7, -1,-7),
31 | partition p002 values in (2,8, -2,-8),
32 | partition p003 values in (3,9, -3,-9),
33 | partition p004 values in (4,10,-4,-10),
34 | partition p005 values in (5,11,-5,-11),
35 | partition p006 values in (6,12,-6,-12)
36 | )
37 | ;
38 |
39 |
40 | -- daily aggregated table
41 |
42 | CREATE TABLE IF NOT EXISTS xhprof_blob_daily LIKE xhprof_blob_30min;
43 |
44 |
--------------------------------------------------------------------------------
/server/scripts/Readme:
--------------------------------------------------------------------------------
1 | Place holder
--------------------------------------------------------------------------------
/server/web_ui/README.txt:
--------------------------------------------------------------------------------
1 | Following changes should be made to httpd.conf file to configure user authentication to access the page
2 |
3 | 1) Write following sections in httpd.conf file
4 |
5 | AuthUserFile /var/www/.zperfmon_user
6 |
7 |
8 |
9 | AuthUserFile /var/www/.zperfmon_admin
10 |
11 |
12 | expln:- Here we have created aliases for two different password files namely zperfmon_user and zperfmon_admin.
13 | Here wwe have already created two password files "/var/www/.zperfmon_admin" and "/var/www/.zperfmon_user"
14 |
15 | 2) Below this create a Directory section in httpd.conf file as shown below :-
16 |
17 | [ex. /var/www/html/zperfmon]
18 | AllowOverride None
19 | AuthName "Require user ceredentials"
20 | AuthType Basic
21 | Require valid-user
22 | AuthBasicProvider zperfmon_user zperfmon_admin
23 |
24 |
25 | expln:- Here we write the exact authentication script.
26 |
27 | 3) Restart the server
28 | /sbin/service httpd restart
29 | 4) Now try to access the page which are in the given directory(/var/www/html/zperfmon), it will ask for user authentication
30 |
--------------------------------------------------------------------------------
/server/web_ui/admin/fetch_hosts.php:
--------------------------------------------------------------------------------
1 | prepare($query);
56 | $stmt->execute();
57 | $hosts = $stmt->fetchAll(PDO::FETCH_ASSOC);
58 | $count_hostnames = array();
59 | foreach($hosts as $value){
60 | $count_hostnames["hosts"][] = $value["hostname"];
61 | }
62 |
63 |
64 | $count_hostnames["count"] = count($count_hostnames["hosts"]);
65 |
66 | echo json_encode($count_hostnames);
67 |
68 | }
69 | main($server_cfg);
70 | ?>
71 |
--------------------------------------------------------------------------------
/server/web_ui/admin/images/delete.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/admin/images/delete.jpg
--------------------------------------------------------------------------------
/server/web_ui/admin/images/download_sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/admin/images/download_sprite.png
--------------------------------------------------------------------------------
/server/web_ui/apis/add-game-worker.php:
--------------------------------------------------------------------------------
1 | addServer('localhost', 4730);
24 |
25 | # Register function "reverse" with the server.
26 | $worker->addFunction("shell_execute", "shell_execute");
27 | $options = getopt("P:");
28 | $pid = getmypid();
29 | file_put_contents($options['P'], $pid);
30 | while (1)
31 | {
32 | # print "Waiting for job...\n";
33 |
34 | $ret= $worker->work();
35 | if ($worker->returnCode() != GEARMAN_SUCCESS)
36 | break;
37 | }
38 |
39 | # A much simple reverse function
40 | function shell_execute($job)
41 | {
42 | $workload= $job->workload();
43 | # echo "Automated game addition to zPerfmon: " . $job->handle() . "\n";
44 | # echo "Workload: $workload\n";
45 | $result= exec($workload, $retval);
46 | # echo "Result: $retval\n";
47 | #print_r($retval);
48 | return $result;
49 | }
50 |
51 | ?>
52 |
--------------------------------------------------------------------------------
/server/web_ui/apis/get_candidates.php:
--------------------------------------------------------------------------------
1 | generic_execute_get_query_detail($query,
51 | array('table' => $game_cfg["db_stats_table"],
52 | 'end_time' => $end_time,
53 | 'start_time' => $start_time,
54 | 'extra_params' => ""));
55 |
56 | $tags = $xhprofModelObject->generic_execute_get_query("get_tag_range",
57 | array('table' => "events",
58 | 'end_time' => $end_time,
59 | 'start_time' => $start_time,
60 | 'extra_params' => ""));
61 | $chart_result["tags"] = $tags;
62 |
63 | echo json_encode($chart_result);
64 | }
65 |
66 | ProcessRequest($server_cfg, $game_cfg);
67 |
68 | ?>
69 |
70 |
--------------------------------------------------------------------------------
/server/web_ui/css/bx_styles-3.0.css:
--------------------------------------------------------------------------------
1 | /* @override http://localhost/bxslider_v3_plugin/css/styles.css */
2 |
3 | /*
4 | * To change the color scheme of slider change each
5 | * background property for each of the five styles below
6 | */
7 |
8 | /*next button*/
9 | .bx-next {
10 | position:absolute;
11 | top:40%;
12 | right:-50px;
13 | z-index:999;
14 | width: 30px;
15 | height: 30px;
16 | text-indent: -999999px;
17 | background: url(gray_next.png) no-repeat 0 -30px;
18 | }
19 |
20 | /*previous button*/
21 | .bx-prev {
22 | position:absolute;
23 | top:40%;
24 | left:-50px;
25 | z-index:999;
26 | width: 30px;
27 | height: 30px;
28 | text-indent: -999999px;
29 | background: url(gray_prev.png) no-repeat 0 -30px;
30 | }
31 |
32 | /*pager links*/
33 | .bx-pager a {
34 | margin-right: 5px;
35 | color: #fff;
36 | padding: 3px 8px 3px 6px;
37 | font-size: 12px;
38 | zoom:1;
39 | background: url(images/gray_pager.png) no-repeat 0 -20px;
40 | }
41 |
42 | /*auto start button*/
43 | .bx-auto .start {
44 | background: url(gray_auto.png) no-repeat 0 2px;
45 | padding-left: 13px;
46 | }
47 |
48 | /*auto stop button*/
49 | .bx-auto .stop {
50 | background: url(gray_auto.png) no-repeat 0 -14px;
51 | padding-left: 13px;
52 | }
53 |
54 | /*
55 | * End color scheme styles
56 | */
57 |
58 |
59 | /*next/prev button hover state*/
60 | .bx-next:hover,
61 | .bx-prev:hover {
62 | background-position: 0 0;
63 | }
64 |
65 | /*pager links hover and active states*/
66 | .bx-pager .pager-active,
67 | .bx-pager a:hover {
68 | background-position: 0 0;
69 | }
70 |
71 | /*pager wrapper*/
72 | .bx-pager {
73 | text-align:center;
74 | padding-top: 7px;
75 | font-size:12px;
76 | color:#666;
77 | }
78 |
79 | /*captions*/
80 | .bx-captions {
81 | text-align:center;
82 | font-size: 12px;
83 | padding: 7px 0;
84 | color: #666;
85 | }
86 |
87 | /*auto controls*/
88 | .bx-auto {
89 | text-align: center;
90 | padding-top: 15px;
91 | }
92 |
93 | .bx-auto a {
94 | color: #666;
95 | font-size: 12px;
96 | }
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/server/web_ui/css/gauges.css:
--------------------------------------------------------------------------------
1 | .gHolder{
2 | position:relative;
3 | width:150px;
4 | height:160px;
5 | }
6 |
7 | .gBackground{
8 | background-position: -4px -18px;
9 | background-repeat: no-repeat;
10 | width:150px;
11 | height:150px;
12 | position:absolute;
13 | z-index:10;
14 | }
15 |
16 | .gLabel{
17 | position:absolute;
18 | z-index:30;
19 | width:150px;
20 | height:30px;
21 | top:10px;
22 | text-align:center;
23 | color:#2b2b2b;
24 | }
25 |
26 | .gFill{
27 | background-position:-336px -12px;
28 | background-repeat: no-repeat;
29 | width:150px;
30 | height:0;
31 | bottom:15px;
32 | left:3px;
33 | position:absolute;
34 | z-index:20;
35 | }
36 |
37 | .gGlass{
38 | background-position:-162px -19px;
39 | background-repeat: no-repeat;
40 | width:150px;
41 | height:160px;
42 | position:absolute;
43 | z-index:40;
44 | font-family:impact;
45 | font-size:40px;
46 | }
47 |
48 | .gBigNumber{
49 | position:absolute;
50 | background-image: none;
51 | background-repeat: no-repeat;
52 | z-index:30;
53 | font-family:impact;
54 | font-size:60px;
55 | line-height:60px;
56 | top:60px;
57 | right:50px;
58 | text-align:right;
59 | }
60 |
61 | .gSmallNumber{
62 | position:absolute;
63 | z-index:30;
64 | font-family:impact;
65 | font-size:30px;
66 | line-height:30px;
67 | top:87px;
68 | right:20px;
69 | text-align:right;
70 | }
71 |
72 | .gGreen, .g_good, .g_okay {
73 | background-image: url('images/gauge-green.png');
74 | }
75 |
76 | .gRed, .g_ugly {
77 | background-image: url('images/gauge-red.png');
78 | }
79 |
80 | .gOrange, .g_bad {
81 | background-image: url('images/gauge-orange.png');
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/server/web_ui/css/images/close_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/close_icon.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/gauge-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/gauge-green.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/gauge-orange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/gauge-orange.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/gauge-red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/gauge-red.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/gray_pager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/gray_pager.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/nav_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/nav_bg.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/zoom-in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/zoom-in.png
--------------------------------------------------------------------------------
/server/web_ui/css/images/zoom-out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/images/zoom-out.png
--------------------------------------------------------------------------------
/server/web_ui/css/jquery.autocomplete.css:
--------------------------------------------------------------------------------
1 | .ac_results {
2 | padding: 0px;
3 | border: 1px solid black;
4 | background-color: white;
5 | overflow: hidden;
6 | z-index: 99999;
7 | }
8 |
9 | .ac_results ul {
10 | width: 100%;
11 | list-style-position: outside;
12 | list-style: none;
13 | padding: 0;
14 | margin: 0;
15 | }
16 |
17 | .ac_results li {
18 | margin: 0px;
19 | padding: 2px 5px;
20 | cursor: default;
21 | display: block;
22 | /*
23 | if width will be 100% horizontal scrollbar will apear
24 | when scroll mode will be used
25 | */
26 | /*width: 100%;*/
27 | font: menu;
28 | font-size: 12px;
29 | /*
30 | it is very important, if line-height not setted or setted
31 | in relative units scroll will be broken in firefox
32 | */
33 | line-height: 16px;
34 | overflow: hidden;
35 | }
36 |
37 | .ac_loading {
38 | background: white url('indicator.gif') right center no-repeat;
39 | }
40 |
41 | .ac_odd {
42 | background-color: #eee;
43 | }
44 |
45 | .ac_over {
46 | background-color: #0A246A;
47 | color: white;
48 | }
49 |
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-icons_2e83ff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-icons_2e83ff_256x240.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-icons_454545_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-icons_454545_256x240.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-icons_888888_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-icons_888888_256x240.png
--------------------------------------------------------------------------------
/server/web_ui/css/smoothness/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/css/smoothness/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/server/web_ui/css/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: 'Ubuntu',arial,serif;
3 | }
4 | .left {
5 | float:left;
6 | }
7 | .right {
8 | float:right;
9 | }
10 | .clear {
11 | clear:both;
12 | }
13 | .hd {
14 | margin-bottom:10px;
15 | color:#212121;
16 | }
17 | .hd .title {
18 | font-family:'Michroma';
19 | font-size:40px;
20 | font-weight:bold;
21 | color:#999;
22 | }
23 | #game-info {
24 | font-family: 'Ubuntu';
25 | font-size: 16px;
26 | }
27 | #game-info #select-game-div {
28 | margin:0 20px 0 10px;
29 | }
30 | #game-info #game-name {
31 | font-family:'Michroma';
32 | font-size:48px;
33 | line-height:36px;
34 | }
35 | #game-info .label {
36 | margin-left:6px;
37 | }
38 | #game-info select {
39 | font-size:14px;
40 | margin-left:4px;
41 | }
42 | #game-info #dashboard-view-link {
43 | margin:8px 0 0 4px;
44 | }
45 |
--------------------------------------------------------------------------------
/server/web_ui/cto-view/cto_query.php:
--------------------------------------------------------------------------------
1 | $item)
34 | {
35 | $new_vector[] = $escape_char . $item . $escape_char;
36 | }
37 |
38 | return $new_vector;
39 | }
40 |
41 | function ProcessRequest($server_cfg, $game_cfg) {
42 |
43 | $columns=$_GET["columns"];
44 | //echo $columns;
45 |
46 | $wrapped_column_names = wrap_escape(explode(",", $columns), "`");
47 | //print_r($wrapped_column_names);
48 | $query = $_GET["query"];
49 | $xhprofModelObject = new XhProfModel($server_cfg, $game_cfg);
50 |
51 | date_default_timezone_set('UTC');
52 | $end_time = time();
53 | $start_time = ($end_time - 12 * 7 * 24 * 60 * 60); # 12 weeks ago
54 | $implode_columns=implode(",",$wrapped_column_names);
55 | if(!($query) || $query == "cto_get_top_pages_avg_load_time")
56 | {
57 |
58 | $chart_result = $xhprofModelObject->generic_execute_get_query_detail($query,
59 | array('table' => "apache_stats_flip_avg",
60 | 'end_time' => $end_time,
61 | 'start_time' => $start_time,
62 | 'columns'=>$implode_columns));
63 | }
64 | else if($query == "cto_get_tracked_functions_by_column")
65 | {
66 | $page = $_GET['page'];
67 | $chart_result = $xhprofModelObject->generic_execute_get_query_detail($query,
68 | array('table' => "tracked_functions_flip_incl_time",
69 | 'end_time' => $end_time,
70 | 'start_time' => $start_time,
71 | 'page' => $page,
72 | 'columns'=>$implode_columns));
73 | }
74 | else
75 | {
76 | echo json_encode("Illegal Query!");
77 | return;
78 | }
79 |
80 | $tags = $xhprofModelObject->generic_execute_get_query("get_tag_range",
81 | array('table' => "events",
82 | 'end_time' => $end_time,
83 | 'start_time' => $start_time,
84 | 'extra_params' => ""));
85 | $chart_result["tags"] = $tags;
86 |
87 | echo json_encode($chart_result);
88 | }
89 |
90 | ProcessRequest($server_cfg, $game_cfg);
91 |
92 | ?>
93 |
94 |
--------------------------------------------------------------------------------
/server/web_ui/dau/index.php:
--------------------------------------------------------------------------------
1 | get_dau(null, $start_time, $end_time);
30 | print_r($data);
31 | }
32 |
33 | function shadow_upload($target_file)
34 | {
35 | if(defined('SHADOW_UPDATE_URL') && !isset($_GET['shadow'])) {
36 | $ch = curl_init();
37 | curl_setopt($ch, CURLOPT_HEADER, 0);
38 | curl_setopt($ch, CURLOPT_VERBOSE, 0);
39 | curl_setopt($ch, CURLOPT_URL, SHADOW_UPDATE_URL."?shadow&v=".$_GET["v"]);
40 | curl_setopt($ch, CURLOPT_POST, true);
41 | $post = array("DAU"=>"@$target_file");
42 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
43 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
44 | $response = curl_exec($ch);
45 | if($response === false) {
46 | error_log("Shadow upload of DAU to ".SHADOW_UPDATE_URL." failed");
47 | }
48 | curl_close($ch);
49 | }
50 | }
51 |
52 | function store_dau()
53 | {
54 | $rows = array();
55 | $tmp_file = fopen($_FILES['DAU']['tmp_name'], "r");
56 |
57 | while($row = fgetcsv($tmp_file, 0, "\t"))
58 | {
59 | $rows[] = $row;
60 | }
61 |
62 | $daustore = new DAUAdapter();
63 |
64 | $daustore->store_dau($rows);
65 | shadow_upload($_FILES['DAU']['tmp_name']);
66 | }
67 |
68 | $method = $_SERVER['REQUEST_METHOD'];
69 |
70 | if($method == "GET") print_dau();
71 | else if ($method == "POST") store_dau();
72 | ?>
73 |
--------------------------------------------------------------------------------
/server/web_ui/eu-view/eu-query.php:
--------------------------------------------------------------------------------
1 | $game, 'array_id' => $array_id,
44 | "hostgroup" => $hostgroup);
45 | }
46 |
47 |
48 | function ProcessRequest($server_cfg, $game_cfg, $params) {
49 |
50 | $query = $_GET["query"];
51 | if (!$query) {
52 | $query = 'eu_web_chart_range';
53 | }
54 |
55 | if (!$query) {
56 | return json_encode("Illegal query.");
57 | }
58 |
59 | $xhprofModelObject = new XhProfModel($server_cfg, $game_cfg);
60 |
61 | date_default_timezone_set('UTC');
62 | $end_time = time();
63 | $start_time = (time() - 12 * 7 * 24 * 60 * 60); # 12 weeks ago
64 |
65 | $chart_result = $xhprofModelObject->generic_execute_get_query_detail($query,
66 | array('table' => "vertica_stats_30min",
67 | 'end_time' => $end_time,
68 | 'start_time' => $start_time,
69 | 'prefix' => str_replace("-","_",$params['hostgroup']),
70 | )
71 | );
72 |
73 | $tags = $xhprofModelObject->generic_execute_get_query("get_tag_range",
74 | array('table' => "events",
75 | 'end_time' => $end_time,
76 | 'start_time' => $start_time,
77 | 'extra_params' => ""));
78 | $chart_result["tags"] = $tags;
79 | echo json_encode($chart_result);
80 | }
81 |
82 | $params = safe_get_params();
83 |
84 | $game_cfg = load_game_config($params['game'], $params['array_id']);
85 | ProcessRequest($server_cfg, $game_cfg, $params);
86 |
87 | ?>
88 |
89 |
--------------------------------------------------------------------------------
/server/web_ui/eu/index.php:
--------------------------------------------------------------------------------
1 | "@$target_file");
31 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
33 | $response = curl_exec($ch);
34 | if($response === false) {
35 | error_log("Shadow upload of EU to ".SHADOW_UPDATE_URL." failed");
36 | }
37 | curl_close($ch);
38 | }
39 | }
40 |
41 | function store_eu($server_cfg)
42 | {
43 | $rows = array();
44 | $tmp_file = fopen($_FILES['EU']['tmp_name'], "r");
45 |
46 | while($row = fgetcsv($tmp_file, 0, ","))
47 | {
48 | $rows[] = $row;
49 | }
50 |
51 | $eustore = new EUAdapter($server_cfg);
52 |
53 | $eustore->store_eu($rows);
54 |
55 | shadow_upload($_FILES['EU']['tmp_name']);
56 | }
57 |
58 | $method = $_SERVER['REQUEST_METHOD'];
59 |
60 | if ($method == "POST") store_eu($server_cfg);
61 |
62 | ?>
63 |
--------------------------------------------------------------------------------
/server/web_ui/fetch.php:
--------------------------------------------------------------------------------
1 | game->addAttribute("name", $zmon_game);
35 |
36 | $dom = new DomDocument();
37 | $dom->loadXML($xml->asXML());
38 | $dom->formatOutput = true;
39 | $formatedXML = $dom->saveXML();
40 |
41 | echo $formatedXML;
42 |
43 | ?>
44 |
45 |
--------------------------------------------------------------------------------
/server/web_ui/get_yaml_config.php:
--------------------------------------------------------------------------------
1 | get_config_file($game);
33 |
34 | $game_config_file = sprintf($server_cfg['hostgroups_config'], $game);
35 |
36 | $str_yaml = null;
37 | if (file_exists($common_config_file)) {
38 | $str_yaml = file_get_contents($common_config_file);
39 | }
40 |
41 | if (file_exists($game_config_file)) {
42 |
43 | $str_yaml .= file_get_contents($game_config_file);
44 | }
45 |
46 | echo $str_yaml;
47 |
--------------------------------------------------------------------------------
/server/web_ui/help/bd_help.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/help/bd_help.pdf
--------------------------------------------------------------------------------
/server/web_ui/help/cto_help.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/help/cto_help.pdf
--------------------------------------------------------------------------------
/server/web_ui/help/eu_help.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/help/eu_help.pdf
--------------------------------------------------------------------------------
/server/web_ui/help/profile_help.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/help/profile_help.pdf
--------------------------------------------------------------------------------
/server/web_ui/help/slow_page_help.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/help/slow_page_help.pdf
--------------------------------------------------------------------------------
/server/web_ui/help/top5_help.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/help/top5_help.pdf
--------------------------------------------------------------------------------
/server/web_ui/images/loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/images/loader.gif
--------------------------------------------------------------------------------
/server/web_ui/images/spinner.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/server/web_ui/images/spinner.gif
--------------------------------------------------------------------------------
/server/web_ui/include/PDOAdapter.php:
--------------------------------------------------------------------------------
1 | pdo = new PDO( "{$db_type}:host={$db_host};dbname={$db_name}",$db_user, $db_pass);
27 | }
28 |
29 |
30 | /* prepare a statement to be later executed with execute/fetchAll */
31 | protected function prepare($query)
32 | {
33 | if($this->pdo)
34 | {
35 | $db = $this->pdo;
36 | $stmt = $db->prepare($query);
37 | return $stmt;
38 | }
39 |
40 | return null;
41 | }
42 |
43 | private function bind($stmt, $parameters)
44 | {
45 | foreach($parameters as $name => $value)
46 | {
47 | $type = null;
48 | if(is_array($value))
49 | {
50 | list($value, $type) = $value;
51 | }
52 | else
53 | {
54 | /* different from default for bindValue, which is STRING */
55 | $type = PDO::PARAM_INT;
56 | }
57 |
58 | $stmt->bindValue(":$name", $value, $type);
59 | }
60 | }
61 |
62 | protected function execute($stmt, $parameters)
63 | {
64 | $this->bind($stmt, $parameters);
65 | return ($stmt->execute());
66 | }
67 |
68 | protected function store($stmt, $parameters)
69 | {
70 | return $this->execute($stmt, $parameters);
71 | }
72 |
73 | protected function fetchAll($stmt, $parameters)
74 | {
75 | if ($this->execute($stmt, $parameters))
76 | {
77 | return $stmt->fetchAll(PDO::FETCH_ASSOC);
78 | }
79 |
80 | return null;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/server/web_ui/include/XhProfJSONView.php:
--------------------------------------------------------------------------------
1 | $value)
58 | {
59 | $var = $var . ($row_begin . implode(",", array_values($value)) . $row_end);
60 | $var = $var . ",";
61 | }
62 | $var = rtrim($var, ",") . $list_end;
63 |
64 | echo "cols:" . $var;
65 | }
66 |
67 |
68 | /*
69 | * Render the model data in form of following form
70 | * [
71 | * cols: [col1, col2, col3]
72 | * rows: [{val11, val12, val13}, {val21, val22, val23}, {val31, val32, val33}]
73 | * agrgt_cols: [col1, col2, col3]
74 | * agrgt: [{val11, val12, val13}, {val21, val22, val23}, {val31, val32, val33}]
75 | * ]
76 | */
77 | public function RenderCombination($chart_cols, $chart_result,
78 | $tables_cols = null, $table_result = null)
79 | {
80 | if (!isset ($chart_cols) || !isset($chart_result)) {
81 | return;
82 | }
83 |
84 | $json_container = array();
85 |
86 | $json_container["cols"] = $chart_cols;
87 | $json_container["rows"] = $chart_result;
88 |
89 | if (isset($tables_cols) && isset($table_result)) {
90 | $json_container["agrgt_cols"] = $tables_cols;
91 | $json_container["agrgt"] = $table_result;
92 | }
93 |
94 | return json_encode($json_container);
95 | }
96 |
97 | }
98 | ?>
99 |
--------------------------------------------------------------------------------
/server/web_ui/include/XhProfView_Interface.php:
--------------------------------------------------------------------------------
1 |
40 |
--------------------------------------------------------------------------------
/server/web_ui/include/ZPerfmonDAO_Interface.php:
--------------------------------------------------------------------------------
1 |
35 |
--------------------------------------------------------------------------------
/server/web_ui/include/gameidMap.php:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # Copyright 2013 Zynga Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | $config["DB"]["host"],
25 | "db_user" => $config["DB"]["user"],
26 | "db_pass" => $config["DB"]["password"],
27 | "db_name" => 'config',
28 | );
29 | }
30 | function getGameMapping($server_cfg){
31 | $cfg = get_report_cfg($server_cfg['report_conf_file']);
32 | $xhprofModelObject = new XhProfModel($server_cfg, $cfg,false,false);
33 | $gameMap = array();
34 | $result = $xhprofModelObject->generic_execute_get_query("get_game_name_by_id", array());
35 | foreach ( $result as $value) {
36 | $gameMap[$value['id']] = $value['name'];
37 | }
38 | return $gameMap;
39 | }
40 | ?>
--------------------------------------------------------------------------------
/server/web_ui/include/prof_summary.php:
--------------------------------------------------------------------------------
1 | isset($totals['pmu']) ? $totals['pmu'] : '',
36 | 'mu' => isset($totals['mu']) ? $totals['mu'] : '',
37 | 'wt' => $totals['wt'],
38 | 'cpu' => $totals['cpu'],
39 | 'nbr' => $probe_count);
40 | }
41 |
42 |
43 |
--------------------------------------------------------------------------------
/server/web_ui/include/setup_page.php:
--------------------------------------------------------------------------------
1 | Error: expected a game name parameter, eg.: \"?game=fish\"