Search in sources :

Example 1 with DefaultServiceAlert

use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.

the class ActivemqServiceStatusCheck method activemqStatus.

/**
 * Check if Activemq is running
 *
 * @return Status of Activemq
 */
private ServiceComponent activemqStatus() {
    String componentName = "Activemq";
    String serviceName = SERVICE_NAME;
    ServiceComponent component = null;
    Connection activemqConnection = null;
    /**
     * Prepare Alert Message
     */
    ServiceAlert alert = null;
    alert = new DefaultServiceAlert();
    alert.setLabel(componentName);
    alert.setServiceName(serviceName);
    alert.setComponentName(componentName);
    String finalServiceMessage = "";
    try {
        if (this.activemqPoolConnection != null) {
            /**
             * Create Instance of Connection from Pool
             */
            activemqConnection = this.activemqPoolConnection.createConnection();
            /**
             *  On successful connection , return status to Kylo
             */
            finalServiceMessage = "Activemq is running.";
            alert.setMessage(finalServiceMessage);
            alert.setState(ServiceAlert.STATE.OK);
            component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.UP).message(finalServiceMessage).addAlert(alert).build();
        }
    } catch (Exception jmsConnectionException) {
        finalServiceMessage = "Activemq is down.";
        alert.setMessage(finalServiceMessage);
        alert.setState(ServiceAlert.STATE.CRITICAL);
        component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.DOWN).message(finalServiceMessage).exception(jmsConnectionException).addAlert(alert).build();
    } finally {
        if (activemqConnection != null)
            try {
                activemqConnection.close();
            } catch (JMSException e) {
                log.error("Unable to close activemq connection", e);
            }
    }
    return component;
}
Also used : DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ServiceComponent(com.thinkbiganalytics.servicemonitor.model.ServiceComponent) Connection(javax.jms.Connection) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException)

Example 2 with DefaultServiceAlert

use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.

the class AmbariServicesStatusCheck method transformAmbariAlert.

/**
 * Transform the ambari alerts to Kylo service alerts
 */
private List<ServiceAlert> transformAmbariAlert(AlertSummary alertSummary) {
    List<ServiceAlert> serviceAlerts = new ArrayList<>();
    if (alertSummary != null) {
        List<AlertItem> alertItems = alertSummary.getItems();
        if (alertItems != null) {
            for (AlertItem alertItem : alertItems) {
                Alert alert = alertItem.getAlert();
                ServiceAlert serviceAlert = new DefaultServiceAlert();
                serviceAlert.setServiceName(alertItem.getAlert().getServiceName());
                serviceAlert.setComponentName(alert.getComponentName());
                serviceAlert.setFirstTimestamp(new Date(alert.getOriginalTimestamp()));
                serviceAlert.setLatestTimestamp(new Date(alert.getLatestTimestamp()));
                serviceAlert.setLabel(alert.getLabel());
                serviceAlert.setMessage(alert.getText());
                if (StringUtils.isNotBlank(alert.getState())) {
                    try {
                        serviceAlert.setState(ServiceAlert.STATE.valueOf(alert.getState()));
                    } catch (IllegalArgumentException e) {
                        serviceAlert.setState(ServiceAlert.STATE.UNKNOWN);
                    }
                } else {
                    serviceAlert.setState(ServiceAlert.STATE.UNKNOWN);
                }
                serviceAlerts.add(serviceAlert);
            }
        }
    }
    return serviceAlerts;
}
Also used : ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ArrayList(java.util.ArrayList) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) Alert(com.thinkbiganalytics.servicemonitor.rest.model.ambari.Alert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) AlertItem(com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertItem) Date(java.util.Date)

Example 3 with DefaultServiceAlert

use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.

the class ClusterServiceStatusCheck method healthCheck.

