Search in sources :

Example 1 with PwmAboutProperty

use of password.pwm.PwmAboutProperty in project pwm by pwm-project.

the class DatabaseService method updateDebugProperties.

private void updateDebugProperties(final Connection connection) {
    if (connection != null) {
        try {
            final Map<PwmAboutProperty, String> returnObj = new LinkedHashMap<>();
            final DatabaseMetaData databaseMetaData = connection.getMetaData();
            returnObj.put(PwmAboutProperty.database_driverName, databaseMetaData.getDriverName());
            returnObj.put(PwmAboutProperty.database_driverVersion, databaseMetaData.getDriverVersion());
            returnObj.put(PwmAboutProperty.database_databaseProductName, databaseMetaData.getDatabaseProductName());
            returnObj.put(PwmAboutProperty.database_databaseProductVersion, databaseMetaData.getDatabaseProductVersion());
            debugInfo.clear();
            debugInfo.putAll(Collections.unmodifiableMap(returnObj));
        } catch (SQLException e) {
            LOGGER.error("error reading jdbc meta data: " + e.getMessage());
        }
    }
}
Also used : PwmAboutProperty(password.pwm.PwmAboutProperty) SQLException(java.sql.SQLException) DatabaseMetaData(java.sql.DatabaseMetaData) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with PwmAboutProperty

use of password.pwm.PwmAboutProperty in project pwm by pwm-project.

the class AppDashboardData method makeAboutJavaData.

private static List<DisplayElement> makeAboutJavaData(final PwmApplication pwmApplication, final Locale locale) {
    final Map<PwmAboutProperty, String> aboutMap = PwmAboutProperty.makeInfoBean(pwmApplication);
    final List<DisplayElement> javaInfo = new ArrayList<>();
    final String notApplicable = Display.getLocalizedMessage(locale, Display.Value_NotApplicable, pwmApplication.getConfig());
    {
        final List<PwmAboutProperty> interestedProperties = Arrays.asList(PwmAboutProperty.java_vmName, PwmAboutProperty.java_vmVendor, PwmAboutProperty.java_vmVersion, PwmAboutProperty.java_runtimeVersion, PwmAboutProperty.java_vmLocation, PwmAboutProperty.java_appServerInfo, PwmAboutProperty.java_osName, PwmAboutProperty.java_osVersion, PwmAboutProperty.java_osArch, PwmAboutProperty.java_memoryFree, PwmAboutProperty.java_memoryAllocated, PwmAboutProperty.java_memoryMax, PwmAboutProperty.java_threadCount);
        for (final PwmAboutProperty property : interestedProperties) {
            javaInfo.add(new DisplayElement(property.name(), DisplayElement.Type.string, property.getLabel(), aboutMap.getOrDefault(property, notApplicable)));
        }
    }
    {
        final PwmNumberFormat numberFormat = PwmNumberFormat.forLocale(locale);
        final String display = numberFormat.format(pwmApplication.getResourceServletService().itemsInCache()) + "items (" + numberFormat.format(pwmApplication.getResourceServletService().bytesInCache()) + " bytes)";
        javaInfo.add(new DisplayElement("resourceFileServletCacheSize", DisplayElement.Type.string, "ResourceFileServlet Cache", display));
    }
    javaInfo.add(new DisplayElement("resourceFileServletCacheHitRatio", DisplayElement.Type.string, "ResourceFileServlet Cache Hit Ratio", pwmApplication.getResourceServletService().cacheHitRatio().pretty(2)));
    {
        final Map<SessionTrackService.DebugKey, String> debugInfoMap = pwmApplication.getSessionTrackService().getDebugData();
        javaInfo.add(new DisplayElement("sessionTotalSize", DisplayElement.Type.string, "Estimated Session Total Size", debugInfoMap.get(SessionTrackService.DebugKey.HttpSessionTotalSize)));
        javaInfo.add(new DisplayElement("sessionAverageSize", DisplayElement.Type.string, "Estimated Session Average Size", debugInfoMap.get(SessionTrackService.DebugKey.HttpSessionAvgSize)));
    }
    return Collections.unmodifiableList(javaInfo);
}
Also used : PwmAboutProperty(password.pwm.PwmAboutProperty) PwmNumberFormat(password.pwm.util.java.PwmNumberFormat) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DisplayElement(password.pwm.http.bean.DisplayElement) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SessionTrackService(password.pwm.svc.sessiontrack.SessionTrackService)

Example 3 with PwmAboutProperty

use of password.pwm.PwmAboutProperty in project pwm by pwm-project.

the class TelemetryService method generatePublishableBean.

