Investigating the Visual Cron API
2011
We recently moved a lot of our processes to Visual Cron. This has given us a lot more control over how things run and how we’re notified when things go wrong. It’s also given us a very straightforward .NET API to query Visual Cron itself.
Here’s a simple starter script that enumerates all the active jobs and active tasks and appends the most recent exit code. We use something like this to monitor the tasks themselves and figure out whether any of them are consistently failing.
using System; using System.Linq; using VisualCron; using VisualCronAPI; namespace VisualCronTest { class Program { static void Main(string[] args) { try { ExitCodes.Load(); OutputJobsAndTasks(new Connection() { Address = "VCSERVER01", UserName = "admin", PassWord = "", Port = 16444, ConnectionType = Connection.ConnectionT.Remote }); //Add further Visual Cron server connections here } catch (Exception ex) { Console.WriteLine(ex.Message); } } public static void OutputJobsAndTasks(Connection conn) { var c = new Client() { LogToFile = false }; var s = c.Connect(conn, true); var jobs = s.Jobs.GetAll(); foreach (var j in jobs.Where(j => j.Stats.Active)) { Console.WriteLine("JOB : " + j.Name); foreach (var t in j.Tasks.Where(t => t.Stats.Active)) Console.WriteLine(" TASK : " + t.Name + " - " + t.Stats.ExitCode == 0? "OK" : "ERROR"); } } } }
The only thing I’m personally hating about Visual Cron at the moment is that every time they make a release they break the remote connection API. This is a real pain because you have to recompile everything that was compiled against the previous version. I don’t believe this is down to fundamental API changes, I think it’s something deliberate, but I haven’t had time to investigate exactly what’s going on yet.
Comment