hudson.model
Class AdministrativeMonitor

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.AdministrativeMonitor
All Implemented Interfaces:
ExtensionPoint, ModelObject, SearchableModelObject, SearchItem
Direct Known Subclasses:
AdministrativeError, HudsonHomeDiskUsageMonitor, MonitorMarkedNodeOffline, OldDataMonitor, ReverseProxySetupMonitor, SCMTrigger.AdministrativeMonitorImpl, TooManyJobsButNoView, UpdateCenter.CoreUpdateMonitor, ZFSInstaller, ZFSInstaller.MigrationCompleteNotice, ZFSInstaller.MigrationFailedNotice

public abstract class AdministrativeMonitor
extends AbstractModelObject
implements ExtensionPoint

Checks the health of a subsystem of Hudson and if there's something that requires administrator's attention, notify the administrator.

How to implement?

Plugins who wish to contribute such notifications can implement this class and put Extension on it to register it to Hudson.

Once installed, it's the implementor'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 Hudson.getAdministrativeMonitor(String). See getUrl().

Views

message.jelly
If isActivated() returns true, Hudson will use the message.jelly view of this object to render the warning text. This happens in the http://SERVER/hudson/manage page. This view should typically render a DIV box with class='error' or class='warning' with a human-readable text inside it. It often also contains a link to a page that provides more details about the problem.

Since:
1.273
Author:
Kohsuke Kawaguchi
See Also:
Hudson.administrativeMonitors

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 String id
          Human-readable ID of this monitor, which needs to be unique within the system.
 
Method Summary
static ExtensionList<AdministrativeMonitor> all()
          All registered AdministrativeMonitor instances.
 void disable(boolean value)
          Mark this monitor as disabled, to prevent this from showing up in the UI.
 void doDisable(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          URL binding to disable this monitor.
 String getDisplayName()
           
 String getSearchUrl()
          Returns the URL of this item relative to the parent SearchItem.
 String getUrl()
          Returns the URL of this monitor, relative to the context path, like "administrativeMonitor/foobar".
abstract  boolean isActivated()
          Returns true if this monitor is activated and wants to produce a warning message.
 boolean isEnabled()
          Returns true if this monitor isn't disabled earlier.
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public final String 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.

Method Detail

getUrl

public String getUrl()
Returns the URL of this monitor, relative to the context path, like "administrativeMonitor/foobar".


getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface ModelObject

getSearchUrl

public final String getSearchUrl()
Description copied from interface: SearchItem
Returns the URL of this item relative to the parent SearchItem.

Specified by:
getSearchUrl in interface SearchItem
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 Hudson.)

disable

public void disable(boolean value)
             throws IOException
Mark this monitor as disabled, to prevent this from showing up in the UI.

Throws:
IOException

isEnabled

public boolean isEnabled()
Returns true if this monitor isn't disabled earlier.

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.


doDisable

public void doDisable(org.kohsuke.stapler.StaplerRequest req,
                      org.kohsuke.stapler.StaplerResponse rsp)
               throws IOException
URL binding to disable this monitor.

Throws:
IOException

all

public static ExtensionList<AdministrativeMonitor> all()
All registered AdministrativeMonitor instances.



Copyright © 2004-2013 Hudson. All Rights Reserved.