本页内容
跟踪运行 Junos OS 的设备上的提交脚本处理
提交脚本跟踪作,跟踪提交脚本作,并将其记录在日志文件中。记录的错误说明提供了详细信息,可帮助您更快地解决问题。
Junos OS上,提交脚本跟踪的默认作是在设备上的 /var/log/cscript.log 文件中记录重要事件,包括错误、警告、进度消息和脚本处理事件。当文件 cscript.log 达到 128 KB 时,将重命名,并在文件末尾附加一个数字 0 到 9(按升序),然后进行压缩。例如,日志文件另存为 cscript.log.0.gz,然后 cscript.log.1.gz ,直到有 10 个跟踪文件。然后,将覆盖最早的跟踪文件 (cscript.log.9.gz)。
默认情况下,Junos OS Evolved 捕获所有应用程序的跟踪数据,并在与 cscript 应用程序对应的跟踪文件中收集所有脚本类型的数据。要查看跟踪数据,请发出 show trace application cscript 命令。有关更多信息,请参阅 在运行 Junos OS 演化版的设备上进行跟踪脚本处理。
提交脚本作跟踪的最低配置
如果未配置提交脚本跟踪选项,则查看提交脚本跟踪输出的最简单方法是配置 output 跟踪标志并发出 show log cscript.log | last 命令。为此,请执行以下步骤:
如果您尚未这样做,请通过在
[edit system scripts commit]层次结构级别包含file语句来启用提交脚本:[edit system scripts commit] user@host# set file filename
通过在
[edit system scripts commit]层次结构级别包含traceoptions flag output语句来启用跟踪选项:[edit system scripts commit] user@host# set traceoptions flag output
提交配置。
[edit] user@host# commit
显示文件 /var/log/cscript.log 中记录的结果跟踪消息。日志末尾是您在步骤 1 中启用的提交脚本生成的输出。要显示日志的末尾,请发出
show log cscript.log | last作模式命令:[edit] user@host# run show log cscript.log | last
表 1 总结了显示文件选定部分 cscript.log 的有用过滤命令。
| 任务 |
命令 |
|---|---|
| 显示与所有提交脚本处理关联的日志记录数据。 |
|
| 仅显示最近提交作的脚本处理。 |
|
| 显示脚本错误的处理。 |
|
| 显示特定脚本的脚本处理。 |
|
示例:为提交脚本启用 traceoptions 的最低配置
显示提交脚本文件 source-route.xsl 的跟踪输出:
[edit]
system {
scripts {
commit {
file source-route.xsl;
traceoptions {
flag output;
}
}
}
}
[edit] user@host# commit and-quit user@host> show log cscript.log | last Jun 20 10:21:24 summary: changes 0, transients 0 (allowed), syslog 0 Jun 20 10:24:15 commit script processing begins Jun 20 10:24:15 reading commit script configuration Jun 20 10:24:15 testing commit script configuration Jun 20 10:24:15 opening commit script '/var/db/scripts/commit/source-route.xsl' Jun 20 10:24:15 script file '/var/db/scripts/commit/source-route.xsl': size=699; md5 = d947972b429d17ce97fe987d94add6fd Jun 20 10:24:15 reading commit script 'source-route.xsl' Jun 20 10:24:15 running commit script 'source-route.xsl' Jun 20 10:24:15 processing commit script 'source-route.xsl' Jun 20 10:24:15 results of 'source-route.xsl' Jun 20 10:24:15 begin dump <commit-script-output xmlns:junos="http://xml.juniper.net/junos/*/junos" xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm" xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0"> <xnm:warning> <edit-path>[edit chassis]</edit-path> <message>IP source-route processing is not enabled.</message> </xnm:warning> </commit-script-output>Jun 20 10:24:15 end dump Jun 20 10:24:15 no errors from source-route.xsl Jun 20 10:24:15 saving commit script changes Jun 20 10:24:15 summary: changes 0, transients 0 (allowed), syslog 0
配置提交脚本的跟踪
无法更改将跟踪文件写入的目录 (/var/log)。但是,您可以通过在 [edit system scripts commit traceoptions] 层次结构级别包含以下语句来自定义其他跟踪文件设置:
[edit system scripts commit traceoptions] file <filename> <files number> <size size> <world-readable | no-world-readable>; flag all; flag events; flag input; flag offline; flag output; flag rpc; flag xslt; no-remote-trace;
以下部分介绍了这些语句:
配置提交脚本日志文件名
默认情况下,记录提交脚本的跟踪输出的文件的名称为 cscript.log。您可以通过在[edit system scripts commit traceoptions]层次结构级别包含file语句来指定其他名称:
[edit system scripts commit traceoptions] file filename;
配置提交脚本日志文件的数量和大小
默认情况下,当跟踪文件的大小达到 128 KB 时,将重命名并压缩为 filename.0.gz,然后 filename.1.gz,依此类推,直到有 10 个跟踪文件。然后,最早的跟踪文件 (filename.9.gz) 将被覆盖。
您可以通过在 [edit system scripts commit traceoptions file filename] 层次结构级别包含以下语句来配置跟踪文件的数量和大小限制:
[edit system scripts commit traceoptions file filename] files number size size;
例如,将最大文件大小设置为 640 KB,将最大文件数设置为 20。当接收跟踪作 (filename) 输出的文件达到 640 KB 时,将其重命名并压缩为 filename.0.gz,并创建一个名为 filename 的新文件。当达到 640 KB 时 filename , filename.0.gz 重命名为 filename.1.gz ,然后 filename 重命名并压缩为 filename.0.gz。重复此过程,直到有 20 个跟踪文件。然后覆盖最早的文件 (filename.19.gz)。
文件数量可以从 2 到 1000 个文件不等。文件大小可以从 10 KB 到 1 GB 不等。
如果设置最大文件大小或最大跟踪文件数,则还必须指定其他参数和文件名。
配置对提交脚本日志文件的访问
默认情况下,对提交脚本日志文件的访问仅限于所有者。您可以通过在[edit system scripts commit traceoptions file filename]层次结构级别包含 world-readable 或 no-world-readable 语句来手动配置访问。
[edit system scripts commit traceoptions file filename] (world-readable | no-world-readable);
该 no-world-readable 语句将提交脚本日志的访问权限限制为所有者。该 world-readable 语句允许对提交脚本日志文件进行无限制访问。
配置提交脚本跟踪作
默认情况下,无论配置设置如何,traceoptions events 标志都会处于打开状态,并且仅记录重要事件。这包括错误、警告、进度消息和脚本处理事件。您可以通过在 [edit system scripts commit traceoptions] 层次结构级别包含以下语句来配置要记录的跟踪作:
[edit system scripts commit traceoptions] flag all; flag events; flag input; flag offline; flag output; flag rpc; flag xslt;
表 2 描述了提交脚本跟踪标志的含义。
| 旗 |
描述 |
默认设置 |
|---|---|---|
|
|
跟踪所有提交脚本作。 |
关闭 |
|
|
跟踪重要的提交脚本事件,包括错误、警告、进度消息和脚本处理事件。 |
上 |
|
|
跟踪提交脚本输入数据。 |
关闭 |
|
|
生成数据以进行离线开发。 |
关闭 |
|
|
跟踪提交脚本输出数据。 |
关闭 |
|
|
跟踪提交脚本 RPC。 |
关闭 |
|
|
跟踪可扩展样式表语言转换 (XSLT) 库。 |
关闭 |