dash: HTTP等服务监控的故障/恢复报警

This commit is contained in:
naiba
2021-04-17 23:36:37 +08:00
parent e916ca06d0
commit 96be2330a9
18 changed files with 343 additions and 204 deletions

View File

@@ -139,6 +139,11 @@ function addOrEditMonitor(monitor) {
modal.find('input[name=Name]').val(monitor ? monitor.Name : null)
modal.find('input[name=Target]').val(monitor ? monitor.Target : null)
modal.find('select[name=Type]').val(monitor ? monitor.Type : 1)
if (monitor && monitor.Notify) {
modal.find(".ui.nb-notify.checkbox").checkbox("set checked");
} else {
modal.find(".ui.nb-notify.checkbox").checkbox("set unchecked");
}
showFormModal('.monitor.modal', '#monitorForm', '/api/monitor')
}

View File

@@ -9,7 +9,7 @@
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script>
<script src="/static/main.js?v202101240939"></script>
<script src="/static/main.js?v202104172324"></script>
</body>
</html>

View File

@@ -1,38 +1,50 @@
{{define "component/monitor"}}
<div class="ui tiny monitor modal transition hidden">
<div class="header">添加监控</div>
<div class="content">
<form id="monitorForm" class="ui form">
<input type="hidden" name="ID">
<div class="field">
<label>名称</label>
<input type="text" name="Name" placeholder="博客">
</div>
<div class="field">
<label>目标</label>
<input type="text" name="Target" placeholder="HTTP(https://t.tt)Ping(t.tt)TCP(t.tt:80)">
</div>
<div class="field">
<label>类型</label>
<select name="Type" class="ui fluid dropdown">
<option value="1">HTTP-GET(SSL到期、变更)</option>
<option value="2">ICMP-Ping</option>
<option value="3">TCP-Ping</option>
</select>
</div>
</form>
<div class="ui warning message">
<p>
类型为 <b>HTTP-GET</b> 时输入URL(带 http/https, HTTPS 协议的会顺带监控SSL证书)<br>
类型为 <b>ICMP-Ping</b> 时输入主机名/IP不带端口<br>
类型为 <b>TCP-Ping</b> 时输入主机名/IP + 端口号example.com:22
</p>
<div class="header">添加监控</div>
<div class="content">
<form id="monitorForm" class="ui form">
<input type="hidden" name="ID" />
<div class="field">
<label>名称</label>
<input type="text" name="Name" placeholder="博客" />
</div>
<div class="field">
<label>目标</label>
<input
type="text"
name="Target"
placeholder="HTTP(https://t.tt)Ping(t.tt)TCP(t.tt:80)"
/>
</div>
<div class="field">
<label>类型</label>
<select name="Type" class="ui fluid dropdown">
<option value="1">HTTP-GET(SSL到期、变更)</option>
<option value="2">ICMP-Ping</option>
<option value="3">TCP-Ping</option>
</select>
</div>
<div class="field">
<div class="ui nb-notify checkbox">
<input name="Notify" type="checkbox" tabindex="0" class="hidden" />
<label>启用故障通知</label>
</div>
</div>
</form>
<div class="ui warning message">
<p>
类型为 <b>HTTP-GET</b> 时输入URL(带 http/https, HTTPS
协议的会顺带监控SSL证书)<br />
类型为 <b>ICMP-Ping</b> 时输入主机名/IP不带端口<br />
类型为 <b>TCP-Ping</b> 时输入主机名/IP + 端口号example.com:22
</p>
</div>
<div class=" actions">
<div class="ui negative button">取消</div>
<button class="ui positive right labeled icon button">确认<i class="checkmark icon"></i>
</button>
</div>
</div>
<div class="actions">
<div class="ui negative button">取消</div>
<button class="ui positive right labeled icon button">
确认<i class="checkmark icon"></i>
</button>
</div>
</div>
{{end}}
{{end}}

View File

@@ -53,4 +53,7 @@
</div>
{{template "component/monitor"}}
{{template "common/footer" .}}
<script>
$('.checkbox').checkbox()
</script>
{{end}}