Skip to main content
Index

Get Temperature and Humidity Information in Near Real-Time

Steps to retrieve near real-time environmental data such as temperature and humidity for your cages and cabinets are shown below.

 

Via GCP Pubsub

Step 1: Create a near real-time channel subscription

1a) Authenticate

Submit your user credentials, Client ID, and Client Secret for OAuth2 authentication.

 

Refer to Generating Client ID and Client Secret key under Getting Started section for instructions on how to create client ID and client secret. Refer to Requesting Access and Refresh tokens for instructions on how to call Oauth API to validate and authenticate your credentials.

 

If you are unaware of your user credentials for Equinix IBX SmartView, contact your local Equinix Service Desk. 

 

1b) Get a subscription

The first step is to create a subscription.

 

Refer to Create a subscription under API Reference section for instructions on how to get asset details. You may skip this step if you already know the asset details. 

Step 2: Get Authenticate with Google pub sub

Authenticate with Google pub-sub using the access token and subscription URL from previous step.

Step 3: Setup and Configuration

3 a) Download and setup Near Real-Time feed consumer code.

 

3 b) Configure the following ENV variable while running the code. GOOGLE_APPLICATION_CREDENTIALS=/localpath/client_secrets.json

 

3 c) Execute the class com.equinix.dcim.subscriber.FeedTest with method init

 

package main;

 

import java.util.Properties;

import java.util.concurrent.TimeUnit;

import com.equinix.dcim.subscriber.Feed;

import com.equinix.dcim.subscriber.goog.GoogleConfiguration;

import com.equinix.dcim.subscriber.impl.FeedImpl;

 

public class FeedTest {  

    public static void main(String args[]) throws Exception {  

        Feed feed = new FeedImpl();

        Properties props = new Properties();

 

        GoogleConfiguration googleConfiguration = new GoogleConfiguration("eighth-pursuit-162421", "equinix_uat1");

        feed.registerConsumer((x) ->

        {  

            System.out.println(x.toString());

        });

 

        feed.init(googleConfiguration);

        int i = 0;

        System.out.println("Started!!!");

        while (i < 2) {  

            TimeUnit.SECONDS.sleep(600);

            i++;

        }  

    }

}

 

3 d) Send email to api-support@equinix.com  to request for the client secret file “client_secrets.json” for read access.

Step 4: Retrieve the near real-time feeds

Retrieve the near real-time feeds using the subscription URL that the consumer had created in Step 3.

 

Via AWS SNS

Step 1: Create a near real-time channel subscription

1a) Authenticate

Submit your user credentials, Client ID, and Client Secret for OAuth2 authentication.

 

Refer to Generating Client ID and Client Secret key under Getting Started section for instructions on how to create client ID and client secret. Refer to Requesting Access and Refresh tokens for instructions on how to call Oauth API to validate and authenticate your credentials.

 

If you are unaware of your user credentials for Equinix IBX SmartView, contact your local Equinix Service Desk. 

 

1b) Get a subscription

The first step is to create a subscription.

 

Refer to Create a subscription under API Reference section for instructions on how to get asset details. You may skip this step if you already know the asset details. 

Step 2: Authenticate with AWS SNS

Authenticate with AWS SNS using the access token and subscription URL from previous step.

Step 3: Setup and Configuration

3 a) Download and setup Near Real-Time feed consumer code.

 

3 b) Configure the following ENV variable while running the code. GOOGLE_APPLICATION_CREDENTIALS=/localpath/client_secrets.json

 

3 c) Execute the class com.equinix.dcim.subscriber.FeedTest with method init

 

AWS_CREDENTIAL_PROFILES_FILE=/Users/apps/aws_client_secrets.json

 

import com.amazonaws.regions.Regions;

import com.amazonaws.services.logs.AWSLogsClient;

import com.amazonaws.services.logs.AWSLogsClientBuilder;

import com.amazonaws.services.logs.model.GetQueryResultsRequest;

import com.amazonaws.services.logs.model.StartQueryRequest;

import com.amazonaws.services.logs.model.StartQueryResult;

import com.google.common.util.concurrent.Uninterruptibles;

 

import java.time.LocalDateTime;

import java.time.ZoneOffset;

import java.util.ArrayList;

import java.util.List;

