Class ::nsmcp::ConfigurationTool
::nsmcp::ConfigurationTool
create ... \
[ -authorizer:required authorizer:required ] \
[ -description (default "Inspect live NaviServer configuration for configuration reviews, SMTP policy interpretation and scaling advice. scope=server (default) returns process-wide sections plus the authenticated virtual server's sections, excluding other virtual servers. scope=process returns every section across all virtual servers and requires diagnostics.configuration.process.read in addition to diagnostics.runtime.read. Includes driver, database-pool, connection-pool, limit, logging and module settings. Policy scripts are returned as data and are never executed. Named credential values and URI userinfo are redacted; referenced files are not read. Configuration reflects the current configuration table, including defaults published there by modules, not necessarily every compiled default or a historical policy. Use section to select an exact section and its descendants. Follow nextArguments to retrieve remaining sections. Pair with server_topology and server_runtime for actual installed components and utilization.") ] \
[ -inputSchema (default "{} object {type string object properties object {
scope object {type string string enum array {0 string server 1 string process} default string server}
section object {type string string description string {Exact section prefix, including descendants; defaults to all authorized sections.}}
limit object {type string integer minimum number 1 maximum number 100 default number 50}
offset object {type string integer minimum number 0 default number 0}
} additionalProperties boolean false}") ] \
[ -name (default "configuration") ] \
[ -outputSchema (default "") ] \
[ -permission (default "diagnostics.runtime.read") ] \
[ -redactor:required redactor:required ]
Defined in /usr/local/ns/tcl/nsmcp/config-tools.tclClass Relations
- class: ::nx::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::nsmcp::Tool
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::nx::Class create ::nsmcp::ConfigurationTool \
-superclass ::nsmcp::Tool
Methods (to be applied on instances)
execute (scripted, public)
<instance of nsmcp::ConfigurationTool
> execute context arguments
- Parameters:
- context (required)
- arguments (required)
- Testcases:
-
No testcase defined.
set options [:options $arguments]
set server [$context server]
set scope [dict get $options scope]
if {$scope eq "process"} {
${:authorizer} require $context diagnostics.configuration.process.read
}
set prefix [dict get $options section]
set sections [:sections]
set secrets {}
dict for {section parameters} $sections {
foreach {name value} $parameters {
if {[:credentialParameter $name] && $value ne ""} {lappend secrets $value}
}
}
set names {}
set excluded 0
foreach section [lsort [dict keys $sections]] {
if {$scope eq "server" && [string match ns/server/* $section]
&& $section ne "ns/server/$server" && [string first "ns/server/$server/" $section] != 0} {
incr excluded
continue
}
if {$prefix ne "" && $section ne $prefix && [string first $prefix/ $section] != 0} continue
lappend names $section
}
set offset [dict get $options offset]
set limit [dict get $options limit]
set array {}
set index 0
foreach section [lrange $names $offset [expr {$offset+$limit-1}]] {
set parameters {}
set parameterIndex 0
set seen {}
foreach {name value} [dict get $sections $section] {
set clean [:value $name $value $secrets]
set folded [string tolower $name]
lappend parameters $parameterIndex object [list name string $name value string $clean redacted boolean [expr {$clean ne $value}] firstOccurrence boolean [expr {$folded ni $seen}]]
lappend seen $folded
incr parameterIndex
}
set sectionScope [expr {[string first "ns/server/" $section] == 0 ? "server" : "process"}]
lappend array $index object [list name string $section scope string $sectionScope parameters array $parameters]
incr index
}
set more [expr {$offset+$index < [llength $names]}]
set next {}
if {$more} {
set next [list scope string $scope section string $prefix limit number $limit offset number [expr {$offset+$index}]]
}
return [list {} object [list server string $server observedAt number [clock seconds] scope string $scope configurationFile string [ns_info config] sectionCount number [llength $names] excludedServerSections number $excluded sections array $array more boolean $more nextArguments object $next coverage object {historical boolean false referencedFilesRead boolean false compiledDefaultsComplete boolean false}]]validate (scripted, public)
<instance of nsmcp::ConfigurationTool
> validate arguments
- Parameters:
- arguments (required)
- Testcases:
-
No testcase defined.
if {[catch {:options $arguments} message]} {
return -code error -errorcode {NSMCP RPC -32602} $message
}