Search in sources :

Example 16 with HBData

use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.

the class SessionsUsageDataCollectorTest method testHBDataFields.

@Test
public void testHBDataFields() {
    for (HBData data : this.collectedData) {
        assertNotNull(data.getCollectorId());
        assertNotNull(data.getCollectorVersion());
        assertNotNull(data.getSchemaVersion());
        assertNotNull(data.getSystemId());
        assertNotNull(data.getTimestamp());
    }
}
Also used : HBData(org.alfresco.heartbeat.datasender.HBData) Test(org.junit.Test)

Example 17 with HBData

use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.

the class ConfigurationDataCollector method collectData.

@Override
public List<HBData> collectData() {
    // Collect repository configuration data
    logger.debug("Preparing repository configuration data...");
    Map<String, Object> configurationValues = new HashMap<>();
    configurationValues.put("smartFoldersEnabled", smartFoldersBundle.isEnabled());
    boolean readOnly = transactionService.getRetryingTransactionHelper().doInTransaction(() -> repoUsageComponent.getUsage().isReadOnly(), true);
    configurationValues.put("serverReadOnly", readOnly);
    configurationValues.put("serverMode", serverModeProvider.getServerMode().toString());
    boolean ftpEnabled = Boolean.valueOf(fileServersSubsystem.getProperty("ftp.enabled"));
    configurationValues.put("ftpEnabled", ftpEnabled);
    configurationValues.put("webDAVEnabled", webdavService.getEnabled());
    configurationValues.put("thumbnailsEnabled", thumbnailService.getThumbnailsEnabled());
    boolean activitiesFeedEnabled = Boolean.valueOf(activitiesFeedSubsystem.getProperty("activities.feed.notifier.enabled"));
    configurationValues.put("activitiesFeedEnabled", activitiesFeedEnabled);
    configurationValues.put("activitiEngineEnabled", workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID));
    boolean inboundEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.inbound.enabled"));
    boolean emailServerEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.server.enabled"));
    boolean inboundServerEnabled = inboundEnabled && emailServerEnabled;
    configurationValues.put("inboundServerEnabled", inboundServerEnabled);
    boolean imapEnabled = Boolean.valueOf(imapSubsystem.getProperty("imap.server.enabled"));
    configurationValues.put("imapEnabled", imapEnabled);
    Map<String, Object> replicationInfo = new HashMap<>();
    replicationInfo.put("enabled", replicationSubsystem.getProperty("replication.enabled"));
    replicationInfo.put("readOnly", replicationSubsystem.getProperty("replication.transfer.readonly"));
    configurationValues.put("replication", replicationInfo);
    if (dataSource instanceof BasicDataSource) {
        Map<String, Object> db = new HashMap<>();
        db.put("maxConnections", ((BasicDataSource) dataSource).getMaxActive());
        configurationValues.put("db", db);
    }
    // Modules information
    List<ModuleDetails> rawInstalledModules = moduleService.getAllModules();
    Map<String, Object> modules = new HashMap<>();
    Map<String, Object> installedModules = new HashMap<>();
    installedModules.put("count", rawInstalledModules.size());
    Map<String, Object> installedModulesList = new HashMap<>();
    for (ModuleDetails md : rawInstalledModules) {
        Map<String, Object> moduleInfo = new HashMap<>();
        moduleInfo.put("version", md.getModuleVersionNumber().toString());
        installedModulesList.put(md.getId(), moduleInfo);
    }
    if (!installedModulesList.isEmpty()) {
        installedModules.put("modules", installedModulesList);
    }
    modules.put("installed", installedModules);
    // Missing modules information
    List<ModuleDetails> rawMissingModules = getMissingModules();
    Map<String, Object> missingModules = new HashMap<>();
    Map<String, Object> missingModulesList = new HashMap<>();
    for (ModuleDetails md : rawMissingModules) {
        Map<String, Object> moduleInfo = new HashMap<>();
        moduleInfo.put("version", md.getModuleVersionNumber().toString());
        missingModulesList.put(md.getId(), moduleInfo);
    }
    if (!missingModulesList.isEmpty()) {
        missingModules.put("modules", missingModulesList);
        modules.put("missing", missingModules);
    }
    configurationValues.put("module", modules);
    // Audit information
    Map<String, Object> audit = new HashMap<>();
    audit.put("enabled", auditService.isAuditEnabled());
    Map<String, Object> auditAppList = new HashMap<>();
    Map<String, AuditService.AuditApplication> rawAppList = transactionService.getRetryingTransactionHelper().doInTransaction(() -> auditService.getAuditApplications(), true);
    for (Map.Entry<String, AuditService.AuditApplication> entry : rawAppList.entrySet()) {
        AuditService.AuditApplication app = entry.getValue();
        Map<String, Object> appInfo = new HashMap<>();
        appInfo.put("enabled", app.isEnabled());
        // replace spaces with hyphens
        String appName = entry.getKey().replace(" ", "-");
        auditAppList.put(appName, appInfo);
    }
    if (!auditAppList.isEmpty()) {
        audit.put("apps", auditAppList);
    }
    configurationValues.put("audit", audit);
    // Authentication chain
    String chainString = authenticationSubsystem.getProperty("chain");
    configurationValues.put("authenticationChain", chainString);
    HBData configurationData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), configurationValues);
    return Arrays.asList(configurationData);
}
Also used : HashMap(java.util.HashMap) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Date(java.util.Date) HBData(org.alfresco.heartbeat.datasender.HBData) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) HashMap(java.util.HashMap) Map(java.util.Map) AuditService(org.alfresco.service.cmr.audit.AuditService)

