Skip to content

User Guide: Device Diagnostics

SCadilhac edited this page Nov 12, 2021 · 1 revision

Device diagnostics

The Diagnostics tab of the device view displays the current diagnostic results, as they were collected during the last Run diagnostics task on this equipment.

The diagnostics themselves must be defined in the Diagnostics main page.

Diagnostic tab
  • The Name column displays the name of the diagnostic.
  • The Value column displays the last collected value of the given diagnostic.
  • The First seen column gives the date when this value was got for the first time.
  • The Last seen column gives the date when the value was got for the last time (thus the last time the diagnostics were run on the device).

A Run diagnostics task is by default automatically scheduled after snapshot tasks, which should collect the up-to-date diagnostic results. You can force a diagnostic task to run and refresh the diagnostic values on the given device by clicking the Run diagnostics on this device button.

Device compliance

The Compliance tab of the device view gives the compliance status of the device. The policies are defined in the Compliance main page.

Device compliance

There are several compliance parts:

  • Software compliance: the device will be flagged as Gold, Silver or Bronze level, if a software rule matches or non compliant if there is no match.
  • Configuration compliance: the table will give the result of each rule when the compliance check was lastly executed for the device.
  • Hardware compliance: this gives the computed end of sale and end of life dates.

The compliance status of a device is automatically refreshed after each snapshot however you can force it to be reevaluated by clicking on the Recheck compliance button and starting the task. This requires read-write role.

Device tasks

In the Taks tab of the device view, you can see the last tasks related to the device. You can see the details of a finished task, including its logs, and cancel a scheduled task before it is actually executed.

Selecting multiple devices

You can select multiple devices in the device list on the left:

Selecting multiple devices
  • Select a first device, then press the Shift key while clicking on a second device to select all devices between these two ones.
  • Select a first device, then press the Ctrl key while clicking on a second device to select just these two devices.
  • Click on the Select all devices button (just below the Search box) to select all the devices currently displayed in the device list.

When you select several devices in the device list, you get the Multiple devices selected panel in the right. There you can do actions that will apply to all selected devices. However you should note that applying actions to a very high number of devices (e.g. several hundreds or thousands) can be quite slow.

When scheduling a script to be run over several devices, you have to select the device type (driver) your script refers to. Only devices of this selected type, among the ones you've selected, will actually be processed.

Starting actions on multiple devices requires read-write & device commands permission level.

Running a script

Device scripts allows you to program commands to be sent to a device or a set of devices. The scripts are written in Javascript language, which is well documented over the Internet. Passing simple commands to a network equipment can be done with a few lines only, and doesn't require real programming skills.

To run a script over a device, click on the Run script icon in the device toolbar.

Login

Running scripts requires read-write & device commands permissions. Obviously, you have to be very cautious with the commands you run over your network devices. Netshot won't check anything, it will simply execute what you write, even if this breaks the target device.

  • The Run script dialog contains a simple Javascript code editor, where you have to put your Javascript code, that will be executed over the target device.
  • Once you have written your script, and before starting the task, you can save the script as a template, so you can load it later if you want to run the same script again. Note that script templates are stored linked to the device driver, so depending on the type of device you are working on you will only see the relevant script templates. Use the Save and Load buttons on the left of the code editor to load or save script templates.
  • As with any other task, you can start it immediately, or schedule it for a late execution or as a repeating event. To do so, click on Start as soon as possible, this will expand and you will be able to select advanced scheduling options.

The entry point in the script is the run function. This is what Netshot will call, with the following parameters:

  • cli: an object to interact with the device through CLI.
    • cli.macro(macro): use a macro to change mode as defined in the device driver.
    • cli.command(command): sends a command to the device and returns the result.
  • device: an object to change device's attributes.
    • device.set(attributeName, attributeValue): change device's attributes, either standard or driver-specific attributes.

For example, the Cisco IOS driver defines the configure macro which brings you to the configure well-known mode, where you can enter configuration commands that will apply to the running configuration. It also defines the end macro to quit the configure mode, and the save macro to copy the running to the startup configuration. Thus to change the description of interface GigabitEthernet0/0/16, run the following script:

function run(cli, device) {
	cli.macro("configure");
	cli.command("interface GigabitEthernet0/0/16");
	cli.command("description New description");
	cli.macro("end");
	cli.macro("save");
}

The following script gets the actual OSPF router-id and writes it into the device comments:

function run(cli, device) {
	cli.macro("enable");
	var protocols = cli.command("show ip protocols");
	var idPattern = /Routing Protocol is "ospf(.|\r|\n)+? Router ID ([0-9\.]+)/;
	var match;
	if (match = idPattern.exec(protocols)) {
		var rid = match[2];
		device.set("comments", "OSPF Router ID = " + rid);
	}
}