NetXMS 7.0.1 常用 CLI 命令与工具详解

NetXMS 7.0.1 命令行工具全解:nxadm 调试控制台、nxdbmgr 数据库管理、nxagentd 注册校验、nxget 指标查询、nxping 探测与各辅助工具,参数说明与逐条实测回显,附账号锁定、数据库锁、端口占用排障实录。

NetXMSNetXMS自托管监控2026/11/01

NetXMS 7.0.1 常用 CLI 命令与工具详解

目标:系统梳理 NetXMS 7.0.1 随服务端与代理附带的全部命令行工具——nxadm 调试控制台、nxdbmgr 数据库管理器、nxagentd 代理管理命令、nxget 远程指标查询、nxping 连通性探测,以及 nxencpasswd、nxgenguid、nxcsum、nxsnmpget/nxsnmpwalk、nxupload/nxdownload、nxscript、nxmibc 等辅助工具,给出每个工具的完整参数说明与逐条实测回显,并沉淀排障实录。全部命令与输出均在 Ubuntu 22.04 双主机环境实测通过:管理服务器 server(10.89.63.3)+ 被监控主机 agent(10.89.63.5),NetXMS 7.0.1 Build 7.0-824-g44d7a0dfb5。

部署过程见 《NetXMS 7.0.1 Docker Compose 部署指南》,产品选型背景见 《NetXMS 介绍与选型指南》,配置文件与运行时参数含义见 《NetXMS 7.0.1 配置参数详解》。本文专注「命令行工具怎么用」这一层。

一、环境信息

  • 操作系统:Ubuntu 22.04(管理服务器与受监控主机均为该系统)
  • NetXMS 版本:7.0.1 Build 7.0-824-g44d7a0dfb5(UNICODE),通信协议 NXCP 5.62.1.60
  • 管理服务器:主机名 server,地址 10.89.63.3,监听 4701(客户端)、4700(代理接入)、4703(代理 TLS 隧道)
  • 被监控主机:主机名 agent,地址 10.89.63.5,运行 nxagentd 监听 4700
  • 后端数据库:PostgreSQL 17,主机 db,库名 netxms,用户 netxms,口令 q1w2e3r4
  • Web 控制台:HTTPS 8443 端口,演示管理账号 admin / q1w2e3r4
  • 服务端配置文件:/etc/netxmsd.conf;代理配置文件:/etc/nxagentd.conf
  • 命令行工具安装位置:/usr/bin(服务端全家桶),代理主机仅含代理相关工具
  • 组件库目录:/usr/lib/x86_64-linux-gnu/netxms/(.nsm 子代理、.ddr 数据库驱动)
  • 数据目录:/var/lib/netxms

二、工具概览

NetXMS 7.0.1 服务端安装后在 /usr/bin 下提供以下命令行工具(实测 ls /usr/bin | grep -iE "^nx|netxms" 输出节选):

netxmsd              nxaction           nxadm              nxaevent
nxagentd             nxap               nxapush            nxcsum
nxdbmgr              nxdownload         nxencpasswd        nxethernetip
nxgenguid            nxget              nxhwid             nxlptest
nxmibc               nxmibdump          nxminfo            nxping
nxscript             nxsnmpget          nxsnmpset          nxsnmpwalk
nxtftp               nxupload           nxwsget

按用途分组如下:

分组工具用途运行位置
服务端管理netxmsd监控服务器主进程(参数详解见配置篇)管理服务器
服务端管理nxadm服务器调试控制台(本地管理通道)管理服务器
数据库nxdbmgr初始化/升级/检查/导出/运行时变量读写管理服务器
代理nxagentd代理进程本体及配置校验/注册被监控主机
数据采集nxget远程读取代理指标/列表/表/配置任意主机
连通性nxpingNetXMS 协议 ICMP 探测任意主机
SNMPnxsnmpget / nxsnmpwalk / nxsnmpset / nxmibc / nxmibdumpSNMP 读写与 MIB 编译/查看任意主机
文件与动作nxupload / nxdownload / nxtftp / nxaction / nxap / nxapush / nxaevent对代理上传下载文件、执行动作、策略管理、推送数据与事件任意主机(需代理开放对应能力)
脚本与模块nxscript / nxminfo / nxlptest / nxwsget / nxethernetipNXSL 本地执行、模块信息、日志解析自测、Web 服务取数、EtherNet/IP 诊断任意主机
杂项nxencpasswd / nxgenguid / nxcsum / nxhwid配置口令加密、GUID 生成、校验和、硬件 ID任意主机

💡 技术拓展:监控系统的管理通道通常有三类——本地调试控制台(NetXMS nxadm、Zabbix 无对应物)、REST API(NetXMS Web Console 附带的 /rest 接口)、图形控制台(NXMC/NXWA)。本地控制台走进程内部通道、不占网络端口,适合脚本化巡检与 API 不可用时的兜底管理;本文第四章讲 nxadm 这条通道,REST API 属于 D5 篇范畴。

⚠️ 注意:历史版本中的独立工具 nxsms(短信猫守护进程)与 nxlog 在 7.0.1 中均不存在,实测回显见 9.9 节;短信能力现在由代理子代理 /usr/lib/x86_64-linux-gnu/netxms/sms.nsm 承载。

三、前置条件

  1. 管理服务器上 netxmsd 正常运行:
nxadm -R
Server is running
  1. 具备管理账号。本文全部演示使用 admin / q1w2e3r4。
  2. nxadm 的调试控制台通道依赖服务端配置项 EnableLocalAdminInterface(默认开启,对应内部标志 AF_ENABLE_LOCAL_ADMIN_INTERFACE=1,可在 4.5 节 show flags 回显中看到)。
  3. nxdbmgr 全部子命令读取 /etc/netxmsd.conf 中的 DBDriver/DBServer/DBName/DBLogin/DBPassword 连接数据库,可用 -c <config> 指定其他配置文件。
  4. 面向代理的工具(nxget/nxupload 等)要求代理在 nxagentd.conf 中以 MasterServers 放行管理网段,本文环境配置为 MasterServers=10.89.63.0/24(full access)。

四、nxadm——服务器调试控制台管理工具

nxadm(NetXMS Server Administration Tool)连接本机 netxmsd 的调试控制台,是脱离 Web 控制台对服务器做巡检、改运行时变量、触发维护动作的核心工具。它不需要指定服务器地址(只作用于本机服务器),认证用服务器用户账号。

4.1 命令行形态与选项

nxadm -h 实测回显(全文照抄):

NetXMS Server Administration Tool  Version 7.0.1
Copyright (c) 2004-2026 Raden Solutions

Usage: nxadm [-u <login>] [-P|-p <password>] -c <command>
       nxadm [-u <login>] [-P|-p <password>] -i
       nxadm [-u <login>] [-P|-p <password>] [-r] -s <script>
       nxadm -P
       nxadm -p <db password>
       nxadm -R
       nxadm -h
       nxadm -v

Options:
   -c <command>   Execute given command at server debug console and disconnect
   -i             Connect to server debug console in interactive mode
   -h             Display help and exit
   -p <password>  Provide database password for server startup or
                  user's password for console access
   -P             Provide database password for server startup or
                  user's password for console access (password read from terminal)
   -r             Use script's return value as exit code
   -R             Check if server is running (started and completed initialization)
   -s <script>    Execute given NXSL script and disconnect
   -u name        User name for authentication
   -v             Display version and exit

nxadm -v 回显:

NetXMS Server Local Administration Tool Version 7.0.1

要点解读:

  • -c 单命令模式:执行一条控制台命令后立即断开,适合放进 cron/巡检脚本;
  • -i 交互模式:进入 nxadm> 提示符的会话,命令集见 4.4 节;
  • -R 健康检查:只回答服务器是否完成初始化,退出码 0 表示正常,是部署脚本里等待服务就绪的标准姿势(-p <db password> 形态则用于数据库口令加密后的启动辅助,与 netxmsd 启动配合);
  • -s 执行脚本库中的 NXSL 脚本,-r 让脚本返回值成为进程退出码。

4.2 单命令模式实测

以下全部为 nxadm -u admin -p q1w2e3r4 -c "<命令>" 的实测回显。

查看服务器版本:

nxadm -u admin -p q1w2e3r4 -c "show version"
NetXMS Server Version 7.0.1 Build 7.0-824-g44d7a0dfb5
NXCP: 5.62.1.60 (AES-256, 3DES, AES-128)
Built with: g++ (Debian 14.2.0-19) 14.2.0

全局统计(对象规模、告警数、运行时长,巡检第一眼看这张表):

nxadm -u admin -p q1w2e3r4 -c "show stats"
Objects............: 110
   Nodes...........: 2
   Interfaces......: 4
   Access points...: 0
   Sensors.........: 0
Collectible DCIs...: 234
Active alarms......: 2
Uptime.............: 0 days,  1:34:17

在线用户与系统权限位图:

nxadm -u admin -p q1w2e3r4 -c "show users"
Login name           GUID                                 System rights
-----------------------------------------------------------------------
ai-operator          6da524c3-1fbd-420d-b8d7-3be28db46bed 0x1020004000000010
anonymous            46fb5138-8066-475c-9311-1a3040569a7f 0x0020004000000010
system               aed08b84-d696-44bd-b9bf-132ab7b20f97 0x1FFFFFFFFFFFFFFF
admin                765f1263-0387-4bcb-83b9-3f8abba2a12f 0x1FFFFFFFFFFFFFFF

当前客户端会话(含 NXMC/Web 连接来源与加密算法):

nxadm -u admin -p q1w2e3r4 -c "show sessions"
CLIENT SESSIONS
 ID  | ADDRESS                        | WEB SERVER           | TYPE    | CIPHER   | USER                 | CLIENT
