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());
}
}
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);
}
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);
}
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);
}
}
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);
}
Aggregations