Список пользователей и список IP-адресов для мониторинга в SoftLayer

У меня есть вопросы относительно мониторинга в Softlayer. Как я могу добавить список IP-адресов? IP-адресов больше, чем основных. Есть ли API для получения IP-адресов для мониторинга?

Как я могу получить список пользователей для уведомления? Код, который я использовал, не приносит пользователя.

    List<Agent> agentList = guest.getMonitoringAgents();

    for (Agent agent : agentList) {

        List<Customer> custList = agent.asService(client).getEligibleAlarmSubscibers();

}

Список IP-адресов Список пользователей


person Mike Oh    schedule 31.05.2016    source источник
comment
Майк, мои извинения за информацию, которую я предоставил ранее, в настоящее время можно получить IP-адреса и список пользователей для уведомления, см. Обновления в моем ответе. Дайте мне знать, если вам нужна дополнительная помощь в этом.   -  person Ruber Cuellar Valenzuela    schedule 01.06.2016


Ответы (1)


Чтобы добавить список IP-адресов, попробуйте следующие способы:

[Обновлено] Вот пример получения IP-адресов аппаратным обеспечением.

package com.softlayer.api.NetworkMonitor;

import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.Hardware;
import com.softlayer.api.service.network.Monitor;
import com.softlayer.api.service.network.subnet.IpAddress;

/**
 * This script will return an arrayObject of objects containing the ipaddresses for hardware
 *
 * Important Manual Page:
 * http://sldn.softlayer.com/reference/services/SoftLayer_Network_Monitor/getIpAddressesByHardware
 * http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Subnet_IpAddress
 *
 * @license <http://sldn.softlayer.com/article/License>
 * @authon SoftLayer Technologies, Inc. <[email protected]>
 * @version 0.2.2
 */
public class GetIpAddressesByHardware {
    /**
     * This is the constructor, is used to Get Ip Addresses By Hardware
     */
    public GetIpAddressesByHardware() {
        // Declare your SoftLayer username and apiKey
        String username = "set me";
        String apiKey = "set me";

        // Define Hardware identifier
        Long hardwareId = new Long(92862);

        // Create client
        ApiClient client = new RestApiClient().withCredentials(username, apiKey);

       Monitor.Service monitorService = Monitor.service(client);

        Hardware hardware = new Hardware();
        hardware.setId(hardwareId);
        try {
            for(IpAddress ipAddress : monitorService.getIpAddressesByHardware(hardware, ""))
            {
                System.out.println("Ip Address: " + ipAddress.getIpAddress());
            }


        } catch (Exception e) {
            System.out.println("Error: " + e);
        }
    }

    /**
     * This is the main method which makes use of GetIpAddressesByHardware method.
     *
     * @param args
     * @return Nothing
     */
    public static void main(String[] args) {
        new GetIpAddressesByHardware();
    }


}

Относительно: как я могу заставить список пользователей уведомлять?

В этом помогут следующие методы:

[Обновлено] Вот скрипт, использующий SoftLayer_Hardware_Server::getUsers

package com.softlayer.api.HardwareServer;

import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.hardware.Server;
import com.softlayer.api.service.user.Customer;

/**
 * This script retrieves a list of users that have access to this computing instance.
 *
 * Important Manual Page:
 * http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getUsers
 * http://sldn.softlayer.com/reference/datatypes/SoftLayer_User_Customer
 *
 * @license <http://sldn.softlayer.com/article/License>
 * @authon SoftLayer Technologies, Inc. <[email protected]>
 * @version 0.2.2
 */
public class GetUsers {
    /**
     * This is the constructor, is used to Get Users from hardware
     */
    public GetUsers() {
        // Declare your SoftLayer username and apiKey
        String username = "set me";
        String apiKey = "set me";

        // Define Hardware identifier
        Long hardwareId = new Long(92862);

        // Create client
        ApiClient client = new RestApiClient().withCredentials(username, apiKey);

        Server.Service serverService = Server.service(client, hardwareId);
        try {
            for(Customer user : serverService.getUsers())
            {
                System.out.println("Id: " + user.getId());
                System.out.println("User: " + user.getLastName() + ", " + user.getFirstName() + "(" + user.getUsername() + ")");
                System.out.println("----------------------------");
            }
        } catch (Exception e) {
            System.out.println("Error: " + e);
        }
    }

