Throughout the book, we encounter many fields that accept TALES expressions including user commands, event commands, performance templates, zProperties, event mappings, and event transformations. Zenoss uses the Template Attribute Language Expression Syntax (TALES) to retrieve device and event attributes for Zenoss objects within any valid Python statement.
If we want to access device attributes, we use the syntax:
${device/attribute}
For example, Zenoss includes the following user command:
traceroute -q 1 -w 2 ${device/manageIp}
The TALES expression substitutes the device IP address that we normally expect to enter when we run the traceroute
command manually. This makes sure that the same command can be run for any device and that the correct device IP will be substituted into the command.
If we want to access event attributes, we use the following syntax:
${evt/attribute}
For example, we create a custom event command in Chapter 7 to write some event information to a file:
echo "The Event with ID ${evt/evit} is on fire!" >> /tmp/SampleEventCommand
In this command, we use TALES to substitute the event ID. When the event runs, we get the following line in our file:
The Event with ID 7f000001365df722fffe960 is on fire!
The following table includes a list of the attributes that we may use when working with our devices. We can find many of these attributes on display on an individual device's Status page.
For a list of event specific attributes, see the list of event fields in Appendix A.
Device Attributes |
Description |
---|---|
|
The device name, which is not necessarily the fully qualified domain name.. |
|
The IP address of the device. |
|
The numeric value of the device's production state: 1000 = Production 500 = Pre-Production 400 = Test 300 = Maintenance -1 = Decommissioned |
|
The device's production state as a human-readable string. |
|
The numeric priority value: 5 = Highest 4 = High 3 = Normal 2 = Low 1 = Lowest 0 = Trivial |
|
The device's priority as a human-readable string. |
|
The location organizer assigned to the device. |
|
The list of system organizers assigned to the device. |
|
The list of group organizers assigned to the device. |
|
The SNMP Description. |
|
The OID from SNMP. |
|
The SNMP contact value. |
|
The system name from SNMP. |
|
The last time Zenoss collected SNMP data for the device. |
|
User-entered comments on the device. |
|
The uptime values for the device. |
|
The device's ping status: 0 = Up 1 = Down 2 = None |
|
The device's SNMP status: 0 = Up 1 = Down 2 = None. |
|
The operating system version . |
|
The software product name defined on the device's edit page. |
|
The operating system manufacturer name defined on the device's edit page. |
|
The hardware product name defined on the device's edit page. |
|
The hardware manufacturer name defined on the device's edit page. |