001package com.pingidentity.ds.log; 002 003import com.unboundid.directory.sdk.common.api.MonitorProvider; 004import com.unboundid.ldap.sdk.Attribute; 005 006import java.util.ArrayList; 007import java.util.List; 008 009/** 010 * This class provides a simple monitoring data provider for the extension. 011 * The information computed is used to provide information about the extension at run time in particular in 012 * cn=monitor 013 */ 014public class S3LogRotationListenerMonitorProvider extends MonitorProvider { 015 016 private final S3LogRotationListener parent; 017 018 /** 019 * A simple constructor that can reference the parent extension to which the instance of the instance 020 * of the monitor provider pertains 021 * @param parent the S3LogRotationListener with which the monitor provider is registered 022 */ 023 S3LogRotationListenerMonitorProvider(S3LogRotationListener parent) { 024 this.parent = parent; 025 } 026 027 /** 028 * Computes the extension name 029 * @return the extension name 030 */ 031 @Override 032 public String getExtensionName() { 033 return "S3LogRotationListenerMonitorProvider"; 034 } 035 036 /** 037 * 038 * @return a list of messages about the extension 039 */ 040 @Override 041 public String[] getExtensionDescription() { 042 return new String[]{"Monitor provider for the S3 Log Rotation Listener"}; 043 } 044 045 /** 046 * This method computes the name of the instance of the monitor provider 047 * It is then used as the CN for the object under cn=monitor and should therefore be unique 048 * @return the name of the instance of the monitor provider 049 */ 050 @Override 051 public String getMonitorInstanceName() { 052 final String suffix = "-monitor"; 053 String name = "default-S3LogRotationListener"; 054 if (parent != null && parent.config != null && parent.config.getConfigObjectName() != null) { 055 name = parent.config.getConfigObjectName(); 056 } 057 return name + suffix; 058 } 059 060 /** 061 * Computes the data to be reported in the monitoring entry 062 * @return a list of attributes with monitoring data for the instance of the monitor provider 063 */ 064 @Override 065 public List<Attribute> getMonitorAttributes() { 066 List<Attribute> result = new ArrayList<>(); 067 result.add(new Attribute("rotated-file-count", 068 parent.rotatedFileCount.toString())); 069 return result; 070 } 071}