    /**
     * This is the main method which makes use of GetUsers method.
     *
     * @param args
     * @return Nothing
     */
    public static void main(String[] args) {
        new GetUsers();
    }


}

Вот сценарий, использующий SoftLayer_Virtual_Guest::getUsers:

package Monitoring;

import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.user.Customer;
import com.softlayer.api.service.virtual.Guest;

/**
 * This script retrieve a list of users that have access to this computing instance.
 *
 * Important Manual Page:
 * http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getUsers
 * http://sldn.softlayer.com/reference/datatypes/SoftLayer_User_Customer
 *
 * @license <http://sldn.softlayer.com/article/License>
 * @authon SoftLayer Technologies, Inc. <[email protected]>
 * @version 0.2.2
 */
public class GetUserList {
    /**
     * This is the constructor, is used to Add users to notify
     */
    public GetUserList() {
        // Declare your SoftLayer username and apiKey
        String username = "set me";
        String apiKey = "set me";

        // Define the virtual guest id
        Long guestId = new Long(18697221);

        // Create client
        ApiClient client = new RestApiClient().withCredentials(username, apiKey);

        // Define SoftLayer_Virtual_Guest service
        Guest.Service guestService = Guest.service(client, guestId);


        try {
            for(Customer user : guestService.getUsers())
            {
                System.out.println("Id: " + user.getId());
                System.out.println("User: " + user.getLastName() + ", " + user.getFirstName() + "(" + user.getUsername() + ")");
                System.out.println("----------------------------");
            }

        } catch (Exception e) {
            System.out.println("Error: " + e);
        }
    }

    /**
     * This is the main method which makes use of GetUserList method.
     *
     * @param args
     * @return Nothing
     */
    public static void main(String[] args) {
        new GetUserList();
    }
}
person Ruber Cuellar Valenzuela    schedule 31.05.2016
comment
Я видел ваш обновленный код, но класс com.softlayer.api.service.network.Monitor не является моей java-библиотекой. Моя версия java lib 0.2.2. Где взять класс Monitor? - person Mike Oh; 02.06.2016
comment
Да, у меня была та же ошибка, но вы должны попробовать последнюю основную ветку и снова скомпилировать исходники через maven. github.com/softlayer/softlayer-java/issues/33 - person Ruber Cuellar Valenzuela; 02.06.2016
comment
В текущей основной версии отсутствует пакет com.softlayer.api.service. Не могли бы вы дать мне ссылку, где вы берете? Спасибо - person Mike Oh; 03.06.2016
comment
Попробуйте выполнить следующие действия: 1. Извлеките или загрузите основную ветку с github.com/softlayer/softlayer-java, 2. Скомпилируйте проект с помощью maven, 3. Откройте скомпилированный проект и попробуйте приведенные мной примеры. - person Ruber Cuellar Valenzuela; 03.06.2016
comment
Извините, что беспокою вас. Загруженный вами zip-файл: softlayer-java-master.zip (91 КБ). Правильно? Класс монитора должен быть там. Правильно ? Но не могу найти.. - person Mike Oh; 08.06.2016
comment
Не волнуйтесь, я рад помочь вам. После загрузки файла softlayer-java-master.zip(91kb) его необходимо разархивировать. после этого откройте командную строку (я полагаю, что вы используете Windows), перейдите по пути, по которому вы разархивировали проект, и скомпилируйте проект с помощью maven mvn compile, после этого откройте проект и попробуйте использовать предоставленные мной скрипты, они должны работать нормально. - person Ruber Cuellar Valenzuela; 08.06.2016
comment
Дайте мне знать, если у вас есть успех или любой вопрос, чтобы я мог вам помочь. - person Ruber Cuellar Valenzuela; 08.06.2016