public TelemetryPublishBean generatePublishableBean() throws URISyntaxException, IOException, PwmUnrecoverableException {
    final StatisticsBundle bundle = pwmApplication.getStatisticsManager().getStatBundleForKey(StatisticsManager.KEY_CUMULATIVE);
    final Configuration config = pwmApplication.getConfig();
    final Map<PwmAboutProperty, String> aboutPropertyStringMap = PwmAboutProperty.makeInfoBean(pwmApplication);
    final Map<String, String> statData = new TreeMap<>();
    for (final Statistic loopStat : Statistic.values()) {
        statData.put(loopStat.getKey(), bundle.getStatistic(loopStat));
    }
    final List<String> configuredSettings = new ArrayList<>();
    for (final PwmSetting pwmSetting : config.nonDefaultSettings()) {
        if (!pwmSetting.getCategory().hasProfiles() && !config.isDefaultValue(pwmSetting)) {
            configuredSettings.add(pwmSetting.getKey());
        }
    }
    String ldapVendorName = null;
    for (final LdapProfile ldapProfile : config.getLdapProfiles().values()) {
        if (ldapVendorName == null) {
            try {
                final DirectoryVendor directoryVendor = ldapProfile.getProxyChaiProvider(pwmApplication).getDirectoryVendor();
                final PwmLdapVendor pwmLdapVendor = PwmLdapVendor.fromChaiVendor(directoryVendor);
                if (pwmLdapVendor != null) {
                    ldapVendorName = pwmLdapVendor.name();
                }
            } catch (Exception e) {
                LOGGER.trace(SessionLabel.TELEMETRY_SESSION_LABEL, "unable to read ldap vendor type for stats publication: " + e.getMessage());
            }
        }
    }
    final Map<String, String> aboutStrings = new TreeMap<>();
    {
        for (final Map.Entry<PwmAboutProperty, String> entry : aboutPropertyStringMap.entrySet()) {
            final PwmAboutProperty pwmAboutProperty = entry.getKey();
            aboutStrings.put(pwmAboutProperty.name(), entry.getValue());
        }
        aboutStrings.remove(PwmAboutProperty.app_instanceID.name());
        aboutStrings.remove(PwmAboutProperty.app_siteUrl.name());
    }
    final TelemetryPublishBean.TelemetryPublishBeanBuilder builder = TelemetryPublishBean.builder();
    builder.timestamp(Instant.now());
    builder.id(makeId(pwmApplication));
    builder.instanceHash(pwmApplication.getSecureService().hash(pwmApplication.getInstanceID()));
    builder.installTime(pwmApplication.getInstallTime());
    builder.siteDescription(config.readSettingAsString(PwmSetting.PUBLISH_STATS_SITE_DESCRIPTION));
    builder.versionBuild(PwmConstants.BUILD_NUMBER);
    builder.versionVersion(PwmConstants.BUILD_VERSION);
    builder.ldapVendorName(ldapVendorName);
    builder.statistics(Collections.unmodifiableMap(statData));
    builder.configuredSettings(Collections.unmodifiableList(configuredSettings));
    builder.about(aboutStrings);
    return builder.build();
}
Also used : Configuration(password.pwm.config.Configuration) ArrayList(java.util.ArrayList) PwmLdapVendor(password.pwm.ldap.PwmLdapVendor) TreeMap(java.util.TreeMap) LdapProfile(password.pwm.config.profile.LdapProfile) URISyntaxException(java.net.URISyntaxException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException) PwmSetting(password.pwm.config.PwmSetting) PwmAboutProperty(password.pwm.PwmAboutProperty) StatisticsBundle(password.pwm.svc.stats.StatisticsBundle) Statistic(password.pwm.svc.stats.Statistic) DirectoryVendor(com.novell.ldapchai.provider.DirectoryVendor) TelemetryPublishBean(password.pwm.bean.TelemetryPublishBean)

Example 4 with PwmAboutProperty

use of password.pwm.PwmAboutProperty in project pwm by pwm-project.

the class DatabaseService method serviceInfo.

@Override
public ServiceInfoBean serviceInfo() {
    final Map<String, String> debugProperties = new LinkedHashMap<>();
    for (final Map.Entry<PwmAboutProperty, String> entry : debugInfo.entrySet()) {
        final PwmAboutProperty pwmAboutProperty = entry.getKey();
        debugProperties.put(pwmAboutProperty.name(), entry.getValue());
    }
    if (status() == STATUS.OPEN) {
        return new ServiceInfoBean(Collections.singletonList(DataStorageMethod.DB), debugProperties);
    } else {
        return new ServiceInfoBean(Collections.emptyList(), debugProperties);
    }
}
Also used : PwmAboutProperty(password.pwm.PwmAboutProperty) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

PwmAboutProperty (password.pwm.PwmAboutProperty)4 LinkedHashMap (java.util.LinkedHashMap)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 DirectoryVendor (com.novell.ldapchai.provider.DirectoryVendor)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TelemetryPublishBean (password.pwm.bean.TelemetryPublishBean)1 Configuration (password.pwm.config.Configuration)1 PwmSetting (password.pwm.config.PwmSetting)1 LdapProfile (password.pwm.config.profile.LdapProfile)1 PwmException (password.pwm.error.PwmException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 DisplayElement (password.pwm.http.bean.DisplayElement)1