跳转至

Ping 主机

ping-host 会对主机执行数次 ping,并将结果发回。它是可直接用于按钮的 随附函数之一。

  • 运行:ping -c {{.count}} {{.host}}
  • host(必填):主机名或IP
  • count(可选,默认4):数据包数量

函数文件

functions/ping-host.yaml
name: ping-host
run: "ping -c {{.count}} {{.host}}"
params:
  - name: host
    type: string
    required: true
    description: Hostname or IP
  - name: count
    type: string
    required: false
    default: "4"
    description: Number of ping packets

添加一个按钮

Ping固定主机3次

Ping gateway button
- name: Ping gateway
  type: button
  function: ping-host
  host: "192.168.1.1"
  count: 3

count 是数字,因此不需要引号。也可以省略它以使用默认值 4:

使用默认计数

Ping DNS button
- name: Ping DNS
  type: button
  function: ping-host
  host: "1.1.1.1"

相关