import java.util.concurrent.TimeUnit;

 

    String awsCloudLogGroupName="/aws/lambda/testawssns";

    AWSLogsClient awsLogsClient = (AWSLogsClient) AWSLogsClientBuilder.standard()

        .withRegion(Regions.US_EAST_2).build();

        StartQueryRequest startQueryRequest = new StartQueryRequest();

        String query = "fields @timestamp, @message " +

            "| sort @timestamp desc " +

            "| limit 20";

        startQueryRequest.setLogGroupName(awsCloudLogGroupName);

        long epocSecStartTime = LocalDateTime.now().minusHours(2).toEpochSecond(ZoneOffset.UTC);//last 2 hour startQueryRequest.setStartTime(epocSecStartTime);

        startQueryRequest.setEndTime(System.currentTimeMillis());

        startQueryRequest.setQueryString(query);

        StartQueryResult startQueryResult = awsLogsClient.startQuery(startQueryRequest);

        GetQueryResultsRequest getQueryResultsRequest = new GetQueryResultsRequest();

        getQueryResultsRequest.withQueryId(startQueryResult.getQueryId());

        List list = new ArrayList();

        int attempts = 0;

        while (attempts++ <

            10) { Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);

            list = awsLogsClient.getQueryResults(getQueryResultsRequest).getResults();

            System.out.println(list);

            if (!list.isEmpty()) {

                break;

            }

        }

    }

 

3 d) Send email to api-support@equinix.com  to request for the client secret file “client_secrets.json” for read access.

Step 4: Retrieve the near real-time feeds

Retrieve the near real-time feeds using the subscription URL that the consumer created above.

 

Via Azure Service Bus

Step 1: Create a near real-time channel subscription

1a) Authenticate

Submit your user credentials, Client ID, and Client Secret for OAuth2 authentication.

 

Refer to Generating Client ID and Client Secret key under Getting Started section for instructions on how to create client ID and client secret. Refer to Requesting Access and Refresh tokens for instructions on how to call Oauth API to validate and authenticate your credentials.

 

If you are unaware of your user credentials for Equinix IBX SmartView, contact your local Equinix Service Desk. 

 

1b) Get a subscription

The first step is to create a subscription.

 

Refer to Create a subscription under API Reference section for instructions on how to get asset details. You may skip this step if you already know the asset details. 

Step 2: Authenticate with Azure Service Bus

Authenticate with Azure Service Bus using the access token and subscription URL from the previous step.

Step 3: Setup and configuration

3a) Download and setup Near Real-Time feed consumer code.

 

3b) Configure the following ENV variable while running the code. GOOGLE_APPLICATION_CREDENTIALS=/localpath/client_secrets.json

 

3c) Execute the class com.equinix.dcim.subscriber.FeedTest with method init

 

AZURE_AUTH_LOCATION=/Users/apps/my.azureauth.cred

import com.microsoft.azure.servicebus.*;

import com.microsoft.azure.servicebus.primitives.ConnectionStringBuilder;

import com.microsoft.azure.servicebus.primitives.ServiceBusException;

 

import java.time.Duration;

import java.util.concurrent.CompletableFuture;

import java.util.function.Consumer;

import java.util.function.Function;

 

String subscriptionName="TOPIC_AZURE_7786/subscriptions/TOPIC_AZURE_7786_subscriber";

String connectionString="Endpoint=sb://equinix.servicebus.windows.net/;SharedAccessKeyName=READ_ONLY_RULE;SharedAccessKey=mWiElYxO+GU3iyoS0wCnKaGT9vhc93sB4WmIzLyBQQY=;EntityPath=TOPIC_AZURE_7786";

 

SubscriptionClient azureClient = new SubscriptionClient

    (new ConnectionStringBuilder(connectionString, subscriptionName), ReceiveMode.PEEKLOCK);

IMessageHandler messageHandler = new IMessageHandler() {

    public CompletableFuture onMessageAsync(IMessage message) {

        if (message.getContentType().contentEquals("application/json")) {

            System.out.println("received : " + new String(message.getBody()));

        }

        return azureClient.completeAsync(message.getLockToken());

    }

 

 

    public void notifyException(Throwable throwable, ExceptionPhase exceptionPhase) {

        System.out.printf(exceptionPhase + "-" + throwable.getMessage());

    }

};

 

try {

    azureClient.registerMessageHandler(

        messageHandler,

        new MessageHandlerOptions(10, false, Duration.ofMinutes(1)));

} catch (InterruptedException e) {

    e.printStackTrace();

} catch (ServiceBusException e) {

    e.printStackTrace();

}

 

3d) Send email to api-support@equinix.com  to request for the client secret file “client_secrets.json” for read access.

Step 4: Retrieve the near real-time feeds

Retrieve the near real-time feeds using the subscription URL that the consumer had created in Step 3.