static ShowPropertyCommand() { ProperiesColumns = new ColumnDesign[3]; ProperiesColumns[0] = new ColumnDesign("Name"); ProperiesColumns[1] = new ColumnDesign("Value"); ProperiesColumns[2] = new ColumnDesign("Description"); }
private void ShowFree(NetworkContext context) { // Refresh context.Network.Refresh(); MachineProfile[] machines = context.Network.GetAllMachineProfiles(); if (machines.Length == 0) { Out.WriteLine("No machines in the network."); } else { ColumnDesign[] columns = new ColumnDesign[4]; columns[0] = new ColumnDesign("Machine"); columns[1] = new ColumnDesign("Used Memory"); columns[2] = new ColumnDesign("Used Disk"); columns[3] = new ColumnDesign("Notes"); TableRenderer table = new TableRenderer(columns, Out); foreach (var machine in machines) { ColumnValue[] row = new ColumnValue[4]; if (machine.IsError) { row[3] = new ColumnValue(" ERROR: " + machine.ErrorMessage); } else { row[0] = new ColumnValue(machine.ServiceAddress.ToString()); row[1] = new ColumnValue(MemoryReport(machine.MemoryUsed, machine.MemoryTotal)); row[2] = new ColumnValue(MemoryReport(machine.DiskUsed, machine.DiskTotal)); if (machine.DiskUsed > ((double)machine.DiskTotal * 0.85d)) { row[3] = new ColumnValue(" WARNING: Node is close to full - used storage within 85% of total"); } } table.AddRow(row); } table.CloseTable(); } }
static AliasesCommand() { Columns = new ColumnDesign[2]; Columns[0] = new ColumnDesign("Alias"); Columns[1] = new ColumnDesign("Execute Command"); }
private void ShowStatus(NetworkContext context) { ColumnDesign[] columns = new ColumnDesign[3]; columns[0] = new ColumnDesign("Status"); columns[1] = new ColumnDesign("Service"); columns[2] = new ColumnDesign("Address"); TableRenderer table = new TableRenderer(columns, Out); context.Network.Refresh(); IDictionary <IServiceAddress, ServiceStatus> statusInfo = null; // Manager servers status, MachineProfile[] managers = context.Network.GetManagerServers(); if (managers.Length > 0) { foreach (var manager in managers) { ColumnValue[] row = new ColumnValue[3]; row[0] = new ColumnValue("UP"); row[1] = new ColumnValue("Manager"); row[2] = new ColumnValue(manager.ServiceAddress.ToString()); try { statusInfo = context.Network.GetBlocksStatus(); } catch (NetworkAdminException e) { Error.WriteLine("Error retrieving manager status info: " + e.Message); } table.AddRow(row); } } else { Error.WriteLine("! Manager server not available"); } // Status of root servers MachineProfile[] roots = context.Network.GetRootServers(); if (roots.Length == 0) { Out.WriteLine("! Root servers not available"); } foreach (MachineProfile r in roots) { ColumnValue[] row = new ColumnValue[3]; if (r.IsError) { row[0] = new ColumnValue("DOWN"); } else { row[0] = new ColumnValue("UP"); } row[1] = new ColumnValue("Root"); row[2] = new ColumnValue(r.ServiceAddress.ToString()); if (r.IsError) { Out.Write(" "); Out.WriteLine(r.ErrorMessage); } table.AddRow(row); } // The block servers we fetch from the map, List <IServiceAddress> blocks = new List <IServiceAddress>(); if (statusInfo != null) { foreach (IServiceAddress s in statusInfo.Keys) { blocks.Add(s); } } else { MachineProfile[] sblocks = context.Network.GetBlockServers(); foreach (MachineProfile b in sblocks) { blocks.Add(b.ServiceAddress); } } blocks.Sort(); if (blocks.Count == 0) { Out.WriteLine("! Block servers not available"); } foreach (IServiceAddress b in blocks) { ColumnValue[] row = new ColumnValue[3]; if (statusInfo != null) { ServiceStatus status = statusInfo[b]; if (status == ServiceStatus.Up) { // Manager reported up row[0] = new ColumnValue("UP"); } else if (status == ServiceStatus.DownClientReport) { // Manager reported down from client report of error row[0] = new ColumnValue("D-CR"); } else if (status == ServiceStatus.DownHeartbeat) { // Manager reported down from heart beat check on the server row[0] = new ColumnValue("D-HB"); } else if (status == ServiceStatus.DownShutdown) { // Manager reported down from shut down request row[0] = new ColumnValue("D-SD"); } else { row[0] = new ColumnValue("?ERR"); } } else { // Try and get status from machine profile MachineProfile r = context.Network.GetMachineProfile(b); if (r.IsError) { row[0] = new ColumnValue("DOWN"); } else { row[0] = new ColumnValue("UP"); } } row[1] = new ColumnValue("Block"); row[2] = new ColumnValue(b.ToString()); table.AddRow(row); } table.CloseTable(); }
private void ShowNetwork(NetworkContext context) { int managerCount = 0; int rootCount = 0; int blockCount = 0; ColumnDesign[] columns = new ColumnDesign[2]; columns[0] = new ColumnDesign("MRB"); columns[0].Width = 20; columns[1] = new ColumnDesign("Address"); TableRenderer table = new TableRenderer(columns, Out); context.Network.Refresh(); MachineProfile[] profiles = context.Network.GetAllMachineProfiles(); foreach (MachineProfile p in profiles) { if (p.IsError) { ColumnValue[] row = new ColumnValue[2]; row[0] = new ColumnValue(p.ErrorMessage); row[1] = new ColumnValue(p.ServiceAddress.ToString()); table.AddRow(row); } else { string mrb = String.Empty; mrb += p.IsManager ? "M" : "."; mrb += p.IsRoot ? "R" : "."; mrb += p.IsBlock ? "B" : "."; ColumnValue[] row = new ColumnValue[2]; row[0] = new ColumnValue(mrb); row[1] = new ColumnValue(p.ServiceAddress.ToString()); table.AddRow(row); managerCount += p.IsManager ? 1 : 0; rootCount += p.IsRoot ? 1 : 0; blockCount += p.IsBlock ? 1 : 0; } } table.CloseTable(); Out.WriteLine(); if (profiles.Length == 1) { Out.WriteLine("one machine in the network."); } else { Out.WriteLine(profiles.Length + " machines in the network."); } if (managerCount == 0) { Out.Write("none manager"); } else if (managerCount == 1) { Out.Write("one manager"); } else { Out.Write(managerCount + " managers"); } Out.Write(", "); if (rootCount == 0) { Out.Write("none root"); } else if (rootCount == 1) { Out.Write("one root"); } else { Out.Write(rootCount + " roots"); } Out.Write(", "); if (blockCount == 0) { Out.Write("none block"); } else if (blockCount == 1) { Out.Write("one block"); } else { Out.Write(blockCount + " blocks"); } Out.WriteLine(); }
static VariablesCommand() { VarColumns = new ColumnDesign[2]; VarColumns[0] = new ColumnDesign("Variable"); VarColumns[1] = new ColumnDesign("Value"); }
private void btn_oprn_report_Click(object sender, EventArgs e) { DataGridView dgv = dgv_columns; int r = -1; if (dgv.SelectedCells.Count == 0) { return; } List <int> list_rows = new List <int>(); int i = 0; bool fl = false; for (i = 0; i < dgv.RowCount; i++) { fl = (bool)dgv[0, i].Value; if (fl) { list_rows.Add(i); } } list_rows.Sort(); string f = ""; List <string> list = new List <string>(); list.AddRange(ColumnDesign.Get_Banner()); foreach (var item in list_rows) { r = item; f = col_design.Get_Report_File(r + 1); if (File.Exists(f)) { list.AddRange(File.ReadAllLines(f)); } else { MessageBox.Show(this, string.Format("Design is not done for the selected Staircase {0}.", dgv[1, r].Value)); } } if (list.Count > 0) { File.WriteAllLines(col_design.Report_File, list.ToArray()); f = col_design.Report_File; if (File.Exists(f)) { frmASTRAReport.OpenReport(f, this); } else { MessageBox.Show(this, "Design is not done for the selected Staircase(s)."); } } }