Search in sources :

Example 1 with Statistic

use of org.ovirt.engine.sdk4.types.Statistic in project ovirt-engine-sdk-java by oVirt.

the class ListHostStatistics method main.

public static void main(String[] args) throws Exception {
    // Create the connection to the server:
    Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
    // Find the host:
    HostsService hostsService = connection.systemService().hostsService();
    Host host = hostsService.list().search("name=myhost").send().hosts().get(0);
    // Follow the link to the statistics and print their names and values:
    List<Statistic> stats = connection.followLink(host.statistics());
    for (Statistic stat : stats) {
        System.out.printf("%s: %s\n", stat.name(), stat.values().get(0).datum());
    }
    // Close the connection to the server:
    connection.close();
}
Also used : Statistic(org.ovirt.engine.sdk4.types.Statistic) Connection(org.ovirt.engine.sdk4.Connection) HostsService(org.ovirt.engine.sdk4.services.HostsService) Host(org.ovirt.engine.sdk4.types.Host)

Aggregations

Connection (org.ovirt.engine.sdk4.Connection)1 HostsService (org.ovirt.engine.sdk4.services.HostsService)1 Host (org.ovirt.engine.sdk4.types.Host)1 Statistic (org.ovirt.engine.sdk4.types.Statistic)1