Is there a way to get the list of all coldfusion scheduled tasks running on different web servers in same network?
I want to find out the details of scheduled tasks running on 5 or 6 coldfusion web-servers, by just writing a single page on one of them. Is there any way to do it? It might be done by reading cron.xml on all of them.
I came across with following code
<cflock name="alltasks" type="exclusive" timeout="10">
<cfscript>
factory = CreateObject("java","coldfusion.serv开发者_Go百科er.ServiceFactory");
cron_service = factory.CronService;
services = cron_service.listALL();
</cfscript>
This code is good for finding out details for web server on which it will be executed.
I am looking for something similar to this, that will get me details of scheduled tasks running on all web-servers in same network. Thanks!!
You could use the cfschedule tag, and place a page on each server that outputs the scheduled tasks for that machine. You could then use an HTTP request to each server to pick up the tasks it's responsible for and output them to the page on your monitoring server.
<!--- ServerList contains all server's(7,8,9) ipaddress,,, --->
<cfset serverList = 'a.b.c.d, p.q.r.s, ....... , u.v.w.x'>
<cfoutput>
Searched In: #serverList#<br>
<Cfloop list="#serverList#" index="s">
<cfif FileExists('\\#s#\C$\ColdFusion8\lib\neo-cron.xml')>
<cfset pathToFindNeo = '\\#s#\C$\ColdFusion8\lib\neo-cron.xml'>
<cfelseif FileExists('\\#s#\C$\CFusionMX7\lib\neo-cron.xml') >
<cfset pathToFindNeo = '\\#s#\C$\CFusionMX7\lib\neo-cron.xml'>
<cfelseif FileExists('\\#s#\C$\ColdFusion9\lib\neo-cron.xml')>
<cfset pathToFindNeo = '\\#s#\C$\ColdFusion9\lib\neo-cron.xml'>
<cfelseif FileExists('\\#s#\ColdFusion\lib\neo-cron.xml')>
<cfset pathToFindNeo = '\\#s#\ColdFusion\lib\neo-cron.xml'>
<cfelse>
<cfset pathToFindNeo = 0>
</cfif>
<h3>#s# [#pathToFindNeo#]</h3>
<!--- Get the scheduler xml file. It's stored as WDDX in CFroot dir--->
<cfif pathToFindNeo neq 0>
<cffile action="Read" file="#pathToFindNeo#" variable="TaskXML">
<!--- Convert the WDDX to CFML - and array of structs --->
<cfwddx action="WDDX2CFML" input="#TaskXML#" output="GetTasks">
<table border="1" width="100%">
<tr>
<td><strong>Name</strong></td>
<Td><strong>URL</strong></Td>
<td><strong>Interval</strong></td>
<Td><strong>Disabled</strong></Td>
<td><strong>Start Date</strong></td>
<td><strong>Start Time</strong></td>
<td><strong>End Time</strong></td>
<td><strong>Operation</strong></td>
</tr>
<cfloop collection="#GetTasks[1]#" item="key">
<cfif GetTasks[1][key]['disabled'] eq 'NO'>
<tr>
<cfelse>
<tr style="background-color:##CCC">
</cfif>
<td>#key#</td>
<td>#GetTasks[1][key]['url']#</td>
<td>#GetTasks[1][key]['interval']#</td>
<td>#GetTasks[1][key]['disabled']#</td>
<td>#GetTasks[1][key]['start_date']#</td>
<td>#GetTasks[1][key]['start_time']#</td>
<td>
<cfif StructKeyExists(GetTasks[1][key], "end_time")>
#GetTasks[1][key]['end_time']#
<cfelse>
-
</Cfif>
</td>
<td>#GetTasks[1][key]['operation']#</td>
</tr>
</cfloop>
</TABLE>
<CFELSE>
FILE 'neo-cron.xml' NOT FOUND
</cfif>
</Cfloop>
</cfoutput>
What I would probably do is create a cfc on the destination server, that would return the results from the lookup of scheduled tasks into some kind of json, xml, or query that would be available with a set username & password to get the data from 1 server to another, as needed....
The way we take care of this is to add a line to a database table with the URL of the task. If you have all your tasks in the one directory the best way to do this is add the database logging in Application.cfc using the available CGI variables.
This can then be checked against what you expected to run.
Hope that helps!
精彩评论