本页内容
在运行 Junos OS 的设备上跟踪提交脚本处理
提交脚本跟踪操作跟踪提交脚本操作,并记录在日志文件中。记录的错误说明提供了详细信息,可帮助您更快地解决问题。
提交脚本跟踪的默认操作是在设备上的 /var/log/cscript.log.log 文件中记录重要事件,包括错误、警告、进度消息和脚本处理事件。当文件 cscript.log 达到 128 KB 时,将用附加到文件的末尾的数字 0 到 9(升序)重命名,然后压缩。例如,日志文件会保存为 cscript.log.0.gz,然后是 cscript.log.1.gz ,直到有 10 个跟踪文件。然后,最早的追踪文件 (cscript.log.9.gz) 将被覆盖。
本节讨论以下主题:
提交脚本操作跟踪的最低配置
如果未配置提交脚本跟踪选项,则查看提交脚本的跟踪输出的最简单的方法是配置 output
跟踪标志并发出 show log cscript.log | last
命令。为此,请执行以下步骤:
如果尚未完成,请通过在层次结构级别包含
file
语句[edit system scripts commit]
来启用提交脚本:[edit system scripts commit] user@host# set file filename
通过在层次结构级别包含
traceoptions flag output
语句[edit system scripts commit]
来启用跟踪选项:[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
有用过滤命令。
任务 |
命令 |
---|---|
显示与所有脚本处理关联的日志记录数据。 |
|
仅显示最近一次提交操作的脚本处理。 |
|
显示脚本错误的处理情况。 |
|
显示特定脚本的脚本处理。 |
|
示例:为提交脚本启用追踪选项的最低配置
显示提交脚本文件 source-route.xsl 的跟踪输出:
[edit] system { scripts { commit { file source-route.xsl; traceoptions { flag output; } } } }
[edit] user@host# commit [edit] user@host# run 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;
以下部分介绍了这些语句:
配置 Commit 脚本日志文件名
默认情况下,记录跟踪输出的文件名称为 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)。
如果设置最大文件大小或最大跟踪文件数,还必须指定其他参数和文件名。
配置提交脚本日志文件的访问
默认情况下,对提交脚本日志文件的访问仅限于所有者。您可以通过在world-readable
[edit system scripts commit traceoptions file <filename>]
层次结构级别包含 or no-world-readable
语句来手动配置访问。
[edit system scripts commit traceoptions file <filename>] (world-readable | no-world-readable);
该 no-world-readable
语句限制对所有者的提交脚本日志访问权限。该 world-readable
语句支持对提交脚本日志文件的无限制访问。
配置提交脚本跟踪操作
默认情况下,无论配置设置如何,追踪选项 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) 库。 |
关闭 |