Welcome to docs.opsview.com

Attribute

Attributes are an advanced feature in Opsview. You can assign 1 or many attributes to a host.

You can also set service checks to use the attributes for a host to then create multiple services for monitoring. For example, if you have host A with 3 URL attributes:

  • /about
  • /login
  • /logout

And you create a service check, called “Website page check” that uses the URL attribute to create multiple services, then for each host that has this service check associated will create X number of services. So for host A, there will be 3 services created:

  • Website page check: /about
  • Website page check: /login
  • Website page check: /logout

You can access these attributes in the Host Macro section when defining a service check. For instance, entering %URL% will return the first URL attribute for a host. If an attribute is not associated with a host, then a blank string is returned.

How It Works

  • A service check will have the multiple services option set with an attribute set
  • When the Nagios® Core configuration is generated, there will be X number of services created, based on the number of attributes
  • If no attributes are defined for the particular host, no services will be generated
  • Host attribute macros, of the form %NAME% will be substituted in the arguments field
  • A macro of the form %NAME:1% will substitute with the values of the Arg1 field for the host macro

Limitations

  • You can change the arguments for a service check using the host attributes, but you cannot change other service check information like check interval, servicegroup, etc. This would require a different servicecheck altogether
  • You cannot say “use these 3 out of the 5 DISK variables set” - it is all or nothing. You could create two attributes, DISK_LOW and DISK_HIGH, instead, with two different service checks referencing these host attributes
  • You can only have at most 1 host attribute in a service check definition. This is the one that will be iterated around. If you have other attributes and the attribute is not defined for the host, then it will be blank. If there are many attributes assigned, the 'first' one (based alphabetically) will be used
  • You cannot have the service description longer than 128 characters, when combined with the service check name. If you do, this will fail a reload and you will get this message:
Service description '....' is greater than 128 characters. Please change the attribute or service check name to be shorter
  • The attribute can only consist of alphanumeric characters, space, a period (”.”), a forward slash (”/”) or a dash (”-”), up to 63 characters - this is because the value could be used in the service name, which has restrictions on the characters used. Any trailing spaces will be removed. The argument field allows any characters, but be aware that Nagios Core may process some special characters like !, $ and \.
  • Special characters must be escaped:
CharacterInput
$ $$
\ \\
! \!

For example:

StringInput
Password11! Password11\!
PAS$WORD PAS$$WORD

Name

This is the name of the attribute.

Names can only consist of the letters A-Z (upper case only) or an underscore, up to 63 characters.

Note: that if you change it here, any currently defined service checks expecting the old name in the arguments (such as %DISK%) will return an empty string instead.

Default Value

This value is used if a host does not have an attribute associated. This is effectively a global attribute that you can override on a host basis.

The value cannot be longer than 63 characters and must be alphanumerics. This is because it could be used for multiple service checks and there are restrictions to the characters here.

If you have strange characters, this should be added to one of the arg fields instead as there is no restriction to the data in there.

Default Arguments

These are the default arguments if the host attribute's arg does not have an override.

Encrypting Args

It is possible to encrypt an arg. This will set the value in the database to be encrypted so that it is not stored in cleartext.

If you encrypt an arg, it will encrypt the default argument as well as all the host attributes that have this arg set. This is not reversable!

It is also possible to remove the encryption of an arg by unticking the Encrypt checkbox. If you remove the encryption, then all values will be removed and blanked out - this is to stop anyone from removing the encryption to read the current values.

If you remove the encryption of an arg, it will blank out the main attribute arg as well as all host attributes for this arg!

If you have blanked out values by mistake, you can restore the database from the last successful reload via the audit logs.

Override Example

Assume an attribute of MYSQL_CREDENTIALS has a default value of Default and a default arg1 of mysqlusername and default arg2 of mysqlpassword.

Assume also there is a service check called Mysql login which has arguments of -u %MYSQL_CREDENTIALS:1% -p %MYSQL_CREDENTIALS:2%

Host1 has no attributes for MYSQL_CREDENTIALS.

Host2 has 1 host attribute for MYSQL_CREDENTIALS with value=mysqlhost2, arg1 override =host2user and arg2 override =host2password.

Host3 has 1 host attribute for MYSQL_CREDENTIALS with value=mysqlhost3, arg1=host3user and no override on arg2.

Opsview would generate:

Host Arg1 Arg2 Resolved arguments
Host1 No attribute set No attribute set -u mysqlusername -p mysqlpassword
Host2 Override: host2user Override: host2password -u host2user -p host2password
Host3 Override: host3user No override -u host3user -p mysqlpassword

Internally Generated Attributes

Some attributes are internally generated, so it is not necessary to manually add information at the host edit pages. There are currently 3 internally generated attributes:

  • INTERFACE - based on the snmp interfaces stored from a query host call
  • SLAVENODE - returns a list of all slave nodes
  • CLUSTERNODE - returns a list of all other cluster nodes within a slave environment

Note however, that you still need to associate the relevant service checks to the host. In the initial database, these templates can be used:

Host Template Service check Description
SNMP MIB-II Interface Monitors bandwidth of the specific interface from the query host list
Opsview Master Slave-node Monitors each slave for connectivity
Opsview Common Cluster-node Monitors each other node in a slave cluster

Associating a host to the appropriate host template will ensure the service checks get created correctly.

Examples

URL's as attributes

Since the main value of an attribute cannot contain certain charactes (colon, comma, question mark), to use an URL as an attribute requires the use of attribute arguments

To do this, on the Settings→Attributes list page,

  • Create a new attribute and set the value to be URL (or similar)

and on the Host edit page Attributes tab,

  • Use the attribute just created (in this case URL)
  • Click on the 'eye' icon to expand the arguments fields
  • Set Arg1 to be the URL you require, e.g. https://docs.opsview.com

and finally,

  • In the Servicecheck arguments for the check use the macro %URL:1 to refer to the URL
Navigation
Print/export
Toolbox