-----+--------------------------------+----------------------+---------+----------+----------------------+----------------------------

0 active sessions


MOBILE DEVICE SESSIONS
 ID  | CIPHER   | USER                 | CLIENT
-----+----------+----------------------+----------------------------

0 active sessions

4.3 show 系列巡检命令详解

线程池状态 show threads:按线程池逐个输出当前线程数(当前/上限)、负载、请求计数与等待时间统计。实测节选(输出节选,实测首尾):

MAIN
   Threads.............. 8 (8/256)
   Load average......... 0.00 0.00 0.00
   Current load......... 0%
   Usage................ 3%
   Active requests...... 0
   Scheduled requests... 4
   Total requests....... 293
   ...
AGENT
   Threads.............. 32 (32/256)
   Usage................ 12%
   Total requests....... 12
   ...
POLLERS
   Threads.............. 10 (10/250)
   Load average......... 0.22 0.15 0.10
   Total requests....... 633
   ...
DATACOLL
   Threads.............. 10 (10/250)
   Total requests....... 18777
   ...

线程池上限与 ThreadPool.* 运行时变量一一对应(MAIN 256、AGENT 256、POLLERS 250、DATACOLL 250),当某池 Wait time 持续增大或 Queue size 非零时说明该池饱和,调大对应 ThreadPool.X.MaxSize 即可。

内部队列 show queues:输出各处理队列积压深度,是判断「数据入库跟不上采集」的直接证据:

nxadm -u admin -p q1w2e3r4 -c "show queues"
Data collector                   : 0
DCI cache loader                 : 0
Template updater                 : 0
Database writer                  : 0
Database writer (alarms)         : 0
Database writer (IData)          : 0
Database writer (raw DCI values) : 129
Event processor                  : 0
...
Scheduler                        : 0

Database writer (raw DCI values) : 129 表示瞬时积压 129 条采集值待写库,属正常波动;若持续数千以上需检查数据库性能或调大 DBWriter.* 参数。

数据库连接池 show dbcp:

nxadm -u admin -p q1w2e3r4 -c "show dbcp"
0 database connections in use

看门狗 show watchdog:输出内部关键线程的心跳状态,排查「服务器假死」时首先看这里:

nxadm -u admin -p q1w2e3r4 -c "show watchdog"
Thread                                           Interval Status
----------------------------------------------------------------------------
Syncer Thread                                    30       Sleeping
Poll Manager                                     5        Sleeping
Ad hoc scheduler                                 5        Sleeping
Recurrent scheduler                              5        Sleeping
Item Poller                                      10       Running

内部标志位 show flags:把 60 余个 AF_* 内部标志一次性 dump 出来,节选(输出节选,实测首尾):

Flags: 0x4A1012828017FCD0
  AF_DAEMON                              = 0
  AF_ENABLE_SNMP_TRAPD                   = 1
  AF_ENABLE_ZONING                       = 1
  AF_DEBUG_CONSOLE_DISABLED              = 1
  AF_DB_LOCKED                           = 1
  AF_ENABLE_LOCAL_ADMIN_INTERFACE        = 1
  AF_SERVER_INITIALIZED                  = 1
  AF_SHUTDOWN                            = 0

AF_DB_LOCKED=1 表示数据库处于本服务器持有锁状态(正常持有),AF_SERVER_INITIALIZED=1 表示初始化完成。

已加载模块与设备驱动 show modules / show ndd:

nxadm -u admin -p q1w2e3r4 -c "show modules"
Loaded server modules:
0 modules loaded
nxadm -u admin -p q1w2e3r4 -c "show ndd"
Loaded network device drivers:
   HIRSCHMANN-CLASSIC               7.0.1
   ...
   MIKROTIK                         7.0.1
   TPLINK                           7.0.1
   ...
   HUAWEI-SW                        7.0.1
   RUGGEDCOM                        7.0.1
66 drivers loaded

show ndd 列出 66 个网络设备驱动(MikroTik、华为、H3C、Cisco 各系列等),决定配置轮询时能识别哪类网络设备。

事件处理策略 show epp:列出内置事件→告警转换规则,实测 70 条,节选(输出节选,实测首尾):

 Chain | ID  | GUID                                 | Version | Comment
-------+-----+--------------------------------------+---------+------------------------------------------
     0 |   1 | 2d2c3d32-49d4-4e76-b6aa-782b30d90f28 |       1 | Show alarm when node is down
     0 |   2 | 4fa20604-b56f-4f12-bb5d-2c3243a126c9 |       1 | Terminate node down alarms when node is up
     0 |   3 | 45999e66-c16c-400d-8b79-63a0f8eb8958 |       1 | Show alarm when network service is down or in unknown state
     ...
    0 |  70 | c3e2a703-3b4c-4d6e-af70-6876cc000003 |       1 | Raise an alarm on VMware ESXi environmental and hardware alerts. One alarm per alert type and source node.

70 rules total

规则分「触发」(如 node is down、threshold violation)与「终结」(对应告警自动关闭)成对出现,全部内置、只读展示;自定义 EPP 规则在 Web Console 的事件处理策略页面维护。

对象树 dump show objects [<filter>]:不带过滤条件时把全部 107 个对象逐个 dump 到屏幕(数据量大,巡检慎用),带过滤条件按名称匹配。实测按名称查看管理服务器节点:

nxadm -u admin -p q1w2e3r4 -c "show objects server"
Object ID 100 "server"
   Class=Node  Status=WARNING  IsModified=0  IsDeleted=0
   Parents: <103 117 133 188 189 190 191 192 195 197 2>
   Children: <101 102>
   Last change.........: 01.Nov.2026 08:39:39
   State flags.........: 0x00000000
   Primary IP..........: 127.0.0.1
   Primary hostname....: 127.0.0.1
   Capabilities........: 000000000010 (isSNMP=0 isAgent=0 isEIP=0 isBridge=0 isRouter=0 isMgmt=1)
   SNMP ObjectId.......: 
   ICMP polling........: ON

每个对象输出 ID、名称、类型(Class)、状态(Status)、父子关系与能力位;show objects 全量 dump 的开头几个根对象节选:

Object ID 1 "Entire Network"
   Class=Network  Status=NORMAL  IsModified=0  IsDeleted=0
   Parents: <>
   Children: <4>
   Last change.........: 01.Nov.2026 06:58:41
Object ID 2 "Infrastructure Services"
   Class=ServiceRoot  Status=NORMAL  IsModified=0  IsDeleted=0
   Parents: <>
   Children: <100>
   Last change.........: 01.Nov.2026 06:58:41
Object ID 3 "Templates"
   Class=TemplateRoot  Status=NORMAL  IsModified=0  IsDeleted=0
   Parents: <>
   Children: <104 113 120 125 134 155 170 177>
   Last change.........: 01.Nov.2026 06:58:42

⚠️ 注意:过滤器按对象名称匹配而非类型。实测 show objects agent 返回空(RC=0)——因为被监控节点在服务器上的注册名并非字面 "agent";查不到对象时先在 Web Console 或全量 dump 里确认真实名称。

其余 show 命令实测速览:

nxadm -u admin -p q1w2e3r4 -c "show pollers summary"
Status .............. 0
Configuration ....... 0
Instance discovery .. 0
Routing table ....... 0
Discovery ........... 0
Topology ............ 0
ICMP ................ 0
Auto bind ........... 0
Map update .......... 0
Total ............... 0
nxadm -u admin -p q1w2e3r4 -c "show discovery ranges"
Active discovery poller is SLEEPING
nxadm -u admin -p q1w2e3r4 -c "show ai providers"
No AI providers configured

show pollers summary 各轮询器当前任务数为 0、show discovery ranges 提示主动发现轮询器处于 SLEEPING,均与空闲环境相符;show ai providers 说明 7.0.1 已内置 AI 提供商槽位管理(未配置时输出如上)。

4.4 交互模式与控制台命令全集

nxadm -u admin -P -i

-P 从终端读取口令(避免明文进历史与进程表),-i 进入 nxadm> 提示符的交互会话,可连续执行命令、支持上箭头翻历史。会话内输入 help 的实测回显(全文照抄):

