add.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. {% extends "portal/layout.html" %}
  2. {% block content %}
  3. <link rel="stylesheet" href="{{ url_for('static', filename='select2/select2.css') }}"/>
  4. <link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.css') }}"/>
  5. <script type="text/javascript" src="{{ url_for('static', filename='select2/select2.min.js') }}"></script>
  6. <script>
  7. function query_nodata() {
  8. var query = $.trim($("#query").val());
  9. var mine = document.getElementById('mine').checked ? 1 : 0;
  10. window.location.href = '/portal/nodata?q=' + query + '&mine=' + mine;
  11. }
  12. function update_nodata() {
  13. $.post(
  14. '/portal/nodata/update',
  15. {
  16. 'name': $.trim($("#name").val()),
  17. 'obj_type': $.trim($("#obj_type").val()),
  18. 'obj': $.trim($("#obj").val()),
  19. 'metric': $.trim($("#metric").val()),
  20. 'tags': $.trim($("#tags").val()),
  21. 'dstype': $.trim($("#dstype").val()),
  22. 'step': $.trim($("#step").val()),
  23. 'mock': $.trim($("#mock").val()),
  24. 'nodata_id': $.trim($("#nodata_id").val())
  25. },
  26. function (json) {
  27. handle_quietly(json);
  28. }
  29. );
  30. }
  31. function on_endpoint_changed(){
  32. var d = $("#obj_type").val()
  33. if (d == "group"){
  34. $("#obj").attr('placeholder', "cop.xiaomi_owt.inf_pdl.falcon")
  35. } else if(d == "host") {
  36. $("#obj").attr('placeholder', "c3-op-mon-nodata01.bj\nc3-op-mon-nodata02.bj")
  37. } else {
  38. $("#obj").attr('placeholder', "11.11.0.11:9900\n11.11.0.12:9900")
  39. }
  40. }
  41. </script>
  42. <input type="hidden" id="nodata_id" value="{{ data.nodata.id }}">
  43. <div style="padding: 20px;">
  44. <div class="panel panel-default">
  45. <div class="panel-heading">{% if data.nodata.id %}modify{% else %}add{% endif %} nodata</div>
  46. <div class="panel-body">
  47. <div role="form">
  48. <div class="form-group">
  49. <label for="name">name:</label>
  50. <input type="text" placeholder="nodata.inf.falcon" value="{{ data.nodata.name }}" class="form-control" id="name">
  51. </div>
  52. <div class="form-group">
  53. <label for="obj_type">
  54. endpoint选择:
  55. </label>
  56. <a target="_blank" href="http://book.open-falcon.com/zh/usage/nodata.html" title="endpoint配置说明">
  57. <span class="glyphicon glyphicon-question-sign" style="float:right;"></span>
  58. </a>
  59. <select class="form-control" id="obj_type" style="vertical-align:top" onchange="on_endpoint_changed()">
  60. <option value="group" {% if data.nodata.obj_type == 'group' %}selected{% endif %}>机器分组</option>
  61. <option value="host" {% if data.nodata.obj_type == 'host' %}selected{% endif %}>机器名</option>
  62. <option value="other" {% if data.nodata.obj_type == 'other' %}selected{% endif %}>其他</option>
  63. </select>
  64. <textarea class="form-control" rows="3" id="obj" placeholder="cop.xiaomi_owt.inf_pdl.falcon" style="margin-top: 5px;">{{ data.nodata.obj }}</textarea>
  65. </div>
  66. <div class="form-group">
  67. <label for="metric">metric:</label>
  68. <input type="text" placeholder="agent.alive" value="{{ data.nodata.metric }}" class="form-control" id="metric">
  69. <span class="help-block"></span>
  70. </div>
  71. <div class="form-group">
  72. <label for="tags">tags:</label>
  73. <input type="text" {% if not data.nodata.id %}placeholder="pdl=falcon,module=nodata"{% endif %} value="{{ data.nodata.tags }}" class="form-control" id="tags">
  74. </div>
  75. <div class="form-group">
  76. <label for="dstype">type:</label>
  77. <select class="form-control" id="dstype">
  78. <option value="GAUGE" {% if data.nodata.dstype == 'GAUGE' %}selected{% endif %}>GAUGE</option>
  79. </select>
  80. </div>
  81. <div class="form-group">
  82. <label for="step">周期(秒):</label>
  83. <input type="text" placeholder="60" value="{{ data.nodata.step }}" class="form-control" id="step">
  84. </div>
  85. <div style="border-left: 10px solid green; padding-left: 5px;margin-bottom: 10px;">
  86. <span>数据上报中断时, 补发如下值:</span>
  87. </div>
  88. <div class="form-group">
  89. <input type="text" placeholder="-1" value="{{ data.nodata.mock}}" class="form-control" id="mock">
  90. </div>
  91. <div class="mb20">
  92. <button class="btn btn-primary" onclick="update_nodata();">
  93. <span class="glyphicon glyphicon-floppy-disk"></span>
  94. Submit
  95. </button>
  96. <a href="{{ url_for('nodatas_get') }}" class="btn btn-default">
  97. <span class="glyphicon glyphicon-arrow-left"></span>
  98. Back
  99. </a>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <a class="orange" target="_blank" href="http://book.open-falcon.com/zh/usage/nodata.html">
  105. <span class="glyphicon glyphicon-question-sign"></span>
  106. Nodata监控用户手册
  107. </a>
  108. </div>
  109. {% endblock %}