Blog Viewer

Scripting How-To: Displaying script results

By Erdem posted 08-10-2015 18:01

  

Overview

Displaying results from within Junos Space 13.1R1.6 or later.

Feature

 

Junos Space Release 13.1R1.6 introduced the ability to execute scripts against one or more devices, chassis components, physical or logical interfaces, and so on.

The results of these scripts can then be displayed directly within Junos Space (or within Job Management) in raw format, embedded within <op-script-results> tags, or with a little tweaking inside the script as HTML.

Shown below is a simple slax script that can be imported into Junos Space to display the output of a "show system processes extensive" command.

This particular script does not need to be staged or enabled on a device, as it includes the @ISLOCAL = "true" annotation.   It will be executed locally on the Junos Space appliance and the command sent to the selected device via NETCONF.  There is no need to enter credentials and so on, this is all managed via Junos Space in this example. It will also work transparently with a device that uses key-based authentication versus one that uses credentials-based authentication.

01 version 1.0;
02  
03 ns junos = "http://xml.juniper.net/junos/*/junos";
06  
07 import "../import/junos.xsl";
08 /* Junos Space annotations */
09 /* @CONTEXT = "/device" */
10 /* @NAME = "System Processes" */
11 /* @DESCRIPTION = "show system processes" */
12 /* @ISLOCAL = "true" */
13  
14 var $local = jcs:open();
15 match / {
16   <op-script-results> {
17         var $command = <command> "show system processes extensive";
18         var $results = jcs:execute( $local , $command );
19         copy-of $results;