login_error
") { 12 | window.location.href = 'login'; 13 | } 14 | else { 15 | $("#data").html(ungzip_new(data)); 16 | } 17 | }); 18 | 19 | /*$.post(my_url, {"keys": JSON.stringify(host_ids)}).success(function (data, status, xhr) { 20 | console.log(xhr); 21 | $("#data").html(ungzip_new(data)); 22 | }).success(function (data, status, xhr) { 23 | console.log(xhr); 24 | });*/ 25 | } 26 | else { 27 | $.get(my_url, "", function (data) { 28 | $("#data").html(data); 29 | }); 30 | } 31 | } 32 | 33 | function get_data(url) { 34 | var result_data = ""; 35 | $.get(url, "", function (data) { 36 | result_data = data; 37 | }); 38 | return result_data 39 | } 40 | 41 | function post_data(url, input_data) { 42 | var result_data = ""; 43 | $.post(url, {"keys": input_data}, function (data) { 44 | result_data = data 45 | }); 46 | return result_data 47 | } 48 | 49 | function show_modal_dialog(id_name) { 50 | $(id_name).modal("show") 51 | } 52 | 53 | function hide_modal_dialog(id_name) { 54 | $(id_name).modal("hide") 55 | } 56 | 57 | function stop(parameter, id_name) { 58 | search_div(id_name) 59 | myActive(id_name) 60 | my_url = parameter 61 | myrefresh() 62 | stop_timer() 63 | } 64 | 65 | function start(parameter, id_name) { 66 | search_div(id_name) 67 | myActive(id_name) 68 | my_url = parameter 69 | myrefresh() 70 | start_timer() 71 | } 72 | 73 | function start_timer() { 74 | stop_timer() 75 | timer = setInterval(myrefresh, interval_refresh) 76 | } 77 | 78 | function stop_timer() { 79 | clearInterval(timer) 80 | } 81 | 82 | myrefresh() 83 | start_timer() 84 | 85 | function myActive(id_name) { 86 | if (id_name == "") { 87 | return false 88 | } 89 | $("#myTab").find("a").each(function () { 90 | if ($(this).attr("id") == id_name) { 91 | $(this).addClass("active"); 92 | } else { 93 | $(this).removeClass("active"); 94 | } 95 | }); 96 | } 97 | 98 | var id_names = ["sql", "slowlog", "tablespace", "general", "user", "thread", "chart", "config", "backup", "mysql_log", "chart_new", "host", "binlog", "alarm"] 99 | 100 | function search_div(id_name) { 101 | if ($.inArray(id_name, id_names) >= 0) { 102 | $("#host_search_div").hide(); 103 | } 104 | else { 105 | $("#host_search_div").show(); 106 | } 107 | //$("#host_search_div").hide() 108 | } 109 | 110 | function set_select_ids() { 111 | host_ids = $("#host_search").val(); 112 | if (host_ids == null || host_ids == 0) { 113 | host_ids = new Array(); 114 | } 115 | } 116 | 117 | function reset_select_ids() { 118 | $("#host_search").each(function () { 119 | $(this).selectpicker('val', $(this).find('option:first').val()); 120 | $(this).find("option").attr("selected", false); 121 | $(this).find("option:first").attr("selected", true); 122 | }); 123 | host_ids = new Array() 124 | } 125 | 126 | function gzip_new(string) { 127 | var charData = string.split('').map(function (x) { 128 | return x.charCodeAt(0); 129 | }); 130 | var binData = new Uint8Array(charData); 131 | var data = pako.gzip(binData); 132 | var strData = String.fromCharCode.apply(null, new Uint16Array(data)); 133 | return btoa(strData); 134 | } 135 | 136 | function ungzip_new(string) { 137 | var strData = atob(string); 138 | var charData = strData.split('').map(function (x) { 139 | return x.charCodeAt(0); 140 | }); 141 | var binData = new Uint8Array(charData); 142 | var data = pako.ungzip(binData); 143 | var strData = String.fromCharCode.apply(null, new Uint16Array(data)); 144 | return strData; 145 | } 146 | 147 | function ajaxSubmit(frm, fn, efn) { 148 | var dataPara = get_form_json(frm); 149 | $.ajax({ 150 | url: frm.action, 151 | type: frm.method, 152 | data: dataPara, 153 | success: fn, 154 | error: efn 155 | }); 156 | } 157 | 158 | function get_form_json(frm) { 159 | var o = {}; 160 | var a = $(frm).serializeArray(); 161 | $.each(a, function () { 162 | if (o[this.name] !== undefined) { 163 | if (!o[this.name].push) { 164 | o[this.name] = [o[this.name]]; 165 | } 166 | o[this.name].push(this.value || ''); 167 | } else { 168 | o[this.name] = this.value || ''; 169 | } 170 | }); 171 | return o; 172 | } 173 | 174 | $(function () { 175 | $(document).on('click', '.accordion-toggle', function (event) { 176 | event.stopPropagation(); 177 | var $this = $(this); 178 | var parent = $this.data('parent'); 179 | var actives = parent && $(parent).find('.collapse.in'); 180 | 181 | // From bootstrap itself 182 | if (actives && actives.length) { 183 | actives.data('collapse'); 184 | actives.collapse('hide'); 185 | } 186 | 187 | var target = $this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); //strip for ie7 188 | $(target).collapse('toggle'); 189 | }); 190 | }) 191 | 192 | function changeFeedback(id) { 193 | var str = document.getElementById(id).className; 194 | var tag = str.substring(25, str.length); 195 | if (tag == "right") { 196 | document.getElementById(id).className = "glyphicon glyphicon-menu-down"; 197 | } else { 198 | document.getElementById(id).className = "glyphicon glyphicon-menu-right"; 199 | } 200 | } 201 | 202 | $("button[type='reset']").click(function () { 203 | $('input').attr("value", ''); 204 | $("textarea").val(""); 205 | $("select.selectpicker").each(function () { 206 | $(this).selectpicker('val', $(this).find('option:first').val()); 207 | $(this).find("option").attr("selected", false); 208 | $(this).find("option:first").attr("selected", true); 209 | $(this).val(0) 210 | }); 211 | }); 212 | 213 | function skip_slave_error(host_id) { 214 | 215 | } 216 | 217 | function kill_mysql_thread_id(host_id, thread_id) { 218 | if (window.confirm("确认kill掉?")) { 219 | $.post("/mysql/kill/" + host_id + "/" + thread_id, "", function (data) { 220 | alert(data); 221 | myrefresh(); 222 | }); 223 | } 224 | } 225 | 226 | function post_request(url, json_data) { 227 | $.post(url, json_data, function (data) { 228 | alert(data) 229 | }); 230 | } 231 | 232 | function logout() { 233 | if (window.confirm("是否确认退出?")) { 234 | $.post("/logout", "", function (data) { 235 | alert("logout ok!") 236 | }); 237 | } 238 | } 239 | 240 | function input_data_for_post(url, json_data, div_id) { 241 | $.post(url, json_data, function (data) { 242 | $(div_id).html(data) 243 | }); 244 | } 245 | 246 | -------------------------------------------------------------------------------- /static/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /templates/alarm_config.html: -------------------------------------------------------------------------------- 1 | 9 | 10 |15 | Remark 16 | | 17 |18 | QPS 19 | | 20 |21 | TPS 22 | | 23 |24 | Trxs 25 | | 26 |27 | Uptime(Day) 28 | | 29 |30 | Version 31 | | 32 |33 | Port 34 | | 35 |36 | User 37 | | 38 |39 | 40 | | 41 |
---|---|---|---|---|---|---|---|---|
47 | {{ data.remark }} 48 | | 49 |50 | {{ data.qps }} 51 | | 52 |53 | {{ data.tps }} 54 | | 55 |56 | {{ data.trxs }} 57 | | 58 |59 | {{ data.uptime }} 60 | | 61 |62 | {{ data.version }}-{{ data.branch.name }} 63 | | 64 |65 | {{ data.port }} 66 | | 67 |68 | {{ data.user }} 69 | | 70 |71 | Details 72 | | 73 |
19 | Checksum 20 | | 21 |22 | Fingerprint 23 | | 24 |25 | First_Seen 26 | | 27 |28 | Last_Seen 29 | | 30 |31 | Count 32 | | 33 |34 | State 35 | | 36 |37 | Detail 38 | | 39 |
---|---|---|---|---|---|---|
45 | {{ status.checksum }} 46 | | 47 |48 | {{ status.fingerprint }} 49 | | 50 |51 | {{ status.first_seen }} 52 | | 53 |54 | {{ status.last_seen }} 55 | | 56 |57 | {{ status.ts_cnt }} 58 | | 59 |60 | {% if(status.is_reviewed == 0) %} 61 | 62 | {% else %} 63 | 64 | {% endif %} 65 | | 66 |67 | 68 | | 69 |
6 | General Log Detail7 | |
8 | |
---|---|
13 | Checksum 14 | | 15 |16 | {{ general_log_detail.checksum }} 17 | | 18 |
21 | Fingerprint 22 | | 23 |24 | {{ general_log_detail.fingerprint }} 25 | | 26 |
29 | First Seen 30 | | 31 |32 | {{ general_log_detail.first_seen }} 33 | | 34 |
37 | Last Seen 38 | | 39 |40 | {{ general_log_detail.last_seen }} 41 | | 42 |
45 | Count 46 | | 47 |48 | {{ general_log_detail.ts_cnt }} 49 | | 50 |
53 | Sample 54 | | 55 |56 | {{ general_log_detail.sample }} 57 | | 58 |
6 | MySQL Log 7 | | 8 |9 | 10 | | 11 |||||
---|---|---|---|---|---|
14 | Host 15 | | 16 |17 | Problem 18 | | 19 |20 | Type 21 | | 22 |23 | Level 24 | | 25 |26 | Created_Time 27 | | 28 |29 | 30 | | 31 |
37 | {{ status.remark }} 38 | | 39 |40 | {{ status.exception_type }} 41 | | 42 |43 | {{ status.log_type }} 44 | | 45 |46 | {{ status.level }} 47 | | 48 |49 | {{ status.created_time }} 50 | | 51 |52 | 53 | | 54 |
6 | 7 | | 8 |9 | MySQL 10 | | 11 |12 | SSH 13 | | 14 |15 | 16 | | 17 ||||||
---|---|---|---|---|---|---|---|---|
20 | ID 21 | | 22 |23 | Remark 24 | | 25 |26 | IP 27 | | 28 |29 | Port 30 | | 31 |32 | User 33 | | 34 |35 | User 36 | | 37 |38 | Port 39 | | 40 |41 | Created_Time 42 | | 43 |44 | 45 | | 46 |
52 | {{ info.host_id }} 53 | | 54 |55 | {{ info.remark }} 56 | | 57 |58 | {{ info.host }} 59 | | 60 |61 | {{ info.port }} 62 | | 63 |64 | {{ info.user }} 65 | | 66 |67 | {{ info.ssh_user }} 68 | | 69 |70 | {{ info.ssh_port }} 71 | | 72 |73 | {{ info.created_time }} 74 | | 75 |76 | 77 | 78 | | 79 |
6 | Host 7 | | 8 |9 | Slave Status 10 | | 11 |12 | Status 13 | | 14 |15 | Thread 16 | | 17 |18 | Net 19 | | 20 |21 | MySQL 22 | | 23 |24 | | 25 |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
28 | Host 29 | | 30 |31 | IP:Port 32 | | 33 |34 | Role 35 | | 36 |37 | Master_Name 38 | | 39 |40 | IO 41 | | 42 |43 | SQL 44 | | 45 |46 | Run 47 | | 48 |49 | QPS 50 | | 51 |52 | TPS 53 | | 54 |55 | Trxs 56 | | 57 |58 | B_P_Z 59 | | 60 |61 | Count 62 | | 63 |64 | Run 65 | | 66 |67 | Send 68 | | 69 |70 | Rece 71 | | 72 |73 | Uptime 74 | | 75 |76 | Branch 77 | | 78 |79 | Version 80 | | 81 |82 | 83 | | 84 |
90 | {{ data.remark }} 91 | | 92 |93 | {{ data.host }}:{{ data.port }} 94 | | 95 |96 | {% if(data.is_slave and data.is_master) %} 97 | & 98 | {% elif(data.is_master) %} 99 | 100 | {% elif(data.is_slave) %} 101 | 102 | {% endif %} 103 | | 104 |105 | {{ data.master_name }} 106 | | 107 |108 | {% if(data.is_slave) %} 109 | {{ data.io_status }} 110 | {% endif %} 111 | | 112 |113 | {% if(data.is_slave) %} 114 | {{ data.sql_status }} 115 | {% endif %} 116 | | 117 |118 | {% if(data.is_running == 1) %} 119 | Yes 120 | {% else %} 121 | No 122 | {% endif %} 123 | | 124 |125 | {{ data.qps }} 126 | | 127 |128 | {{ data.tps }} 129 | | 130 |131 | {{ data.trxs }} 132 | | 133 |134 | {{ data.innodb_buffer_pool_size }} 135 | | 136 |1000) %} class="text-danger" {% endif %}> 137 | {{ data.threads }} 138 | | 139 |5) %} class="text-danger" {% endif %}> 140 | {{ data.threads_running }} 141 | | 142 |143 | {{ data.send_bytes }} 144 | | 145 |146 | {{ data.receive_bytes }} 147 | | 148 |149 | {{ data.uptime }} 150 | | 151 |152 | {{ data.branch.name }} 153 | | 154 |155 | {{ data.version }} 156 | | 157 |158 | 159 | 160 | 161 | 162 | | 163 |
MySQL Tablesspace Report | 38 |||||||||
---|---|---|---|---|---|---|---|---|
Host | 41 |Rows | 42 |Data_T | 43 |Index_T | 44 |Total | 45 |File_T | 46 |Free_T | 47 |Table_C | 48 |Last Update Time | 49 |
{{ info.host_info.remark }} | 53 |{{ info.rows_total }} | 54 |{{ info.data_total }} | 55 |{{ info.index_total }} | 56 |{{ info.total }} | 57 |{{ info.file_total }} | 58 |{{ info.free_total }} | 59 |{{ info.table_count }} | 60 |{{ info.last_update_time }} | 61 |
MySQL Status Report | 70 ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
73 | | QPS | 74 |TPS | 75 |Thread | 76 |Tmp Table | 77 |Tmp Disk Table | 78 |||||||||||
Host | 81 |Min | 82 |Max | 83 |Avg | 84 |Min | 85 |Max | 86 |Avg | 87 |Min | 88 |Max | 89 |Avg | 90 |Min | 91 |Max | 92 |Avg | 93 |Min | 94 |Max | 95 |Avg | 96 |
99 | |
OS Report | 107 |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
110 | | CPU1 Load | 111 |CPU5 Load | 112 |CPU15 Load | 113 |CPU User | 114 |CPU Sys | 115 |IO Util | 116 |||||||||||||
Host | 119 |Min | 120 |Max | 121 |Avg | 122 |Min | 123 |Max | 124 |Avg | 125 |Min | 126 |Max | 127 |Avg | 128 |Min | 129 |Max | 130 |Avg | 131 |Min | 132 |Max | 133 |Avg | 134 |Min | 135 |Max | 136 |Avg | 137 |
MySQL Slow Log Report | 145 |||||||||
---|---|---|---|---|---|---|---|---|
Host | 148 |
6 | {{ host_info.remark }} Show Processlist 7 | | 8 |||||||||
---|---|---|---|---|---|---|---|---|
11 | ID 12 | | 13 |14 | User 15 | | 16 |17 | Host 18 | | 19 |20 | DB 21 | | 22 |23 | Command 24 | | 25 |26 | Time 27 | | 28 |29 | State 30 | | 31 |32 | Info 33 | | 34 |35 | Opertion 36 | | 37 |
43 | {{ status.id }} 44 | | 45 |46 | {{ status.user }} 47 | | 48 |49 | {{ status.host }} 50 | | 51 |52 | {{ status.db }} 53 | | 54 |55 | {{ status.command }} 56 | | 57 |58 | {{ status.time }} 59 | | 60 |61 | {{ status.state }} 62 | | 63 |64 | {{ status.info }} 65 | | 66 |67 | 68 | | 69 |
6 | SQL 7 | | 8 |9 | Query Time 10 | | 11 |12 | Lock Time 13 | | 14 |15 | 16 | | 17 |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20 | Fingerprint 21 | | 22 |23 | DB 24 | | 25 |26 | User 27 | | 28 |29 | Last_Seen 30 | | 31 |32 | Count 33 | | 34 |35 | Max 36 | | 37 |38 | Min 39 | | 40 |41 | Avg 42 | | 43 |44 | Total 45 | | 46 |47 | Max 48 | | 49 |50 | Min 51 | | 52 |53 | Avg 54 | | 55 |56 | Total 57 | | 58 |59 | 60 | | 61 |
67 | 68 | {{ status.fingerprint_tmp }} 69 | 70 | | 71 |72 | {{ status.db_max }} 73 | | 74 |75 | {{ status.user_max }} 76 | | 77 |78 | {{ status.last_seen }} 79 | | 80 |10) %} class="text-danger" {% endif %}> 81 | {{ status.ts_cnt }} 82 | | 83 |84 | {{ status.Query_time_max }} 85 | | 86 |87 | {{ status.Query_time_min }} 88 | | 89 |90 | {{ status.Query_time_avg }} 91 | | 92 |93 | {{ status.Query_time_sum }} 94 | | 95 |96 | {{ status.Lock_time_max }} 97 | | 98 |99 | {{ status.Lock_time_min }} 100 | | 101 |102 | {{ status.Lock_time_avg }} 103 | | 104 |105 | {{ status.Lock_time_sum }} 106 | | 107 |108 | 109 | 110 | {% if(status.is_reviewed == 0) %} 111 | 112 | {% else %} 113 | 114 | {% endif %} 115 | | 116 |
119 | {{ status.fingerprint }} 120 | | 121 |
5 | User 6 | | 7 |8 | Host 9 | | 10 |11 | Command 12 | | 13 |14 | Count 15 | | 16 |17 | State 18 | | 19 |20 | SQL 21 | | 22 |
---|---|---|---|---|---|
28 | {{ status.user }} 29 | | 30 |31 | {{ status.host }} 32 | | 33 |34 | {{ status.command }} 35 | | 36 |37 | {{ status.count }} 38 | | 39 |40 | {{ status.state }} 41 | | 42 |43 | {{ status.sql }} 44 | | 45 |
5 | User 6 | | 7 |8 | Host 9 | | 10 |11 | Select 12 | | 13 |14 | Insert 15 | | 16 |17 | Update 18 | | 19 |20 | Delete 21 | | 22 |23 | 24 | | 25 |26 | 27 | | 28 |
---|---|---|---|---|---|---|---|
34 | {{ status.user }} 35 | | 36 |37 | {{ status.host }} 38 | | 39 |40 | {{ status.select }} 41 | | 42 |43 | {{ status.insert }} 44 | | 45 |46 | {{ status.update }} 47 | | 48 |49 | {{ status.delete }} 50 | | 51 |52 | Detail 53 | | 54 |55 | 56 | 57 | | 58 |