Back to OP5 Monitor FAQ

How to import hosts via Excel with service objects cloning and auto-detection of disks

This how-to is shipped as a courtesy to OP5 customers. The contents of this how-to are not supported by ITRS.

OP5Monitor-Excel-Import Copied

This program is intended to bulk-import hosts into an OP5 Monitor installation using the OP5 Monitor’s HTTP API. It reads an Excel-file (.xlsx format, introduced in Excel 2007) line-by-line. The first line is interpreted as the header line. The headings have to conclude with Naemon/Nagios Core’s host object attribute names, such as “address”, “alias”, “hostgroups”, “parents”, … in order to create the host objects. Each column of the Excel file has to use either of the below listed header captions as a heading or one of the following special headings:

Even if the heading is defined for a certain column, you can leave the cell empty for one of several hosts. In this case, the script will act as if the corresponding column would not exist at all.

OP5 Monitor - How to import hosts via Excel with service objects cloning and auto-detection of disks.

Command line arguments Copied

Excel file column headers Copied

The script is meant to be installed directly on the OP5 Monitor host. This means the Excel file generated by the customer has to be transferred to the OP5 Monitor server.

Scalar column headers Copied

The following header captions can be used for scalar type attributes. These attributes can contain a single string or number as a value. Please note Excel’s behavior of automatically reformatting strings when an inappropriate cell formatting is set. Especially, IP addresses tend to get misformatted when using the “standard” cell formatting in Excel (it is recommended to use “Text” as cell formatting instead).

The only required attributes that have to be present in order to create a host correctly, are the “host_name” and “address” attributes.

Array-style column headers Copied

Some of the header captions can be used for multi-value options. Each of the cells may contain a single word or value, but also a list of values, separated by commas. This way, for example you can add two host groups by using the “network,servers” notation. The array-style column headers are the following ones:

None of these attributes are required.

Boolean column headers Copied

Some of the host object attributes that can be used as headings for the columns in the Excel file are booleans. They can have a “true” or a “false” value. You can use the content “1”, “true” or “yes” as a value to set the cell to “true”, all other content will set the cell to “false” and an empty cell will make the script NOT pass this attribute to OP5 Monitor which means that the default value will be used. The following header captions are the booleans:

None of these attributes are required.

Cloning of service checks from specific hosts Copied

If the special word CLONEFROM is found as a header for any of the columns and the value of the corresponding cell for the specific host that is to be added is set to “true”, “1” or “yes”, all service check objects that are directly attached to the host object(s) defined in the CLONEFROM cell for the specific host (comma-notation can be used to list several source hosts) are cloned to the newly created host.

Please note that only DIRECTLY attached service objects are cloned, not those that are attached to a host group object to which the host object belongs.

Automatic detection and adding of Windows Disk usage checks Copied

If the special word AUTODETECT_WIN_DISKS is found as a header for any of the columns and the value of the corresponding cell for the specific host that is to be added is set to “true”, “1”, or “yes”, the host object’s address will be connected through the “check_nrpe” check plugin to ask the NSClient++ agent on the remote Windows host for available Windows disk drives (C:, D: etc.) that are of type “fixed” (normal hard drives, no CDROMs etc.). For each of the disk drives detected on the remote host, a corresponding service check is automatically added.

Please note that this feature starts the NRPE client locally. Master/Poller environments are not (yet) supported. If the monitored Windows host is not directly reachable via check_nrpe from the machine where this program is installed, the automatic detection and adding of Disk Drive service checks will not work.

Configuration File Copied

By default, the configuration file is searched in the path /opt/api-scripts/api-scripts.config.yml. The configuration file is a representation of a hash data structure, noted in the YAML format. The default configuration file looks as follows:

config file

---op5api:  server: localhost  user: monitor  password: monitor  authentication_realm: op5 Monitor API Access  ssl_verify_hostname: falseexcel_import:  check_nrpe_path: /opt/plugins/check_nrpe  check_nrpe_use_ssl: false  windows_disk_checks:    check_command: check_nrpe_win_drivesize    service_description: Disk %s utilization    check_command_args: Drive=%s MaxWarn=80% MaxCrit=90%    template: default-service

The configuration values should be self-explanatory. Under the op5api section, the credentials and server address of the OP5 Monitor installation are configured. The excel_import section configures all specific options for this program to work. Under the sub-section windows_disk_checks the options for the automatically added Windows Disk Usage service checks are set.

Program installation Copied

RPM installation (on CentOS/RHEL/APS) Copied

You can use the op5Monitor-Excel-Import--installer.tar.gz package to do a one-step installation:

Just unpack the file somewhere on your APS/Linux, change into the created directory and execute the ./install.sh script.

A local repository containing the needed additional rpm files (Perl modules) is automatically created. Afterwards, the script’s rpm file is installed under /opt/api-scripts.

Manual installation Copied

If you have a CentOS installation with enabled EPEL repositories, you can just pick the rpm file and do a yum localinstall.

In any other case, you can use the distribution tarball op5Monitor-Excel-Import-.tar.gz. You will have to take care of the dependencies yourself and make sure the following Perl modules are installed on your system:

Download Copied

["Geneos"] ["FAQ"]

Was this topic helpful?