Creating custom User Commands

User Commands are a convenient way to troubleshoot a device from the user interface and Zenoss Core includes a few such commands by default, such as ping, snmpwalk, and traceroute. By combining shell commands and TALES expressions, we can run commands against our devices from within the Zenoss Core web portal.

The following screenshot shows the defined commands, which you can see by navigating to Advanced | Settings | Commands:

Creating custom User Commands

Note

Although the terminology is similar, User Commands are different than Event Commands. We can run user commands against a device. An event command is a shell script that gets executed as a result of an event.

Let's examine the ping command. The actual command Zenoss Core executes against the device is ping -c2 ${device/manageIp}. The first half of the command construction (ping -c2) is a ping command that sends no more than two ping requests. The second half of the command (${device/manageIp} is a TALES expression that substitutes the IP address of the device into the command. The device portion defines the currently-selected device, while the part after the slash (/) gets the attribute of the device. You can find a list of the device attributes in Appendix B,

As an example, let's ping a device in our inventory. I'm going to ping my favorite server, Coyote. So, find the device in the Devices view of the Infrastructure menu and select it. When you select the device, the Commands menu will become active. From the list of commands, select Ping. Refer to the following screenshot:

Creating custom User Commands

Note

To run a command on more than one device at a time, select multiple devices from the list, and then run the command.

The command will run against each selected device and Zenoss Core will display the results, as seen in the following screenshot:

Creating custom User Commands

As you can see, I have some device issues, including devices without IP addresses.

Adding a User Command

Adding a new command is straight forward. Let's walk through the process of adding a new nmap command. We use nmap to determine open ports and available services on a machine. From the Commands page:

  1. Select Add User Command from the Commands menu.
  2. Enter a descriptive name (for example, nmap) in the Add User Command dialog box.
  3. Click on Submit to add the command and display the command properties.
  4. Type a short explanation in the Description field, such as Display interesting ports on a device.
  5. Enter the following in the Command field: nmap -v ${device/manageIp}.
  6. Enter your password to confirm the changes.
  7. Click on Save.
Adding a User Command

To test the command, you can run it against a device in the same way that we tested the ping command.

Let's step away from the user-level administration and settings and look at our administration options for the Zenoss Core application itself.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.116.254