问题
We have a Java application (ESB) that uses quartz 2.2.1 and we use it to schedule hundreds of user jobs.
I want to build monitoring page (or scheduler administration page) in my application for our users so that they can see if quartz scheduler is running fine or there is any issue in this component.
Does quartz provides any monitoring API for this purpose? Can anyone please tell us what all data points should we show in this monitoring (or administration) page based on your experience? Some of the points that I can think of:
- Scheduler Status (Running | Paused | Shutdown).
- Number of jobs running with "Previous Fire Time" and "Next FireTime" information.
- Thread pool implementation and its size.
- JDBCJobStore configuration details.
Is there a way to show the information about triggers that were misfired? I don't see any API that provides me information about misfired triggers. Can anyone tell me how to get this information from scheduler?
Any help in this regard shall be appreciated.
回答1:
You named here many different issues
Scheduler Status(1) :
Scheduler sched =...
sched.isInStandbyMode();
sched.isStarted();
sched.isShutdown();
Number of jobs running with...(2) see here
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
for (String groupName : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
String jobName = jobKey.getName();
String jobGroup = jobKey.getGroup();
//get job's trigger
List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);
Date nextFireTime = triggers.get(0).getNextFireTime();
System.out.println("[jobName] : " + jobName + " [groupName] : "
+ jobGroup + " - " + nextFireTime);
}
}
Thread pool implementation and its size.(3)
Scheduler sched =...
sched.getMetaData().getThreadPoolClass()
sched.getMetaData().getThreadPoolSize()
Regarding "triggers that were misfired", you can use listeners, specifically TriggerListener.html#triggerMisfired may be helpful for you.
来源:https://stackoverflow.com/questions/37690199/quartz-scheduler-administration-page-information-about-misfired-triggers