Search in sources :

Example 1 with GetRouterMonitorResultsCommand

use of com.cloud.agent.api.routing.GetRouterMonitorResultsCommand in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method performBasicTestsOnRouter.

private GetRouterMonitorResultsAnswer performBasicTestsOnRouter(DomainRouterVO router) {
    if (!RouterHealthChecksEnabled.value()) {
        return null;
    }
    String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
    if (StringUtils.isNotBlank(controlIP) && !controlIP.equals("0.0.0.0")) {
        final GetRouterMonitorResultsCommand command = new GetRouterMonitorResultsCommand(false, true);
        command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlIP);
        command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
        try {
            final Answer answer = _agentMgr.easySend(router.getHostId(), command);
            if (answer == null) {
                s_logger.warn("Unable to fetch basic router test results data from router " + router.getHostName());
                return null;
            }
            if (answer instanceof GetRouterMonitorResultsAnswer) {
                return (GetRouterMonitorResultsAnswer) answer;
            } else {
                s_logger.warn("Unable to fetch basic router test results from router " + router.getHostName() + " Received answer " + answer.getDetails());
                return new GetRouterMonitorResultsAnswer(command, false, null, answer.getDetails());
            }
        } catch (final Exception e) {
            s_logger.warn("Error while performing basic tests on router: " + router.getInstanceName(), e);
            return null;
        }
    }
    return null;
}
Also used : GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) GetRouterAlertsAnswer(com.cloud.agent.api.GetRouterAlertsAnswer) GetRouterMonitorResultsCommand(com.cloud.agent.api.routing.GetRouterMonitorResultsCommand) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) JsonSyntaxException(com.google.gson.JsonSyntaxException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ParseException(java.text.ParseException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException)

Example 2 with GetRouterMonitorResultsCommand

use of com.cloud.agent.api.routing.GetRouterMonitorResultsCommand in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method fetchAndUpdateRouterHealthChecks.

private GetRouterMonitorResultsAnswer fetchAndUpdateRouterHealthChecks(DomainRouterVO router, boolean performFreshChecks) {
    if (!RouterHealthChecksEnabled.value()) {
        return null;
    }
    String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
    if (StringUtils.isNotBlank(controlIP) && !controlIP.equals("0.0.0.0")) {
        final GetRouterMonitorResultsCommand command = new GetRouterMonitorResultsCommand(performFreshChecks, false);
        command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlIP);
        command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
        try {
            final Answer answer = _agentMgr.easySend(router.getHostId(), command);
            if (answer == null) {
                s_logger.warn("Unable to fetch monitoring results data from router " + router.getHostName());
                return null;
            }
            if (answer instanceof GetRouterMonitorResultsAnswer) {
                return (GetRouterMonitorResultsAnswer) answer;
            } else {
                s_logger.warn("Unable to fetch health checks results to router " + router.getHostName() + " Received answer " + answer.getDetails());
                return new GetRouterMonitorResultsAnswer(command, false, null, answer.getDetails());
            }
        } catch (final Exception e) {
            s_logger.warn("Error while collecting alerts from router: " + router.getInstanceName(), e);
            return null;
        }
    }
    return null;
}
Also used : GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) GetRouterAlertsAnswer(com.cloud.agent.api.GetRouterAlertsAnswer) GetRouterMonitorResultsCommand(com.cloud.agent.api.routing.GetRouterMonitorResultsCommand) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) JsonSyntaxException(com.google.gson.JsonSyntaxException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ParseException(java.text.ParseException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2 Answer (com.cloud.agent.api.Answer)2 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)2 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)2 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)2 GetRouterAlertsAnswer (com.cloud.agent.api.GetRouterAlertsAnswer)2 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)2 GetRouterMonitorResultsAnswer (com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer)2 GetRouterMonitorResultsCommand (com.cloud.agent.api.routing.GetRouterMonitorResultsCommand)2 GroupAnswer (com.cloud.agent.api.routing.GroupAnswer)2 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 ConnectionException (com.cloud.exception.ConnectionException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2