检查用户输入的命令
目的
您可以检查一组常见的操作:用户何时登录到路由器及其发出的 CLI 命令。
若要检查用户输入的命令,请执行以下步骤:
配置用于跟踪 CLI 命令的日志文件
行动
要配置日志文件以跟踪 CLI 命令,请执行以下步骤:
-
在配置模式下,转至以下层级:
[edit] user@host# edit system syslog
配置日志文件:
[edit system syslog] user@host# edit file filename
例如:
[edit system syslog] user@host# edit file cli-commands
配置交互式命令设施和严重性级别:
[edit system syslog filename] user@host# set interactive-commands info
验证配置:
[edit system syslog] user@host# show file cli-commands { interactive-commands info; }提交配置:
user@host# commit
意义
配置示例显示,日志文件 cli-commands 在信息严重性级别上配置了 interactive-commands 工具。 表 1 列出并描述了严重性级别。
| 严重性级别 | 描述 |
|---|---|
| 信息 | 记录所有顶级 CLI 命令(包括 configure 命令)和所有配置模式命令。 |
| 注意事项 | 记录配置模式命令 rollback 和 commit。 |
| 警告 | 在任何软件进程重新启动时进行记录。 |
显示配置的日志文件
目的
要在配置模式下显示日志文件,请输入以下命令:
行动
[edit system syslog] user@host# run show log filename
例如:
[edit system syslog] user@host# run show log cli-commands
示例输出
[edit system syslog] user@host# run show log cli-commands Sep 16 11:24:25 nut mgd[3442]: UI_COMMIT_PROGRESS: commit: signaling 'Syslog daemon', pid 2457, signal 1, status 0 Sep 16 11:24:25 nut mgd[3442]: UI_COMMIT_PROGRESS: commit: signaling 'SNMP daemon', pid 2592, signal 31, status 0 Sep 16 11:28:36 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'run show log cli-commands ' Sep 16 11:30:39 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'run show log security ' Sep 16 11:31:26 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'run show log messages ' Sep 16 11:41:21 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'edit file cli-commands ' Sep 16 11:41:25 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'show ' Sep 16 11:44:57 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'set interactive-commands info ' Sep 16 14:32:15 nut mgd[3442]: UI_CMDLINE_READ_LINE: User 'user', command 'run show log cli-commands '
意义
示例输出显示了自配置日志文件以来输入的 CLI 命令。