public void Check(TaskServer server, string taskName) { var msg = new StringBuilder("[Health Check]\n"); { msg.AppendFormat("CPU Temp: {0:F1}\n", GetCpuTemp()); } { List<CpuUsage> cpuUsage = GetCpuUsage(server.CancelToken); // use the total CPU usage only foreach (var usage in cpuUsage.Take(1)) { msg.AppendFormat("{0}:{1:F1}% ", usage.Name, usage.UsagePercent); } msg.Append('\n'); } { double memTotal = 0.0, memFree = 0.0, memAvail = 0.0; GetMemInfoM(ref memTotal, ref memFree, ref memAvail); msg.AppendFormat("Mem: {0:F1}/{1:F1}M Avail ({2:F1}%)\n", memAvail, memTotal, memAvail * 100.0 / memTotal); } { double diskFree, diskTotal; GetDiskInfoG(out diskFree, out diskTotal); msg.AppendFormat("Disk: {0:F1}/{1:F1}G Free ({2:F1}%)\n", diskFree, diskTotal, (int)(diskFree * 100.0 / diskTotal)); } TwitterManager.Update(msg.ToString()); }
static void Main(string[] args) { Log.Trace.TraceEvent(TraceEventType.Information, 0, "Start"); try { int errorRebootCount = 0; string bootMsg = "Boot..."; while (true) { InitializeSystems(); { var taskServer = new TaskServer(MaxTasks, HeartBeatSec); TaskParameter[] tasks = SetupTasks(bootMsg); Log.Trace.TraceEvent(TraceEventType.Information, 0, "Task server start"); ServerResult result = taskServer.Run(tasks); Log.Trace.TraceEvent(TraceEventType.Information, 0, "Task server exit"); bool exit; switch (result) { case ServerResult.Reboot: Log.Trace.TraceEvent(TraceEventType.Information, 0, "Reboot"); exit = false; break; case ServerResult.Shutdown: Log.Trace.TraceEvent(TraceEventType.Information, 0, "Shutdown"); exit = true; break; case ServerResult.ErrorReboot: errorRebootCount++; Log.Trace.TraceEvent(TraceEventType.Information, 0, "Reboot by Error ({0}/{1})", errorRebootCount, MaxErrorReboot); exit = (errorRebootCount >= MaxErrorReboot); break; case ServerResult.FatalShutdown: Log.Trace.TraceEvent(TraceEventType.Information, 0, "Fatal Shutdown"); exit = true; break; default: Trace.Fail("must not reach"); exit = true; break; } if (exit) { break; } } TerminateSystems(); Log.Trace.TraceEvent(TraceEventType.Information, 0, "GC..."); GC.Collect(); Log.Trace.TraceEvent(TraceEventType.Information, 0, "GC complete"); ConfigurationManager.RefreshSection("AppSettings"); bootMsg = "Reboot..."; } } catch (Exception e) { Log.Trace.TraceData(TraceEventType.Critical, 0, e); } Log.Trace.TraceEvent(TraceEventType.Information, 0, "Terminate"); }
public void CheckTwitter(TaskServer server, string taskName) { CheckMasterTimeline(taskName); CheckMentionTimeline(taskName); }