Back to OP5 Monitor FAQ

How to export objects such as host and services to a CSV file

Using the mon query ls command, you can query Livestatus/LMD directly and get the information you need in a comma separated syntax. This is helpful since the output can be directly written to a CSV file for further processing.

To list the available tables, run:

## mon query ls

If you are interested in services, the “services” table is a good bet. Point the command at this table for a list of columns to choose from:

## mon query ls services

Pick the columns you want from the table listing and add them with the -c flag. In this example, we’ll print the host and description (name) of all services:

## mon query ls services -c host_name,description

Since the output is semicolon separated, you can write it directly to a CSV file:

## mon query ls services -c host_name,description > /tmp/services.csv

For more advanced usage and additional help, see:

## mon query ls --help

Examples from the command help Copied

mon query ls hosts
mon query ls hosts -c address name=darkstar
mon query ls hosts -c name name -r ^a name~^b -o 2
mon query ls hosts -c name state -ne 0 acknowledged -e 1 -a2 state=0 -o2 -l3
mon query ls hosts -c name parents -e ''
mon query ls hosts -c name parents\>=monitor
mon query ls services -c host_name,description,state,plugin_output state -gt 0
["Geneos"] ["FAQ"]

Was this topic helpful?