Example 18 with HBData

use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.

the class ModelUsageDataCollector method collectData.

@Override
public List<HBData> collectData() {
    logger.debug("Preparing repository usage (model) data...");
    final CustomModelsInfo customModelsInfo = transactionService.getRetryingTransactionHelper().doInTransaction(() -> customModelService.getCustomModelsInfo(), true);
    Map<String, Object> modelUsageValues = new HashMap<>();
    modelUsageValues.put("numOfActiveModels", new Integer(customModelsInfo.getNumberOfActiveModels()));
    modelUsageValues.put("numOfActiveTypes", new Integer(customModelsInfo.getNumberOfActiveTypes()));
    modelUsageValues.put("numOfActiveAspects", new Integer(customModelsInfo.getNumberOfActiveAspects()));
    HBData modelUsageData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), modelUsageValues);
    return Arrays.asList(modelUsageData);
}
Also used : CustomModelsInfo(org.alfresco.repo.dictionary.CustomModelsInfo) HBData(org.alfresco.heartbeat.datasender.HBData)

Example 19 with HBData

use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.

the class NonLockingJob method execute.

@Override
public void execute(final JobExecutionContext jobExecutionContext) throws JobExecutionException {
    final JobDataMap dataMap = jobExecutionContext.getJobDetail().getJobDataMap();
    final HBBaseDataCollector collector = (HBBaseDataCollector) dataMap.get(COLLECTOR_KEY);
    final HBDataSenderService hbDataSenderService = (HBDataSenderService) dataMap.get(DATA_SENDER_SERVICE_KEY);
    ParameterCheck.mandatory(COLLECTOR_KEY, collector);
    ParameterCheck.mandatory(DATA_SENDER_SERVICE_KEY, hbDataSenderService);
    try {
        List<HBData> data = collector.collectData();
        hbDataSenderService.sendData(data);
        if (logger.isDebugEnabled()) {
            logger.debug("Finished collector job. ID:" + collector.getCollectorId());
        }
    } catch (final Exception e) {
        // Log the error but don't rethrow, collector errors are non fatal
        logger.error("Heartbeat failed to collect data for collector ID: " + collector.getCollectorId(), e);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) HBDataSenderService(org.alfresco.heartbeat.datasender.HBDataSenderService) HBBaseDataCollector(org.alfresco.heartbeat.HBBaseDataCollector) HBData(org.alfresco.heartbeat.datasender.HBData) JobExecutionException(org.quartz.JobExecutionException)

Example 20 with HBData

use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.

the class InfoDataCollector method collectData.

@Override
public List<HBData> collectData() {
    logger.debug("Preparing repository info data...");
    final Descriptor serverDescriptor = this.serverDescriptorDAO.getDescriptor();
    Map<String, Object> infoValues = new HashMap<>();
    infoValues.put("repoName", serverDescriptor.getName());
    Map<String, Object> version = new HashMap<>();
    version.put("full", serverDescriptor.getVersion());
    version.put("servicePack", serverDescriptor.getVersionMajor() + "." + serverDescriptor.getVersionMinor());
    version.put("major", serverDescriptor.getVersionMajor());
    version.put("minor", serverDescriptor.getVersionMinor());
    version.put("patch", serverDescriptor.getVersionRevision());
    version.put("build", serverDescriptor.getVersionBuild());
    String hotfix = serverDescriptor.getVersionLabel();
    if (hotfix != null && hotfix.length() > 0) {
        version.put("hotfix", hotfix.startsWith(".") ? hotfix.substring(1) : hotfix);
    }
    infoValues.put("version", version);
    infoValues.put("schema", new Integer(serverDescriptor.getSchema()));
    infoValues.put("edition", serverDescriptor.getEdition());
    infoValues.put("deploymentMethod", deploymentMethodProvider.getDeploymentMethod().toString());
    infoValues.put("osVendor", System.getProperty("os.name"));
    infoValues.put("osVersion", System.getProperty("os.version"));
    infoValues.put("osArch", System.getProperty("os.arch"));
    infoValues.put("javaVendor", System.getProperty("java.vendor"));
    infoValues.put("javaVersion", System.getProperty("java.version"));
    infoValues.put("userLanguage", Locale.getDefault().getLanguage());
    infoValues.put("userTimezone", TimeZone.getDefault().getID());
    infoValues.put("userUTCOffset", OffsetDateTime.now().getOffset().getId().replaceAll("Z", "+00.00"));
    if (servletContext != null) {
        infoValues.put("serverInfo", servletContext.getServerInfo());
    } else
        infoValues.put("serverInfo", null);
    try (Connection con = dataSource.getConnection()) {
        DatabaseMetaData dbmeta = con.getMetaData();
        Map<String, Object> db = new HashMap<>();
        db.put("vendor", dbmeta.getDatabaseProductName());
        db.put("version", dbmeta.getDatabaseProductVersion());
        db.put("driverName", dbmeta.getDriverName());
        db.put("driverVersion", dbmeta.getDriverVersion());
        infoValues.put("db", db);
    } catch (SQLException e) {
    // No need to log exception if the data cannot be retrieved
    }
    HBData infoData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), infoValues);
    return Arrays.asList(infoData);
}
Also used : HashMap(java.util.HashMap) SQLException(java.sql.SQLException) Connection(java.sql.Connection) Descriptor(org.alfresco.service.descriptor.Descriptor) HBData(org.alfresco.heartbeat.datasender.HBData) DatabaseMetaData(java.sql.DatabaseMetaData) Date(java.util.Date)

Aggregations

HBData (org.alfresco.heartbeat.datasender.HBData)24 Test (org.junit.Test)16 Map (java.util.Map)7 Date (java.util.Date)5 HashMap (java.util.HashMap)5 OperatingSystemMXBean (com.sun.management.OperatingSystemMXBean)2 UnixOperatingSystemMXBean (com.sun.management.UnixOperatingSystemMXBean)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HBBaseDataCollector (org.alfresco.heartbeat.HBBaseDataCollector)1 HBDataSenderService (org.alfresco.heartbeat.datasender.HBDataSenderService)1 CustomModelsInfo (org.alfresco.repo.dictionary.CustomModelsInfo)1 ThumbnailDefinition (org.alfresco.repo.thumbnail.ThumbnailDefinition)1 AuditService (org.alfresco.service.cmr.audit.AuditService)1 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)1