Valid commands are:
   at +<sec> <script> [<params>]     - Schedule one time script execution task
   at <schedule> <script> [<params>] - Schedule repeated script execution task
   backup show <node>                - Show latest device configuration backup
   backup start <node>               - Start device configuration backup
   backup status <node>              - Show device configuration backup status
   clear                             - Show list of valid component names for clearing
   clear <component>                 - Clear internal data or queue for given component
   dbcp reset                        - Reset database connection pool
   debug [<level>|off]               - Set debug level (valid range is 0..9)
   debug [<debug tag> <level>|off|default]
                                     - Set debug level for a particular debug tag
   debug sql [on|off]                - Turn SQL query trace on or off
   down                              - Shutdown NetXMS server
   exec <script> [<params>]          - Executes NXSL script from script library
   exit                              - Exit from remote session
   ha status|switchover              - HA cluster status / graceful switchover
   kill <session>                    - Kill client session
   get <variable>                    - Get value of server configuration variable
   help                              - Display this help
   hkrun                             - Run housekeeper immediately
   ldapsync                          - Synchronize ldap users with local user database
   log <text>                        - Write given text to server log file
   logmark                           - Write marker ******* MARK ******* to server log file
   logrotate                         - Force server log file rotation
   notify <session> <code> [<data>]  - Send notification message to client session
   ping <address>                    - Send ICMP echo request to given IP address
   poll <type> <node>                - Initiate node poll
   raise <exception>                 - Raise exception
   recommission <node>               - Clear decommissioned state of node (node stays unmanaged)
   reload mib                        - Reload MIB tree from compiled file
   scan <range start> <range end> [proxy <id>|zone <uin>] [discovery] 
                                     - Manual active discovery scan for given range. Without 'discovery' parameter prints results only
   set <variable> <value>            - Set value of server configuration variable
   show ai memory                    - Show AI memory entries
   show ai operators                 - Show AI operator instances
   show ai providers                 - Show configured AI providers
   show ai slots                     - Show AI provider slots
   show arp <node>                   - Show ARP cache for node
   show authtokens                   - Show user authentication tokens
   show components <node>            - Show physical components of given node
   show dbcp                         - Show active sessions in database connection pool
   show dbstats                      - Show DB library statistics
   show discovery ranges             - Show state of active network discovery by address range
   show ep                           - Show event processing threads statistics
   show epp                          - Show event processing policy rules
   show fdb <node>                   - Show forwarding database for node
   show flags                        - Show internal server flags
   show heap details                 - Show detailed heap information
   show heap summary                 - Show heap usage summary
   show index <index>                - Show internal index
   show modules                      - Show loaded server modules
   show ndd                          - Show loaded network device drivers
   show objects [<filter>]           - Dump network objects to screen
   show parents <object>             - Show parent tree for object (by ID or name)
   show pollers [summary]            - Show pollers state information
   show queues                       - Show internal queues statistics
   show routing-table <node>         - Show cached routing table for node
   show sessions                     - Show active client sessions
   show stats                        - Show global server statistics
   show syncer                       - Show syncer statistics
   show tasks                        - Show background tasks
   show threads [<pool>]             - Show thread statistics
   show topology <node>              - Collect and show link layer topology for node
   show tunnels                      - Show active agent tunnels
   show users                        - Show users
   show version                      - Show NetXMS server version
   show vlans <node>                 - Show cached VLAN information for node
   show watchdog                     - Display watchdog information
   sync                              - Wakeup syncer thread immediately
   tcpping <address> <port>          - TCP ping on given address and port
   tp loadtest <pool> <tasks>        - Start test tasks in given thread pool
   trace <node1> <node2>             - Show network path trace between two nodes
   tunnel bind <tunnel> <node>       - Bind agent tunnel to node
   tunnel unbind <node>              - Unbind agent tunnel from node
   v5migrate pause                   - Pause background migration of V5 collected data
   v5migrate resume                  - Resume paused migration of V5 collected data
   v5migrate status                  - Show state of background migration of V5 collected data

Almost all commands can be abbreviated to 2 or 3 characters

You can use the following shortcuts to execute command from history:
   !!    - Execute last command
   !<N>  - Execute Nth command from history
   !-<N> - Execute Nth command back from last one

命令集分五类记忆:巡检类(show 系列)、调参类(get/set/debug)、维护触发类(hkrun/logrotate/sync/ldapsync/reload mib/dbcp reset/clear/down)、动作类(ping/tcpping/poll/scan/exec/at/notify/kill/raise)、拓扑与代理类(show arp/fdb/routing-table/vlans/topology/trace/tunnel/backup)。除 show version 外几乎所有命令都可用 2~3 字符缩写(如 sh st 即 show stats)。

4.5 运行时配置变量读写:get / set

控制台的 get/set 与 nxdbmgr 读写的是同一套数据库运行时变量,区别在于它经服务器进程操作,修改即时生效于运行中的服务器并持久化,无需重启。完整往返实测:

nxadm -u admin -p q1w2e3r4 -c "get Objects.StatusPollingInterval"
Objects.StatusPollingInterval = 60
nxadm -u admin -p q1w2e3r4 -c "set Server.MessageOfTheDay D1-cli-demo"
Configuration variable Server.MessageOfTheDay updated
nxadm -u admin -p q1w2e3r4 -c "get Server.MessageOfTheDay"
Server.MessageOfTheDay = D1-cli-demo
nxadm -u admin -p q1w2e3r4 -c "set Server.MessageOfTheDay "
Configuration variable Server.MessageOfTheDay updated

set 回显 Configuration variable ... updated 即表示新值已写库并推送给运行中的进程;恢复默认用 set 空值。变量含义与默认值全表见 《NetXMS 7.0.1 配置参数详解》。

4.6 连通性测试:ping / tcpping

服务器内置的 ICMP / TCP 探测命令,验证「服务器进程自己能否到达被监控对象」——与操作系统 ping 的区别是它走服务器的发送逻辑,结果与状态轮询同源:

nxadm -u admin -p q1w2e3r4 -c "ping 10.89.63.5"
Success, RTT = 0 ms
nxadm -u admin -p q1w2e3r4 -c "tcpping 10.89.63.5 4700"
Success

排障口诀:节点 ICMP 轮询异常先用 ping 确认服务器→节点通,再用 tcpping <ip> 4700 确认代理端口可达,两步把「网络层不通 / 端口不通 / 代理不应答」切开。

4.7 维护触发命令

clear——清理内部组件的计数器或队列,不带参数时列出合法对象(实测):

nxadm -u admin -p q1w2e3r4 -c "clear"
Valid components:
   DBWriter Counters
   DBWriter DataQueue
   NCQueue <channel-name>

三类对象:数据库写入器统计计数器、待写库队列、指定网络通道的收发队列。

log / logmark——向服务器日志写一行文本 / 一行标记,排障时用于「打时间锚点」:先 logmark 再复现问题,日志里可直接定位本次试验的起止段。实测:

nxadm -u admin -p q1w2e3r4 -c "log D1-cli-demo-message"
nxadm -u admin -p q1w2e3r4 -c "logmark"

两条命令本身无输出(RC=0),效果落在服务器日志新增的两行:

2026.11.01 08:41:15.582 *I* [                   ] D1-cli-demo-message
2026.11.01 08:41:15.677 *I* [                   ] ******* MARK *******

其余触发类命令(语义取自 4.4 节 help 全集,均为「踢一下立即返回」):

命令作用典型场景
hkrun立即执行一次清扫任务(不等计划时间)调整数据保留参数后立刻验证清理效果
logrotate强制服务器日志轮转改日志路径后无需重启即切换
sync立即唤醒同步线程对象变更后内存缓存未及时刷新
ldapsync立即执行一次 LDAP 用户同步验证 LDAP 映射改动
reload mib从编译文件重新加载 MIB 树nxmibc 编译新 MIB 后立即生效
dbcp reset重置数据库连接池数据库切换/网络抖动后重建连接
debug [级别|off]动态调整调试级别(0..9),可按调试标签单独设置,debug sql on/off 开关 SQL 追踪排障时临时开调试,事后必须关闭
down关闭服务器命令行优雅停机

⚠️ 注意:down 会直接停止服务器,监控中断且存在事件丢失窗口,生产环境执行前务必确认;debug 高级别日志量极大,用完记得 debug off。

4.8 -s:执行脚本库中的 NXSL 脚本

-s 按名称在服务器脚本库中查找并执行 NXSL 脚本。演示环境不存在该脚本,实测回显即失败路径:

nxadm -u admin -p q1w2e3r4 -s "D1-demo-script"
Server error 57 (Invalid script name)
RC=57
nxadm -u admin -p q1w2e3r4 -r -s "D1-demo-script"
Server error 57 (Invalid script name)
RC=57

加 -r 时脚本返回值成为进程退出码(失败时仍是错误码 57),配合自动化脚本判断成败。与控制台命令 exec <script> 都执行脚本库脚本,差别在于 -s 是进程级专用形态、可用 -r 传播返回值;脚本不存在时统一报 server error 57。

4.9 排障实录:Authentication failed (server error 61)

现象:某一时段内,任意 nxadm 命令都返回同一个错误(实测,三条不同命令回显一致):

=== show objects ===
Authentication failed (server error 61: Internal error)
=== get DBLockStatus ===
Authentication failed (server error 61: Internal error)
=== show heap summary ===
Authentication failed (server error 61: Internal error)

对照:单纯密码敲错时报的是另一种错误(实测):

nxadm -u admin -p q1we3r4 -c "show authtokens"
Authentication failed (server error 2: Access denied)
RC=5

error 2(Access denied)是常规「口令不对」;error 61 是认证阶段的内部错误——本次成因是 admin 账号处于锁定状态(此前连续认证失败触发)。

处理:用 nxdbmgr 解锁用户(详见第五章):

nxdbmgr unlock-user admin
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

Database is locked by server 10.89.63.3 [server Linux Release 7.0.0-38-generic]
RC=0

注意它打印了数据库锁警告行但仍完成了解锁(RC=0):unlock-user 只改用户表,不需要独占数据库,服务器持锁不影响它生效。

验证(解锁后实测):

nxadm -u admin -p q1w2e3r4 -c "show objects"
Object ID 1 "Entire Network"
   Class=Network  Status=NORMAL  IsModified=0  IsDeleted=0
   Parents: <>
   Children: <4>
   Last change.........: 01.Nov.2026 06:58:41
nxadm -u admin -p q1w2e3r4 -c "get DBLockStatus"
DBLockStatus = 10.89.63.3

认证恢复正常。顺带两个发现:get DBLockStatus 直接给出当前持锁者(即服务器自身 10.89.63.3,属正常持锁);show heap summary 返回 Heap summary information unavailable——堆统计需服务器带相应支持启动,属能力限制而非错误。

预防:账号锁定阈值由 Server.Security.IntruderLockoutThreshold 控制(默认 0 = 不锁定),设为 N 后连续 N 次失败口令即锁定,届时只能 nxdbmgr unlock-user <login> 解锁。

五、nxdbmgr——数据库管理器

