Input Variable is designed to receive the input from users during Qapp execution and the Qapp processes data and output results based on the input.
The Input Variable node is after the Start node and before the Canvas node. The variables can be called in the Output node of the Canvas node.
The variables, such as name, type, and default value, are defined with scripts in the JSON format.
Sample codes:
[
{ "name": "vlan", "type": "int", "label": "VLAN", "value": 1, "desc": "Please input a VLAN ID"},
{ "name": "map_vlan", "type": "bool", "label": "Map VLAN Swith", "value": false },
{ "name": "source_ip", "type": "string", "label": "Source IP", "value": "0.0.0.0" },
{ "name": "source_port", "type": "string", "label": "Source Port", "value": "UDP", "items": [ "TCP", "UDP", "IP" ] },
{ "name": "vrf", "type": "string", "label": "VRF", "value": "", "items": "$vrf" },
{ "name": "template_folder", "type": "string", "label": "Template Folder","style": "folder","desc":"Please select a folder" },
{ "name": "template_file", "type": "string", "label": "Template File","style": "file","desc":"Please select a file" }
]
A variable contains the following properties:
Create a Qapp that sends alerts if a device CPU is higher than an input value.
1.Click the icon from the taskbar and select New Qapp from the drop-down menu to open the Qapp Editor.
2.Click the icon on the Start node, select Input Variables, and click Extend.
3.Rename the Node Name as inputCPU and define the input variable as follow:
[
{ "name": "CPU_value", "type": "int", "label": "CPU Threshold", "value": "80"}
]
4.Click the icon on the inputCPU node, select Canvas, and click Extend.
5.Double-click the Canvas node and keep the default settings at the Device Queue node.
6.Extend a Device(this) node from the Device Queue node, and keep the default options.
7.Extend a CLI command node from the Device(this) node.
8.At the Command node, enter show process cpu and select the show processes cpu (Cisco IOS Switch, Cisco Router) parser.
9.Click the icon on the Command node, then select Device Data Table and click Extend.
10.Click the icon and export one_min_cpu_usage to the table node.
11. Extend a Basic Output node from the Table node and add a condition at the Basic Output node.
If $one_min_cpu_usage > $inputCPU.CPU_Value
12. Extend an Alert node from the Output node.
13. Enable the Device Alert checkbox and define the alert:
1)Select $_device as the target device.
2)Rename the alert name as High CPU.
3)In the Alert field, enter alert content, such as The CPU usage exceeds the $InputCPU.CPU_value, check the device.
14. Save and run the Qapp. For the demo purpose, set the input value to 1. A sample result is as follows: