├── 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\""; 60 | exit(1); 61 | } 62 | 63 | if(isset($arrayid) && $arrayid == "all") { 64 | $arrayid = null; 65 | } 66 | 67 | $game_cfg = load_game_config($game, $arrayid); 68 | 69 | if (!$game_cfg) { 70 | echo "Error: invalid game name: \"$game\""; 71 | exit(1); 72 | } 73 | 74 | ?> 75 | -------------------------------------------------------------------------------- /server/web_ui/include/slack_api.php: -------------------------------------------------------------------------------- 1 | true, // return web page 30 | CURLOPT_HEADER => false, // don't return headers 31 | CURLOPT_FOLLOWLOCATION => true, // follow redirects 32 | CURLOPT_ENCODING => "", // handle compressed 33 | CURLOPT_USERAGENT => "zperfmon", // who am i 34 | CURLOPT_AUTOREFERER => true, // set referer on redirect 35 | CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect 36 | CURLOPT_TIMEOUT => 60, // timeout on response 37 | CURLOPT_MAXREDIRS => 10, 38 | CURLOPT_POST => 2, 39 | CURLOPT_POSTFIELDS => $post_values); 40 | 41 | $ch = curl_init ( $api ); 42 | curl_setopt_array ( $ch, $options ); 43 | $content = curl_exec ( $ch ); 44 | $err = curl_errno ( $ch ); 45 | $errmsg = curl_error ( $ch ); 46 | $httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE ); 47 | curl_close ( $ch ); 48 | if($httpCode!=200){ 49 | die("HTTP Error Code : ".$httpCode."\nCURL Error : $errmsg\n"); 50 | } 51 | 52 | $content = trim($content); 53 | $content = explode("\n",$content); 54 | return $content[0]; 55 | 56 | } 57 | 58 | ?> 59 | -------------------------------------------------------------------------------- /server/web_ui/js/autoheight.js: -------------------------------------------------------------------------------- 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 | 18 | function doIframe(){ 19 | o = document.getElementsByTagName('iframe'); 20 | for(i=0;i/zperfmon/js/datatables.1.9.4/ 6 | 7 | DataTables-1.9.4/media/images 8 | DataTables-1.9.4/media/css 9 | DataTables-1.9.4/media/js 10 | 11 | 12 | You can also run the link_datatable script provided here. 13 | -------------------------------------------------------------------------------- /server/web_ui/js/datatables.1.9.4/link_datatable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HTTPD_ROOT="/var/www/html/zperfmon" 4 | DATA_TABLE_DIR=$1 5 | 6 | if [[ "${DATA_TABLE_DIR}__" != "__" && -f ${DATA_TABLE_DIR} ]] 7 | then 8 | ln -s "${DATA_TABLE_DIR}/media/css" ${HTTPD_ROOT}/zperfmon/js/datatables.1.9.4/css 9 | ln -s "${DATA_TABLE_DIR}/media/images" ${HTTPD_ROOT}/zperfmon/js/datatables.1.9.4/images 10 | ln -s "${DATA_TABLE_DIR}/media/js" ${HTTPD_ROOT}/zperfmon/js/datatables.1.9.4/js 11 | echo "Links created from ${DATA_TABLE_DIR} to ${HTTPD_ROOT}/zperfmon" 12 | else 13 | echo "Please give me as argument directory where datatables was extracted." 14 | fi 15 | -------------------------------------------------------------------------------- /server/web_ui/js/jquery.cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery Cookie plugin 3 | * 4 | * Copyright (c) 2010 Klaus Hartl (stilbuero.de) 5 | * Dual licensed under the MIT and GPL licenses: 6 | * http://www.opensource.org/licenses/mit-license.php 7 | * http://www.gnu.org/licenses/gpl.html 8 | * 9 | */ 10 | jQuery.cookie = function (key, value, options) { 11 | 12 | // key and at least value given, set cookie... 13 | if (arguments.length > 1 && String(value) !== "[object Object]") { 14 | options = jQuery.extend({}, options); 15 | 16 | if (value === null || value === undefined) { 17 | options.expires = -1; 18 | } 19 | 20 | if (typeof options.expires === 'number') { 21 | var days = options.expires, t = options.expires = new Date(); 22 | t.setDate(t.getDate() + days); 23 | } 24 | 25 | value = String(value); 26 | 27 | return (document.cookie = [ 28 | encodeURIComponent(key), '=', 29 | options.raw ? value : encodeURIComponent(value), 30 | options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE 31 | options.path ? '; path=' + options.path : '', 32 | options.domain ? '; domain=' + options.domain : '', 33 | options.secure ? '; secure' : '' 34 | ].join('')); 35 | } 36 | 37 | // key and possibly options given, get cookie... 38 | options = value || {}; 39 | var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; 40 | return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; 41 | }; 42 | -------------------------------------------------------------------------------- /server/web_ui/profile-view/dev-view.css: -------------------------------------------------------------------------------- 1 | .yui_style tr:nth-child(odd) { 2 | background: #EDF5FF 3 | } 4 | .yui_style tr:nth-child(even) { 5 | background: white 6 | } 7 | .ui-datepicker { 8 | width: 18em; 9 | padding: .2em .2em 0; 10 | } 11 | .yui_style td { 12 | height:30px; 13 | } 14 | #hide_button span{ 15 | padding: 17px 2px;background-image: url(http://yui.yahooapis.com/2.8.2r1/build/assets/skins/sam/sprite.png);border: 1px solid;border-color: grey; 16 | } 17 | #show_button span{ 18 | padding: 17px 2px;background-image: url(http://yui.yahooapis.com/2.8.2r1/build/assets/skins/sam/sprite.png);border: 1px solid;border-color: grey; 19 | } 20 | #SidePanelOuter{ 21 | border: 1px solid #AAA; 22 | border-radius: 4px; 23 | padding: 10px; 24 | } 25 | .hide{ 26 | display:none; 27 | } 28 | #SidePane{ 29 | width:309px; 30 | } 31 | #mainpanetable { 32 | float:left; 33 | margin-top:0px; 34 | } 35 | -------------------------------------------------------------------------------- /server/web_ui/profile-view/getLastProfile.php: -------------------------------------------------------------------------------- 1 | generic_execute_get_query("get_last_profile_slots", 36 | array('table' => $game_cfg["xhprof_blob_table"], 37 | 'end_time' => $end_time, 38 | 'start_time' => $start_time, 39 | 'extra_params' => "")); 40 | 41 | 42 | echo json_encode($result); 43 | } 44 | 45 | ProcessRequest($server_cfg, $game_cfg); 46 | ?> 47 | -------------------------------------------------------------------------------- /server/web_ui/profile-view/getProfileList.php: -------------------------------------------------------------------------------- 1 | generic_execute_get_query("get_profile_slots", 37 | array('table' => $game_cfg["xhprof_blob_table"], 38 | 'end_time' => $end_time, 39 | 'start_time' => $start_time, 40 | 'extra_params' => "")); 41 | 42 | 43 | echo json_encode($result); 44 | } 45 | 46 | ProcessRequest($server_cfg, $game_cfg); 47 | ?> 48 | -------------------------------------------------------------------------------- /server/web_ui/profile-view/getReleaseList.php: -------------------------------------------------------------------------------- 1 | generic_execute_get_query("get_release_list", 35 | array('table' => 'events', 36 | 'extra_params' => "")); 37 | 38 | 39 | echo json_encode($result); 40 | } 41 | 42 | ProcessRequest($server_cfg, $game_cfg); 43 | ?> 44 | -------------------------------------------------------------------------------- /server/web_ui/report/index.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /server/web_ui/report/report-css.php: -------------------------------------------------------------------------------- 1 | 125 | 126 | -------------------------------------------------------------------------------- /server/web_ui/xhprof_html: -------------------------------------------------------------------------------- 1 | ../../xhprof/xhprof_html -------------------------------------------------------------------------------- /server/web_ui/xhprof_lib: -------------------------------------------------------------------------------- 1 | ../../xhprof/xhprof_lib -------------------------------------------------------------------------------- /server/web_ui/zperfmon-server.ini: -------------------------------------------------------------------------------- 1 | ; append include_path 2 | include_path=/usr/share/pear:/usr/share/php:/var/www/html/zperfmon/include/:/etc/zperfmon/:/etc/zperfmon/conf.d/:/usr/local/zperfmon/include/:/var/www/html/zperfmon/xhprof_lib/utils:/usr/local/zperfmon/bin:. 3 | -------------------------------------------------------------------------------- /server/zperfmon-server.conf: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteRule ^/$ /zperfmon/ [R] 3 | 4 | RewriteRule ^/zperfmon/(.*)/(\d+\.\d+\.\d+\.\d+)$ /zperfmon/profile-view/ipview.php?game=$1&ip=$2 [L,QSA] 5 | RewriteRule ^/zperfmon/(.*)/ips$ /zperfmon/profile-view/ipview.php?game=$1&iplist=true [L,QSA] 6 | RewriteRule ^/zperfmon/(.*)/top5$ /zperfmon/profile-view/ipview.php?top5&game=$1 [L,QSA] 7 | RewriteRule ^/zperfmon/(.*)/daily$ /zperfmon/profile-view/dailyview.php?game=$1 [L,QSA] 8 | RewriteRule ^/zperfmon/configs/([^/]+).yaml /zperfmon/get_yaml_config.php?game=$1 [L,QSA] 9 | RewriteRule ^/zperfmon/apis/events(.*) /zperfmon/apis/get_events.php$1 [L,QSA] 10 | RewriteRule ^/zperfmon/api/(.*) /zperfmon/apis/index.php?action=$1 [L,QSA] 11 | RewriteRule ^/zperfmon/(.*)/candidates /zperfmon/apis/get_candidates.php?game=$1 [L,QSA] 12 | RewriteRule ^/zperfmon/get_ini.php /zperfmon/apis/get_ini.php [L,QSA] 13 | 14 | AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript 15 | KeepAlive On; 16 | -------------------------------------------------------------------------------- /xhprof/CHANGELOG: -------------------------------------------------------------------------------- 1 | Modification History: 2 | 3 | *** NOTE *** 4 | DO NOT UPDATE THIS FILE. UPDATE package.xml INSTEAD. 5 | This file contains the CHANGELOG for the initial release. For subsequent 6 | releases, the CHANGLELOG is maintained in the package.xml file itself. 7 | Please edit package.xml instead. 8 | ************ 9 | 10 | 03/02/2008 kannan, checkin xhprof_html/ and xhprof_lib/ directories. 11 | cjiang [These contain PHP sources for the UI as well 12 | as various supporting libraries to compute 13 | "flat" info, diff reports, aggregate results 14 | of multiple runs, typeahead support, etc.] 15 | 02/20/2008 kannan add basic sanity tests for the extension 16 | 02/19/2008 kannan register constants for optional profiler flags; 17 | add xhprof.output_dir ini setting. 18 | 01/22/2008 ps port cpu affinity functions to FreeBSD 19 | 01/15/2008 kannan intercept builtins even if zend_execute_internal 20 | were null to begin with 21 | 01/14/2008 kannan track builtins by default; 22 | fix compiler warnings with fwd decls 23 | 12/22/2008 cjiang Further refactoring of the code for open sourcing: 24 | (1). Remove level 1 profiling mode. 25 | (2). Add xhprof_sample_enable, xhprof_sample_disable. 26 | (3). Unifiy function and global variable prefix. 27 | (4). Group relevant functions together. 28 | (5). Migrate change history to CHANAGELOG file. 29 | 12/19/2008 kannan First step refactoring for open sourcing: 30 | (1). Put basic direcotry structure 31 | (2). Rename extension and function names 32 | (3). Add LICENCE header. 33 | 06/17/2008 veeve use cycle_timer() for XHPROF_MODE_SAMPLED 34 | 03/27/2008 cjiang Add a 'hash-based' filter to reduce the number 35 | of expensive call-stack tranversal on recursion 36 | detection. 37 | 03/17/2008 kannan must not keep state on C stack to handle 38 | exit (which causes _zend_bailout to longjmp 39 | 02/25/2008 kannan add xhprof_flags to toggle various metric 40 | collections (buitins on/off, cpu metric on/off 41 | memory stats on/off) 42 | 02/14/2008 cjiang Use cycle_timer based on 'rdtsc' instruction 43 | on x86 machines to replace gettimeofday. rdtsc 44 | is extremely cheap compared with gettimeofday 45 | or getrusage. 46 | 12/06/2007 veeve bump version 1.1.2, 47 | added hp_global_t 48 | added mode callbacks, made modes extensible 49 | added sampler mode 50 | 12/05/2007 veeve added doc; house cleaning 51 | 11/28/2007 kannan split include accounting into load/run_init 52 | 11/09/2007 kannan memory usage profiling 53 | 10/27/2007 kannan handle recursive calls, "include" operations 54 | 10/20/2007 kannan add hierarchical profiling; incl vs. exclusive 55 | function times; browser based UI; diff and 56 | aggregation support 57 | 10/10/2007 hzhao creation (flat function profiles) 58 | 59 | Authors: 60 | Haiping Zhao hzhao@facebook.com 61 | Kannan Muthukkaruppan kannan@facebook.com 62 | Venkat Venkataramani veeve@facebook.com 63 | Changhao Jiang cjiang@facebook.com 64 | -------------------------------------------------------------------------------- /xhprof/CREDITS: -------------------------------------------------------------------------------- 1 | Originally developed at Facebook, XHProf was open sourced in Mar, 2009. 2 | 3 | Creators: 4 | Changhao Jiang 5 | Kannan Muthukkaruppan 6 | Venkat Venkataramani 7 | Haiping Zhao 8 | 9 | Additional Contributors: 10 | George Cabrera - UI enhancements 11 | Paul Saab - FreeBSD port 12 | 13 | Zynga Contributors: 14 | Binu Jose Philip 15 | Gaurav 16 | Gopal Vijayaraghavan 17 | Saurabh Odhyan 18 | Ujwalendu Prakash 19 | -------------------------------------------------------------------------------- /xhprof/README: -------------------------------------------------------------------------------- 1 | For installation and usage notes refer to: 2 | xhprof_html/docs/index.html 3 | 4 | To view the latest version of the doc, go to: 5 | http://pecl.php.net/package/xhprof ---> [View Documentation] 6 | 7 | 8 | -------------------------------------------------------------------------------- /xhprof/examples/sample.php: -------------------------------------------------------------------------------- 1 | 0) { 5 | bar($x - 1); 6 | } 7 | } 8 | 9 | function foo() { 10 | for ($idx = 0; $idx < 5; $idx++) { 11 | bar($idx); 12 | $x = strlen("abc"); 13 | } 14 | } 15 | 16 | // start profiling 17 | xhprof_enable(); 18 | 19 | // run program 20 | foo(); 21 | 22 | // stop profiler 23 | $xhprof_data = xhprof_disable(); 24 | 25 | // display raw xhprof data for the profiler run 26 | print_r($xhprof_data); 27 | 28 | 29 | $XHPROF_ROOT = realpath(dirname(__FILE__) .'/..'); 30 | include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php"; 31 | include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php"; 32 | 33 | // save raw data for this profiler run using default 34 | // implementation of iXHProfRuns. 35 | $xhprof_runs = new XHProfRuns_Default(); 36 | 37 | // save the run under a namespace "xhprof_foo" 38 | $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo"); 39 | 40 | echo "---------------\n". 41 | "Assuming you have set up the http based UI for \n". 42 | "XHProf at some address, you can view run at \n". 43 | "http:///index.php?run=$run_id&source=xhprof_foo\n". 44 | "---------------\n"; 45 | -------------------------------------------------------------------------------- /xhprof/extension/config.m4: -------------------------------------------------------------------------------- 1 | 2 | PHP_ARG_ENABLE(xhprof, whether to enable xhprof support, 3 | [ --enable-xhprof Enable xhprof support]) 4 | 5 | if test "$PHP_XHPROF" != "no"; then 6 | PHP_NEW_EXTENSION(xhprof, xhprof.c, $ext_shared) 7 | fi 8 | -------------------------------------------------------------------------------- /xhprof/extension/php_xhprof.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Facebook 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 | 18 | #ifndef PHP_XHPROF_H 19 | #define PHP_XHPROF_H 20 | 21 | extern zend_module_entry xhprof_module_entry; 22 | #define phpext_xhprof_ptr &xhprof_module_entry 23 | 24 | #ifdef PHP_WIN32 25 | #define PHP_XHPROF_API __declspec(dllexport) 26 | #else 27 | #define PHP_XHPROF_API 28 | #endif 29 | 30 | #ifdef ZTS 31 | #include "TSRM.h" 32 | #endif 33 | 34 | PHP_MINIT_FUNCTION(xhprof); 35 | PHP_MSHUTDOWN_FUNCTION(xhprof); 36 | PHP_RINIT_FUNCTION(xhprof); 37 | PHP_RSHUTDOWN_FUNCTION(xhprof); 38 | PHP_MINFO_FUNCTION(xhprof); 39 | 40 | PHP_FUNCTION(xhprof_enable); 41 | PHP_FUNCTION(xhprof_disable); 42 | PHP_FUNCTION(xhprof_sample_enable); 43 | PHP_FUNCTION(xhprof_sample_disable); 44 | 45 | #endif /* PHP_XHPROF_H */ 46 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Basic Profiling Test 3 | Author: Kannan 4 | --FILE-- 5 | 67 | --EXPECT-- 68 | Part 1: Default Flags 69 | foo==>bar : ct= 2; wt=*; 70 | foo==>strlen : ct= 1; wt=*; 71 | main() : ct= 1; wt=*; 72 | main()==>foo : ct= 1; wt=*; 73 | main()==>xhprof_disable : ct= 1; wt=*; 74 | 75 | Part 2: CPU 76 | foo==>bar : cpu=*; ct= 2; wt=*; 77 | foo==>strlen : cpu=*; ct= 1; wt=*; 78 | main() : cpu=*; ct= 1; wt=*; 79 | main()==>foo : cpu=*; ct= 1; wt=*; 80 | main()==>xhprof_disable : cpu=*; ct= 1; wt=*; 81 | 82 | Part 3: No Builtins 83 | foo==>bar : ct= 2; wt=*; 84 | main() : ct= 1; wt=*; 85 | main()==>foo : ct= 1; wt=*; 86 | 87 | Part 4: Memory 88 | foo==>bar : ct= 2; mu=*; pmu=*; wt=*; 89 | foo==>strlen : ct= 1; mu=*; pmu=*; wt=*; 90 | main() : ct= 1; mu=*; pmu=*; wt=*; 91 | main()==>foo : ct= 1; mu=*; pmu=*; wt=*; 92 | main()==>xhprof_disable : ct= 1; mu=*; pmu=*; wt=*; 93 | 94 | Part 5: Memory & CPU 95 | foo==>bar : cpu=*; ct= 2; mu=*; pmu=*; wt=*; 96 | foo==>strlen : cpu=*; ct= 1; mu=*; pmu=*; wt=*; 97 | main() : cpu=*; ct= 1; mu=*; pmu=*; wt=*; 98 | main()==>foo : cpu=*; ct= 1; mu=*; pmu=*; wt=*; 99 | main()==>xhprof_disable : cpu=*; ct= 1; mu=*; pmu=*; wt=*; 100 | 101 | 102 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Test (direct and indirect) recursive function calls. 3 | Author: Kannan 4 | --FILE-- 5 | 0) { 16 | if ($use_direct_recursion) 17 | foo($depth - 1, $use_direct_recursion); 18 | else 19 | bar($depth - 1, $use_direct_recursion); 20 | } 21 | } 22 | 23 | 24 | xhprof_enable(); 25 | foo(4, true); 26 | $output = xhprof_disable(); 27 | 28 | echo "Direct Recursion\n"; 29 | print_canonical($output); 30 | echo "\n"; 31 | 32 | 33 | xhprof_enable(); 34 | foo(4, false); 35 | $output = xhprof_disable(); 36 | 37 | echo "Indirect Recursion\n"; 38 | print_canonical($output); 39 | echo "\n"; 40 | 41 | ?> 42 | --EXPECT-- 43 | Direct Recursion 44 | foo==>foo@1 : ct= 1; wt=*; 45 | foo@1==>foo@2 : ct= 1; wt=*; 46 | foo@2==>foo@3 : ct= 1; wt=*; 47 | foo@3==>foo@4 : ct= 1; wt=*; 48 | main() : ct= 1; wt=*; 49 | main()==>foo : ct= 1; wt=*; 50 | main()==>xhprof_disable : ct= 1; wt=*; 51 | 52 | Indirect Recursion 53 | bar==>foo@1 : ct= 1; wt=*; 54 | bar@1==>foo@2 : ct= 1; wt=*; 55 | bar@2==>foo@3 : ct= 1; wt=*; 56 | bar@3==>foo@4 : ct= 1; wt=*; 57 | foo==>bar : ct= 1; wt=*; 58 | foo@1==>bar@1 : ct= 1; wt=*; 59 | foo@2==>bar@2 : ct= 1; wt=*; 60 | foo@3==>bar@3 : ct= 1; wt=*; 61 | main() : ct= 1; wt=*; 62 | main()==>foo : ct= 1; wt=*; 63 | main()==>xhprof_disable : ct= 1; wt=*; 64 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Test Class Methods, Constructors, Destructors. 3 | Author: Kannan 4 | --FILE-- 5 | _attr = $attr; 15 | } 16 | 17 | private static function inner_static() { 18 | return C::$_static_attr; 19 | } 20 | 21 | public static function outer_static() { 22 | return C::inner_static(); 23 | } 24 | 25 | public function get_attr() { 26 | return $this->_attr; 27 | } 28 | 29 | function __destruct() { 30 | echo "Destroying class {$this->_attr}\n"; 31 | } 32 | } 33 | 34 | 35 | xhprof_enable(); 36 | 37 | // static methods 38 | echo C::outer_static() . "\n"; 39 | 40 | // constructor 41 | $obj = new C("Hello World"); 42 | 43 | // instance methods 44 | $obj->get_attr(); 45 | 46 | // destructor 47 | $obj = null; 48 | 49 | 50 | $output = xhprof_disable(); 51 | 52 | echo "Profiler data for 'Class' tests:\n"; 53 | print_canonical($output); 54 | echo "\n"; 55 | 56 | ?> 57 | --EXPECT-- 58 | i am a class static 59 | In constructor... 60 | Destroying class Hello World 61 | Profiler data for 'Class' tests: 62 | C::outer_static==>C::inner_static : ct= 1; wt=*; 63 | main() : ct= 1; wt=*; 64 | main()==>C::__construct : ct= 1; wt=*; 65 | main()==>C::__destruct : ct= 1; wt=*; 66 | main()==>C::get_attr : ct= 1; wt=*; 67 | main()==>C::outer_static : ct= 1; wt=*; 68 | main()==>xhprof_disable : ct= 1; wt=*; 69 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Test Include File (load/run_init operations) 3 | Author: Kannan 4 | --FILE-- 5 | 38 | --EXPECT-- 39 | abc,def,ghi 40 | I am in foo()... 41 | 11 42 | I am in bar()... 43 | Test for 'include_once' & 'require_once' operation 44 | main() : ct= 1; wt=*; 45 | main()==>dirname : ct= 6; wt=*; 46 | main()==>load::tests/xhprof_004_inc.php : ct= 1; wt=*; 47 | main()==>load::tests/xhprof_004_require.php: ct= 1; wt=*; 48 | main()==>run_init::tests/xhprof_004_inc.php: ct= 1; wt=*; 49 | main()==>run_init::tests/xhprof_004_require.php: ct= 1; wt=*; 50 | main()==>xhprof_disable : ct= 1; wt=*; 51 | run_init::tests/xhprof_004_inc.php==>explode: ct= 1; wt=*; 52 | run_init::tests/xhprof_004_inc.php==>foo: ct= 1; wt=*; 53 | run_init::tests/xhprof_004_inc.php==>implode: ct= 1; wt=*; 54 | run_init::tests/xhprof_004_require.php==>bar: ct= 1; wt=*; 55 | run_init::tests/xhprof_004_require.php==>explode: ct= 1; wt=*; 56 | run_init::tests/xhprof_004_require.php==>implode: ct= 1; wt=*; 57 | run_init::tests/xhprof_004_require.php==>strlen: ct= 1; wt=*; 58 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Timer Tests 3 | Author: Kannan 4 | --FILE-- 5 | $range_high)) { 54 | echo "Failed ${description}. Expected: ${expected} microsecs. ". 55 | "Actual: ${actual} microsecs.\n"; 56 | } else { 57 | echo "OK: ${description}\n"; 58 | } 59 | echo "-------------\n"; 60 | } 61 | 62 | verify(10000, 63 | $output["sleep_10000_micro==>usleep"]["wt"], 64 | "sleep_10000_micro"); 65 | verify(20000, 66 | $output["sleep_20000_micro==>usleep"]["wt"], 67 | "sleep_20000_micro"); 68 | verify(50000, 69 | $output["sleep_50000_micro==>usleep"]["wt"], 70 | "sleep_50000_micro"); 71 | 72 | ?> 73 | --EXPECT-- 74 | Verifying sleep_10000_micro... 75 | OK: sleep_10000_micro 76 | ------------- 77 | Verifying sleep_20000_micro... 78 | OK: sleep_20000_micro 79 | ------------- 80 | Verifying sleep_50000_micro... 81 | OK: sleep_50000_micro 82 | ------------- 83 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Basic Sampling Test 3 | Author: mpal 4 | --FILE-- 5 | 70 | --EXPECT-- 71 | Part 1: Sampling Profile 72 | Test Case : Percent of Total Time 73 | Individual : 74 | Folded : 75 | Part 1: output 76 | In general, sampling output depends upon execution speed. 77 | Currently checking that this runs to completion. 78 | 79 | -------------------------------------------------------------------------------- /xhprof/extension/tests/xhprof_008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | XHPRrof: Sampling Mode Test 3 | Author: kannan 4 | --FILE-- 5 | goo==>bar==>foo==>usleep") { 38 | $count1++; 39 | } 40 | } 41 | 42 | // how many usleep samples did we get in two calls to goo()? 43 | $count2 = 0; 44 | foreach ($output2 as $sample) { 45 | if ($sample == "main()==>goo==>bar==>foo==>usleep") { 46 | $count2++; 47 | } 48 | } 49 | 50 | // 51 | // our default sampling frequency is 0.1 seconds. So 52 | // we would expect about 8 samples (given that foo() 53 | // sleeps for 0.8 seconds). However, we might in future 54 | // allow the sampling frequency to be modified. So rather 55 | // than depend on the absolute number of samples, we'll 56 | // check to see if $count2 is roughly double of $count1. 57 | // 58 | 59 | if (($count1 == 0) 60 | || (($count2 / $count1) > 2.5) 61 | || (($count2 / $count1) < 1.5)) { 62 | echo "Test failed\n"; 63 | echo "Count of usleep samples in one call to goo(): $count1\n"; 64 | echo "Count of usleep samples in two calls to goo(): $count2\n"; 65 | echo "Samples in one call to goo(): \n"; 66 | var_dump($output1); 67 | echo "Samples in two calls to goo(): \n"; 68 | var_dump($output2); 69 | } else { 70 | echo "Test passed\n"; 71 | } 72 | 73 | ?> 74 | --EXPECT-- 75 | Test passed 76 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/css/base-context-min.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, Yahoo! Inc. All rights reserved. 3 | Code licensed under the BSD License: 4 | http://developer.yahoo.com/yui/license.html 5 | version: 3.3.0 6 | build: 3167 7 | */ 8 | .yui3-cssbase h1{font-size:138.5%;}.yui3-cssbase h2{font-size:123.1%;}.yui3-cssbase h3{font-size:108%;}.yui3-cssbase h1,.yui3-cssbase h2,.yui3-cssbase h3{margin:1em 0;}.yui3-cssbase h1,.yui3-cssbase h2,.yui3-cssbase h3,.yui3-cssbase h4,.yui3-cssbase h5,.yui3-cssbase h6,.yui3-cssbase strong{font-weight:bold;}.yui3-cssbase abbr,.yui3-cssbase acronym{border-bottom:1px dotted #000;cursor:help;}.yui3-cssbase em{font-style:italic;}.yui3-cssbase blockquote,.yui3-cssbase ul,.yui3-cssbase ol,.yui3-cssbase dl{margin:1em;}.yui3-cssbase ol,.yui3-cssbase ul,.yui3-cssbase dl{margin-left:2em;}.yui3-cssbase ol li{list-style:decimal outside;}.yui3-cssbase ul li{list-style:disc outside;}.yui3-cssbase dl dd{margin-left:1em;}.yui3-cssbase th,.yui3-cssbase td{border:1px solid #000;padding:.5em;}.yui3-cssbase th{font-weight:bold;text-align:center;}.yui3-cssbase caption{margin-bottom:.5em;text-align:center;}.yui3-cssbase p,.yui3-cssbase fieldset,.yui3-cssbase table,.yui3-cssbase pre{margin-bottom:1em;}.yui3-cssbase input[type=text],.yui3-cssbase input[type=password],.yui3-cssbase textarea{width:12.25em;*width:11.9em;} -------------------------------------------------------------------------------- /xhprof/xhprof_html/css/datatablegrouper.css: -------------------------------------------------------------------------------- 1 | /* The group cell */ 2 | .yui-skin-sam .yui-dt .group 3 | { 4 | border-top: 1px solid #CBCBCB; 5 | border-bottom: 1px solid #7f7f7f; 6 | font-weight: bold; 7 | background-image: url(http://yui.yahooapis.com/2.7.0/build/assets/skins/sam/sprite.png); 8 | background-position: 0px -1300px; 9 | color: black; 10 | cursor: pointer; 11 | } 12 | 13 | /* Group inner style */ 14 | .yui-skin-sam .yui-dt .group .liner 15 | { 16 | padding: 4px 10px; 17 | } 18 | 19 | /* Selected group */ 20 | .yui-skin-sam .yui-dt .group-selected 21 | { 22 | background-image: none; 23 | background-color: #426FD9; 24 | color: White; 25 | } 26 | 27 | /* Disabled group */ 28 | .yui-skin-foodstorm .yui-dt .group-disabled 29 | { 30 | cursor: default; 31 | } 32 | 33 | /* The first group in the data table */ 34 | .yui-skin-sam .yui-dt .group-first 35 | { 36 | border-top: 1px solid #7f7f7f; 37 | } 38 | 39 | /* The first row in the group */ 40 | .yui-skin-sam .yui-dt .group-first-row td 41 | { 42 | } 43 | 44 | /* The group when collapsed */ 45 | .yui-skin-sam .yui-dt .group-collapsed 46 | { 47 | margin-top: 0px; /* Makes the group cover up the first row in the group. */ 48 | } 49 | 50 | /* The first rown in the group when collapsed */ 51 | .yui-skin-sam .yui-dt .group-first-row-collapsed td 52 | { 53 | padding-top: 0px; /* Makes the group cover up the first row in the group. */ 54 | } 55 | 56 | /* Base styles for the group icon */ 57 | .yui-skin-sam .yui-dt .group .icon 58 | { 59 | width: 18px; 60 | height: 15px; 61 | position: absolute; 62 | cursor: pointer; 63 | } 64 | 65 | /* The label within the group */ 66 | .yui-skin-sam .yui-dt .group .label 67 | { 68 | margin-left: 25px; 69 | } 70 | 71 | /* The group icon when expanded */ 72 | .yui-skin-sam .yui-dt .group-expanded .icon 73 | { 74 | background-image: url(dt-group-arrow-down.png); 75 | background-repeat: no-repeat; 76 | } 77 | 78 | /* The group icon when collapsed */ 79 | .yui-skin-sam .yui-dt .group-collapsed .icon 80 | { 81 | background-image: url(dt-group-arrow-up.png); 82 | background-repeat: no-repeat; 83 | } 84 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/css/dt-group-arrow-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/xhprof/xhprof_html/css/dt-group-arrow-down.png -------------------------------------------------------------------------------- /xhprof/xhprof_html/css/dt-group-arrow-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/xhprof/xhprof_html/css/dt-group-arrow-up.png -------------------------------------------------------------------------------- /xhprof/xhprof_html/css/xhprof.css: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * M O D I F I E D as follows 4 | * 5 | * Copyright (c) 2010 Zynga 6 | * 7 | * Added utility functions, YUI support and igbinary+bzip support. 8 | */ 9 | 10 | /* Copyright (c) 2009 Facebook 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | td.sorted { 26 | color:#0000FF; 27 | } 28 | 29 | td.vbar, th.vbar { 30 | text-align: right; 31 | border-left: 32 | solid 1px #bdc7d8; 33 | } 34 | 35 | td.vbbar, th.vbar { 36 | text-align: right; 37 | border-left: 38 | solid 1px #bdc7d8; 39 | color:blue; 40 | } 41 | 42 | /* diff reports: display regressions in red */ 43 | td.vrbar { 44 | text-align: right; 45 | border-left:solid 1px #bdc7d8; 46 | color:red; 47 | } 48 | 49 | /* diff reports: display improvements in green */ 50 | td.vgbar { 51 | text-align: right; 52 | border-left: solid 1px #bdc7d8; 53 | color:green; 54 | } 55 | 56 | td.vwbar, th.vwbar { 57 | text-align: right; 58 | border-left: solid 1px white; 59 | } 60 | 61 | td.vwlbar, th.vwlbar { 62 | text-align: left; 63 | border-left: solid 1px white; 64 | } 65 | 66 | p.blue { 67 | color:blue 68 | } 69 | 70 | .bubble { 71 | background-color:#C3D9FF 72 | } 73 | 74 | ul.xhprof_actions { 75 | float: right; 76 | padding-left: 16px; 77 | list-style-image: none; 78 | list-style-type: none; 79 | margin:10px 10px 10px 3em; 80 | position:relative; 81 | } 82 | 83 | ul.xhprof_actions li { 84 | border-bottom:1px solid #D8DFEA; 85 | } 86 | 87 | ul.xhprof_actions li a:hover { 88 | background:#3B5998 none repeat scroll 0 0; 89 | color:#FFFFFF; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/css/xhprof_yui.css: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2010 Zynga 4 | * 5 | * YUI table support for xhprof flat profile rendering. 6 | */ 7 | 8 | #show_checkbox 9 | { 10 | margin: 0px; 11 | position: absolute; 12 | top: 200px; 13 | left:1350px; 14 | z-index: 10003; 15 | } 16 | .hide 17 | { 18 | display:none; 19 | } 20 | .yui-dt-first 21 | { 22 | } 23 | .yui-skin-sam .yui-dt td 24 | { 25 | text-align:right; 26 | } 27 | iframe { 28 | overflow-x: hidden; 29 | overflow-y: hidden; 30 | } 31 | .right{ 32 | text-align:right; 33 | } 34 | .left{ 35 | text-align:left; 36 | } 37 | .summary tr:nth-child(odd) {background: #EDF5FF;} 38 | .summary tr:nth-child(even) {background: white;} 39 | .ui-dialog{left:600px;} 40 | #function_table table{ 41 | margin: 30px; 42 | } 43 | .red{ 44 | color:red; 45 | } 46 | .green{ 47 | color:green; 48 | } 49 | .title { 50 | font-family: 'Michroma'; 51 | font-size: 40px; 52 | font-weight: bold; 53 | color: #999; 54 | } 55 | .left { 56 | float: left; 57 | } 58 | .right { 59 | float: right; 60 | .summary tr th{ 61 | text-align: center; 62 | } 63 | 64 | .summary tr td{ 65 | padding-right:10px; 66 | } 67 | .summary td.vbar, th.vbar{ 68 | border-left:none; 69 | } 70 | .summary td.vrbar, th.vrbar{ 71 | border-left:none; 72 | } 73 | .summary td.vgbar, th.vgbar{ 74 | border-left:none; 75 | } 76 | #link_address_anchor{ 77 | font-size:18px; 78 | color:#555; 79 | } 80 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/index_json.php: -------------------------------------------------------------------------------- 1 | array(XHPROF_STRING_PARAM, ''), 52 | 'wts' => array(XHPROF_STRING_PARAM, ''), 53 | 'symbol' => array(XHPROF_STRING_PARAM, ''), 54 | 'sort' => array(XHPROF_STRING_PARAM, 'wt'), // wall time 55 | 'run1' => array(XHPROF_STRING_PARAM, ''), 56 | 'run2' => array(XHPROF_STRING_PARAM, ''), 57 | 'source' => array(XHPROF_STRING_PARAM, 'xhprof'), 58 | 'all' => array(XHPROF_UINT_PARAM, 0), 59 | 'file' => array(XHPROF_STRING_PARAM, ''), 60 | 'file1' => array(XHPROF_STRING_PARAM, ''), 61 | 'file2' => array(XHPROF_STRING_PARAM, ''), 62 | ); 63 | 64 | // pull values of these params, and create named globals for each param 65 | xhprof_param_init($params); 66 | 67 | /* reset params to be a array of variable names to values 68 | by the end of this page, param should only contain values that need 69 | to be preserved for the next page. unset all unwanted keys in $params. 70 | */ 71 | foreach ($params as $k => $v) { 72 | $params[$k] = $$k; 73 | 74 | // unset key from params that are using default values. So URLs aren't 75 | // ridiculously long. 76 | if ($params[$k] == $v[1]) { 77 | unset($params[$k]); 78 | } 79 | } 80 | 81 | $vbar = ' class="vbar"'; 82 | $vwbar = ' class="vwbar"'; 83 | $vwlbar = ' class="vwlbar"'; 84 | $vbbar = ' class="vbbar"'; 85 | $vrbar = ' class="vrbar"'; 86 | $vgbar = ' class="vgbar"'; 87 | 88 | $xhprof_runs_impl = new XHProfRuns_Default(dirname($file)); 89 | header('Content-type: application/json'); 90 | displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts, 91 | $symbol, $sort, $run1, $run2, $file, $file1, $file2); 92 | 93 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/jquery/indicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/zperfmon/c509f40f0f56d36723ba3f0c96c985517a55e775/xhprof/xhprof_html/jquery/indicator.gif -------------------------------------------------------------------------------- /xhprof/xhprof_html/jquery/jquery.autocomplete.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Autocomplete - jQuery plugin 1.0.2 3 | * 4 | * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer 5 | * 6 | * Dual licensed under the MIT and GPL licenses: 7 | * http://www.opensource.org/licenses/mit-license.php 8 | * http://www.gnu.org/licenses/gpl.html 9 | * 10 | * Revision: $Id: jquery.autocomplete.css,v 1.1.1.1 2009/03/17 18:35:18 kannan Exp $ 11 | * 12 | */ 13 | 14 | .ac_results { 15 | padding: 0px; 16 | border: 1px solid black; 17 | background-color: white; 18 | overflow: hidden; 19 | z-index: 99999; 20 | } 21 | 22 | .ac_results ul { 23 | width: 100%; 24 | list-style-position: outside; 25 | list-style: none; 26 | padding: 0; 27 | margin: 0; 28 | } 29 | 30 | .ac_results li { 31 | margin: 0px; 32 | padding: 2px 5px; 33 | cursor: default; 34 | display: block; 35 | /* 36 | if width will be 100% horizontal scrollbar will apear 37 | when scroll mode will be used 38 | */ 39 | /*width: 100%;*/ 40 | font: menu; 41 | font-size: 12px; 42 | /* 43 | it is very important, if line-height not setted or setted 44 | in relative units scroll will be broken in firefox 45 | */ 46 | line-height: 16px; 47 | overflow: hidden; 48 | } 49 | 50 | .ac_loading { 51 | background: white url('indicator.gif') right center no-repeat; 52 | } 53 | 54 | .ac_odd { 55 | background-color: #eee; 56 | } 57 | 58 | .ac_over { 59 | background-color: #0A246A; 60 | color: white; 61 | } 62 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/jquery/jquery.tooltip.css: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery Tooltip plugin 1.3 3 | * 4 | * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ 5 | * http://docs.jquery.com/Plugins/Tooltip 6 | * 7 | * Copyright (c) 2006 - 2008 Jörn Zaefferer 8 | * 9 | * $Id: jquery.tooltip.css,v 1.1.1.1 2009/03/17 18:35:18 kannan Exp $ 10 | * 11 | * Dual licensed under the MIT and GPL licenses: 12 | * http://www.opensource.org/licenses/mit-license.php 13 | * http://www.gnu.org/licenses/gpl.html 14 | */ 15 | 16 | #tooltip { 17 | position: absolute; 18 | z-index: 3000; 19 | border: 1px solid #111; 20 | background-color: lightyellow; 21 | padding: 5px; 22 | opacity: 0.9; 23 | } 24 | #tooltip h3, #tooltip div { margin: 0; } 25 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/piechart.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 | 19 | Developer View - Profile Dissection 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 |
Back
33 |
34 | 35 | 36 |
37 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /xhprof/xhprof_html/typeahead.php: -------------------------------------------------------------------------------- 1 | 45 | 46 | -------------------------------------------------------------------------------- /xhprof/xhprof_lib/display/typeahead_common.php: -------------------------------------------------------------------------------- 1 | array(XHPROF_STRING_PARAM, ''), 41 | 'run' => array(XHPROF_STRING_PARAM, ''), 42 | 'run1' => array(XHPROF_STRING_PARAM, ''), 43 | 'run2' => array(XHPROF_STRING_PARAM, ''), 44 | 'source' => array(XHPROF_STRING_PARAM, 'xhprof'), 45 | ); 46 | 47 | // pull values of these params, and create named globals for each param 48 | xhprof_param_init($params); 49 | 50 | if (!empty($run)) { 51 | 52 | // single run mode 53 | $raw_data = $xhprof_runs_impl->get_run($run, $source, $desc_unused); 54 | $functions = xhprof_get_matching_functions($q, $raw_data); 55 | 56 | } else if (!empty($run1) && !empty($run2)) { 57 | 58 | // diff mode 59 | $raw_data = $xhprof_runs_impl->get_run($run1, $source, $desc_unused); 60 | $functions1 = xhprof_get_matching_functions($q, $raw_data); 61 | 62 | $raw_data = $xhprof_runs_impl->get_run($run2, $source, $desc_unused); 63 | $functions2 = xhprof_get_matching_functions($q, $raw_data); 64 | 65 | 66 | $functions = array_unique(array_merge($functions1, $functions2)); 67 | asort($functions); 68 | } else { 69 | xhprof_error("no valid runs specified to typeahead endpoint"); 70 | $functions = array(); 71 | } 72 | 73 | // If exact match is present move it to the front 74 | if (in_array($q, $functions)) { 75 | $old_functions = $functions; 76 | 77 | $functions = array($q); 78 | foreach ($old_functions as $f) { 79 | // exact match case has already been added to the front 80 | if ($f != $q) { 81 | $functions[] =$f; 82 | } 83 | } 84 | } 85 | 86 | foreach ($functions as $f) { 87 | echo $f."\n"; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /zperfmon_arch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | --------------------------------------------------------------------------------