giip
SES 商机登记
8分钟阅读

CQE Repository Script Management Guide

Learn how to manage, execute, and monitor script registration in the CQE (Custom Query Engine) Repository.

🤖 前往 CQE 仓库列表 →

📋 Overview

The CQE Repo List provides a centralized repository for your maintenance and diagnostic scripts. You can store scripts once and deploy them across any number of logical servers (LSVR) with custom execution parameters.

🔍 Script Details & Execution

When you click on a script in the list, the detail modal opens with the following capabilities:

1. Script Content

View the full source code of the script. This is read-only in the list view; use the edit feature if modifications are needed.

2. Execution Settings (NEW)

Before registering a script to a server, you can configure how it should run:

  • Active: Toggle whether the script is enabled for the selected servers.
  • Repeat: If enabled, the script will run periodically.
  • Interval (min): Set the frequency for repeated execution (in minutes).
  • Start Date: Specify when the first execution should occur.

3. Server Registration (LSVR Queue Put)

You can select one or more servers from your current project to receive this script.

  • LSVR Selector: Use the checkboxes to choose target servers.
  • Add to Queue: Click this button to register the script with the defined settings for all selected servers.

📊 Script Usage Status

At the bottom of the modal, the Usage Status Table displays all servers currently registered for this specific script.

  • Hostname: The name of the server using the script.
  • Usage: The logical server's defined purpose.
  • Settings: View the active/repeat/interval status for each registration.
  • Last Run: Tracks the last time the script was successfully executed on that machine.

API 参考

有关此功能的 API 详细规范,请参阅专用指南。

📘 系统管理 API 参考

故障排除

症状原因解决
加入队列后脚本仍未执行执行设置中 激活 (Active) 处于关闭状态在详情弹窗中开启 Active,然后重新加入队列。
LSVR 选择器中看不到目标服务器当前所选项目没有服务器,或服务器属于其他项目确认已在顶部选择正确的项目。
重复执行不生效已开启 重复 (Repeat),但 间隔 (分钟) 为空将间隔设置为 1 或更大后重新注册。
使用状况中的 最后运行 未更新目标服务器的代理尚未接收到队列检查代理连接状态以及开始时间是否为过去时刻。

🔌 CQE API (自动化)

上述界面操作对应以下 CQE API 动词(byAK/bySk 分发器)。请求发送 text(动词+参数名)、jsondata(值)和 token。

  • CQERepoPut msName msDetail msBody msPer msPrice msType — 将脚本注册到仓库。

    • text 只承载 参数名: CQERepoPut msName msDetail msBody msPer msPrice msType
    • jsondata 承载实际值: {"msName":"...","msDetail":"...","msBody":"#!/bin/sh\n...","msPer":0,"msPrice":0,"msType":"sh"}
    • msType 限制为 5 个字符(varchar(5))。诸如 powershell、expect、cmdwin 这类长名称无法保存 — 请使用下表中的短代码。
    msType目标操作系统代理实际的运行方式
    ps1Windowspowershell.exe(无界面)
    cmdWindowscmd.exe
    batWindows规范化为 cmd,然后用 cmd.exe
    wsfWindowswscript.exe //B //Nologo
    ps1ui / cmduiWindows在桌面会话中以可见窗口运行
    shLinuxsh <tempfile>
    pyLinuxpython3 <tempfile>
    ps1Linuxpwsh <tempfile>

    不要混用操作系统。 Windows 代理只运行上表中的 Windows 类型; 其他任何值都会被记录为 unsupported_script_type 并且 不会执行。Linux 代理则相反 — 它会把 所有未知类型都交给 sh 运行,因此把 bat/wsf 脚本分配给 Linux 服务器会悄悄地以 sh 运行并出错。请按照将要分配的服务器的操作系统,注册与之匹配的类型。

    • 注册 Linux shell 脚本: 在 msType 中填入 sh,在 msBody 中填入完整的 shell 脚本。Linux 代理会把正文写入临时文件并 用 sh 运行,因此 #!/bin/bash shebang 会被忽略。请避免仅限 bash 的语法([[ ]]、数组……),改用 POSIX shell 编写,或者在第一行用 exec bash "$0" "$@" 交给 bash。

      #!/bin/sh
      # Runs under sh, so use POSIX syntax only. sk/lssn/apiaddrv2 arrive as environment variables.
      curl -s -H "Authorization: Bearer $sk" "$apiaddrv2/health" | jq -r .status
    • 脚本正文放在哪里: 两种方式都可行。

      • 把完整正文放进 msBody — 主机上无需预先安装任何东西,并且 giip 端的修改会推送到所有服务器。推荐。
      • 把脚本保留在主机上,仅调用它 — 适用于已经需要 jq/curl 等前置条件的主机,或者正文非常长的情况。此时你必须自行跟踪每台主机的部署状态。
      • msBody 为 ntext,因此实际上没有长度限制(观测到的最大值: 20,883 个字符)。
  • CQEQueuePut mssn lssngroup csn interval active script_type custom_values repeat startdate auid — 将脚本分配到服务器。

    • lssngroup: 逗号分隔的 LSSN 列表(每台服务器一条分配)。
    • interval: 分钟。repeat: 0/1 = 一次性, 2 = 递归(每隔 interval 重复)。
    • custom_values: 按服务器注入的值 → 替换脚本正文中的 {{CustomVariables}}。
  • CQEQueueGet lssn hostname os op — 代理轮询以接收下一个脚本正文。

脚本正文占位符: {{CustomVariables}}(每次分配的 custom_values,服务端注入)、{{sk}}(代理令牌)、{{lssn}}(代理 LSSN)。

Linux 代理还会把 sk、lssn 和 apiaddrv2 导出 为环境变量。除了 {{sk}}/{{lssn}} 占位符之外,你也可以直接引用 $sk、$lssn 和 $apiaddrv2。

执行限制

Windows 代理Linux 代理
时间限制默认 600 秒; 可通过 giipAgent.cfg 中的 cqetimeoutsec 修改。超过时脚本会被终止无
运行方式临时文件,无界面进程临时文件,用 sh 执行
正文长度无限制(ntext)相同

运行间隔: interval 以分钟为单位。实际节奏由代理轮询周期决定 — interval=0 并不 表示“没有计划”,而是表示 在每次轮询轮转时重新分发。多个激活的队列会轮流处理,因此在有 N 个队列时,感知到的间隔会拉长到大约 N 倍(在 giipdb docs/30_Specs/SPEC_AND_CHECKLIST.md 中实测)。把间隔设为 1 分钟也不会让它比轮询周期运行得更频繁。

结果存储在哪里: 脚本的 stdout/stderr 会输出到 运行代理的那台服务器上的本地日志文件。只有 摘要 会发送到 giip — 一次 KVSPut(kType=lssn、kKey=<lssn>、kFactor=giipagent)会创建一条 event_type="script_execution" 记录,其中包含 script_type、exit_code、execution_time_seconds、mslsn 和 mssn。输出本身不会保存在 giip 中。 若要在 giip 中查看输出,请让脚本用 KVSPut 发布它(保留期随该 KVS 配置)。

失败通知: 没有内置通知。请通过查询 exit_code 非零的 script_execution 记录来检测失败,或者在脚本内部发送告警。

完整规范: giipdb docs/30_Specs/CQE_SPECIFICATION.md。


Version: 1.3 Last Updated: 2026-10-19 Source File: giipv3/public/help/cqerepolist.en.md