public ServiceStatusResponse healthCheck() {
    String serviceName = "Kylo Cluster";
    String MEMBER_COUNT_PROPERTY = "member count";
    String MEMBERS_PROPERTY = "members";
    Map<String, Object> properties = new HashMap<>();
    boolean isClustered = clusterService.isClustered();
    boolean valid = true;
    List<ServiceComponent> components = new ArrayList<>();
    String serviceMessage = "";
    List<ServiceAlert> serviceAlerts = new ArrayList<>();
    if (isClustered) {
        int memberCount = clusterService.getMembersAsString().size();
        List<String> members = clusterService.getMembersAsString();
        if (StringUtils.isNotBlank(expectedNodes)) {
            try {
                int expectedNodeCount = Integer.valueOf(expectedNodes);
                if (expectedNodeCount != memberCount) {
                    valid = false;
                    serviceMessage = "Error.  Missing " + (expectedNodeCount - memberCount) + " nodes. ";
                } else {
                    serviceMessage = " All " + expectedNodeCount + " nodes are connected. ";
                }
            } catch (NumberFormatException e) {
                valid = false;
                serviceMessage = "  Unable to validate the expected kylo node count.  Ensure the 'kylo.cluster.nodeCount' property is set to a valid number.";
            }
        }
        final boolean isValid = valid;
        final String finalServiceMessage = serviceMessage;
        members.stream().forEach(member -> {
            String componentName = member;
            boolean currentlyConnected = member.equalsIgnoreCase(clusterService.getAddressAsString());
            properties.put(MEMBER_COUNT_PROPERTY, memberCount);
            properties.put(MEMBERS_PROPERTY, members.toString());
            String message = "There are " + memberCount + " members in the cluster. ";
            if (currentlyConnected) {
                message = "Currently connected to this node. " + message;
            }
            ServiceAlert alert = null;
            if (isValid) {
                message = finalServiceMessage + message;
            } else {
                alert = new DefaultServiceAlert();
                alert.setLabel(componentName);
                alert.setServiceName(serviceName);
                alert.setComponentName(componentName);
                alert.setMessage(finalServiceMessage);
                alert.setState(ServiceAlert.STATE.CRITICAL);
            }
            ServiceComponent component = new DefaultServiceComponent.Builder(componentName, isValid ? ServiceComponent.STATE.UP : ServiceComponent.STATE.DOWN).message(message).properties(properties).addAlert(alert).build();
            components.add(component);
        });
    } else {
        serviceMessage = "Kylo is not configured to be running as a cluster";
        ServiceComponent component = new DefaultServiceComponent.Builder(serviceName, ServiceComponent.STATE.UP).message(serviceMessage).properties(properties).build();
        components.add(component);
    }
    return new DefaultServiceStatusResponse(serviceName, components);
}
Also used : HashMap(java.util.HashMap) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ServiceComponent(com.thinkbiganalytics.servicemonitor.model.ServiceComponent) ArrayList(java.util.ArrayList) DefaultServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert)

Example 4 with DefaultServiceAlert

use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.

the class ClouderaServicesStatusCheck method apiHealthCheckToServiceAlert.

private ServiceAlert apiHealthCheckToServiceAlert(String componentName, ApiHealthCheck healthCheck) {
    ServiceAlert alert = new DefaultServiceAlert();
    alert.setComponentName(componentName);
    alert.setLabel(healthCheck.getName());
    alert.setMessage(healthCheck.getSummary().name());
    alert.setState(apiHealthSummaryAlertState(healthCheck.getSummary()));
    return alert;
}
Also used : DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert)

Aggregations

DefaultServiceAlert (com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert)4 ServiceAlert (com.thinkbiganalytics.servicemonitor.model.ServiceAlert)4 DefaultServiceComponent (com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent)2 ServiceComponent (com.thinkbiganalytics.servicemonitor.model.ServiceComponent)2 ArrayList (java.util.ArrayList)2 DefaultServiceStatusResponse (com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse)1 Alert (com.thinkbiganalytics.servicemonitor.rest.model.ambari.Alert)1 AlertItem (com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertItem)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Connection (javax.jms.Connection)1 JMSException (javax.jms.JMSException)1