2016-05-31 7 views
0

Softlayerでの監視に関する質問があります。 IPアドレスリストを追加するにはどうすればよいですか?プライマリipsよりも多くのIPがあります。監視のためにIPを取得するためのAPIはありますか?SoftLayerでの監視のためのユーザリストとIPリスト

ユーザーリストに通知するにはどうすればよいですか?私が使用したコードはユーザーを持ちません。

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

    for (Agent agent : agentList) { 

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

}

Ip List User List

+0

マイク、私の情報のための私の謝罪前に提供されていますが、現在はip addrを得ることができますエッセーと通知するユーザーリストは、私の答えの更新を参照してください。あなたがこれにもっと援助が必要な場合は私に教えてください。 –

答えて

0

追加するには、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(); 
    } 
} 
+0

あなたの更新されたコードを見ましたが、 "com.softlayer.api.service.network.Monitor"クラスは私のJavaライブラリではありません。私のJavaのlibバージョンは0.2.2です。 Monitorクラスはどこで入手できますか? –

+0

ええ、私は同じ間違いがありましたが、最新のmasterブランチを試して、maven経由でソースをもう一度コンパイルする必要があります。 https://github.com/softlayer/softlayer-java/issues/33 –

+0

現在のマスターバージョンには、「com.softlayer.api.service」パッケージはありません。あなたはどこにいるのか私にリンクできますか?プル 1.または2.のMavenでプロジェクトをコンパイルし、3. [プロジェクトがコンパイルされ、例を試してみてください、https://github.com/softlayer/softlayer-javaからmasterブランチをダウンロード:ありがとう –

関連する問題