nxdbmgr 是服务端的数据库瑞士刀:初始化、升级、检查、导出导入、运行时变量读写、账号解锁与口令重置。所有子命令默认从 /etc/netxmsd.conf 读取 DBDriver/DBServer/DBName/DBLogin/DBPassword 连接数据库,-c <config> 可指定其他配置文件。

5.1 帮助与版本

nxdbmgr -h 实测回显(全文照抄):

NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

Usage: nxdbmgr [<options>] <command> [<options>]
Valid commands are:
   background-convert   : Convert collected data to TimescaleDB format in background
   background-upgrade   : Run pending background upgrade procedures
   batch <file>         : Run SQL batch file
   check                : Check database for errors
   check-data-tables    : Check database for missing data tables
   convert              : Convert standard PostgreSQL schema to TimescaleDB schema
   export <file>        : Export database to file
   get <pattern>        : Get value of server configuration variable(s) matching given pattern
   import <file>        : Import database from file
   init [<type>]        : Initialize database. If type is not provided it will be deduced from driver name.
   migrate <source>     : Migrate database from given source
   reset-monitoring     : Reset all monitoring state (alarms, thresholds, object status, DCI states)
   reset-system-account : Unlock user "system" and set new random password
   set <name> <value>   : Set value of server configuration variable
   set-user-password <login> : Set password for the given user
   unlock               : Forced database unlock
   unlock-user <login>  : Unlock user account
   upgrade              : Upgrade database to new version
