Class AdministrativeMonitor
- All Implemented Interfaces:
ExtensionPoint,ModelObject,SearchableModelObject,SearchItem,org.kohsuke.stapler.StaplerProxy
- Direct Known Subclasses:
AdministrativeError,ApiTokenPropertyDisabledDefaultAdministrativeMonitor,ApiTokenPropertyEnabledNewLegacyAdministrativeMonitor,AsynchronousAdministrativeMonitor,BuiltInNodeMigration,CompletedInitializationMonitor,ControllerExecutorsAgents,ControllerExecutorsNoAgents,CSRFAdministrativeMonitor,DoubleLaunchChecker,HsErrPidList,HudsonHomeDiskUsageMonitor,JavaVersionRecommendationAdminMonitor,Jenkins.EnforceSlaveAgentPortAdministrativeMonitor,LegacyApiTokenAdministrativeMonitor,MonitorMarkedNodeOffline,NullIdDescriptorMonitor,OldDataMonitor,OperatingSystemEndOfLifeAdminMonitor,PluginManager.PluginCycleDependenciesMonitor,PluginManager.PluginDeprecationMonitor,PluginManager.PluginUpdateMonitor,PluginWrapper.PluginWrapperAdministrativeMonitor,ResourceDomainRecommendation,ReverseProxySetupMonitor,RootUrlNotSetMonitor,SCMTrigger.AdministrativeMonitorImpl,SecurityIsOffMonitor,SlowTriggerAdminMonitor,TooManyJobsButNoView,UpdateCenter.CoreUpdateMonitor,UpdateSiteWarningsMonitor,URICheckEncodingMonitor
How to implement?
Plugins who wish to contribute such notifications can implement this
class and put Extension on it to register it to Jenkins.
Once installed, it's the implementer's responsibility to perform
monitoring and activate/deactivate the monitor accordingly. Sometimes
this can be done by updating a flag from code (see SCMTrigger
for one such example), while other times it's more convenient to do
so by running some code periodically (for this, use Trigger.timer)
AdministrativeMonitors are bound to URL by Jenkins.getAdministrativeMonitor(String).
See getUrl().
Views
- message.jelly
-
If
isActivated()returns true, Jenkins will use themessage.jellyview of this object to render the warning text. This happens in thehttp://SERVER/jenkins/managepage. This view should typically render a DIV box with class='alert alert-danger' or class='alert alert-warning' with a human-readable text inside it. It often also contains a link to a page that provides more details about the problem.
Additionally 2 numbers are shown in the Jenkins header of administrators, one with the number or active non-security relevant monitors and one with the number of active security relevant monitors.
Use with System Read permission
By default administrative monitors are visible only to users with Administer permission.
Users with Jenkins.SYSTEM_READ permission can access administrative monitors that override getRequiredPermission().
Care needs to be taken to ensure users with that permission don't have access to actions modifying system state.
For more details, see getRequiredPermission().
- Since:
- 1.273
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotected -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<AdministrativeMonitor> all()All registeredAdministrativeMonitorinstances.voidChecks if the current user has the minimum required permission to view this administrative monitor.voiddisable(boolean value) Mark this monitor as disabled, to prevent this from showing up in the UI.voiddoDisable(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) URL binding to disable this monitor.Deprecated.final StringReturns the URL of this item relative to the parentSearchItem.Ensure that URLs in this administrative monitor are only accessible to users withgetRequiredPermission().getUrl()Returns the URL of this monitor, relative to the context path, like "administrativeMonitor/foobar".static booleanChecks if the current user has the minimum required permission to view any administrative monitor.booleanChecks if the current user has the minimum required permission to view this administrative monitor.abstract booleanReturns true if this monitor is activated and wants to produce a warning message.booleanbooleanReturns true if this monitorisn't disabledearlier.booleanReturns true if this monitor is security related.Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.search.SearchItem
getSearchGroup, getSearchIcon
-
Field Details
-
id
Human-readable ID of this monitor, which needs to be unique within the system.This ID is used to remember persisted setting for this monitor, so the ID should remain consistent beyond the Hudson JVM lifespan.
-
-
Constructor Details
-
AdministrativeMonitor
-
AdministrativeMonitor
protected AdministrativeMonitor()
-
-
Method Details
-
getUrl
Returns the URL of this monitor, relative to the context path, like "administrativeMonitor/foobar". -
getDisplayName
- Specified by:
getDisplayNamein interfaceModelObject
-
getSearchUrl
Description copied from interface:SearchItemReturns the URL of this item relative to the parentSearchItem.- Specified by:
getSearchUrlin interfaceSearchItem- Returns:
- URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
-
disable
Mark this monitor as disabled, to prevent this from showing up in the UI.- Throws:
IOException
-
isEnabled
public boolean isEnabled()Returns true if this monitorisn't disabledearlier.This flag implements the ability for the admin to say "no thank you" to the monitor that he wants to ignore.
-
isActivated
public abstract boolean isActivated()Returns true if this monitor is activated and wants to produce a warning message.This method is called from the HTML rendering thread, so it should run efficiently.
-
isActivationFake
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isActivationFake() -
isSecurity
public boolean isSecurity()Returns true if this monitor is security related. This will be used to determine which icon will be used in the navigation bar.- Since:
- 2.267
-
doDisable
public void doDisable(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException URL binding to disable this monitor.- Throws:
IOException
-
getRequiredPermission
Deprecated.Callers should usecheckRequiredPermission()orhasRequiredPermission().Required permission to view this admin monitor. By defaultJenkins.ADMINISTER, butJenkins.SYSTEM_READorJenkins.MANAGEare also supported.Changing this permission check to return
Jenkins.SYSTEM_READwill make the active administrative monitor appear onManageJenkinsActionto users without Administer permission.doDisable(StaplerRequest2, StaplerResponse2)will still always require Administer permission.This method only allows for a single permission to be returned. If more complex permission checks are required, override
checkRequiredPermission()andhasRequiredPermission()instead.Implementers need to ensure that
doActand other web methods perform necessary permission checks: Users with System Read permissions are expected to be limited to read-only access. Form UI elements that change system state, e.g. toggling a feature on or off, need to be hidden from users lacking Administer permission.- Since:
- 2.233
-
checkRequiredPermission
public void checkRequiredPermission()Checks if the current user has the minimum required permission to view this administrative monitor.Subclasses may override this method and
hasRequiredPermission()instead ofgetRequiredPermission()to perform more complex permission checks, for example, checking eitherJenkins.MANAGEorJenkins.SYSTEM_READ.- Since:
- 2.468
- See Also:
-
hasRequiredPermission
public boolean hasRequiredPermission()Checks if the current user has the minimum required permission to view this administrative monitor.Subclasses may override this method and
checkRequiredPermission()instead ofgetRequiredPermission()to perform more complex permission checks, for example, checking eitherJenkins.MANAGEorJenkins.SYSTEM_READ.- Since:
- 2.468
- See Also:
-
hasPermissionToDisplay
public static boolean hasPermissionToDisplay()Checks if the current user has the minimum required permission to view any administrative monitor.- Returns:
- true if the current user has the minimum required permission to view any administrative monitor.
- Since:
- 2.468
-
getTarget
Ensure that URLs in this administrative monitor are only accessible to users withgetRequiredPermission().- Specified by:
getTargetin interfaceorg.kohsuke.stapler.StaplerProxy
-
all
All registeredAdministrativeMonitorinstances.
-
checkRequiredPermission()orhasRequiredPermission().