Valid options are:
   -c <config> : Use alternate configuration file. Default is /etc/netxmsd.conf
   -C <dba>    : Create database and user before initialization using provided DBA credentials
   -d          : Check collected data (may take very long time).
   -D          : Migrate only collected data.
   -e <table>  : Exclude specific table from export, import, or migration.
   -E          : Fail check if fix required
   -f          : Force repair - do not ask for confirmation.
   -F <syntax> : Fallback database syntax to use if not set in metadata.
   -h          : Display help and exit.
   -I          : MySQL only - specify TYPE=InnoDB for new tables.
   -j <count>  : Number of parallel migration workers (default 4, range 1-64).
   -L <log>    : Migrate only specific log.
   -m          : Improved machine readability of output.
   -M          : MySQL only - specify TYPE=MyISAM for new tables.
   -N          : Do not replace existing configuration value ("set" command only).
   -o          : Show output from SELECT statements in a batch.
   -p <passwd> : Set admin password during init (if not set, a random password will be generated).
   -P          : Pause after error.
   -q          : Quiet mode (don't show startup banner).
   -s          : Skip collected data during export, import, conversion, or migration.
   -S          : Skip collected data during export, import, or migration and do not clear or create data tables.
   -t          : Enable trace mode (show executed SQL queries).
   -T <recs>   : Transaction size for migration.
   -v          : Display version and exit.
   -x          : Ignore collected data import/migration errors
   -X          : Ignore SQL errors when upgrading (USE WITH CAUTION!!!)
   -Y <table>  : Migrate only given table.
   -Z <log>    : Exclude specific log from export, import, or migration.
Valid database types:
   db2 mssql mysql oracle pgsql sqlite tsdb
Notes:
   * -e, -L, -Y, and -Z options can be specified more than once for different tables
   * -L and -Y options automatically exclude all other (not explicitly listed) tables
   * DBA credentials should be provided in form login/password
   * Configuration variable name pattern can include character % to match any number of characters
   * Valid log names for -L and -Z options:
        action, ai, alarm, asset, audit, certificate, deployment, downtime,
        event, incident, maintenance, notification, otel, snmptrap, syslog,
        winevent
   * Use -Z all to exclude all logs

18 个命令 × 27 个选项,三个要点:支持的数据库类型枚举(db2/mssql/mysql/oracle/pgsql/sqlite/tsdb)与 DBDriver 一致;-N 只对 set 有意义;-Z all 可在导出时排除全部日志表。

nxdbmgr -v 打印版本行后进程退出码为 1(实测 RC=1),别用它的退出码做判断:

nxdbmgr -v
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

5.2 get / set:运行时变量(服务器在线时可用)

与 nxadm 控制台不同,nxdbmgr get/set 直连数据库,服务器停着也能读写。get 支持 % 通配。实测:

nxdbmgr get DBLockStatus
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

DBLockStatus = 10.89.63.3
nxdbmgr get %ICMP%
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

ICMP.CollectPollStatistics = 1
ICMP.PingSize              = 46
ICMP.PingTimeout           = 1500
ICMP.PollingInterval       = 60
ICMP.StatisticPeriod       = 60

%ICMP% 匹配名字中包含 ICMP 的变量(输出按列对齐)。安全组查询节选:

nxdbmgr get %Server.Security.%
Server.Security.2FA.EnforceForAll             = 0
Server.Security.2FA.GraceLoginCount           = 5
Server.Security.2FA.TokenTimeout              = 120
Server.Security.2FA.TrustedDeviceTTL          = 0
Server.Security.CaseInsensitiveLoginNames     = 0
Server.Security.ExtendedLogQueryAccessControl = 0

set 往返与 -N 不覆盖保护实测:

nxdbmgr set Server.MessageOfTheDay nxdbmgr-demo
nxdbmgr get Server.MessageOfTheDay
Server.MessageOfTheDay = nxdbmgr-demo
nxdbmgr -N set Server.MessageOfTheDay not-overwritten
nxdbmgr get Server.MessageOfTheDay
Server.MessageOfTheDay = nxdbmgr-demo

-N 的含义是「目标已有非空值就不覆盖」:第二条 set 静默返回 RC=0 但值未变——适合部署脚本做「仅首次设置」的幂等写入。演示后已用 nxdbmgr set Server.MessageOfTheDay "" 恢复空值。

5.3 check / check-data-tables:完整性检查(需停服务器)

服务器运行时 check 会被数据库锁挡下(实测):

nxdbmgr check
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

Checking database (excluding collected data):
Database is locked by server 10.89.63.3 [server Linux Release 7.0.0-38-generic]
Do you wish to force database unlock? (Yes/No) Database check aborted

交互提示是否强制解锁,回答 No 即中止。正确姿势是先停 netxmsd 再 check,逐项 PASSED(输出节选,实测首尾):

nxdbmgr check
* Business service tickets - service bindings                          [   0% ][PASSED]
* Business service tickets - check bindings                            [   0% ][PASSED]
* Business service tickets - hierarchy                                 [   0% ][PASSED]
* Business service checks - state                                      [   0% ][PASSED]
* Business service downtime                                            [   0% ][PASSED]
* Assets                                                               [   0% ][PASSED]
* Asset to node links                                                  [   0% ][PASSED]
* Node to asset links                                                  [   0% ][PASSED]
Database doesn't contain any errors
Database check completed

选项:-d 连采集数据表一起检查(可能非常久);-E 需要修复时直接判失败(适合巡检脚本);-f 免确认直接修复。check-data-tables 只查缺失的数据表,轻量得多。

5.4 export / import:逻辑备份

导出同样要求服务器停止并释放锁(持锁时实测只打印锁警告、不生成文件)。停服后做「跳过采集数据」的轻量导出:

nxdbmgr export -s /tmp/nx_schema.nxexp
Exporting table traffic_observers
Exporting table observation_points
Exporting table observation_point_hosts
Database export complete.
ls -l /tmp/nx_schema.nxexp
-rw-r--r-- 1 root root 28442624 Nov  1 08:54 /tmp/nx_schema.nxexp

.nxexp 是 NetXMS 自有逻辑导出格式(非 SQL 文本),配对的 import <file> 把它写回目标库。常用裁剪项:-s 跳过采集数据、-S 进一步不清建数据表、-e <table> 排除单表、-Z <log> 或 -Z all 排除日志表。

5.5 batch:执行 SQL 批处理文件

batch <file> 把 SQL 文件送进 NetXMS 的数据库通道执行,-o 让 SELECT 的结果集也打印出来。手写 SQL 最大的坑是表名与实际 schema 不一致,两条实测失败回显正是典型(PostgreSQL 错误码 42P01 原样透传):

nxdbmgr -o batch /tmp/test.sql
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

SQL query failed (42P01 ERROR:  relation "objects" does not exist
LINE 1: SELECT COUNT(*) AS object_count FROM objects
                                             ^):
SELECT COUNT(*) AS object_count FROM objects
nxdbmgr -o batch /tmp/test2.sql
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

SQL query failed (42P01 ERROR:  relation "object" does not exist
LINE 1: SELECT COUNT(*) AS node_count FROM object WHERE object_type=...
                                           ^):
SELECT COUNT(*) AS node_count FROM object WHERE object_type=30

单数 object、复数 objects 都不对——NetXMS 的对象表另有其名,写 SQL 前先查 schema。另一个实测要点:SQL 失败时进程退出码仍是 0(上例 RC=0),批处理脚本不能只靠退出码判成败,需 grep 输出里的 SQL query failed。-t 可追踪每条执行的 SQL 语句。

5.6 set-user-password / unlock-user / reset-system-account:账号急救

set-user-password 在管理入口全部不可用时重置任意用户口令。新口令必须交互输入,不接受管道喂入(实测):

echo "q1w2e3r4" | nxdbmgr set-user-password admin
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

New password: Cannot read password

真实终端上交互执行时,若服务器仍持锁会停在锁检查这一步(实测,前两行为终端输入回显):

q1w2e3r4
q1w2e3r4
NetXMS Database Manager Version 7.0.1 Build 7.0-824-g44d7a0dfb5

Database is locked by server 10.89.63.3 [server Linux Release 7.0.0-38-generic]

即改口令需要独占数据库:先停服务器,或回答强制解锁。

unlock-user 解锁被锁账号,与上面相反,它不需要独占——打印锁警告行但实际完成解锁、RC=0(完整往返实录见 4.9 节)。

reset-system-account 解锁内置 system 账号并设置随机口令,用于 system 账号失控的兜底;随机口令在输出中给出一次,务必当场记录。

5.7 init / upgrade / migrate / convert:数据库生命周期(离线操作)

这组命令涉及建库、改结构、搬数据,全部要求服务器停止;语义取自 5.1 节 help:

命令作用关键选项
init [type]初始化空库(写入 schema 与全部默认运行时变量),type 省略时按 DBDriver 推断-C <dba> 先建库建用户(login/password 形式);-p 初始化时设定 admin 口令,不设则生成随机口令
upgrade数据库结构升级到当前程序版本-X 忽略 SQL 错误(危险,help 里带三个感叹号警告)
background-upgrade执行 upgrade 遗留的后台升级过程—
migrate <source>从另一套数据库整体迁移数据(如 mysql → pgsql)-j 并行工作线程(默认 4,范围 1-64)、-T 事务大小、-Y <table> 只迁单表、-L <log> 只迁指定日志、-D 只迁采集数据、-x 忽略采集数据错误
convert标准 PostgreSQL 结构转 TimescaleDB 结构-s 跳过采集数据
background-convert后台方式把采集数据转 TimescaleDB 格式—
reset-monitoring清空全部监控状态(告警、阈值、对象状态、DCI 状态),保留配置与对象定义—
unlock强制解除数据库锁—

⚠️ 注意:init 与 reset-monitoring 是破坏性操作,生产执行前先按 5.4 节导出备份;unlock 会把锁从正在运行的服务器手里强行抢走,两个进程同时写库会损坏数据,只应在确认服务器进程已死、锁是残留(stale lock)时使用。

六、nxagentd——代理管理命令

nxagentd 既是常驻代理进程本体,也提供一组「不启动进程就能完成校验与注册」的管理参数。被监控主机上安装代理后,/usr/bin/nxagentd 即可用。

6.1 命令行帮助

nxagentd -h 实测回显(全文照抄):

Usage: nxagentd [options]
Where valid options are:
   -B <uin>         : Set zone UIN
   -c <file>        : Use configuration file <file> (default {search})
   -C               : Load configuration file, dump resulting configuration, and exit
   -d               : Run as daemon/service
   -D <level>       : Set debug level (0..9)
   -f               : Run in foreground
   -g <gid>         : Change group ID to <gid> after start
   -G <name>        : Use alternate global section <name> in configuration file
   -h               : Display help and exit
   -K               : Shutdown all connected external sub-agents
   -l               : Get log file location
   -M <addr>        : Download config from management server <addr>
   -o <format>      : Set configuration outpot format (json, tree, or xml)
   -O <option>      : Set configuration option
   -p               : Path to pid file (default: /var/run/nxagentd.pid)
   -P <text>        : Set platform suffix to <text>
   -Q <entry>       : Load configuration file, query values for given entry, and exit
   -r <addr>        : Register agent on management server <addr>
   -S               : Run as systemd daemon
   -t <tag>:<level> : Set debug level for specific tag
   -T               : Reset agent identity
   -u <uid>         : Change user ID to <uid> after start
   -v               : Display version and exit

管理向选项速记:-C/-Q/-l 查配置、-r 注册、-T 重置代理身份(克隆后必做)、-K 踢掉外部子代理、-M 从服务器拉配置。

6.2 版本与配置校验

nxagentd -v
NetXMS Core Agent Version 7.0.1 Build 7.0-824-g44d7a0dfb5 (UNICODE)

-C 加载配置并以树形 dump 后退出,是「改完配置先验一遍」的标准动作(实测):

nxagentd -C
Error reading additional configuration files from "/etc/nxagentd.conf.d"
config
 +- CORE
     +- MasterServers
     |    value: 10.89.63.0/24
     +- LogFile
     |    value: {stdout}
     +- SubAgent
          value: filemgr

首行的 Error 是扩展配置目录不存在时的提示,不影响主配置 dump。换 JSON 格式输出(-o json -C,实测):

nxagentd -o json -C
{
   "CORE": {
      "MasterServers": "10.89.63.0/24",
      "LogFile": "{stdout}",
      "SubAgent": "filemgr"
   }
}

-o 支持 json / tree / xml 三种格式,方便配置巡检脚本消费。

6.3 日志位置与配置项查询

nxagentd -l
{stdout}

-l 回显日志实际去向(与 netxmsd -l 同思路)。-Q <entry> 查询指定配置项的值,未显式配置且无内建默认回显时退出码为 2(实测 nxagentd -Q ListenPort 无任何输出、RC=2),脚本里判 RC 即可区分「查到」与「没查到」。

6.4 -r:向管理服务器注册代理

nxagentd -r <服务器地址> 以前台方式启动代理并立即向指定服务器发起注册,成功标志是日志行 Successfully registered on management server <地址>。实测完整启动日志(输出节选,实测首尾):

nxagentd -r 10.89.63.3
2026.11.01 08:43:49.573 *I* [logger             ] Log rotation policy set to 2 (size=16777216, count=4)
2026.11.01 08:43:49.573 *I* [startup            ] Core agent version 7.0.1 (build tag 7.0-824-g44d7a0dfb5)
2026.11.01 08:43:49.573 *I* [config             ] Main configuration file: /etc/nxagentd.conf
2026.11.01 08:43:49.573 *I* [startup            ] Data directory: /var/lib/netxms
2026.11.01 08:43:49.575 *I* [db.drv             ] Database driver "sqlite.ddr" loaded and initialized successfully
2026.11.01 08:43:49.579 *I* [startup            ] Agent ID is 1af9e95b-08fd-4954-9add-cdb37f9c8bfa
2026.11.01 08:43:49.579 *I* [startup            ] Local host name is "agent"
2026.11.01 08:43:49.580 *I* [startup            ] Arbitrary command execution disabled
2026.11.01 08:43:49.583 *I* [subagents          ] Subagent "Linux" (/usr/lib/x86_64-linux-gnu/netxms/linux.nsm) loaded successfully (version 7.0.1)
2026.11.01 08:43:49.583 *W* [filemgr            ] No root directories in file manager configuration
2026.11.01 08:43:49.583 *E* [subagents          ] Initialization of subagent "FILEMGR" (/usr/lib/x86_64-linux-gnu/netxms/filemgr.nsm) failed
2026.11.01 08:43:49.584 *I* [startup            ] System hardware ID is 01B6CB61198C1584EE20BD17CE6330091A7A4833
2026.11.01 08:43:50.585 *I* [comm               ] Listening on socket 0.0.0.0:4700
2026.11.01 08:43:50.585 *I* [comm               ] Listening on socket :::4700
2026.11.01 08:43:50.587 *I* [                   ] Successfully registered on management server 10.89.63.3
2026.11.01 08:43:51.588 *I* [                   ] NetXMS Agent started
2026.11.01 08:44:00.285 *I* [                   ] Tunnel with 10.89.63.3 established
Agent running. Press Ctrl+C to shutdown.

Stopping agent...

日志里可读出六件关键事:代理身份 Agent ID(注册与 -T 重置的对象)、Arbitrary command execution disabled(未开 EnableAgentActions,远程命令类动作默认被禁,见 9.8 节排障)、FILEMGR 子代理初始化失败(见 6.5 节排障)、监听 4700、注册成功、隧道建立。注册的前提是服务器侧 Agent.EnableRegistration=1(默认值,见配置篇)且 MasterServers 放行。

6.5 排障实录:98 Address already in use

同机已有一个代理在跑时再次启动第二个实例,端口绑定阶段即失败(实测日志):

2026.11.01 07:07:10.889 *E* [comm               ] Unable to bind IPv4 socket (98 Address already in use)
2026.11.01 07:07:10.889 *E* [sa                 ] Unable to bind socket (98 Address already in use)
2026.11.01 07:07:10.890 *E* [comm               ] Unable to bind IPv6 socket (98 Address already in use)
2026.11.01 07:07:10.890 *E* [comm               ] Cannot bind at least one socket, terminating agent process

98 是系统 errno(EADDRINUSE),IPv4/IPv6 各报一次后进程自杀。处理:ss -ltnp | grep 4700 找到占用进程,确认是否已有代理在运行;确需换端口则改配置项 ListenPort 后 nxagentd -Q ListenPort 验证生效。

同段日志还暴露了 FILEMGR 子代理失败的原因链:No root directories in file manager configuration → Initialization of subagent "FILEMGR" ... failed——启用了 filemgr 子代理却没配任何 RootDirectory,文件类能力(上传/下载,见 9.6 节)随之全部不可用。修复二选一:在 nxagentd.conf 增加 RootDirectory 映射,或不加载 filemgr 子代理。

七、nxget——远程指标查询工具

nxget 通过 NXCP 协议直连被监控主机上的代理(4700 端口)读取指标、列表、表、配置,不经过管理服务器,是验证「代理侧到底有什么数据、什么配置生效」的第一工具。

7.1 命令行帮助

nxget -h 实测回显(全文照抄):

Usage: nxget [<options>] <host> [<parameter> [<parameter> ...]]
Tool specific options are:
   -b           : Batch mode - get all parameters listed on command line.
   -c           : Get agent's effective configuration
   -C           : Get agent's configuration file
   -d delimiter : Print table content as delimited text.
   -E           : Take screenshot. First parameter is file name, second (optional) is session name.
   -f           : Do not try lists and tables if requested metric does not exist.
   -F           : Get information about given file set. Each parameter is separate file name.
   -i seconds   : Get specified parameter(s) continuously with given interval.
   -I           : Get list of supported parameters.
   -l           : Requested parameter is a list.
   -n           : Show parameter's name in result.
   -N addr      : Check state of network service at given address.
   -o proto     : Protocol number to be used for service check.
   -P port      : Network service port (to be used wth -N option).
   -r string    : Service check request string.
   -R string    : Service check expected response string.
   -t type      : Set type of service to be checked.
                  Possible types are: custom, ssh, pop3, smtp, ftp, http, https, telnet.
   -T           : Requested parameter is a table.
   -U           : Get list of active user sessions.
   -Y           : Read remote system time.

Common options:
   -A           : Connect to agent using TLS tunnel.
   -D level     : Set debug level (0..9 or off, default is off).
   -e policy    : Set encryption policy. Possible values are:
                    0 = Encryption disabled;
                    1 = Encrypt connection only if agent requires encryption;
                    2 = Encrypt connection if agent supports encryption;
                    3 = Force encrypted connection;
                  Default value is 2.
   -g fprint    : Expected SHA-256 fingerprint of agent's certificate (implies -A).
   -h           : Display help and exit.
   -K file      : Specify server's key file
                  (default is /var/lib/netxms/.server_key).
   -M count     : Number of additional connection attempts if connection cannot be
                  established (default is 0).
   -O port      : Proxy agent's port number. Default is 4700.
   -p port      : Agent's port number. Default is 4700.
   -s secret    : Shared secret for agent authentication.
   -S secret    : Shared secret for proxy agent authentication.
   -v           : Display version and exit.
   -w seconds   : Set command timeout (default is 5 seconds).
   -W seconds   : Set connection timeout (default is 30 seconds).
   -X addr      : Use proxy agent at given address.

工具选项与通用选项分层设计:-p/-e/-s/-X 这套通用选项在 nxget/nxaction/nxupload/nxdownload/nxap/nxwsget 等所有面向代理的工具里含义完全一致,学会一次全部通用。

7.2 单指标与批量查询

nxget 10.89.63.5 Agent.Version
7.0.1
nxget 10.89.63.5 System.Uptime
23230
nxget 10.89.63.5 System.CPU.LoadAvg
2.62

-n 在结果里带上参数名:

nxget -n 10.89.63.5 System.CPU.Count
System.CPU.Count = 6

批量模式 -b 一次取多个参数(实测):

nxget -b 10.89.63.5 Agent.Version System.CPU.Count
7.0.1
6

⚠️ 注意:不带 -b 时命令行上的多个参数只查询第一个——实测 nxget 10.89.63.5 System.CPU.Count System.Memory.TotalRAM 仅输出 6 一行。写采集脚本时取多值务必加 -b。

7.3 不存在的指标:404 系列

指标名写错统一返回 404: Unknown metric、退出码 1(实测多种写法全部命中):

nxget -n 10.89.63.5 System.CPU
404: Unknown metric
nxget 10.89.63.5 System.Interfaces -T
nxget 10.89.63.5 NoSuch.Metric
nxget 10.89.63.5 System.Memory.Total
nxget 10.89.63.5 System.CPU.AvgLoad
nxget 10.89.63.5 System.LocalTime
nxget 10.89.63.5 System.InterfaceList -l
404: Unknown metric

注意 System.CPU(缺 .Count 后缀)、System.Memory.Total(实为 System.Memory.TotalRAM)、System.Interfaces(需实例化语法)都是「差一点就对」的常见踩坑名。指标名不要靠猜,用 -I 列全集。

7.4 -I:列出代理支持的全部参数

nxget -I 10.89.63.5

每行格式为 参数名 数据类型 "描述",实测节选(输出节选,实测首尾):

System.IsVirtual INT "Virtual system indicator"
Agent.AcceptedConnections COUNTER32 "Agent: accepted connections"
Agent.AcceptErrors COUNTER32 "Agent: accept() call errors"
Agent.AccessLevel STRING "Agent: access level"
Agent.ActiveConnections UINT "Agent: active connections"
Agent.AuthenticationFailures COUNTER32 "Agent: authentication failures"
...
Agent.Heap.Active UINT64 "Agent: active heap memory"
VNC.LocalServerState(*) INT "Check if VNC server is accessible on loopback interface"
Hardware.MemoryDevice.Bank(*) STRING "Hardware: memory device {instance} bank"
Hardware.MemoryDevice.ConfiguredSpeed(*) UINT "Hardware: memory device {instance} configured speed"
Hardware.MemoryDevice.FormFactor(*) STRING "Hardware: memory device {instance} form factor"
Hardware.MemoryDevice.Location(*) STRING "Hardware: memory device {instance} location"

带 (*) 的是实例化参数:描述里的 {instance} 在查询时替换为具体实例(如 Hardware.MemoryDevice 系列按内存插槽实例化),这也是 7.3 节 System.Interfaces 裸查 404 的原因。写 DCI 之前先 -I 对照,能省掉整类「指标名拼错」问题。

7.5 -c / -C:远程读代理配置

-c 读代理生效配置(合并扩展目录与命令行覆盖后的结果),-C 读原始配置文件。实测:

nxget -c 10.89.63.5
{
   "CORE": {
      "MasterServers": "10.89.63.0/24",
      "LogFile": "{stdout}",
      "SubAgent": "filemgr"
   }
}

输出与 6.2 节 nxagentd -o json -C 本地 dump 完全一致——「远程看到的」与「本地生效的」互相印证,是代理配置漂移排查的标准对法。

7.6 -Y / -U:系统时间与会话列表

nxget -Y 10.89.63.5
Time..........: 01.Nov.2026 08:52:51.381
UNIX time.....: 1793523171381
Offset........: 0 ms
RTT...........: 0 ms
Sync allowed..: false

-Y 读远端系统时间并给出本地-远端偏差(Offset)与往返时延,排「事件时间戳对不上」类问题时先用它确认两端时钟差。-U 列出远端活动用户会话,实测本环境代理返回:

nxget -U 10.89.63.5
500: Internal error

500 表示代理侧无法完成该查询,属环境能力边界而非用法错误。

八、nxping——NetXMS 协议连通性探测

nxping 不走系统 ICMP,而是用 NetXMS 自己的探测报文(与服务器 ICMP 轮询同源),在监控主机上装好工具即可模拟服务器视角测目标。

8.1 命令行帮助

nxping -h 实测回显(全文照抄):

Usage: nxping [<options>] <address> ...
Valid options are:
   -h           : Display help and exit.
   -c count     : Set number of packets to be sent (default is 10).
   -i interval  : Send packets with given interval in milliseconds (default is one second).
   -n           : Set "don't fragment" flag.
   -p           : Show only targets with partial packet loss in summary.
   -s size      : Set packet size (default is 48).
   -t timeout   : Set timeout in milliseconds (default is 500).
   -v           : Display version and exit.

支持一次给多个地址(<address> ...),-p 只汇总「部分丢包」的目标,适合批量网段健康速检。

8.2 实测:通与不通

nxping -c 3 10.89.63.5
10.89.63.5: sequence=1 time=0 ms
10.89.63.5: sequence=2 time=1 ms
10.89.63.5: sequence=3 time=0 ms

==== 3 iterations completed ====

10.89.63.5: 0 ms average response time, 0% packet loss, 0 send errors
nxping -c 2 10.89.63.9
10.89.63.9: sequence=1 timeout
10.89.63.9: sequence=2 timeout

==== 2 iterations completed ====

10.89.63.9: 0 ms average response time, 100% packet loss, 0 send errors

10.89.63.9 是网上不存在的主机,逐包 timeout、丢包率 100%。注意不通时退出码仍是 0(实测 RC=0),nxping 的 RC 只反映工具自身执行成败,丢包信息在汇总行里。

8.3 排障实录:Invalid address

nxping agent
Invalid address agent

==== 10 iterations completed ====

主机名无法解析时逐包不发出、直接报 Invalid address <名字>,但迭代仍计满默认 10 次。本环境主机名没有 DNS 解析,改用 IP 即恢复。批量脚本里固定用 IP,或先 getent hosts <名字> 预检。

九、辅助工具群

9.1 nxencpasswd——配置口令加密器

nxencpasswd -h 实测回显(全文照抄):

Usage: nxencpasswd [<options>] <login> [<password>]
       nxencpasswd [<options>] -a [<password>]
Valid options are:
   -a           : Encrypt agent's secret.
   -h           : Display help and exit.
   -v           : Display version and exit.

NOTE: If password is not provided it will be requested from terminal.

两种形态实测:加密服务器数据库口令(<login> <password> 成对给出)与加密代理共享密钥(-a):

nxencpasswd admin q1w2e3r4
nV/1lnntVzRR7kZzOo0DqFHuRnM6jQOoUe5GczqNA6g=
nxencpasswd -a q1w2e3r4
GsbNsInnLqPCpgp+8SvHuMKmCn7xK8e4wqYKfvErx7g=

产出的密文直接填进配置文件对应项(DBPassword 等),避免明文口令落盘;填法与配套启动方式见 《NetXMS 7.0.1 配置参数详解》。

9.2 nxgenguid——GUID 生成器

Usage: nxgenguid [<options>]
Valid options are:
   -h           : Display help and exit.
   -n           : Do not add newline.
   -v           : Display version and exit.
nxgenguid
721d9b1c-7971-4439-a3bf-95ef9474c369

-n 不带换行,适合拼进脚本变量。用于给对象、策略、集成配置手工造唯一标识。

9.3 nxcsum——校验和计算

用法是位置参数 nxcsum <method> <file>,没有 -m 选项。不带参数与错用选项的实测回显一致(method 位被填成了 -h/-m):

nxcsum
Invalid count of arguments
Usage: nxcsum <method> <file>
Valid methods are: md5, sha1, sha224, sha256, sha384, sha512
nxcsum sha256 /etc/hostname
4ad28e4a6461bd64b920f72f86c0d16edc544c4a1f26060518ebb900025d496a

六种摘要算法覆盖到 sha512,适合校验上传/下载文件与配置分发完整性。

9.4 nxhwid——硬件 ID

nxhwid -h 只有一行 Usage: nxhwid [-D](实测 RC=1)。不带参数执行:

nxhwid
Hardware ID: 01B6CB61198C1584EE20BD17CE6330091A7A4833
System ID:   n/a

该值与 6.4 节代理启动日志里的 System hardware ID is 01B6CB61198C1584EE20BD17CE6330091A7A4833 完全一致——代理注册、许可证绑定都以这个硬件 ID 为锚,克隆主机后两者会「对不上号」,正是 -T 重置身份要解决的场景。

9.5 nxsnmpget / nxsnmpwalk / nxsnmpset——SNMP 三件套

三个工具选项集基本相同(v1/2c/3、团体名、v3 USM 认证加密、超时、MIB 路径),以 nxsnmpget -h 为主(实测全文照抄):

Usage: nxsnmpget [<options>] <host> <variables>
Valid options are:
   -a <method>   : Authentication method for SNMP v3 USM. Valid methods are MD5, SHA1, SHA224, SHA256, SHA384, SHA512
   -A <passwd>   : User's authentication password for SNMP v3 USM
   -c <string>   : Community string. Default is "public"
   -C <codepage> : Codepage for remote system
   -e <method>   : Encryption method for SNMP v3 USM. Valid methods are DES and AES
   -E <passwd>   : User's encryption password for SNMP v3 USM
   -h            : Display help and exit
   -i <seconds>  : Repeat request with given interval in seconds
   -m <path>     : Path to compiled MIB file
   -M            : Do not load MIB tree
   -n            : Show numeric OIDs only
   -p <port>     : Agent's port number. Default is 161
   -R            : Raw output (disable display hint formatting)
   -u <user>     : User name for SNMP v3 USM
   -v <version>  : SNMP version to use (valid values is 1, 2c, and 3)
   -w <seconds>  : Request timeout (default is 3 seconds)
   -x            : Show raw value in hex

nxsnmpwalk 差异:<start_oid> 起始 OID、-n <name> 为 v3 上下文名、-N 显示数字 OID;nxsnmpset 差异:语法 <variable>[@<type>] <value>,-t 指定类型(INTEGER/STRING/OID/IPADDR/COUNTER32/GAUGE32/TIMETICKS/COUNTER64/UINT32),-B/-H 接受 base64/十六进制裸值。

本环境被监控主机未运行 SNMP 服务,实测回显恰好覆盖两类典型失败。用符号名查询(MIB 未编译):

nxsnmpget 10.89.63.5 sysDescr.0 -v 2c -w 2
Warning: Unable to load MIB tree from /var/lib/netxms/netxms.cmib (File I/O error)
Invalid OID: sysDescr.0
RC=4

sysDescr.0 这类符号名需要编译 MIB 树(netxms.cmib)才能解析,缺失时先 Warning 再 Invalid OID。改用数字 OID 跳过 MIB 解析:

nxsnmpget 10.89.63.5 1.3.6.1.2.1.1.1.0 -v 2c -w 2
Warning: Unable to load MIB tree from /var/lib/netxms/netxms.cmib (File I/O error)
Request timed out
RC=3
nxsnmpwalk 10.89.63.5 1.3.6.1.2.1.1 -v 2c -w 2
Warning: Unable to load MIB tree from /var/lib/netxms/netxms.cmib (File I/O error)
SNMP Error: Request timed out
RC=3

timeout/RC=3 即「目标 161 端口无人应答」——本环境没有 snmpd,属预期失败路径。排障顺序:先 -M(不加载 MIB 树,消掉 Warning)+ 数字 OID 测连通,超时查目标 SNMP 服务与防火墙;要按符号名批量操作再用 nxmibc 编译 MIB(9.11 节)。

9.6 nxupload / nxdownload——对代理文件传输

nxupload -h 工具段实测(通用选项与 nxget 完全相同,不再重复):

Usage: nxupload [<options>] <host> <file>
Tool specific options are:
   -C <options> : Set package deployment options or command line (depending on package type)
   -d <file>    : Fully qualified destination file name
   -i           : Start installation of uploaded package.
   -q           : Quiet mode.
   -t <type>    : Set package type (default is "executable").
   -u           : Start agent upgrade from uploaded package.
   -z           : Compress data stream with LZ4.
   -Z           : Compress data stream with DEFLATE.

nxdownload -h 工具段实测:

Usage: nxdownload [<options>] <host> <path to source file> [<path to destination file>]
Tool specific options are:
   -F           : Get file fingerprints instead of download.
   -q           : Quiet mode.
   -z           : Compress data stream with LZ4.
   -Z           : Compress data stream with DEFLATE.

-i/-u 让 upload 兼任软件包分发与代理自升级通道。实测本环境两工具均失败:

nxdownload 10.89.63.5 /etc/nxagentd.conf /tmp/dl_agent.conf
Downloading to /tmp/dl_agent.conf
<Download>:                  400: Unknown command
nxupload 10.89.63.5 /tmp/test.txt
Upload:                  400: Unknown command

400 的根因在 6.5 节已埋下:FILEMGR 子代理因未配 RootDirectory 初始化失败,代理侧文件管理通道整个不存在,上传/下载命令到达后无人处理。配好 RootDirectory 重载代理后此类命令方可用。

9.7 nxtftp——TFTP 文件传输

nxtftp -h 实测回显(全文照抄,RC=1):

Usage:
   nxtftp [-D] [-p port] [-r remote_file ] command server file

Valid commands are:
   get - get file from server
   put - put file to server

基于 TFTP 的轻量传输(端口可 -p 改),典型用途是给无法开 NXCP 端点的设备(如交换机升级场景)收发文件。

9.8 nxaction——远程执行代理动作

nxaction -h 工具段实测:

Usage: nxaction [<options>] <host> <action> [<action args>]
Tool specific options are:
   -o           : Show action's output.

通用选项与 nxget 相同。实测执行 echo 动作:

nxaction 10.89.63.5 echo hello -o
404: Unknown metric
RC=1

失败与 6.4 节代理日志的 Arbitrary command execution disabled 呼应:代理未开启任意命令执行(EnableAgentActions 未开),echo 这类命令动作在代理侧不存在,返回 404。要在代理上跑远程命令,先开对应配置;否则 nxaction 只能执行内置动作类型。

9.9 nxap / nxapush / nxaevent——策略列表与推送

nxap(代理策略管理)工具段实测:

Usage: nxap [<options>] -l <host>
   or: nxap [<options>] -u <guid> <host>
Tool specific options are:
   -l           : List policies.
   -u <guid>    : Uninstall policy.
nxap -l 10.89.63.5
GUID                                 Type ServerInfo                                                       ServerId         Version
-----------------------------------------------------------------------------------------------------------------------------------

表头下无行即「代理上未装载任何策略」,RC=0。

nxapush(向代理推送 DCI 值)-h 实测节选(全文照抄):

NetXMS Agent PUSH  Version 7.0.1
Usage: nxapush [OPTIONS] [@batch_file] [values]
       nxapush [OPTIONS] -
Options:
  -h, --help                  Display this help message.
  -l, --local-cache           Push to agent's local cache.
  -o, --object <id>           Push data on behalf of object with given id.
  -q, --quiet                 Suppress all messages.
  -s, --statsite              Use statsite sink format.
  -t, --timestamp-unix <time> Specify timestamp for data as UNIX timestamp.
  -T, --timestamp-text <time> Specify timestamp for data as YYYYMMDDhhmmss.
  -v, --verbose               Enable verbose messages. Add twice for debug
  -V, --version               Display version information.

值格式 dci=value,statsite 格式 dci|value|timestamp,@文件 批量、- 读标准输入。在被监控主机上实测:

nxapush -v PushParam1=42
1 data pair to send
RC=0

nxaevent(向代理提交自定义事件)-h 实测:

NetXMS Agent Event Sender  Version 7.0.1
Usage: nxaevent [OPTIONS] event_code [parameters]
Options:
  -h, --help                  Display this help message.
  -n, --named-parameters      Parameters are provided in named format: name=value.
  -o, --object <id>           Send event on behalf of object with given id.
  -q, --quiet                 Suppress all messages.
  -t, --timestamp-unix <time> Specify timestamp for event as UNIX timestamp.
  -T, --timestamp-text <time> Specify timestamp for event as YYYYMMDDhhmmss.
  -v, --verbose               Enable verbose messages. Add twice for debug
  -V, --version               Display version information.
nxaevent 47000 d1-demo-event
RC=0

静默成功(无输出、RC=0),事件进入代理事件流。两者组合即「应用自己报数、自己报警」的推送式监控:nxapush 填 DCI 值、nxaevent 发系统事件码,替代轮询采集。

💡 技术拓展:推送 vs 轮询是采集架构的两大流派——Prometheus 原生只轮询(exporter 被动等抓),Telegraf/StatsD 支持推送;NetXMS 两者都吃:DCI 轮询走服务器采集线程,nxapush/nxaevent 走代理本地入口。大批量短生命周期指标(如 CI 流水线计数)用推送更省服务器资源。

9.10 nxscript——本地 NXSL 脚本执行器

注意 nxscript 不认 -h(实测 nxscript -h 回显 nxscript: invalid option -- 'h' 后打版本行,RC=127),帮助在参数错误时自动输出:

NetXMS Scripting Host  Version 7.0.1
Copyright (c) 2005-2026 Victor Kirhenshtein

Usage: nxscript [options] script [arg1 [... argN]]

Valid options are:
   -5         Convert given script to NXSL version 5
   -b         Input is a binary file
   -c         Compile only
   -C <count> Run script multiple times
   -d         Dump compiled script code
   -e <name>  Entry point
   -E         Show expression variables on exit
   -m         Show memory usage information
   -M         Show program metadata
   -o <file>  Write compiled script
   -r         Print script return value
   -R         Show list of required modules
   -t         Enable instruction trace

它是 NXSL 的本地沙箱:不连服务器即可编译(-c)、反编译查看字节码(-d)、跑脚本(-r 打印返回值)。写服务器侧脚本(4.8 节 -s/exec)前先用它验证语法与逻辑。

9.11 nxmibc / nxmibdump / nxminfo——MIB 编译与模块信息

nxmibc(MIB 编译器)-h 实测节选(全文照抄):

NetXMS MIB Compiler  Version 7.0.1 (7.0-824-g44d7a0dfb5)
Usage:
nxmibc [options] source1 ... sourceN
Valid options:
   -a        : Compile all input files (continue after file parsing errors)
   -d <dir>  : Include all MIB files from given directory to compilation
   -e <ext>  : Specify file extensions (default extension: "mib")
   -m        : Produce machine-readable output
   -o <file> : Set output file name (default is netxms.cmib)
   -P        : Pause before exit
   -r        : Scan sub-directories
   -s        : Strip descriptions from MIB objects
   -u        : Do not compress output file
   -z        : Compress output file

编译产物默认 /var/lib/netxms/netxms.cmib——正是 9.5 节 Warning 里缺失的那个文件;编译完用 4.7 节 reload mib 让服务器免重启加载。

nxmibdump(查看 .cmib 内容)-h 实测:

Usage: nxmibdump [options] <mib-file> [<oid-or-name>]

Options:
   -h            : Display this help and exit

If OID or object name is provided, prints details of that object.
Otherwise, prints MIB file header information only.

nxminfo(模块信息查看器)面向 .nxm 模块文件,实测对子代理文件无效:

nxminfo /usr/lib/x86_64-linux-gnu/netxms/linux
NetXMS Module Info Tool Version 7.0.1 Build 7.0-824-g44d7a0dfb5

Cannot load module (/usr/lib/x86_64-linux-gnu/netxms/linux.nxm: cannot open shared object file: No such file or directory)
RC=2

工具自动补 .nxm 后缀,而 linux/filemgr 是 .nsm 子代理,扩展名对不上即报 cannot open——查子代理版本看代理启动日志(6.4 节 Subagent "Linux" ... loaded successfully (version 7.0.1) 行),别用 nxminfo。

9.12 nxlptest / nxwsget / nxethernetip——日志解析、Web 服务、工业协议

nxlptest(日志解析自测器)-h 实测:

NetXMS Log Parsing Tester  Version 7.0.1
Usage:
   nxlptest [options] parser

Where valid options are:
   -D level   : Set debug level
   -f file    : Input file (overrides parser settings)
   -h         : Show this help
   -i         : Use standard input instead of file defined in parser
   -o offset  : Start offset in file
   -v         : Show version and exit

用真实日志样本喂给已定义的日志解析器,验证事件抽取规则后再上线。

nxwsget(Web 服务取数器)工具段实测节选:

Usage: nxwsget [<options>] <host> <URL> <path> [<path> ...]
Tool specific options:
   -a auth      : HTTP authentication type. Valid methods are "none", "basic", "digest",
                  "ntlm", "bearer", "any", or "anysafe". Default is "none".
   -c           : Do not verify service certificate.
   -C           : Do not verify certificate's name against host.
   -d data      : Request data.
   -F           : Follow location header that the server sends as part of a 3xx response.
   -H header    : HTTP header (can be used multiple times).
   -i seconds   : Query service continuously with given interval.
   -l           : Requested parameter is a list.
   -m method    : HTTP request method. Valid methods are GET, POST, PUT, PATCH, DELETE.
   -L login     : Web service login name.
   -P passwod   : Web service password.
   -r seconds   : Cache retention time.
   -t           : Use text parsing.

借代理出网发 HTTP 并按 JSON path 取值,对应服务器侧 Web Service DCI;开发采集项时先用它把 path 调对。

nxethernetip(EtherNet/IP 诊断器)实测:

NetXMS EtherNet/IP Diagnostic Tool Version 7.0.1
Usage: nxethernetip [<options>] <host> <command> [<arguments>]
Valid commands are:
   FindClassInstances <class>  : find all instances of given class
   GetAllAttributes <path>     : read all object attributes (path is class.instance)
   GetAttribute <path>         : read value of specific attribute (path is class.instance.attribute)
   GetTCPIPObject [<instance>] : read TCP/IP object from device (use ? as instance for discovery)
   ListIdentity                : read device identity
   ListInterfaces              : read list of supported interfaces
   ListServices                : read list of supported services
Valid options are:
   -h                : Display help and exit
   -p <port>         : Port number (default is 44818)
   -u                : Use UDP for communication
   -w <milliseconds> : Request timeout (default is 5000 milliseconds)

面向 PLC 类设备(默认 44818 端口),ListIdentity 摸设备身份、GetAttribute 读单个属性,对应服务器侧 EIP 采集。

9.13 已消失的历史工具

7.0.1 中不存在 nxsms、nxlog、nxevent、nxpush 四个名字(实测):

command -v nxsms nxlog
RC=127
nxevent 47000 test
nxpush Test=1
sh: 1: nxevent: not found
sh: 1: nxpush: not found

对应关系:短信能力由子代理 /usr/lib/x86_64-linux-gnu/netxms/sms.nsm 承载(无独立 CLI);「nxevent/nxpush」的正确名字是 nxaevent/nxapush(9.9 节)。从旧文档/脚本迁移时先 command -v 验名字。

十、注意事项

  1. 数据库锁规则:netxmsd 运行时独占数据库锁(DBLockStatus 可查持锁者)。check/export/import/init/upgrade/convert 这类整库级操作必须先停服务器;get/set/unlock-user 这类轻量操作在线可用。被 Database is locked by server ... 挡住时,先判断命令是否真的需要独占,不要顺手 unlock 抢锁(5.7 节警告)。
  2. nxadm 只作用于本机服务器:它没有服务器地址参数,远程管理走 NXCP 4701 的控制台客户端或 REST API;Server.RestrictLocalConsoleAccess=1(默认)限制的就是远程访问本地控制台这条通道。
  3. get/set 即改即生效且持久化:控制台与 nxdbmgr 两条通道写的都是数据库运行时变量,改完立即生效、重启后保留;但变量名必须先 get % 全集确认,通配符匹配的是完整变量名(配置篇 3.1 节)。
  4. 指标名以 nxget -I 为准:404 系列(7.3 节)说明猜名字必翻车;带 (*) 的实例化参数要带实例查询,多参数必须 -b。
  5. 口令安全:命令行 -p 明文会进 shell 历史与进程表,交互场景用 -P(nxadm)或从终端读取(nxencpasswd 不带口令参数);配置文件里的口令用 nxencpasswd 加密存放。
  6. 面向代理工具的通用选项是一套:-p/-e/-s/-A/-X/-w 在 nxget/nxaction/nxupload/nxdownload/nxap/nxwsget 中含义一致,加密策略 -e 的 0~3 枚举与服务器变量 Agent.DefaultEncryptionPolicy 同源。
  7. 退出码不可全信:nxdbmgr batch SQL 失败仍 RC=0、nxping 全丢包仍 RC=0、nxdbmgr -v 反而 RC=1——脚本判成败要 grep 输出关键行(SQL query failed / packet loss),不能只看 $?。

十一、常见问题(FAQ)

Q1:nxadm 所有命令都报 Authentication failed (server error 61: Internal error)? 账号被锁(此前连续认证失败)。与密码错误的 server error 2 区分,用 nxdbmgr unlock-user <login> 解锁——它打印锁警告行但实际生效(RC=0)。完整实录见 4.9 节。

Q2:nxadm 报 Authentication failed (server error 2: Access denied)? 口令或用户名不对(实测 RC=5)。核对 -u/-p,注意 -p 明文里的特殊字符可能被 shell 吃掉,改用 -P 交互输入。

Q3:nxdbmgr check/export 报 Database is locked by server ...? 服务器在跑。停服再操作;只是查/改变量或解锁用户则无需停服(在线可用,见第十章第 1 条)。

Q4:nxagentd 启动即退,日志 Unable to bind ... (98 Address already in use)? 4700 已被占用——通常已有代理在跑。ss -ltnp | grep 4700 确认,杀旧进程或改 ListenPort(6.5 节实录)。

Q5:nxget 全是 404: Unknown metric? 指标名不对或未实例化。nxget -I <host> 列全集对照;(*) 参数带实例;多参数加 -b(7.3/7.4 节)。

Q6:nxsnmpget 报 Warning: Unable to load MIB tree ... netxms.cmib? MIB 未编译。数字 OID + -M 可绕过;需要符号名时 nxmibc 编译出 netxms.cmib,服务器侧再 reload mib(9.5/9.11 节)。

Q7:nxupload/nxdownload 报 400: Unknown command、nxaction 报 404? 代理侧能力未开:前者查 filemgr 子代理的 RootDirectory 配置(6.5 节),后者需开启代理的任意命令执行(6.4 节 Arbitrary command execution disabled)。

十二、参考链接

NetXMS 7.0.1 常用 CLI 命令与工具详解 - Quzuo