├── instructions_install-dependencies-for-balance.md ├── README.md ├── sample-config.txt ├── charts.ps1 ├── data.ps1 └── nats_io.ps1 /instructions_install-dependencies-for-balance.md: -------------------------------------------------------------------------------- 1 | Instructions for Windows OS: 2 | - open powershell session 3 | - type winget install nodejs and press enter 4 | - close powershell session 5 | - open a new powershell session 6 | - type npm install @polkadot/api and press enter 7 | - close powershell session 8 | 9 | Note: powershell session is needed by default to use wallet balance feature, To enable windows command use follow steps below: 10 | 11 | > Verify the PATH Environment Variable: 12 | - Open System Properties: Right-click on This PC (or Computer), and select Properties. 13 | - Advanced System Settings: In the left-hand menu, click on Advanced system settings. 14 | - Environment Variables: In the System Properties window, click Environment Variables. 15 | > Edit PATH: 16 | - In the System variables section, scroll down and find the Path variable. Click on Edit. 17 | - Make sure the path C:\Program Files\nodejs\ is included in the list of paths. If it's not, add it by clicking New and typing C:\Program Files\nodejs\. 18 | - Restart Command Prompt: After updating the PATH, close and reopen Command Prompt for the changes to take effect. 19 | 20 | Instructions for Linux OS: 21 | open shell and type following command(s) and press enter 22 | - sudo apt install nodejs -y && sudo apt install npm -y && npm install @polkadot/api 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Autonomys monitoring powershell script 2 | A simple to run and lightweight powershell script that captures live information using prometheus metrics endpoint. 3 | 4 | To use the monitor: 5 | - save all files from latest monitor release in a folder on local computer 6 | - copy contents of sample-config.txt to a new file and save it in the same folder. Name the new file as config.txt 7 | - adjust config.txt to match your node, farmer and (optional) cluster set-up [refer to **Requirements:** section below] 8 | - run subspace_advanced_CLI_monitor.ps1 file in powershell 9 | 10 | 11 | 12 | > Note: If you recently restarted Farmer please wait for few minutes and the metrics will show eventually 13 | > - Tip: Validate prometheus-listen-on endpoints defined in node & farmer start-up files are working correctly, use a web browser and check data is populated at endpoints - http://node-local-ip:port/metrics & http://farmer-local-ip:port/metrics 14 | 15 | **Requirements:** 16 | - must use latest CLI release (see https://github.com/autonomys/subspace/releases) 17 | - powershell is installed (Windows should have powershell pre-installed. For installing powershell on linux see https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.4) 18 | - To use wallet balance and/or enhanced node data display feature, see steps outlined in [instructions_install-dependencies-for-balance.md](https://github.com/irbujam/ss_log_event_monitor/blob/main/instructions_install-dependencies-for-balance.md) 19 | - add --prometheus-listen-on [node-local-ip:port] to node start-up script 20 | - add --prometheus-listen-on [farmer-local-ip:port] to farmer start-up script 21 | - change node/farmer settings in the config.txt file so that the ip:port are matching to the values set for --prometheus-listen-on your node and farmer 22 | 23 | > If using cluster, apply additional settings as below: 24 | - add command line options -m and -n to nats-server start-up script (example: nats-server -n my-nats-server1 -m 18080 -c nats.config) 25 | - change nats-server settings in the config.txt file so that the ip matches to the computer running nats-server and port matches to 'http listener port' as in option scpecified for -m in the nats-server start-up script 26 | 27 | > To enable web access, do the following: 28 | > - enable api in config file 29 | > - ensure to create an inbound rule under windows defender firewall for http listening port as specified in the config file. This must be done on the computer that hosts ps1 script 30 | > - must run the ps1 file as admin in powershell console 31 | > - the endpoint to use is http://ip:port/summary 32 | > - 33 | 34 | 35 | **Key features:** 36 | - monitoring support for multi component (remote or local) nodes, farmer and (optional) cluster set-up, using prometheus metrics endpoints 37 | - monitor script can run independently on a pc separate from cluster/farms/nodes hosted pc 38 | - multi OS (Windows and Linux) support for running the monitoring tool 39 | - web service enabled to view stats using a web browser on phone/ pc or as a second screen to legacy monitor console display 40 | - run-time changes to config.txt reflected in monitor 41 | - customizable alerts enabled for discord and telegram 42 | - Configurable summary and detail stats view at start-up 43 | - local Time Zone display 44 | 45 | >*** Use at your own risk. For questions and feedback please contact (rs_00) in autonomys discord channel. 46 | 47 | -------------------------------------------------------------------------------- /sample-config.txt: -------------------------------------------------------------------------------- 1 | #### start of config file 2 | #### sample config below contains user defined environment values 3 | #### '#' in front of the line indicates a comment line and is just there for readability and can be deleted 4 | #### please stick to using below format 5 | # 6 | #-----------------------------------------------------[Optional]---------------------------------------------------------- 7 | # Display wallet balance/rank - This option is 'off' by default 8 | # 9 | # - To use this feature install dependenncies as outlined in instructions_install-dependencies-for-balance.md 10 | # 11 | # To see balance: 12 | # - Provide a valid wallet address against "wallet-address :" and uncomment the line 13 | # - For multi-wallet, save all the addresses in a separate text file with each address separated by space. Name 14 | # the address file as .txt, where can be any file name. For example vlt_addr.txt 15 | # - Use either wallet file name OR a single wallet address. Both can not be used at the same time 16 | # 17 | # Refresh interval: balance is set to refresh hourly (3600 seconds) by default, change to suit your needs 18 | # 19 | # Rank: This option is a separate add-on and is 'off' by default 20 | # - Change value to Y against "show-rank :" and uncomment the line 21 | # - If turned on, rank will refresh every 12 hours plus the duration set for balance refresh interval 22 | # 23 | # ************************************************************************** 24 | # [Rank refresh ships with a fixed non-configurable value for reasons below] 25 | # ************************************************************************** 26 | # 27 | # - If turned on initial load run will take a few (~3 to 5) minutes as all account data is read from chain. 28 | # Subsequent in-between refresh loads should be faster 29 | # 30 | #------------------------------------------------------------------------------------------------------------------------- 31 | 32 | #wallet-address : 33 | #wallet-address : 34 | balance-refresh (seconds) : 3600 35 | #Show-Rank : N 36 | rpc-node-url : wss://rpc.mainnet.subspace.foundation/ws 37 | 38 | #------------------------------------------------------ [Earnings] ------------------------------------------------------- 39 | # block speed - avg chain block production rate for single block (used to skip over days for earnings calculations) 40 | # - defaults to 6.5 if not provided 41 | # 42 | # disable earnings - completely disbale earnings calculation and display 43 | #------------------------------------------------------------------------------------------------------------------------- 44 | 45 | block-speed (seconds) : 6.5 46 | earning-accuracy (blocks/ minute) : 10 47 | # disable-Earnings : Y 48 | 49 | #-----------------------------------------------------[Optional]---------------------------------------------------------- 50 | # Local node synced block height v/s highest block height display - This option is 'off' by default unless uncommented 51 | # 52 | # - To use this feature install dependenncies as outlined in instructions_install-dependencies-for-balance.md 53 | #------------------------------------------------------------------------------------------------------------------------- 54 | 55 | #local-node-rpc-port : 9944 56 | 57 | #------------------------------------------------------------------------------------------------------------------------- 58 | # http endpoint set-up (use Y-enabled, N-disabled for enable-api setting). "N" is default 59 | # 60 | # You can use either localhost or an IP 61 | # If using an IP please ensure to create an inbound rule under windows defender firewall, on computer hosting the ps1 script, 62 | # for the specified listening port and that the port is not in use 63 | # 64 | # API endpoint to use on web browser http://ip:port/summary (example http://127.0.0.1:5004/summary) 65 | #------------------------------------------------------------------------------------------------------------------------- 66 | 67 | Enable-API: N 68 | 69 | API-host: 127.0.0.1:5004 70 | #API-host: 192.168.2.251:5004 71 | 72 | #------------------------------------------------------------------------------------------------------------------------- 73 | # discord webhook / Telegram bot api-token - change to use your own 74 | # Set alert repeat frequency, the value will default to auto-refresh time if not set or a lower value is provided 75 | #------------------------------------------------------------------------------------------------------------------------- 76 | 77 | Discord-url : https://discord.com/api/webhooks/0000000000000000000/1AAAA................ 78 | 79 | Telegram-api-token: 1234567890:UUUUUUUUUUUUUUUU..... 80 | Telegram-chat-id: 1010000000 81 | 82 | Alert-frequency(seconds) : 3600 83 | 84 | #-----------------------------------------------------[Optional]---------------------------------------------------------- 85 | # Customizable alert notification generation for individual components 86 | # 87 | # To generate individual alerts, set values as shown in example below against "send-an-alert :" and uncomment the line 88 | # - alerts for node and farmer only, set value to 'node, farmer' 89 | # - alerts for all cluster components only set value to 'Cluster' 90 | # - alerts for node, farmer, nats and controller only set value to 'farmer, node, controller, nats' 91 | # - alerts for nothing set value to 'none' 92 | # 93 | # the default value is preset to: 'all' and alerts will be sent for everything 94 | #------------------------------------------------------------------------------------------------------------------------- 95 | 96 | # Send-an-Alert : all 97 | 98 | #------------------------------------------------------------------------------------------------------------------------- 99 | ## adjust console screen refresh time as apppropriate (if 0 is provided the value will default to 30 seconds) 100 | ## Recommended value: 90 seconds or lower 101 | #------------------------------------------------------------------------------------------------------------------------- 102 | 103 | Auto-refresh(seconds) : 60 104 | 105 | #------------------------------------------------------------------------------------------------------------------------- 106 | ## adjust screen view at start-up (S-Summary, D-Detail). "S" is default 107 | #------------------------------------------------------------------------------------------------------------------------- 108 | 109 | Start-up-View (S/D) : S 110 | 111 | #------------------------------------------------------------------------------------------------------------------------- 112 | ## insert a new line for each nats server like shown in sample below 113 | ## change IP and port to match your nats server set-up 114 | ## 115 | # 116 | # Tip: you can add or remove a line for nats server while the script is running and the updates will show in next refresh 117 | #------------------------------------------------------------------------------------------------------------------------- 118 | 119 | ## comment below line(s) if not using cluster 120 | Nats-server: 192.168.2.203:8080 121 | 122 | #------------------------------------------------------------------------------------------------------------------------- 123 | ## insert a new line for each node like shown in sample below 124 | ## change IP and port to match your node set-up 125 | ## 126 | ## Since the script is 100% endpoint based and does not require special permission to get hostname, 127 | ## you can set up a one time friendly name to show instead of IP should you prefer 128 | # 129 | # Tip: you can add or remove a line for node while the script is running and the updates will show in next refresh 130 | #------------------------------------------------------------------------------------------------------------------------- 131 | 132 | Node: 192.168.2.203:9191 :pc1 133 | 134 | #------------------------------------------------------------------------------------------------------------------------- 135 | ## adjust display for size unit - TiB (TibiByte) or TB (Terabyte), TiB is default 136 | #------------------------------------------------------------------------------------------------------------------------- 137 | 138 | size-display-unit : TiB 139 | 140 | #------------------------------------------------------------------------------------------------------------------------- 141 | ## insert a new line for each farmer like shown in sample below 142 | ## change IP and port to match your farmer set-up 143 | ## 144 | ## Since the script is 100% endpoint based and does not require special permission to get hostname, 145 | ## you can set up a one time friendly name to show instead of IP should you prefer 146 | # 147 | # Tip: you can add or remove a line for farmer while the script is running and the updates will show in next refresh 148 | #------------------------------------------------------------------------------------------------------------------------- 149 | 150 | Farmer : 192.168.2.203:8181 : pc1 151 | Farmer : 192.168.2.105:8181: pc2 152 | 153 | #------------------------------------------------------------------------------------------------------------------------- 154 | # Account for reserved disk space for piece_cache in total space allocated for the farm 155 | # 156 | # Supplied initial value is 1% assuming it is the currently reserved space for piece_cache, of the total space allocated 157 | # If no value is provided the default is 0%, meaning farm size displayed is without piece_cache reserved space allocation 158 | # 159 | # Tip: Set this value to 0% if using cluster, set to 1% for non-cluster 160 | #------------------------------------------------------------------------------------------------------------------------- 161 | 162 | piece_cache_size: 0% 163 | 164 | #------------------------------------------------------------------------------------------------------------------------- 165 | # 166 | ## end of config file 167 | -------------------------------------------------------------------------------- /charts.ps1: -------------------------------------------------------------------------------- 1 | 2 | function fBuildBarChart ([string]$_io_chart_labels, [string]$_io_chart_alt_labels, [string]$_io_chart_progress_data, [string]$_io_chart_plotted_size_data, [string]$_chart_sector_time_data, [string]$_io_chart_eta_data, [string]$_io_chart_size_data, [string]$_io_chart_uptime_data, [string]$_io_chart_sectorsPerHour_data, [string]$_io_chart_disk_data_arr, [string]$_io_chart_title) 3 | { 4 | $_io_html_bar_chart = "" 5 | 6 | $_io_html_bar_chart += 7 | 8 | ' 9 | 10 | ' 178 | 179 | return $_io_html_bar_chart 180 | } 181 | 182 | function fBuildRadarChart ([string]$_io_chart_farm_labels, [string]$_chart_farm_alt_labels, [string]$_io_chart_farm_sectorsPerHour_data, [string]$_io_chart_farm_minutesPerSector_data, [string]$_io_chart_rewards_data, [string]$_io_chart_farm_disk_data_arr, [string]$_io_chart_title) 183 | { 184 | $_io_html_radar_chart = "" 185 | 186 | $_io_html_radar_chart += 187 | ' 188 | ' 293 | 294 | return $_io_html_radar_chart 295 | } 296 | 297 | function fBuildNetPerformanceChart ([string]$_io_chart_farm_labels, [string]$_chart_farm_alt_labels, [string]$_chart_total_sectors_per_hour_data, [string]$_chart_sector_time_data, [string]$_io_chart_farm_disk_data_arr, [string]$_io_chart_title) 298 | { 299 | $_io_html_NetPerf_chart = "" 300 | 301 | $_io_html_NetPerf_chart += 302 | ' 303 | ' 406 | 407 | return $_io_html_NetPerf_chart 408 | } 409 | 410 | function fBuildPieChart ([string]$_io_chart_labels, [string]$_chart_alt_labels, [string]$_chart_rewards_data, [string]$_io_chart_disk_data_arr, [string]$_io_chart_title) 411 | { 412 | $_io_html_pie_chart = "" 413 | 414 | $_io_html_pie_chart += 415 | ' 416 | 417 | ' 504 | 505 | return $_io_html_pie_chart 506 | } 507 | 508 | 509 | function fBuildDonutProgressBarChart ([int]$_io_ind_chart_seq_num, [string]$_io_chart_label, [string]$_io_chart_alt_label, [string]$_io_chart_progress_data, [string]$_io_chart_plotted_size_data, [string]$_chart_sector_time_data, [string]$_io_chart_eta_data, [string]$_io_chart_size_data, [string]$_io_chart_uptime_data, [string]$_io_chart_sectorsPerHour_data, [string]$_io_chart_disk_data_arr, [string]$_io_chart_title) 510 | { 511 | $_io_html_bar_chart = "" 512 | $_ind_chart_id = "barChart" + $_io_ind_chart_seq_num.toString() 513 | #$_div_progress_id = "progress" + $_io_ind_chart_seq_num.toString() 514 | 515 | # 516 | # var ce_SectorTime = ' + $_io_chart_SectorTimes_data + '; 517 | $_io_html_bar_chart += 518 | ' 519 | 520 | 521 | ' 638 | 639 | return $_io_html_bar_chart 640 | } 641 | -------------------------------------------------------------------------------- /data.ps1: -------------------------------------------------------------------------------- 1 | 2 | function fGetDataForHtml ([array]$_io_farmers_hostip_arr) { 3 | $_resp_process_metrics_arr = [System.Collections.ArrayList]@() 4 | [array]$_process_header_arr = $null 5 | [array]$_process_sub_header_arr = $null 6 | [array]$_process_data_arr = $null 7 | 8 | for ($arrPos = 0; $arrPos -lt $_io_farmers_hostip_arr.Count; $arrPos++) 9 | { 10 | $_farmer_metrics_raw = "" 11 | $_node_metrics_raw = "" 12 | $_host_friendly_name = "" 13 | $_process_resp_raw = $null 14 | if ($_io_farmers_hostip_arr[$arrPos].toString().Trim(' ') -ne "" -and $_io_farmers_hostip_arr[$arrPos].toString().IndexOf("#") -lt 0) { 15 | $_config = $_io_farmers_hostip_arr[$arrPos].toString().split(":").Trim(" ") 16 | $_process_type = $_config[0].toString() 17 | if ($_process_type.toLower() -eq "node" -or $_process_type.toLower() -eq "farmer") { 18 | $_host_ip = $_config[1].toString() 19 | $_host_port = $_config[2].toString() 20 | if ($_config.Count -gt 3) { 21 | $_host_friendly_name = $_config[3].toString() 22 | } 23 | $_host_url = $_host_ip + ":" + $_host_port 24 | $_hostname = "" 25 | 26 | ## Experimental 27 | ## Message: start changes here in case of host name resolution related issues while using this tool 28 | # 29 | # START COMMENT - Type # in front of the line until the line where it says "STOP COMMENT" 30 | ## What is happening here is an attempt to hide IP info on screen display and use hostname instead 31 | #try { 32 | # $_hostname_obj = [system.net.dns]::gethostentry($_host_ip) 33 | # $_hostname = $_hostname_obj.NameHost 34 | #} 35 | #catch 36 | #{ 37 | # $_hostname = $_host_ip 38 | #} 39 | # STOP COMMENT - Remove the # in front of the next 1 line directly below this line, this will display IP in display 40 | $_hostname = $_host_ip 41 | if ($_host_friendly_name -and $_host_friendly_name.length -gt 0) 42 | { 43 | $_hostname = $_host_friendly_name 44 | } 45 | # 46 | $_process_resp_raw = $null 47 | foreach ($_process_status_arr_obj in $script:_process_status_arr) 48 | { 49 | if ($_process_status_arr_obj) 50 | { 51 | if ($_process_status_arr_obj.Id -eq $_host_url) 52 | { 53 | $_b_process_running_ok = $_process_status_arr_obj.ProcessStatus 54 | $_process_resp_raw = $_process_status_arr_obj.ProcessResp 55 | break 56 | } 57 | } 58 | else {break} 59 | } 60 | # 61 | # get process header information 62 | $_process_status = "Running" 63 | if ($_b_process_running_ok -eq $true) { 64 | $_process_status = "Running" 65 | } 66 | else { 67 | $_process_status = "Stopped" 68 | } 69 | 70 | $_node_sync_state_disp = "" 71 | $_node_peers_connected = "" 72 | if ($_process_type.toLower() -eq "node") { # get node metrics 73 | $_node_metrics_raw = $_process_resp_raw 74 | [void]$_node_metrics_raw_arr.add($_node_metrics_raw) 75 | $_node_metrics_formatted_arr = fParseMetricsToObj $_node_metrics_raw_arr[$_node_metrics_raw_arr.Count - 1] 76 | 77 | $_node_metrics_arr = fGetNodeMetrics $_node_metrics_formatted_arr 78 | $_node_sync_state = $_node_metrics_arr[0].Sync.State 79 | $_node_peers_connected = $_node_metrics_arr[0].Peers.Connected 80 | $_node_sync_state_disp = "Yes" 81 | if ($_node_sync_state -eq $null) { 82 | $_node_peers_connected = "-" 83 | $_node_sync_state_disp = "-" 84 | } 85 | elseif ($_node_sync_state -eq 1 -or $_b_process_running_ok -eq $false) { 86 | $_node_sync_state_disp = "No" 87 | } 88 | } 89 | # 90 | # build process header 91 | $_process_header = [PSCustomObject]@{ 92 | UUId = $_host_url 93 | Hostname = $_hostname 94 | ProcessType = $_process_type 95 | State = $_process_status 96 | SyncStatus = $_node_sync_state_disp 97 | Peers = $_node_peers_connected 98 | } 99 | $_process_header_arr += $_process_header 100 | } 101 | 102 | if ($_process_type.toLower() -ne "farmer") { continue } 103 | 104 | $_farmer_metrics_raw = $_process_resp_raw 105 | [void]$_farmers_metrics_raw_arr.add($_farmer_metrics_raw) 106 | $_farmer_metrics_formatted_arr = fParseMetricsToObj $_farmers_metrics_raw_arr[$_farmers_metrics_raw_arr.Count - 1] 107 | # 108 | [array]$_disk_metrics_arr = $null 109 | foreach ($_farmer_disk_metrics_arr_obj in $script:_farmer_disk_metrics_arr) 110 | { 111 | if ($_farmer_disk_metrics_arr_obj) 112 | { 113 | if ($_farmer_disk_metrics_arr_obj.Id -eq $_host_url) 114 | { 115 | $_disk_metrics_arr = $_farmer_disk_metrics_arr_obj.MetricsArr 116 | break 117 | } 118 | } 119 | else {break} 120 | } 121 | $_disk_UUId_arr = $_disk_metrics_arr[0].Id 122 | $_disk_sector_performance_arr = $_disk_metrics_arr[0].Performance 123 | $_disk_rewards_arr = $_disk_metrics_arr[0].Rewards 124 | $_disk_misses_arr = $_disk_metrics_arr[0].Misses 125 | $_disk_plots_completed_arr = $_disk_metrics_arr[0].PlotsCompleted 126 | $_disk_plots_remaining_arr = $_disk_metrics_arr[0].PlotsRemaining 127 | $_disk_plots_expired_arr = $_disk_metrics_arr[0].PlotsExpired 128 | $_disk_plots_expiring_arr = $_disk_metrics_arr[0].PlotsAboutToExpire 129 | 130 | # get process data information 131 | $_process_completed_sectors = 0 132 | $_process_completed_sectors_disp = "-" 133 | $_process_total_sectors = 0 134 | $_process_total_sectors_disp = "-" 135 | $_process_remaining_sectors = 0 136 | $_process_remaining_sectors_disp = "-" 137 | # 138 | # 139 | $_max_process_remaining_sectors = 0 140 | # 141 | # 142 | $_process_total_disks = 0 143 | $_process_total_disks_disp = "-" 144 | $_process_total_disks_for_eta = 0 145 | $_process_total_disks_net_plotting = 0 146 | foreach ($_disk_UUId_obj in $_disk_UUId_arr) 147 | { 148 | # get performance - must do first as ETA is calculated based on this information 149 | $_minutes_per_sector_data_disp = "-" 150 | $_sectors_per_hour_data_disp = "-" 151 | $_time_per_sector_data_obj = New-TimeSpan -seconds 0 152 | $_replot_sector_count = 0 153 | $_replot_sector_count_hold = 0 154 | $_expiring_sector_count = 0 155 | foreach ($_disk_sector_performance_obj in $_disk_sector_performance_arr) 156 | { 157 | if ($_disk_sector_performance_obj) { 158 | if ($_disk_sector_performance_obj.Id -eq "overall" -or $_disk_UUId_obj.Id -ne $_disk_sector_performance_obj.Id) { continue } 159 | } 160 | # 161 | foreach ($_disk_plots_remaining_obj in $_disk_plots_remaining_arr) 162 | { 163 | if ($_disk_plots_remaining_obj) { 164 | if ($_disk_UUId_obj.Id -ne $_disk_plots_remaining_obj.Id) { continue } 165 | } 166 | else {break} 167 | $_disk_plots_remaining = [int]($_disk_plots_remaining_obj.Sectors) 168 | if ($_disk_plots_remaining -gt 0) { # determine if actually plotting and not replotting 169 | $_minutes_per_sector_data_disp = $_disk_sector_performance_obj.MinutesPerSector.ToString() 170 | $_sectors_per_hour_data_disp = $_disk_sector_performance_obj.SectorsPerHour.ToString() 171 | if ($_disk_sector_performance_obj.DiskSectorPlotCount -gt 0) { 172 | switch ($_disk_sector_performance_obj.PlotTimeUnit) { 173 | "seconds" { 174 | $_time_per_sector_data_obj = New-TimeSpan -seconds ($_disk_sector_performance_obj.DiskSectorPlotTime / $_disk_sector_performance_obj.DiskSectorPlotCount) 175 | } 176 | "minutes" { 177 | $_time_per_sector_data_obj = New-TimeSpan -seconds (($_disk_sector_performance_obj.DiskSectorPlotTime * 60) / $_disk_sector_performance_obj.DiskSectorPlotCount) 178 | } 179 | "hours" { 180 | $_time_per_sector_data_obj = New-TimeSpan -seconds (($_disk_sector_performance_obj.DiskSectorPlotTime * 3600) / $_disk_sector_performance_obj.DiskSectorPlotCount) 181 | } 182 | } 183 | } 184 | 185 | } 186 | } 187 | #$_minutes_per_sector_data_disp = $_disk_sector_performance_obj.MinutesPerSector.ToString() 188 | #$_sectors_per_hour_data_disp = $_disk_sector_performance_obj.SectorsPerHour.ToString() 189 | } 190 | # 191 | ## replot info gathering 192 | foreach ($_disk_plots_remaining_obj in $_disk_plots_remaining_arr) 193 | { 194 | if ($_disk_plots_remaining_obj) { 195 | if ($_disk_UUId_obj.Id -ne $_disk_plots_remaining_obj.Id) { continue } 196 | } 197 | else {break} 198 | $_disk_plots_remaining = [int]($_disk_plots_remaining_obj.Sectors) 199 | if ($_disk_plots_remaining -eq 0) { # means plotting is at 100% and replotting may be ongoing depending on plotcount > 0 200 | # expired sectors info 201 | #$_replot_sector_count = $_disk_sector_performance_obj.DiskSectorPlotCount # replots were counted in original plot counts so not reliable data point doe replot calc 202 | foreach ($_disk_plots_expired_obj in $_disk_plots_expired_arr) 203 | { 204 | if ($_disk_plots_expired_obj) { 205 | if ($_disk_UUId_obj.Id -ne $_disk_plots_expired_obj.Id) { continue } 206 | } 207 | $_replot_sector_count = [int]($_disk_plots_expired_obj.Sectors) 208 | break 209 | # 210 | } 211 | # 212 | # expiring sectors info 213 | foreach ($_disk_plots_expiring_obj in $_disk_plots_expiring_arr) 214 | { 215 | if ($_disk_plots_expiring_obj) { 216 | if ($_disk_UUId_obj.Id -ne $_disk_plots_expiring_obj.Id) { continue } 217 | } 218 | $_expiring_sector_count = [int]($_disk_plots_expiring_obj.Sectors) 219 | break 220 | } 221 | ## rebuild storage for replot if more sectors expired or expiring in the meantime as needed 222 | $_b_add_exp_arr_id = $true 223 | $_replot_sector_count_hold = 0 224 | for ($_h = 0; $_h -lt $script:_replot_sector_count_hold_arr.count; $_h++) 225 | { 226 | if ($script:_replot_sector_count_hold_arr[$_h]) { 227 | if ($_disk_UUId_obj.Id -ne $script:_replot_sector_count_hold_arr[$_h].Id) { continue } 228 | 229 | if ($script:_replot_sector_count_hold_arr[$_h].ExpiredSectors -eq 0 -or $script:_replot_sector_count_hold_arr[$_h].ExpiredSectors -lt ($_replot_sector_count + $_expiring_sector_count)) 230 | { 231 | $script:_replot_sector_count_hold_arr[$_h].ExpiredSectors = $_replot_sector_count + $_expiring_sector_count 232 | } 233 | elseif ($_replot_sector_count -eq 0 -and $_expiring_sector_count -eq 0) 234 | { 235 | $script:_replot_sector_count_hold_arr[$_h].ExpiredSectors = 0 236 | } 237 | $_replot_sector_count_hold = $script:_replot_sector_count_hold_arr[$_h].ExpiredSectors 238 | $_b_add_exp_arr_id = $false 239 | break 240 | } 241 | } 242 | if ($_b_add_exp_arr_id -eq $true) 243 | { 244 | $_expiring_plots_info = [PSCustomObject]@{ 245 | Id = $_disk_UUId_obj.Id 246 | ExpiredSectors = ($_replot_sector_count + $_expiring_sector_count) 247 | } 248 | $script:_replot_sector_count_hold_arr += $_expiring_plots_info 249 | $_replot_sector_count_hold = $_replot_sector_count + $_expiring_sector_count 250 | } 251 | } 252 | } 253 | # 254 | ## get size, % progresion and ETA 255 | $_b_printed_size_metrics = $false 256 | $_total_disk_sectors_disp = "-" 257 | $_plotting_percent_complete = "-" 258 | $_plotting_percent_complete_disp = "-" 259 | $_eta = "-" 260 | $_eta_disp = "-" 261 | $_completed_sectors = 0 262 | $_disk_plotted_size_TiB = "-" 263 | $_remaining_sectors = 0 264 | foreach ($_disk_plots_completed_obj in $_disk_plots_completed_arr) 265 | { 266 | if ($_disk_plots_completed_obj) { 267 | if ($_disk_UUId_obj.Id -ne $_disk_plots_completed_obj.Id) { continue } 268 | } 269 | else {break} 270 | # 271 | 272 | foreach ($_disk_plots_remaining_obj in $_disk_plots_remaining_arr) 273 | { 274 | if ($_disk_plots_remaining_obj) { 275 | if ($_disk_UUId_obj.Id -ne $_disk_plots_remaining_obj.Id) { continue } 276 | } 277 | else {break} 278 | 279 | $_remaining_sectors = [int]($_disk_plots_remaining_obj.Sectors) 280 | $_completed_sectors = [int]($_disk_plots_completed_obj.Sectors) 281 | $_disk_plotted_size_TiB = [math]::Round(($_completed_sectors + $_expiring_sector_count + $_replot_sector_count) * $script:_mulitplier_size_converter / $script:_TiB_to_GiB_converter, 2) 282 | #$_total_sectors_GiB = $_completed_sectors + $_remaining_sectors 283 | $_total_sectors_GiB = $_completed_sectors + $_remaining_sectors + $_expiring_sector_count + $_replot_sector_count 284 | 285 | $_process_total_disks += 1 286 | $_process_total_disks_disp = $_process_total_disks 287 | 288 | $_process_total_disks_net_plotting += 1 289 | $_process_total_disks_for_eta = $_process_total_disks_net_plotting 290 | 291 | if ($_remaining_sectors -eq 0) { 292 | $_process_total_disks_net_plotting = $_process_total_disks_net_plotting - 1 293 | $_process_total_disks_for_eta = $_process_total_disks_net_plotting 294 | } 295 | 296 | $_process_remaining_sectors += $_remaining_sectors 297 | $_process_remaining_sectors_disp = $_process_remaining_sectors 298 | # 299 | # 300 | if($_remaining_sectors -gt $_max_process_remaining_sectors) 301 | { 302 | $_max_process_remaining_sectors = $_remaining_sectors 303 | } 304 | # 305 | # 306 | $_process_completed_sectors += $_completed_sectors 307 | $_process_completed_sectors_disp = $_process_completed_sectors 308 | $_process_total_sectors += $_total_sectors_GiB 309 | $_process_total_sectors_disp = $_process_total_sectors 310 | 311 | #$_total_disk_sectors_TiB = [math]::Round($_total_sectors_GiB / 1000, 2) 312 | $_total_disk_sectors_TiB = [math]::Round($_total_sectors_GiB * $script:_mulitplier_size_converter / $script:_TiB_to_GiB_converter, 2) 313 | 314 | #$_total_disk_sectors_disp = $_total_disk_sectors_TiB.ToString() + " TiB" 315 | $_total_disk_sectors_disp = $_total_disk_sectors_TiB.ToString() 316 | if ($_total_sectors_GiB -ne 0 -and ($_total_sectors_GiB - $_expiring_sector_count - $_replot_sector_count) -ne 0) { 317 | #$_plotting_percent_complete = [math]::Round(($_completed_sectors / $_total_sectors_GiB) * 100, 1) 318 | $_plotting_percent_complete = [math]::Round(($_completed_sectors / ($_total_sectors_GiB - $_expiring_sector_count - $_replot_sector_count)) * 100, 2) 319 | $_plotting_percent_complete_disp = $_plotting_percent_complete.ToString() + "%" 320 | } 321 | if ($_minutes_per_sector_data_disp -ne "-" -and $_sectors_per_hour_data_disp -ne "-") { 322 | #$_eta = [math]::Round((([double]($_minutes_per_sector_data_disp) * $_remaining_sectors)) / (60 * 24), 2) 323 | #$_eta_disp = $_eta.toString() + " days" 324 | $_eta = [double]($_time_per_sector_data_obj.TotalSeconds) * $_remaining_sectors 325 | $_eta_obj = New-TimeSpan -seconds $_eta 326 | #$_eta_disp = $_eta_obj.days.ToString()+"d " + $_eta_obj.hours.ToString()+"h " + $_eta_obj.minutes.ToString() + "m " 327 | $_eta_disp = fConvertTimeSpanToString $_eta_obj 328 | } 329 | } 330 | } 331 | # get rewards and misses 332 | $_rewards_data_disp = "-" 333 | foreach ($_disk_rewards_obj in $_disk_rewards_arr) 334 | { 335 | if ($_disk_UUId_obj.Id -ne $_disk_rewards_obj.Id) { 336 | continue 337 | } 338 | $_rewards_data_disp = $_disk_rewards_obj.Rewards.ToString() 339 | } 340 | 341 | $_misses_data_disp = "-" 342 | $_misses_data_timeout_disp = "-" 343 | $_misses_data_rejected_disp = "-" 344 | $_misses_data_failed_disp = "-" 345 | foreach ($_disk_misses_obj in $_disk_misses_arr) 346 | { 347 | if ($_disk_UUId_obj.Id -ne $_disk_misses_obj.Id) { 348 | continue 349 | } 350 | $_misses_data_disp = $_disk_misses_obj.Misses.ToString() 351 | $_misses_data_timeout_disp = $_disk_misses_obj.Timeout.ToString() 352 | $_misses_data_rejected_disp = $_disk_misses_obj.Rejected.ToString() 353 | $_misses_data_failed_disp = $_disk_misses_obj.Failed.ToString() 354 | } 355 | # 356 | # build process data 357 | 358 | $_process_data = [PSCustomObject]@{ 359 | UUId = $_host_url 360 | Hostname = $_hostname 361 | ProcessType = $_process_type 362 | DiskId = $_disk_UUId_obj.Id 363 | Size = $_total_disk_sectors_disp 364 | PercentComplete = $_plotting_percent_complete_disp 365 | SectorsCompleted = $_disk_plotted_size_TiB 366 | ETA = $_eta_disp 367 | ReplotStatus = $_replot_sector_count 368 | ReplotStatusHold = $_replot_sector_count_hold 369 | ExpiringSectors = $_expiring_sector_count 370 | SectorsPerHour = $_sectors_per_hour_data_disp 371 | #MinutesPerSector = $_minutes_per_sector_data_disp 372 | MinutesPerSector = $_time_per_sector_data_obj.TotalSeconds 373 | Rewards = $_rewards_data_disp 374 | Misses = $_misses_data_disp 375 | Timeout = $_misses_data_timeout_disp 376 | Rejected = $_misses_data_rejected_disp 377 | Failed = $_misses_data_failed_disp 378 | } 379 | $_process_data_arr += $_process_data 380 | } 381 | 382 | # get process sub-header information 383 | $_avg_sectors_per_hour = 0.0 384 | $_avg_minutes_per_sector = 0.0 385 | $_avg_seconds_per_sector = 0.0 386 | $_farm_sector_times = 0.0 387 | $_uptime = $null 388 | #$_uptime_disp = "0d 0h 0m 0a" 389 | $_uptime_disp = "-" 390 | foreach ($_disk_sector_performance_obj in $_disk_sector_performance_arr) 391 | { 392 | # get process sub header information 393 | if ($_disk_sector_performance_obj) { 394 | if ($_disk_sector_performance_obj.Id -eq "overall") { 395 | #$_avg_sectors_per_hour = 0.0 396 | #$_avg_minutes_per_sector = 0.0 397 | #if ($_disk_sector_performance_obj.TotalSeconds -gt 0) { 398 | # $_avg_sectors_per_hour = [math]::Round(($_disk_sector_performance_obj.TotalSectors * 3600)/ $_disk_sector_performance_obj.TotalSeconds, 1) 399 | #} 400 | #if ($_disk_sector_performance_obj.TotalSectors) { 401 | # $_avg_minutes_per_sector = [math]::Round($_disk_sector_performance_obj.TotalSeconds / ($_disk_sector_performance_obj.TotalSectors * 60), 1) 402 | #} 403 | $_uptime = fGetElapsedTime $_disk_sector_performance_obj 404 | #$_uptime_disp = $_uptime.days.ToString()+"d "+$_uptime.hours.ToString()+"h "+$_uptime.minutes.ToString()+"m "+$_uptime.seconds.ToString()+"s" 405 | $_uptime_disp = fConvertTimeSpanToString $_uptime 406 | # 407 | ## build process sub header 408 | #$_process_sub_header = [PSCustomObject]@{ 409 | # UUId = $_host_url 410 | # Hostname = $_hostname 411 | # ProcessType = $_process_type 412 | # Uptime = $_uptime_disp 413 | # SectorsPerHourAvg = $_avg_sectors_per_hour.toString() 414 | # MinutesPerSectorAvg = $_avg_minutes_per_sector.toString() 415 | # TotalSectors = $_process_total_sectors_disp 416 | # CompletedSectors = $_process_completed_sectors_disp 417 | # RemainingSectors = $_process_remaining_sectors_disp 418 | # TotalDisks = $_process_total_disks_disp 419 | # TotalDisksForETA = $_process_total_disks_for_eta 420 | # TotalRewards = $_disk_sector_performance_obj.TotalRewards.toString() 421 | #} 422 | #$_process_sub_header_arr += $_process_sub_header 423 | # 424 | break 425 | } 426 | } 427 | } 428 | # 429 | ## write farm level averages for sector times 430 | $_actual_plotting_disk_count = 0 431 | foreach ($_disk_sector_performance_obj in $_disk_sector_performance_arr) 432 | { 433 | if ($_disk_sector_performance_obj) { 434 | if ($_disk_sector_performance_obj.Id -eq "overall") { continue } 435 | } 436 | # 437 | foreach ($_disk_plots_remaining_obj in $_disk_plots_remaining_arr) 438 | { 439 | if ($_disk_plots_remaining_obj) { 440 | if ($_disk_sector_performance_obj.Id -ne $_disk_plots_remaining_obj.Id) { continue } 441 | } 442 | else {break} 443 | $_disk_plots_remaining = $_disk_plots_remaining_obj.Sectors 444 | if ($_disk_plots_remaining -gt 0) { # determine if actually plotting and not replotting 445 | #$_avg_minutes_per_sector += $_disk_sector_performance_obj.MinutesPerSector 446 | #$_avg_sectors_per_hour += $_disk_sector_performance_obj.SectorsPerHour 447 | $_actual_plotting_disk_count += 1 448 | switch ($_disk_sector_performance_obj.PlotTimeUnit) { 449 | "seconds" { 450 | $_avg_sectors_per_hour += [math]::Round(($_disk_sector_performance_obj.DiskSectorPlotCount * 3600) / $_disk_sector_performance_obj.DiskSectorPlotTime, 1) 451 | $_avg_minutes_per_sector += [math]::Round($_disk_sector_performance_obj.DiskSectorPlotTime / ($_disk_sector_performance_obj.DiskSectorPlotCount * 60), 1) 452 | $_avg_seconds_per_sector += [math]::Round($_disk_sector_performance_obj.DiskSectorPlotTime / $_disk_sector_performance_obj.DiskSectorPlotCount, 1) 453 | } 454 | "minutes" { 455 | $_avg_sectors_per_hour += [math]::Round($_disk_sector_performance_obj.DiskSectorPlotCount / $_disk_sector_performance_obj.DiskSectorPlotTime, 1) 456 | $_avg_minutes_per_sector += [math]::Round($_disk_sector_performance_obj.DiskSectorPlotTime / $_disk_sector_performance_obj.DiskSectorPlotCount, 1) 457 | $_avg_seconds_per_sector += [math]::Round(($_disk_sector_performance_obj.DiskSectorPlotTime * 60) / $_disk_sector_performance_obj.DiskSectorPlotCount, 1) 458 | } 459 | "hours" { 460 | $_avg_sectors_per_hour += [math]::Round($_disk_sector_performance_obj.DiskSectorPlotCount / ($_disk_sector_performance_obj.DiskSectorPlotTime * 60), 1) 461 | $_avg_minutes_per_sector += [math]::Round(($_disk_sector_performance_obj.DiskSectorPlotTime * 60) / $_disk_sector_performance_obj.DiskSectorPlotCount, 1) 462 | $_avg_seconds_per_sector += [math]::Round(($_disk_sector_performance_obj.DiskSectorPlotTime * 3600) / $_disk_sector_performance_obj.DiskSectorPlotCount, 1) 463 | } 464 | } 465 | } 466 | else { # means plotting is at 100% and replotting may be ongoing depending on plotcount > 0 - check TBD 467 | # Not needing info for replotting at farm level yet 468 | } 469 | } 470 | } 471 | if ($_actual_plotting_disk_count -gt 0) 472 | { 473 | $_avg_minutes_per_sector = $_avg_minutes_per_sector / $_actual_plotting_disk_count 474 | $_avg_sectors_per_hour = $_avg_sectors_per_hour / $_actual_plotting_disk_count 475 | $_farm_sector_times = $_avg_seconds_per_sector / $_actual_plotting_disk_count 476 | } 477 | $_tmp_sector_time_farm = 0 478 | if ($_process_total_disks_for_eta -gt 0 -and $_avg_sectors_per_hour -gt 0) 479 | { 480 | $_tmp_sector_time_farm = [double](3600/ ([double]($_avg_sectors_per_hour) * $_process_total_disks_for_eta)) 481 | } 482 | $_disk_plots_remaining_arr_sorted = fSortObjArrBySectorRemaining $_disk_plots_remaining_arr $_process_total_disks_for_eta 483 | $_eta_hold_ = 0 484 | for ($_h = 0; $_h -lt ($_disk_plots_remaining_arr_sorted | Measure-Object).count; $_h++) 485 | { 486 | $_disk_plots_remaining_arr_sorted[$_h].ETA = $_eta_hold_ + [double]($_tmp_sector_time_farm) * $_disk_plots_remaining_arr_sorted[$_h].AdditionalSectorsForETA * $_disk_plots_remaining_arr_sorted[$_h].PlotCountMultiplier 487 | $_eta_hold_ = $_disk_plots_remaining_arr_sorted[$_h].ETA 488 | } 489 | for ($_i = 0; $_i -lt $_process_data_arr.Count; $_i++) 490 | { 491 | $_tmp_eta = 0 492 | $_process_data_arr_obj = $_process_data_arr[$_i] 493 | if ($_process_data_arr_obj) { 494 | foreach ($_disk_plots_remaining_sorted_obj in $_disk_plots_remaining_arr_sorted) 495 | { 496 | if ($_disk_plots_remaining_sorted_obj) { 497 | if ($_process_data_arr_obj.DiskId -ne $_disk_plots_remaining_sorted_obj.Id) { continue } 498 | } 499 | else {break} 500 | $_tmp_eta = $_disk_plots_remaining_sorted_obj.ETA 501 | $_tmp_eta_obj = New-TimeSpan -seconds $_tmp_eta 502 | $_process_data_arr[$_i].ETA = fConvertTimeSpanToString $_tmp_eta_obj 503 | break 504 | } 505 | } 506 | } 507 | 508 | # build process sub header 509 | $_process_sub_header = [PSCustomObject]@{ 510 | UUId = $_host_url 511 | Hostname = $_hostname 512 | ProcessType = $_process_type 513 | UptimeTSObj = $_uptime 514 | Uptime = $_uptime_disp 515 | SectorsPerHourAvg = $_avg_sectors_per_hour.toString() 516 | MinutesPerSectorAvg = $_avg_minutes_per_sector.toString() 517 | SectorTime = $_farm_sector_times 518 | TotalSectors = $_process_total_sectors_disp 519 | CompletedSectors = $_process_completed_sectors_disp 520 | #RemainingSectors = $_process_remaining_sectors_disp 521 | # 522 | # 523 | RemainingSectors = $_max_process_remaining_sectors 524 | # 525 | # 526 | TotalDisks = $_process_total_disks_disp 527 | TotalDisksForETA = $_process_total_disks_for_eta 528 | TotalRewards = $_disk_sector_performance_obj.TotalRewards.toString() 529 | } 530 | $_process_sub_header_arr += $_process_sub_header 531 | # 532 | } 533 | } 534 | # get latest github version 535 | $_gitVersionDisp = " - " 536 | $_gitVersionDispColor = $_html_red 537 | if ($null -ne $gitVersion) { 538 | $currentVersion = $gitVersion[0] -replace "[^.0-9]" 539 | $_gitVersionDisp = $gitVersion[0] 540 | } 541 | # get last refresh datetime 542 | $_refresh_date = (Get-Date).ToLocalTime().toString() 543 | # 544 | ## build process metrics 545 | $_process_metrics = [PSCustomObject]@{ 546 | ProcessHeader = $_process_header_arr 547 | ProcessSubHeader = $_process_sub_header_arr 548 | ProcessData = $_process_data_arr 549 | GithubVersion = $_gitVersionDisp 550 | RefreshedOn = $_refresh_date 551 | } 552 | [void]$_resp_process_metrics_arr.add($_process_metrics) 553 | 554 | return $_resp_process_metrics_arr 555 | } 556 | 557 | function fConverPSArrToJScriptArr ([array]$_io_arr) { 558 | $_resp_js = '' 559 | 560 | $_resp_js += '[' 561 | for ($j=0; $j -lt $_io_arr.Count; $j++) 562 | { 563 | if ($j -eq 0) { 564 | $_resp_js += '{' 565 | $_resp_js += 'UUId:' + ' "' + $_io_arr[$j].UUId + '"' 566 | $_resp_js += ',Hostname:' + ' "' + $_io_arr[$j].Hostname + '"' 567 | $_resp_js += ',ProcessType:' + ' "' + $_io_arr[$j].ProcessType + '"' 568 | $_resp_js += ',DiskId:' + ' "' + $_io_arr[$j].DiskId + '"' 569 | $_resp_js += ',Size:' + ' "' + $_io_arr[$j].Size + '"' 570 | $_resp_js += ',PercentComplete:' + ' "' + $_io_arr[$j].PercentComplete + '"' 571 | $_resp_js += ',SectorsCompleted:' + ' "' + $_io_arr[$j].SectorsCompleted + '"' 572 | $_resp_js += ',ETA:' + ' "' + $_io_arr[$j].ETA + '"' 573 | $_resp_js += ',ReplotStatus:' + ' "' + $_io_arr[$j].ReplotStatus + '"' 574 | $_resp_js += ',SectorsPerHour:' + ' "' + $_io_arr[$j].SectorsPerHour + '"' 575 | #$_resp_js += ',MinutesPerSector:' + ' "' + $_io_arr[$j].MinutesPerSector + '"' 576 | if ($_io_arr[$j].MinutesPerSector -eq "-") { 577 | $_resp_js += ',MinutesPerSector:' + ' "' + $_io_arr[$j].MinutesPerSector + '"' 578 | } 579 | else{ 580 | $_temp_min_per_sector = New-TimeSpan -seconds $_io_arr[$j].MinutesPerSector 581 | #$_resp_js += ',MinutesPerSector:' + ' "' + ($_temp_min_per_sector.minutes.ToString() + "m " + $_temp_min_per_sector.seconds.ToString() + "s") + '"' 582 | $_resp_js += ',MinutesPerSector:' + ' "' + (fConvertTimeSpanToString $_temp_min_per_sector) + '"' 583 | } 584 | $_resp_js += ',Rewards:' + ' "' + $_io_arr[$j].Rewards + '"' 585 | $_resp_js += ',Misses:' + ' "' + $_io_arr[$j].Misses + '"' 586 | $_resp_js += '}' 587 | } 588 | else 589 | { 590 | $_resp_js += ',{' 591 | $_resp_js += 'UUId:' + ' "' + $_io_arr[$j].UUId + '"' 592 | $_resp_js += ',Hostname:' + ' "' + $_io_arr[$j].Hostname + '"' 593 | $_resp_js += ',ProcessType:' + ' "' + $_io_arr[$j].ProcessType + '"' 594 | $_resp_js += ',DiskId:' + ' "' + $_io_arr[$j].DiskId + '"' 595 | $_resp_js += ',Size:' + ' "' + $_io_arr[$j].Size + '"' 596 | $_resp_js += ',PercentComplete:' + ' "' + $_io_arr[$j].PercentComplete + '"' 597 | $_resp_js += ',SectorsCompleted:' + ' "' + $_io_arr[$j].SectorsCompleted + '"' 598 | $_resp_js += ',ETA:' + ' "' + $_io_arr[$j].ETA + '"' 599 | $_resp_js += ',ReplotStatus:' + ' "' + $_io_arr[$j].ReplotStatus + '"' 600 | $_resp_js += ',SectorsPerHour:' + ' "' + $_io_arr[$j].SectorsPerHour + '"' 601 | #$_resp_js += ',MinutesPerSector:' + ' "' + $_io_arr[$j].MinutesPerSector + '"' 602 | if ($_io_arr[$j].MinutesPerSector -eq "-") { 603 | $_resp_js += ',MinutesPerSector:' + ' "' + $_io_arr[$j].MinutesPerSector + '"' 604 | } 605 | else { 606 | $_temp_min_per_sector = New-TimeSpan -seconds $_io_arr[$j].MinutesPerSector 607 | #$_resp_js += ',MinutesPerSector:' + ' "' + ($_temp_min_per_sector.minutes.ToString() + "m " + $_temp_min_per_sector.seconds.ToString() + "s") + '"' 608 | $_resp_js += ',MinutesPerSector:' + ' "' + (fConvertTimeSpanToString $_temp_min_per_sector) + '"' 609 | } 610 | $_resp_js += ',Rewards:' + ' "' + $_io_arr[$j].Rewards + '"' 611 | $_resp_js += ',Misses:' + ' "' + $_io_arr[$j].Misses + '"' 612 | $_resp_js += '}' 613 | } 614 | } 615 | $_resp_js += ']' 616 | 617 | return $_resp_js 618 | } 619 | -------------------------------------------------------------------------------- /nats_io.ps1: -------------------------------------------------------------------------------- 1 | 2 | function fGenAlertNotifications ([string]$_io_alert_text) { 3 | try { 4 | $_seconds_elapsed = $_alert_stopwatch.Elapsed.TotalSeconds 5 | if ($script:_b_first_time -eq $true -or $_seconds_elapsed -ge $_alert_frequency_seconds) { 6 | fSendDiscordNotification $script:_url_discord $_io_alert_text 7 | $_b_bot_msg_sent_ok = fSendTelegramBotNotification $_io_alert_text 8 | } 9 | } 10 | catch {} 11 | } 12 | 13 | function fPingNatsServer ([string]$_io_nats_url) { 14 | [object]$_io_nats_response_obj = [PSCustomObject]@{ 15 | ServerName = $null 16 | Status = $null 17 | } 18 | 19 | $_nats_url_endpoint = "http://" + $_io_nats_url + "/healthz" 20 | try { 21 | $_nats_resp_obj = Invoke-RestMethod -Method 'GET' -uri $_nats_url_endpoint -TimeoutSec 5 22 | if ($_nats_resp_obj) { 23 | $_io_nats_response_obj.Status = $_nats_resp_obj.status.toString() 24 | } 25 | $_nats_url_endpoint = "http://" + $_io_nats_url + "/varz" 26 | $_nats_resp_obj = Invoke-RestMethod -Method 'GET' -uri $_nats_url_endpoint -TimeoutSec 5 27 | if ($_nats_resp_obj) { 28 | $_io_nats_response_obj.ServerName = $_nats_resp_obj.server_name.toString() 29 | } 30 | else 31 | { 32 | $_io_nats_response_obj.ServerName = "Inactive" 33 | } 34 | } 35 | catch { 36 | $_alert_text = "Nats Server" + " status: Stopped, Host:" + $_io_nats_url 37 | fGenAlertNotifications $_alert_text 38 | $_io_nats_response_obj.ServerName = "Inactive" 39 | } 40 | return $_io_nats_response_obj 41 | } 42 | 43 | function fGetNatsServerActiveConnections ([string]$_io_nats_url) { 44 | [array]$_controller_obj_arr = $null 45 | [array]$_cache_obj_arr = $null 46 | [array]$_farmer_obj_arr = $null 47 | [array]$_plotter_obj_arr = $null 48 | # 49 | [array]$_io_nats_connections_obj_arr = $null 50 | $_io_nats_connections_obj = [PSCustomObject]@{ 51 | ServerName = $script:_nats_server_name 52 | Controller = $null 53 | Cache = $null 54 | Farmer = $null 55 | Plotter = $null 56 | } 57 | # 58 | ## 59 | $_cluster_id_seq_disp = $script:_cluster_id_seq.toString() 60 | if ($script:_cluster_id_seq -le 9) { $_cluster_id_seq_disp = "c" + $script:_cluster_id_seq.toString() } 61 | $_nats_url_endpoint = "http://" + $_io_nats_url + "/connz?subs=1" 62 | try { 63 | $_nats_resp_obj = Invoke-RestMethod -Method 'GET' -uri $_nats_url_endpoint -TimeoutSec 5 64 | if ($_nats_resp_obj) { 65 | $_nats_connection_count = $_nats_resp_obj.connections.Count 66 | $_nats_connections_arr = $_nats_resp_obj.connections 67 | for ($_nats_connections_arr_pos = 0; $_nats_connections_arr_pos -lt $_nats_connections_arr.Count; $_nats_connections_arr_pos++) 68 | { 69 | $_nats_connection_item = $_nats_connections_arr[$_nats_connections_arr_pos] 70 | $_nats_connection_item_details_obj = [PSCustomObject]@{ 71 | Seq_no = $_cluster_id_seq_disp 72 | ServerName = $script:_nats_server_name 73 | CID = $_nats_connection_item.cid 74 | IP = $_nats_connection_item.ip 75 | Port = $_nats_connection_item.port 76 | StartTime = $_nats_connection_item.start 77 | LastSeen = $_nats_connection_item.last_activity 78 | Uptime = $_nats_connection_item.uptime 79 | Subscriptions = $_nats_connection_item.subscriptions_list 80 | } 81 | [array]$_nats_connection_item_subs_arr = $_nats_connection_item.subscriptions_list 82 | 83 | for ($_nats_connection_item_subs_arr_pos = 0; $_nats_connection_item_subs_arr_pos -lt $_nats_connection_item_subs_arr.Count; $_nats_connection_item_subs_arr_pos++) 84 | { 85 | if ($_nats_connection_item_subs_arr[$_nats_connection_item_subs_arr_pos].toLower().IndexOf("subspace.controller.piece") -ge 0) 86 | { 87 | $_controller_obj_arr += $_nats_connection_item_details_obj 88 | break 89 | } 90 | #elseif ($_nats_connection_item_subs_arr.toLower().IndexOf("subspace.controller.default.cache-identify") -ge 0) 91 | elseif ($_nats_connection_item_subs_arr[$_nats_connection_item_subs_arr_pos].toLower().IndexOf("cache-identify") -ge 0) 92 | { 93 | $_cache_obj_arr += $_nats_connection_item_details_obj 94 | break 95 | } 96 | elseif ($_nats_connection_item_subs_arr[$_nats_connection_item_subs_arr_pos].toLower().IndexOf("subspace.controller.farmer-identify") -ge 0 ` 97 | -or $_nats_connection_item_subs_arr[$_nats_connection_item_subs_arr_pos].toLower().IndexOf("farm.read-piece") -ge 0 ` 98 | -or $_nats_connection_item_subs_arr[$_nats_connection_item_subs_arr_pos].toLower().IndexOf("farm.plotted-sectors") -ge 0) 99 | { 100 | $_farmer_obj_arr += $_nats_connection_item_details_obj 101 | break 102 | } 103 | elseif ($_nats_connection_item_subs_arr[$_nats_connection_item_subs_arr_pos].toLower().IndexOf("subspace.plotter") -ge 0) 104 | { 105 | $_plotter_obj_arr += $_nats_connection_item_details_obj 106 | break 107 | } 108 | } 109 | } 110 | } 111 | # 112 | $_io_nats_connections_obj.Controller = $_controller_obj_arr 113 | $_io_nats_connections_obj.Cache = $_cache_obj_arr 114 | $_io_nats_connections_obj.Farmer = $_farmer_obj_arr 115 | $_io_nats_connections_obj.Plotter = $_plotter_obj_arr 116 | $_io_nats_connections_obj_arr += $_io_nats_connections_obj 117 | } 118 | catch {} 119 | return $_io_nats_connections_obj_arr 120 | } 121 | 122 | function fSanitizeConnections ([array]$_io_arr, [string]$_io_nats_url) { 123 | [array]$_sanitized_arr = $null 124 | # 125 | $_sorted_arr = $_io_arr 126 | if ($_io_arr.Count -gt 1) 127 | { 128 | $_sorted_arr = $_io_arr | Sort-Object @{Expression={$_.IP}; descending=$false}, @{Expression={$_.Port}; descending=$true} 129 | } 130 | for ($_i = 0; $_i -lt $_sorted_arr.Count; $_i++) 131 | { 132 | if ($_i -eq 0) 133 | { 134 | #$_sanitized_arr += $_sorted_arr[$_i] 135 | $_b_nats_obj_disconnected = fCheckNatsObjsForDisconnection $_sorted_arr[$_i] $_io_nats_url 136 | if (!($_b_nats_obj_disconnected)) 137 | { 138 | $_sanitized_arr += $_sorted_arr[$_i] 139 | } 140 | } 141 | elseif ($_sorted_arr[$_i].IP -ne $_sorted_arr[$_i-1].IP) 142 | { 143 | $_b_nats_obj_disconnected = fCheckNatsObjsForDisconnection $_sorted_arr[$_i] $_io_nats_url 144 | if (!($_b_nats_obj_disconnected)) 145 | { 146 | $_sanitized_arr += $_sorted_arr[$_i] 147 | } 148 | } 149 | elseif ($_sorted_arr[$_i].IP -eq $_sorted_arr[$_i-1].IP -and $_sorted_arr[$_i].Port -ne $_sorted_arr[$_i-1].Port) 150 | { 151 | $_b_nats_obj_disconnected = fCheckNatsObjsForDisconnection $_sorted_arr[$_i] $_io_nats_url 152 | if (!($_b_nats_obj_disconnected)) 153 | { 154 | $_sanitized_arr += $_sorted_arr[$_i] 155 | } 156 | } 157 | } 158 | # 159 | return $_sanitized_arr 160 | } 161 | 162 | function fCheckNatsObjsForDisconnection ([object]$_io_arr_item_obj, [string]$_io_nats_url) { 163 | [boolean]$_io_b_nats_obj_disconnected = $false 164 | [array]$_nats_closed_connection_obj_arr = $null 165 | if ($script:_nats_server_health_status) 166 | { 167 | $_nats_closed_connection_obj_arr = fGetNatsServerClosedConnections $_io_nats_url 168 | } 169 | for ($_nats_closed_connection_obj_arr_pos = 0; $_nats_closed_connection_obj_arr_pos -lt $_nats_closed_connection_obj_arr.Count; $_nats_closed_connection_obj_arr_pos++) 170 | { 171 | $_nats_closed_connection_obj_arr_item = $_nats_closed_connection_obj_arr[$_nats_closed_connection_obj_arr_pos] 172 | 173 | if ($_nats_closed_connection_obj_arr_item.IP -eq $_io_arr_item_obj.IP -and $_nats_closed_connection_obj_arr_item.Port -eq $_io_arr_item_obj.Port) 174 | { 175 | $_io_b_nats_obj_disconnected = $true 176 | break 177 | } 178 | } 179 | # 180 | return $_io_b_nats_obj_disconnected 181 | } 182 | 183 | function fGetNatsServerClosedConnections ([string]$_io_nats_url) { 184 | [array]$_io_nats_connections_obj_arr = $null 185 | [object]$_io_nats_connections_obj = $null 186 | 187 | $_nats_url_endpoint = "http://" + $_io_nats_url + "/connz?state=closed" 188 | try { 189 | $_nats_resp_obj = Invoke-RestMethod -Method 'GET' -uri $_nats_url_endpoint -TimeoutSec 5 190 | if ($_nats_resp_obj) { 191 | $_nats_connection_count = $_nats_resp_obj.connections.Count 192 | $_nats_connections_arr = $_nats_resp_obj.connections 193 | for ($_nats_connections_arr_pos = 0; $_nats_connections_arr_pos -lt $_nats_connections_arr.Count; $_nats_connections_arr_pos++) 194 | { 195 | $_nats_connection_item = $_nats_connections_arr[$_nats_connections_arr_pos] 196 | $_nats_connection_item_details_obj = [PSCustomObject]@{ 197 | CID = $_nats_connection_item.cid 198 | IP = $_nats_connection_item.ip 199 | Port = $_nats_connection_item.port 200 | StartTime = $_nats_connection_item.start 201 | LastSeen = $_nats_connection_item.last_activity 202 | StopTime = $_nats_connection_item.stop 203 | Reason = $_nats_connection_item.reason 204 | Uptime = $_nats_connection_item.uptime 205 | } 206 | $_io_nats_connections_obj = $_nats_connection_item_details_obj 207 | $_io_nats_connections_obj_arr += $_io_nats_connections_obj 208 | } 209 | } 210 | } 211 | catch {} 212 | return $_io_nats_connections_obj_arr 213 | } 214 | 215 | function fPreserveNatsConnectionsDetails ([string]$_io_nats_url) { 216 | [array]$_nats_active_connection_obj_arr = $null 217 | [array]$_nats_closed_connection_obj_arr = $null 218 | # 219 | [array]$_tmp_conn_obj_arr = $null 220 | # 221 | $_nats_server_response = fPingNatsServer $_io_nats_url 222 | $script:_nats_server_health_status = $_nats_server_response.Status 223 | $script:_nats_server_name = $_nats_server_response.ServerName 224 | if ($script:_nats_server_health_status) { 225 | $_nats_active_connection_obj_arr = fGetNatsServerActiveConnections $_io_nats_url 226 | for ($_nats_active_connection_obj_arr_pos = 0; $_nats_active_connection_obj_arr_pos -lt $_nats_active_connection_obj_arr.Count; $_nats_active_connection_obj_arr_pos++) 227 | { 228 | #$_tmp_conn_obj_arr = $script:_ss_controller_obj_arr 229 | $_tmp_conn_obj_arr = $null 230 | #$script:_ss_controller_obj_arr += $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos].Controller 231 | $_nats_controller_obj_item_arr = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos].Controller 232 | for ($_nats_controller_obj_item_arr_pos = 0; $_nats_controller_obj_item_arr_pos -lt $_nats_controller_obj_item_arr.Count; $_nats_controller_obj_item_arr_pos++) 233 | { 234 | $_nats_controller_obj_item = $_nats_controller_obj_item_arr[$_nats_controller_obj_item_arr_pos] 235 | <# 236 | [boolean]$_b_new_cluster_component = $true 237 | for ($_ss_controller_obj_arr_pos = 0; $_ss_controller_obj_arr_pos -lt $script:_ss_controller_obj_arr.Count; $_ss_controller_obj_arr_pos++) 238 | { 239 | #if ($script:_ss_controller_obj_arr.IP -eq $_nats_controller_obj_item.IP) 240 | if ($script:_ss_controller_obj_arr.IP -eq $_nats_controller_obj_item.IP -and $script:_ss_controller_obj_arr.Port -eq $_nats_controller_obj_item.Port) 241 | { 242 | $_b_new_cluster_component = $false 243 | break 244 | } 245 | } 246 | if ($_b_new_cluster_component) 247 | { 248 | #$script:_ss_controller_obj_arr += $_nats_controller_obj_item 249 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 250 | } 251 | #else { $_tmp_conn_obj_arr = $script:_ss_controller_obj_arr } 252 | #> 253 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 254 | } 255 | $script:_ss_controller_obj_arr = fSanitizeConnections $_tmp_conn_obj_arr $_io_nats_url 256 | # 257 | #$_tmp_conn_obj_arr = $script:_ss_cache_obj_arr 258 | $_tmp_conn_obj_arr = $null 259 | $_nats_controller_obj_item_arr = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos].Cache 260 | for ($_nats_controller_obj_item_arr_pos = 0; $_nats_controller_obj_item_arr_pos -lt $_nats_controller_obj_item_arr.Count; $_nats_controller_obj_item_arr_pos++) 261 | { 262 | $_nats_controller_obj_item = $_nats_controller_obj_item_arr[$_nats_controller_obj_item_arr_pos] 263 | <# 264 | [boolean]$_b_new_cluster_component = $true 265 | for ($_ss_cache_obj_arr_pos = 0; $_ss_cache_obj_arr_pos -lt $script:_ss_cache_obj_arr.Count; $_ss_cache_obj_arr_pos++) 266 | { 267 | #if ($script:_ss_cache_obj_arr.IP -eq $_nats_controller_obj_item.IP) 268 | if ($script:_ss_cache_obj_arr.IP -eq $_nats_controller_obj_item.IP -and $script:_ss_cache_obj_arr.Port -eq $_nats_controller_obj_item.Port) 269 | { 270 | $_b_new_cluster_component = $false 271 | break 272 | } 273 | } 274 | if ($_b_new_cluster_component) 275 | { 276 | #$script:_ss_cache_obj_arr += $_nats_controller_obj_item 277 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 278 | } 279 | #else { $_tmp_conn_obj_arr = $script:_ss_cache_obj_arr } 280 | #> 281 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 282 | } 283 | $script:_ss_cache_obj_arr = fSanitizeConnections $_tmp_conn_obj_arr $_io_nats_url 284 | # 285 | #$_tmp_conn_obj_arr = $script:_ss_farmer_obj_arr 286 | $_tmp_conn_obj_arr = $null 287 | $_nats_controller_obj_item_arr = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos].Farmer 288 | for ($_nats_controller_obj_item_arr_pos = 0; $_nats_controller_obj_item_arr_pos -lt $_nats_controller_obj_item_arr.Count; $_nats_controller_obj_item_arr_pos++) 289 | { 290 | $_nats_controller_obj_item = $_nats_controller_obj_item_arr[$_nats_controller_obj_item_arr_pos] 291 | <# 292 | [boolean]$_b_new_cluster_component = $true 293 | for ($_ss_farmer_obj_arr_pos = 0; $_ss_farmer_obj_arr_pos -lt $script:_ss_farmer_obj_arr.Count; $_ss_farmer_obj_arr_pos++) 294 | { 295 | #if ($script:_ss_farmer_obj_arr.IP -eq $_nats_controller_obj_item.IP) 296 | if ($script:_ss_farmer_obj_arr.IP -eq $_nats_controller_obj_item.IP -and $script:_ss_farmer_obj_arr.Port -eq $_nats_controller_obj_item.Port) 297 | { 298 | $_b_new_cluster_component = $false 299 | break 300 | } 301 | } 302 | if ($_b_new_cluster_component) 303 | { 304 | #$script:_ss_farmer_obj_arr += $_nats_controller_obj_item 305 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 306 | } 307 | #else { $_tmp_conn_obj_arr = $script:_ss_farmer_obj_arr } 308 | #> 309 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 310 | } 311 | $script:_ss_farmer_obj_arr = fSanitizeConnections $_tmp_conn_obj_arr $_io_nats_url 312 | # 313 | #$_tmp_conn_obj_arr = $script:_ss_plotter_obj_arr 314 | $_tmp_conn_obj_arr = $null 315 | $_nats_controller_obj_item_arr = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos].Plotter 316 | for ($_nats_controller_obj_item_arr_pos = 0; $_nats_controller_obj_item_arr_pos -lt $_nats_controller_obj_item_arr.Count; $_nats_controller_obj_item_arr_pos++) 317 | { 318 | $_nats_controller_obj_item = $_nats_controller_obj_item_arr[$_nats_controller_obj_item_arr_pos] 319 | <# 320 | [boolean]$_b_new_cluster_component = $true 321 | for ($_ss_plotter_obj_arr_pos = 0; $_ss_plotter_obj_arr_pos -lt $script:_ss_plotter_obj_arr.Count; $_ss_plotter_obj_arr_pos++) 322 | { 323 | #if ($script:_ss_plotter_obj_arr.IP -eq $_nats_controller_obj_item.IP) 324 | if ($script:_ss_plotter_obj_arr.IP -eq $_nats_controller_obj_item.IP -and $script:_ss_plotter_obj_arr.Port -eq $_nats_controller_obj_item.Port) 325 | { 326 | $_b_new_cluster_component = $false 327 | break 328 | } 329 | } 330 | if ($_b_new_cluster_component) 331 | { 332 | #$script:_ss_plotter_obj_arr += $_nats_controller_obj_item 333 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 334 | } 335 | #else { $_tmp_conn_obj_arr = $script:_ss_plotter_obj_arr } 336 | #> 337 | $_tmp_conn_obj_arr += $_nats_controller_obj_item 338 | } 339 | $script:_ss_plotter_obj_arr = fSanitizeConnections $_tmp_conn_obj_arr $_io_nats_url 340 | } 341 | } 342 | # 343 | # 344 | return $_nats_active_connection_obj_arr 345 | } 346 | 347 | function fWriteNatsServerInfoToConsole ([string]$_io_nats_url, [array]$_io_process_arr) { 348 | [array]$_nats_active_connection_obj_arr = $null 349 | [object]$_upper_line_separator_nats_server_CursorPosition = $null 350 | [object]$_header_nats_server_CursorPosition = $null 351 | [object]$_bottom_line_separator_nats_server_CursorPosition = $null 352 | [object]$_cluster_data_begin_row_pos = $null 353 | $_new_rows_for_console = 0 354 | [boolean]$_b_cluster_alert_triggered = $false 355 | $_cluster_header_column_num = 5 356 | $_cluster_header_column_size = 17 357 | $_b_cluster_information_printed = $true 358 | # 359 | if ($script:_new_rows_written_to_console -eq 0) 360 | { 361 | $_b_cluster_information_printed = $false 362 | } 363 | else 364 | { 365 | $_cluster_data_begin_row_pos = $script:_cluster_data_prev_row_pos_hold 366 | } 367 | # 368 | $_nats_active_connection_obj_arr = fPreserveNatsConnectionsDetails $_io_nats_url 369 | $script:_custom_alert_text = "Nats Server Name: $script:_nats_server_name" 370 | ## 371 | $_header_filler_length = 0 372 | 373 | $_cluster_id_seq_col_title = "Id" 374 | $_cluster_id_seq_col_size = 2 375 | 376 | if (!($_b_cluster_information_printed)) 377 | { 378 | $_console_msg = " " 379 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 380 | # get the current header cursor position for repositioning later 381 | $_upper_line_separator_nats_server_CursorPosition = $host.UI.RawUI.CursorPosition 382 | # 383 | Write-Host "" -ForegroundColor $_line_spacer_color 384 | $_console_msg = "|" 385 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 386 | # get the current header cursor position for repositioning later 387 | $_header_nats_server_CursorPosition = $host.UI.RawUI.CursorPosition 388 | # 389 | Write-Host "" -ForegroundColor $_line_spacer_color 390 | $_console_msg = "|" 391 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 392 | # get the current header cursor position for repositioning later 393 | $_bottom_line_separator_nats_server_CursorPosition = $host.UI.RawUI.CursorPosition 394 | # 395 | Write-Host "" -ForegroundColor $_line_spacer_color 396 | # 397 | $_nats_server_header_title = $_cluster_id_seq_col_title 398 | $_header_title = $_nats_server_header_title 399 | $_console_msg = "|" 400 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 401 | $_header_filler_length += $_header_title.Length 402 | $_console_msg = $_header_title 403 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 404 | 405 | $_nats_server_header_title = " Server Name " 406 | $_header_title = $_nats_server_header_title 407 | $_console_msg = "|" 408 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 409 | $_header_filler_length += $_header_title.Length 410 | $_console_msg = $_header_title 411 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 412 | $_console_msg = "|" 413 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 414 | # get the current header cursor position for repositioning later 415 | $_header_nats_server_header_CursorPosition = $host.UI.RawUI.CursorPosition 416 | # 417 | Write-Host "" -ForegroundColor $_line_spacer_color 418 | # 419 | $_label_spacer = fBuildDynamicSpacer $_cluster_id_seq_col_size $_label_line_separator 420 | $_console_msg = "|" + $_label_spacer 421 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 422 | 423 | $_label_spacer = fBuildDynamicSpacer $_header_title.Length $_label_line_separator 424 | $_console_msg = "|" + $_label_spacer 425 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 426 | # get the current header line separator cursor position for repositioning later 427 | $_line_separator_server_CursorPosition = $host.UI.RawUI.CursorPosition 428 | $_cluster_data_begin_row_pos = $_line_separator_server_CursorPosition 429 | # 430 | } 431 | # 432 | # set cursor position to first header data location 433 | [Console]::SetCursorPosition(0, ($_cluster_data_begin_row_pos.Y)) 434 | Write-Host "" -ForegroundColor $_line_spacer_color 435 | # 436 | $_console_msg = "|" 437 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 438 | $_cluster_id_seq_disp = $script:_cluster_id_seq.toString() 439 | if ($script:_cluster_id_seq -le 9) { $_cluster_id_seq_disp = "c" + $script:_cluster_id_seq.toString() } 440 | $_console_msg = $_cluster_id_seq_disp 441 | $script:_cluster_id_seq += 1 442 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 443 | 444 | $_console_msg = "|" 445 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 446 | $_console_msg = $script:_nats_server_name + ":" 447 | $_console_msg_color = "" 448 | if ($script:_nats_server_name -eq $null -or $script:_nats_server_name.Length -eq 0 -or $script:_nats_server_name.toLower() -eq "inactive") 449 | { 450 | $_console_msg_color = $_html_red 451 | } 452 | else { 453 | $_console_msg_color = $_line_spacer_color 454 | } 455 | Write-Host $_console_msg -nonewline -ForegroundColor $_console_msg_color 456 | # 457 | $_console_msg = "" 458 | $_console_msg_color = "" 459 | $_process_state_disp = $_label_line_separator_upper 460 | $_console_msg = $_process_state_disp 461 | if ($script:_nats_server_name -eq $null -or $script:_nats_server_name.Length -eq 0 -or $script:_nats_server_name.toLower() -eq "inactive") 462 | { 463 | $_console_msg_color = $_html_red 464 | } 465 | else { 466 | $_console_msg_color = $_html_green 467 | } 468 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 469 | # 470 | $_spacer_length = $_cluster_header_column_size - $script:_nats_server_name.Length - 2 ##column separators 471 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 472 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 473 | # get the current header line separator cursor position for repositioning later 474 | $_data_nats_server_CursorPosition = $host.UI.RawUI.CursorPosition 475 | # 476 | ## 477 | if (!($_b_cluster_information_printed)) 478 | { 479 | # set cursor position to last header location 480 | [Console]::SetCursorPosition($_header_nats_server_header_CursorPosition.X, $_header_nats_server_header_CursorPosition.Y) 481 | # 482 | $_controller_header_title = " Controller " 483 | $_header_title = $_controller_header_title 484 | $_header_filler_length += $_header_title.Length 485 | $_console_msg = $_header_title 486 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 487 | $_console_msg = "|" 488 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 489 | # get the current header cursor position for repositioning later 490 | $_header_controller_CursorPosition = $host.UI.RawUI.CursorPosition 491 | [object]$_data_controller_CursorPosition = $null 492 | # 493 | # set cursor position to last header location 494 | [Console]::SetCursorPosition($_line_separator_server_CursorPosition.X, $_line_separator_server_CursorPosition.Y) 495 | $_label_spacer = fBuildDynamicSpacer $_header_title.Length $_label_line_separator 496 | $_console_msg = "|" + $_label_spacer 497 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 498 | # get the current header line separator cursor position for repositioning later 499 | $_line_separator_controller_CursorPosition = $host.UI.RawUI.CursorPosition 500 | $script:_cluster_data_prev_row_pos_hold = $_line_separator_controller_CursorPosition 501 | $_cluster_data_begin_row_pos = $script:_cluster_data_prev_row_pos_hold 502 | } 503 | # 504 | # 505 | $_ss_controller_disp_name_length = 0 506 | $_b_nats_connection_type_match_found = $false 507 | [boolean]$_no_connection_exists = $true 508 | $_item_sequence_num = -1 509 | for ($_ss_controller_obj_arr_pos = 0; $_ss_controller_obj_arr_pos -lt $script:_ss_controller_obj_arr.Count; $_ss_controller_obj_arr_pos++) 510 | { 511 | $_b_nats_connection_type_match_found = $false 512 | [object]$_nats_active_connection_obj_arr_item = $null 513 | $_ss_controller_obj_arr_item = $script:_ss_controller_obj_arr[$_ss_controller_obj_arr_pos] 514 | # 515 | # 516 | if ($_ss_controller_obj_arr_item.ServerName -eq $script:_nats_server_name) 517 | { 518 | $_no_connection_exists = $false 519 | $_item_sequence_num += 1 520 | if ($_new_rows_for_console -lt ($_item_sequence_num + 1)) { $_new_rows_for_console = $_item_sequence_num + 1 } 521 | # 522 | # 523 | for ($_nats_active_connection_obj_arr_pos = 0; $_nats_active_connection_obj_arr_pos -lt $_nats_active_connection_obj_arr.Count; $_nats_active_connection_obj_arr_pos++) 524 | { 525 | $_nats_active_connection_obj_arr_item = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos] 526 | if ($_ss_controller_obj_arr_item.ServerName -eq $_nats_active_connection_obj_arr_item.ServerName) 527 | { 528 | for ($_connection_arr_pos = 0; $_connection_arr_pos -lt $_nats_active_connection_obj_arr_item.Controller.Count; $_connection_arr_pos++) 529 | { 530 | #if ($_ss_controller_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Controller[$_connection_arr_pos].IP) 531 | if ($_ss_controller_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Controller[$_connection_arr_pos].IP -and $_ss_controller_obj_arr_item.Port -eq $_nats_active_connection_obj_arr_item.Controller[$_connection_arr_pos].Port) 532 | { 533 | $_b_nats_connection_type_match_found = $true 534 | $_ss_controller_disp_name_length = $_ss_controller_obj_arr_item.IP.Length 535 | break 536 | } 537 | } 538 | } 539 | if ($_b_nats_connection_type_match_found) { break } 540 | } 541 | if ($_ss_controller_disp_name_length -eq 0) 542 | { 543 | $_ss_controller_disp_name_length = $_ss_controller_obj_arr_item.IP.Length 544 | } 545 | # 546 | [Console]::SetCursorPosition($_data_nats_server_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1+$_item_sequence_num)) 547 | 548 | # 549 | $_console_msg = "|" 550 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 551 | $_console_msg = $_ss_controller_obj_arr_item.IP.toString() + ":" 552 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 553 | # 554 | $_console_msg = "" 555 | $_console_msg_color = "" 556 | $_process_state_disp = $_label_line_separator_upper 557 | $_console_msg = $_process_state_disp 558 | if ($_b_nats_connection_type_match_found) 559 | { 560 | $_console_msg_color = $_html_green 561 | } 562 | else { 563 | $_console_msg_color = $_html_red 564 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("controller") -ge 0) { 565 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 566 | $script:_custom_alert_text += "SS Controller" + " status: Stopped, Host:" + $_ss_controller_obj_arr_item.IP 567 | $_b_cluster_alert_triggered = $true 568 | } 569 | } 570 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 571 | # 572 | $_spacer_length = $_cluster_header_column_size - $_ss_controller_disp_name_length - 2 ##column separators 573 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 574 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 575 | # get the current header data cursor position for repositioning later 576 | $_data_controller_CursorPosition = $host.UI.RawUI.CursorPosition 577 | # 578 | # 579 | } 580 | # 581 | # 582 | } 583 | #if ($script:_ss_controller_obj_arr.Count -le 0) 584 | if ($_no_connection_exists -or $script:_ss_controller_obj_arr.Count -le 0) 585 | { 586 | Write-Host "" -ForegroundColor $_line_spacer_color 587 | # 588 | # set cursor position to first header data location 589 | [Console]::SetCursorPosition($_data_nats_server_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1)) 590 | # 591 | $_console_msg = "|" 592 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 593 | $_console_msg = "Inactive" + ":" 594 | $_ss_controller_disp_name_length = ("Inactive").Length 595 | Write-Host $_console_msg -nonewline -ForegroundColor $_html_red 596 | # 597 | $_console_msg = "" 598 | $_console_msg_color = "" 599 | $_process_state_disp = $_label_line_separator_upper 600 | $_console_msg = $_process_state_disp 601 | if ($_b_nats_connection_type_match_found) 602 | { 603 | $_console_msg_color = $_html_green 604 | } 605 | else { 606 | $_console_msg_color = $_html_red 607 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("controller") -ge 0) { 608 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 609 | $script:_custom_alert_text += "SS Controller" + " status: Inactive, Host:" + "None set-up" 610 | $_b_cluster_alert_triggered = $true 611 | } 612 | } 613 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 614 | # 615 | $_spacer_length = $_cluster_header_column_size - $_ss_controller_disp_name_length - 2 ##column separators 616 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 617 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 618 | # get the current header data cursor position for repositioning later 619 | $_data_controller_CursorPosition = $host.UI.RawUI.CursorPosition 620 | } 621 | ## 622 | if (!($_b_cluster_information_printed)) 623 | { 624 | # set cursor position to last header location 625 | [Console]::SetCursorPosition($_header_controller_CursorPosition.X, $_header_controller_CursorPosition.Y) 626 | $_cache_header_title = " Cache " 627 | $_header_title = $_cache_header_title 628 | $_console_msg = $_header_title 629 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 630 | $_header_filler_length += $_header_title.Length 631 | $_console_msg = "|" 632 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 633 | # get the current header cursor position for repositioning later 634 | $_header_cache_CursorPosition = $host.UI.RawUI.CursorPosition 635 | [object]$_data_cache_CursorPosition = $null 636 | # 637 | # set cursor position to last header line separator location 638 | [Console]::SetCursorPosition($_line_separator_controller_CursorPosition.X, $_line_separator_controller_CursorPosition.Y) 639 | $_label_spacer = fBuildDynamicSpacer $_header_title.Length $_label_line_separator 640 | $_console_msg = "|" + $_label_spacer 641 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 642 | # get the current header line separator cursor position for repositioning later 643 | $_line_separator_cache_CursorPosition = $host.UI.RawUI.CursorPosition 644 | # 645 | } 646 | # 647 | $_ss_cache_disp_name_length = 0 648 | $_b_nats_connection_type_match_found = $false 649 | [boolean]$_no_connection_exists = $true 650 | $_item_sequence_num = -1 651 | for ($_ss_cache_obj_arr_pos = 0; $_ss_cache_obj_arr_pos -lt $script:_ss_cache_obj_arr.Count; $_ss_cache_obj_arr_pos++) 652 | { 653 | $_b_nats_connection_type_match_found = $false 654 | [object]$_nats_active_connection_obj_arr_item = $null 655 | $_ss_cache_obj_arr_item = $script:_ss_cache_obj_arr[$_ss_cache_obj_arr_pos] 656 | # 657 | if ($_ss_cache_obj_arr_item.ServerName -eq $script:_nats_server_name) 658 | { 659 | $_no_connection_exists = $false 660 | $_item_sequence_num += 1 661 | if ($_new_rows_for_console -lt ($_item_sequence_num + 1)) { $_new_rows_for_console = $_item_sequence_num + 1 } 662 | # 663 | for ($_nats_active_connection_obj_arr_pos = 0; $_nats_active_connection_obj_arr_pos -lt $_nats_active_connection_obj_arr.Count; $_nats_active_connection_obj_arr_pos++) 664 | { 665 | $_nats_active_connection_obj_arr_item = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos] 666 | if ($_ss_cache_obj_arr_item.ServerName -eq $_nats_active_connection_obj_arr_item.ServerName) 667 | { 668 | for ($_connection_arr_pos = 0; $_connection_arr_pos -lt $_nats_active_connection_obj_arr_item.Cache.Count; $_connection_arr_pos++) 669 | { 670 | #if ($_ss_cache_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Cache[$_connection_arr_pos].IP) 671 | if ($_ss_cache_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Cache[$_connection_arr_pos].IP -and $_ss_cache_obj_arr_item.Port -eq $_nats_active_connection_obj_arr_item.Cache[$_connection_arr_pos].Port) 672 | { 673 | $_b_nats_connection_type_match_found = $true 674 | $_ss_cache_disp_name_length = $_ss_cache_obj_arr_item.IP.Length 675 | break 676 | } 677 | } 678 | } 679 | if ($_b_nats_connection_type_match_found) { break } 680 | } 681 | if ($_ss_cache_disp_name_length -eq 0) 682 | { 683 | $_ss_cache_disp_name_length = $_ss_cache_obj_arr_item.IP.Length 684 | } 685 | # 686 | # set cursor position to first header data location 687 | [Console]::SetCursorPosition($_data_controller_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1+$_item_sequence_num)) 688 | # 689 | $_console_msg = "|" 690 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 691 | $_console_msg = $_ss_cache_obj_arr_item.IP.toString() + ":" 692 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 693 | # 694 | $_console_msg = "" 695 | $_console_msg_color = "" 696 | $_process_state_disp = $_label_line_separator_upper 697 | $_console_msg = $_process_state_disp 698 | if ($_b_nats_connection_type_match_found) 699 | { 700 | $_console_msg_color = $_html_green 701 | } 702 | else { 703 | $_console_msg_color = $_html_red 704 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cache") -ge 0) { 705 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 706 | $script:_custom_alert_text += "SS Cache" + " status: Stopped, Host:" + $_ss_cache_obj_arr_item.IP 707 | $_b_cluster_alert_triggered = $true 708 | } 709 | } 710 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 711 | # 712 | $_spacer_length = $_cluster_header_column_size - $_ss_cache_disp_name_length - 2 ##column separators 713 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 714 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 715 | # get the current header data cursor position for repositioning later 716 | $_data_cache_CursorPosition = $host.UI.RawUI.CursorPosition 717 | # 718 | } 719 | # 720 | } 721 | if ($_no_connection_exists -or $script:_ss_cache_obj_arr.Count -le 0) 722 | { 723 | # 724 | # set cursor position to first header data location 725 | [Console]::SetCursorPosition($_data_controller_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1)) 726 | # 727 | $_console_msg = "|" 728 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 729 | $_console_msg = "Inactive" + ":" 730 | $_ss_cache_disp_name_length = ("Inactive").Length 731 | Write-Host $_console_msg -nonewline -ForegroundColor $_html_red 732 | # 733 | $_console_msg = "" 734 | $_console_msg_color = "" 735 | $_process_state_disp = $_label_line_separator_upper 736 | $_console_msg = $_process_state_disp 737 | if ($_b_nats_connection_type_match_found) 738 | { 739 | $_console_msg_color = $_html_green 740 | } 741 | else { 742 | $_console_msg_color = $_html_red 743 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cache") -ge 0) { 744 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 745 | $script:_custom_alert_text += "SS Cache" + " status: Inactive, Host:" + "None set-up" 746 | $_b_cluster_alert_triggered = $true 747 | } 748 | } 749 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 750 | # 751 | $_spacer_length = $_cluster_header_column_size - $_ss_cache_disp_name_length - 2 ##column separators 752 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 753 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 754 | # get the current header data cursor position for repositioning later 755 | $_data_cache_CursorPosition = $host.UI.RawUI.CursorPosition 756 | } 757 | ## 758 | if (!($script:_b_disable_farmer_display_at_cluster)) 759 | { 760 | ## 761 | if (!($_b_cluster_information_printed)) 762 | { 763 | # set cursor position to last header location 764 | [Console]::SetCursorPosition($_header_cache_CursorPosition.X, $_header_cache_CursorPosition.Y) 765 | $_farmer_header_title = " Farmer " 766 | $_header_title = $_farmer_header_title 767 | $_console_msg = $_header_title 768 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 769 | $_header_filler_length += $_header_title.Length 770 | $_console_msg = "|" 771 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 772 | # get the current header cursor position for repositioning later 773 | $_header_farmer_CursorPosition = $host.UI.RawUI.CursorPosition 774 | [object]$_data_farmer_CursorPosition = $null 775 | # 776 | # set cursor position to last header line separator location 777 | [Console]::SetCursorPosition($_line_separator_cache_CursorPosition.X, $_line_separator_cache_CursorPosition.Y) 778 | $_label_spacer = fBuildDynamicSpacer $_header_title.Length $_label_line_separator 779 | $_console_msg = "|" + $_label_spacer 780 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 781 | # get the current header line separator cursor position for repositioning later 782 | $_line_separator_farmer_CursorPosition = $host.UI.RawUI.CursorPosition 783 | } 784 | # 785 | # 786 | $_ss_farmer_disp_name_length = 0 787 | $_b_nats_connection_type_match_found = $false 788 | [boolean]$_no_connection_exists = $true 789 | $_item_sequence_num = -1 790 | for ($_ss_farmer_obj_arr_pos = 0; $_ss_farmer_obj_arr_pos -lt $script:_ss_farmer_obj_arr.Count; $_ss_farmer_obj_arr_pos++) 791 | { 792 | $_ss_farmer_disp_name_length = 0 793 | $_b_nats_connection_type_match_found = $false 794 | [object]$_nats_active_connection_obj_arr_item = $null 795 | $_ss_farmer_obj_arr_item = $script:_ss_farmer_obj_arr[$_ss_farmer_obj_arr_pos] 796 | # 797 | # 798 | if ($_ss_farmer_obj_arr_item.ServerName -eq $script:_nats_server_name) 799 | { 800 | $_no_connection_exists = $false 801 | $_item_sequence_num += 1 802 | if ($_new_rows_for_console -lt ($_item_sequence_num + 1)) { $_new_rows_for_console = $_item_sequence_num + 1 } 803 | # 804 | # 805 | for ($_nats_active_connection_obj_arr_pos = 0; $_nats_active_connection_obj_arr_pos -lt $_nats_active_connection_obj_arr.Count; $_nats_active_connection_obj_arr_pos++) 806 | { 807 | $_nats_active_connection_obj_arr_item = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos] 808 | if ($_ss_farmer_obj_arr_item.ServerName -eq $_nats_active_connection_obj_arr_item.ServerName) 809 | { 810 | for ($_connection_arr_pos = 0; $_connection_arr_pos -lt $_nats_active_connection_obj_arr_item.Farmer.Count; $_connection_arr_pos++) 811 | { 812 | #if ($_ss_farmer_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Farmer[$_connection_arr_pos].IP) 813 | if ($_ss_farmer_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Farmer[$_connection_arr_pos].IP -and $_ss_farmer_obj_arr_item.Port -eq $_nats_active_connection_obj_arr_item.Farmer[$_connection_arr_pos].Port) 814 | { 815 | $_b_nats_connection_type_match_found = $true 816 | $_ss_farmer_disp_name_length = $_ss_farmer_obj_arr_item.IP.Length 817 | break 818 | } 819 | } 820 | } 821 | if ($_b_nats_connection_type_match_found) { break } 822 | } 823 | if ($_ss_farmer_disp_name_length -eq 0) 824 | { 825 | $_ss_farmer_disp_name_length = $_ss_farmer_obj_arr_item.IP.Length 826 | } 827 | # 828 | # set cursor position to first header data location 829 | [Console]::SetCursorPosition($_data_cache_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1+$_item_sequence_num)) 830 | # 831 | $_console_msg = "|" 832 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 833 | # 834 | # match nats farmer hostname from config for console display 835 | $_nats_farmer_hostname = $_ss_farmer_obj_arr_item.IP.toString() 836 | $_hostname = "" 837 | for ($arrPos = 0; $arrPos -lt $_io_process_arr.Count; $arrPos++) 838 | { 839 | $_farmer_metrics_raw = "" 840 | $_node_metrics_raw = "" 841 | [array]$_process_state_arr = $null 842 | $_b_process_running_ok = $false 843 | if ($_io_process_arr[$arrPos].toString().Trim(' ') -ne "" -and $_io_process_arr[$arrPos].toString().IndexOf("#") -lt 0) { 844 | $_config = $_io_process_arr[$arrPos].toString().split(":").Trim(" ") 845 | $_process_type = $_config[0].toString() 846 | $_b_disk_plot_id_match_found = $false 847 | if ($_process_type.toLower() -eq "farmer") { 848 | $_host_ip = $_config[1].toString() 849 | $_host_port = $_config[2].toString() 850 | $_host_friendly_name = "" 851 | if ($_config.Count -gt 3) { 852 | $_host_friendly_name = $_config[3].toString() 853 | } 854 | $_host_url = $_host_ip + ":" + $_host_port 855 | 856 | $_hostname = $_host_ip 857 | if ($_host_friendly_name -and $_host_friendly_name.length -gt 0) 858 | { 859 | $_hostname = $_host_friendly_name 860 | } 861 | [array]$_tmp_disk_metrics_arr = $null 862 | foreach ($_farmer_disk_metrics_arr_obj in $script:_farmer_disk_metrics_arr) 863 | { 864 | if ($_farmer_disk_metrics_arr_obj) 865 | { 866 | if ($_farmer_disk_metrics_arr_obj.Id -eq $_host_url) 867 | { 868 | $_tmp_disk_metrics_arr = $_farmer_disk_metrics_arr_obj.MetricsArr 869 | break 870 | } 871 | } 872 | else {break} 873 | } 874 | # 875 | $_tmp_disk_UUId_arr = $_tmp_disk_metrics_arr[0].Id 876 | 877 | $_nats_farmer_subscriptions_arr = $_ss_farmer_obj_arr_item.Subscriptions 878 | foreach ($_tmp_disk_UUId_obj in $_tmp_disk_UUId_arr) 879 | { 880 | if ($_tmp_disk_UUId_obj) { 881 | for ($_nats_farmer_subscriptions_arr_pos = 0; $_nats_farmer_subscriptions_arr_pos -lt $_nats_farmer_subscriptions_arr.Count; $_nats_farmer_subscriptions_arr_pos++) 882 | { 883 | if ($_nats_farmer_subscriptions_arr[$_nats_farmer_subscriptions_arr_pos].toLower().IndexOf($_tmp_disk_UUId_obj.Id.toLower()) -ge 0) 884 | { 885 | $_nats_farmer_hostname = $_hostname 886 | $_ss_farmer_disp_name_length = $_nats_farmer_hostname.Length 887 | $_b_disk_plot_id_match_found = $true 888 | break 889 | } 890 | } 891 | } 892 | if ($_b_disk_plot_id_match_found) { break } 893 | } 894 | if ($_b_disk_plot_id_match_found) { break } 895 | } 896 | } 897 | } 898 | $_console_msg = $_nats_farmer_hostname + ":" 899 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 900 | # 901 | $_console_msg = "" 902 | $_console_msg_color = "" 903 | $_process_state_disp = $_label_line_separator_upper 904 | $_console_msg = $_process_state_disp 905 | if ($_b_nats_connection_type_match_found) 906 | { 907 | $_console_msg_color = $_html_green 908 | } 909 | else { 910 | $_console_msg_color = $_html_red 911 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("farmer") -ge 0) { 912 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 913 | $script:_custom_alert_text += "SS Farmer" + " status: Stopped, Host:" + $_nats_farmer_hostname 914 | $_b_cluster_alert_triggered = $true 915 | } 916 | } 917 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 918 | # 919 | $_spacer_length = $_cluster_header_column_size - $_ss_farmer_disp_name_length - 2 ##column separators 920 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 921 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 922 | # get the current header data cursor position for repositioning later 923 | $_data_farmer_CursorPosition = $host.UI.RawUI.CursorPosition 924 | # 925 | } 926 | # 927 | } 928 | if ($_no_connection_exists -or $script:_ss_farmer_obj_arr.Count -le 0) 929 | { 930 | # 931 | # set cursor position to first header data location 932 | [Console]::SetCursorPosition($_data_cache_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1)) 933 | # 934 | $_console_msg = "|" 935 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 936 | $_console_msg = "Inactive" + ":" 937 | $_ss_farmer_disp_name_length = ("Inactive").Length 938 | Write-Host $_console_msg -nonewline -ForegroundColor $_html_red 939 | # 940 | $_console_msg = "" 941 | $_console_msg_color = "" 942 | $_process_state_disp = $_label_line_separator_upper 943 | $_console_msg = $_process_state_disp 944 | if ($_b_nats_connection_type_match_found) 945 | { 946 | $_console_msg_color = $_html_green 947 | } 948 | else { 949 | $_console_msg_color = $_html_red 950 | if ($_nats_farmer_hostname.Length -le 0) { $_nats_farmer_hostname = "None set-up" } 951 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("farmer") -ge 0) { 952 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 953 | $script:_custom_alert_text += "SS Farmer" + " status: Inactive, Host:" + $_nats_farmer_hostname 954 | $_b_cluster_alert_triggered = $true 955 | } 956 | } 957 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 958 | # 959 | $_spacer_length = $_cluster_header_column_size - $_ss_farmer_disp_name_length - 2 ##column separators 960 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 961 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 962 | # get the current header data cursor position for repositioning later 963 | $_data_farmer_CursorPosition = $host.UI.RawUI.CursorPosition 964 | } 965 | } 966 | ## 967 | if (!($_b_cluster_information_printed)) 968 | { 969 | # set cursor position to last header location 970 | [Console]::SetCursorPosition($_header_farmer_CursorPosition.X, $_header_farmer_CursorPosition.Y) 971 | if ($script:_b_disable_farmer_display_at_cluster) 972 | { 973 | [Console]::SetCursorPosition($_header_cache_CursorPosition.X, $_header_cache_CursorPosition.Y) 974 | } 975 | $_plotter_header_title = " Plotter " 976 | $_header_title = $_plotter_header_title 977 | $_console_msg = $_header_title 978 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 979 | $_header_filler_length += $_header_title.Length 980 | $_console_msg = "|" 981 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 982 | # get the current header cursor position for repositioning later 983 | $_header_plotter_CursorPosition = $host.UI.RawUI.CursorPosition 984 | [object]$_data_plotter_CursorPosition = $null 985 | # 986 | # set cursor position to last header line separator location 987 | [Console]::SetCursorPosition($_line_separator_farmer_CursorPosition.X, $_line_separator_farmer_CursorPosition.Y) 988 | if ($script:_b_disable_farmer_display_at_cluster) 989 | { 990 | [Console]::SetCursorPosition($_line_separator_cache_CursorPosition.X, $_line_separator_cache_CursorPosition.Y) 991 | } 992 | $_label_spacer = fBuildDynamicSpacer $_header_title.Length $_label_line_separator 993 | $_console_msg = "|" + $_label_spacer + "|" 994 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 995 | # get the current header line separator cursor position for repositioning later 996 | $_line_separator_plotter_CursorPosition = $host.UI.RawUI.CursorPosition 997 | } 998 | # 999 | $_ss_plotter_disp_name_length = 0 1000 | $_b_nats_connection_type_match_found = $false 1001 | [boolean]$_no_connection_exists = $true 1002 | $_item_sequence_num = -1 1003 | for ($_ss_plotter_obj_arr_pos = 0; $_ss_plotter_obj_arr_pos -lt $script:_ss_plotter_obj_arr.Count; $_ss_plotter_obj_arr_pos++) 1004 | { 1005 | $_b_nats_connection_type_match_found = $false 1006 | [object]$_nats_active_connection_obj_arr_item = $null 1007 | $_ss_plotter_obj_arr_item = $script:_ss_plotter_obj_arr[$_ss_plotter_obj_arr_pos] 1008 | # 1009 | if ($_ss_plotter_obj_arr_item.ServerName -eq $script:_nats_server_name) 1010 | { 1011 | $_no_connection_exists = $false 1012 | $_item_sequence_num += 1 1013 | if ($_new_rows_for_console -lt ($_item_sequence_num + 1)) { $_new_rows_for_console = $_item_sequence_num + 1 } 1014 | # 1015 | for ($_nats_active_connection_obj_arr_pos = 0; $_nats_active_connection_obj_arr_pos -lt $_nats_active_connection_obj_arr.Count; $_nats_active_connection_obj_arr_pos++) 1016 | { 1017 | $_nats_active_connection_obj_arr_item = $_nats_active_connection_obj_arr[$_nats_active_connection_obj_arr_pos] 1018 | if ($_ss_plotter_obj_arr_item.ServerName -eq $_nats_active_connection_obj_arr_item.ServerName) 1019 | { 1020 | for ($_connection_arr_pos = 0; $_connection_arr_pos -lt $_nats_active_connection_obj_arr_item.Plotter.Count; $_connection_arr_pos++) 1021 | { 1022 | #if ($_ss_plotter_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Plotter[$_connection_arr_pos].IP) 1023 | if ($_ss_plotter_obj_arr_item.IP -eq $_nats_active_connection_obj_arr_item.Plotter[$_connection_arr_pos].IP -and $_ss_plotter_obj_arr_item.Port -eq $_nats_active_connection_obj_arr_item.Plotter[$_connection_arr_pos].Port) 1024 | { 1025 | $_b_nats_connection_type_match_found = $true 1026 | $_ss_plotter_disp_name_length = $_ss_plotter_obj_arr_item.IP.Length 1027 | break 1028 | } 1029 | } 1030 | } 1031 | if ($_b_nats_connection_type_match_found) { break } 1032 | } 1033 | if ($_ss_plotter_disp_name_length -eq 0) 1034 | { 1035 | $_ss_plotter_disp_name_length = $_ss_plotter_obj_arr_item.IP.Length 1036 | } 1037 | # 1038 | # set cursor position to first header data location 1039 | [Console]::SetCursorPosition($_data_farmer_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1+$_item_sequence_num)) 1040 | if ($script:_b_disable_farmer_display_at_cluster) 1041 | { 1042 | [Console]::SetCursorPosition($_data_cache_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1+$_item_sequence_num)) 1043 | } 1044 | # 1045 | $_console_msg = "|" 1046 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1047 | $_console_msg = $_ss_plotter_obj_arr_item.IP.toString() + ":" 1048 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1049 | # 1050 | $_console_msg = "" 1051 | $_console_msg_color = "" 1052 | $_process_state_disp = $_label_line_separator_upper 1053 | $_console_msg = $_process_state_disp 1054 | if ($_b_nats_connection_type_match_found) 1055 | { 1056 | $_console_msg_color = $_html_green 1057 | } 1058 | else { 1059 | $_console_msg_color = $_html_red 1060 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("plotter") -ge 0) { 1061 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 1062 | $script:_custom_alert_text += "SS Plotter" + " status: Stopped, Host:" + $_ss_plotter_obj_arr_item.IP 1063 | $_b_cluster_alert_triggered = $true 1064 | } 1065 | } 1066 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 1067 | # 1068 | $_spacer_length = $_cluster_header_column_size - $_ss_plotter_disp_name_length - 2 ##column separators 1069 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 1070 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 1071 | # get the current header data cursor position for repositioning later 1072 | $_data_plotter_CursorPosition = $host.UI.RawUI.CursorPosition 1073 | # 1074 | #Finish only if last column 1075 | $_console_msg = "|" 1076 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1077 | # 1078 | } 1079 | # 1080 | } 1081 | #if ($script:_ss_plotter_obj_arr.Count -le 0) 1082 | if ($_no_connection_exists -or $script:_ss_plotter_obj_arr.Count -le 0) 1083 | { 1084 | # 1085 | # set cursor position to first header data location 1086 | [Console]::SetCursorPosition($_data_farmer_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+1)) 1087 | if ($script:_b_disable_farmer_display_at_cluster) 1088 | { 1089 | [Console]::SetCursorPosition($_data_cache_CursorPosition.X, $_data_cache_CursorPosition.Y) 1090 | } 1091 | # 1092 | $_console_msg = "|" 1093 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1094 | $_console_msg = "Inactive" + ":" 1095 | $_ss_plotter_disp_name_length = ("Inactive").Length 1096 | Write-Host $_console_msg -nonewline -ForegroundColor $_html_red 1097 | # 1098 | $_console_msg = "" 1099 | $_console_msg_color = "" 1100 | $_process_state_disp = $_label_line_separator_upper 1101 | $_console_msg = $_process_state_disp 1102 | if ($_b_nats_connection_type_match_found) 1103 | { 1104 | $_console_msg_color = $_html_green 1105 | } 1106 | else { 1107 | $_console_msg_color = $_html_red 1108 | if ($script:_alert_category_txt.toLower().IndexOf("all") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("everything") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("cluster") -ge 0 -or $script:_alert_category_txt.toLower().IndexOf("plotter") -ge 0) { 1109 | if ($script:_custom_alert_text.Length -gt 0) { $script:_custom_alert_text += " | " } 1110 | $script:_custom_alert_text += "SS Plotter" + " status: Inactive, Host:" + "None set-up" 1111 | $_b_cluster_alert_triggered = $true 1112 | } 1113 | } 1114 | Write-Host $_console_msg -ForegroundColor $_fg_color_black -BackgroundColor $_console_msg_color -nonewline 1115 | # 1116 | $_spacer_length = $_cluster_header_column_size - $_ss_plotter_disp_name_length - 2 ##column separators 1117 | $_label_spacer = fBuildDynamicSpacer $_spacer_length $_spacer 1118 | Write-Host $_label_spacer -nonewline -ForegroundColor $_line_spacer_color 1119 | # get the current header data cursor position for repositioning later 1120 | $_data_plotter_CursorPosition = $host.UI.RawUI.CursorPosition 1121 | # 1122 | #Finish only if last column 1123 | $_console_msg = "|" 1124 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1125 | } 1126 | # 1127 | ##Write finish line seprator 1128 | if ($_new_rows_for_console -eq 0) { $_new_rows_for_console = 1 } 1129 | $script:_new_rows_written_to_console += $_new_rows_for_console 1130 | # 1131 | # set cursor position to first header data location 1132 | [Console]::SetCursorPosition($_data_plotter_CursorPosition.X, ($_cluster_data_begin_row_pos.Y+$_new_rows_for_console)) 1133 | ## 1134 | ## more than 1 nats server(s) separation line 1135 | Write-Host "" -ForegroundColor $_line_spacer_color 1136 | 1137 | #$_label_spacer = fBuildDynamicSpacer (($_cluster_header_column_size * $_cluster_header_column_num) + $_cluster_header_column_num - 1) $_label_line_separator_upper 1138 | $_label_spacer = fBuildDynamicSpacer $_cluster_header_column_size $_label_line_separator 1139 | $_console_msg = "|" 1140 | for ($_cluster_header_column_num_pos = 0; $_cluster_header_column_num_pos -lt $_cluster_header_column_num; $_cluster_header_column_num_pos++) 1141 | { 1142 | if ($_cluster_header_column_num_pos -eq 0) 1143 | { 1144 | $_console_msg += fBuildDynamicSpacer $_cluster_id_seq_col_size $_label_line_separator 1145 | $_console_msg += "|" 1146 | } 1147 | 1148 | if ($_cluster_header_column_num_pos -lt ($_cluster_header_column_num - 1)) 1149 | { 1150 | $_console_msg += $_label_spacer + "|" 1151 | } 1152 | elseif (!($script:_b_disable_farmer_display_at_cluster)) 1153 | { 1154 | $_console_msg += $_label_spacer + "|" 1155 | } 1156 | } 1157 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1158 | ## 1159 | # get the nats finish line separator cursor position for repositioning later 1160 | $_finish_line_separator_nats_server_CursorPosition = $host.UI.RawUI.CursorPosition 1161 | # 1162 | # 1163 | for ($_new_rows_for_console_pos = 0; $_new_rows_for_console_pos -lt $_new_rows_for_console; $_new_rows_for_console_pos++) 1164 | { 1165 | try { 1166 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*0), ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1167 | $_console_msg = "|" 1168 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1169 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*0)+$_cluster_id_seq_col_size+1, ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1170 | $_console_msg = "|" 1171 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1172 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*1)+$_cluster_id_seq_col_size+1, ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1173 | $_console_msg = "|" 1174 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1175 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*2)+$_cluster_id_seq_col_size+1, ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1176 | $_console_msg = "|" 1177 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1178 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*3)+$_cluster_id_seq_col_size+1, ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1179 | $_console_msg = "|" 1180 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1181 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*4)+$_cluster_id_seq_col_size+1, ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1182 | $_console_msg = "|" 1183 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1184 | [Console]::SetCursorPosition((($_cluster_header_column_size+1)*5)+$_cluster_id_seq_col_size+1, ($_cluster_data_begin_row_pos.Y+1+$_new_rows_for_console_pos)) 1185 | if (!($script:_b_disable_farmer_display_at_cluster)) 1186 | { 1187 | $_console_msg = "|" 1188 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1189 | } 1190 | } 1191 | catch {} 1192 | } 1193 | ## 1194 | ##Write nats server header and wrap-up 1195 | if (!($_b_cluster_information_printed)) 1196 | { 1197 | # set cursor position to last cluster header top line separator location 1198 | [Console]::SetCursorPosition($_upper_line_separator_nats_server_CursorPosition.X, $_upper_line_separator_nats_server_CursorPosition.Y) 1199 | $_label_spacer = fBuildDynamicSpacer ($_header_filler_length + ($_cluster_header_column_num - 1) + $_cluster_id_seq_col_size - 1) $_label_line_separator 1200 | if ($script:_b_disable_farmer_display_at_cluster) 1201 | { 1202 | $_label_spacer = fBuildDynamicSpacer ($_header_filler_length + ($_cluster_header_column_num - 1) + $_cluster_id_seq_col_size - 2) $_label_line_separator 1203 | } 1204 | $_console_msg = $_label_spacer 1205 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1206 | # set cursor position to last cluster header location 1207 | [Console]::SetCursorPosition($_header_nats_server_CursorPosition.X, $_header_nats_server_CursorPosition.Y) 1208 | $_cluster_header_title = "Cluster:" 1209 | $_label_spacer = fBuildDynamicSpacer (($_header_filler_length + ($_cluster_header_column_num - 1) + ($_cluster_id_seq_col_size) - $_cluster_header_title.Length - 2)/2) $_spacer 1210 | $_console_msg = $_label_spacer 1211 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1212 | $_console_msg = $_cluster_header_title + " " 1213 | Write-Host $_console_msg -nonewline -ForegroundColor $_farmer_header_color 1214 | # 1215 | $_label_spacer = fBuildDynamicSpacer (($_header_filler_length + ($_cluster_header_column_num - 1) + ($_cluster_id_seq_col_size - 1) - $_cluster_header_title.Length - 2)/2) $_spacer 1216 | $_console_msg = $_label_spacer + "|" 1217 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1218 | # set cursor position to last cluster header bottom line separator location 1219 | [Console]::SetCursorPosition($_bottom_line_separator_nats_server_CursorPosition.X, $_bottom_line_separator_nats_server_CursorPosition.Y) 1220 | # 1221 | $_label_spacer = fBuildDynamicSpacer ($_header_filler_length + $_cluster_header_column_num - 1 + $_cluster_id_seq_col_size - 1) $_label_line_separator 1222 | if ($script:_b_disable_farmer_display_at_cluster) 1223 | { 1224 | $_label_spacer = fBuildDynamicSpacer ($_header_filler_length + $_cluster_header_column_num - 1 + $_cluster_id_seq_col_size - 2) $_label_line_separator 1225 | } 1226 | $_console_msg = $_label_spacer + "|" 1227 | Write-Host $_console_msg -nonewline -ForegroundColor $_line_spacer_color 1228 | } 1229 | # set cursor position to cluster finish line separator location 1230 | [Console]::SetCursorPosition($_finish_line_separator_nats_server_CursorPosition.X, $_finish_line_separator_nats_server_CursorPosition.Y) 1231 | $script:_cluster_data_prev_row_pos_hold = $_finish_line_separator_nats_server_CursorPosition 1232 | ## 1233 | ##NOT USED - below lines 1234 | #[array]$_nats_closed_connection_obj_arr = $null 1235 | #if ($script:_nats_server_health_status) 1236 | #{ 1237 | # $_nats_closed_connection_obj_arr = fGetNatsServerClosedConnections $_io_nats_url 1238 | #} 1239 | #for ($_nats_closed_connection_obj_arr_pos = 0; $_nats_closed_connection_obj_arr_pos -lt $_nats_closed_connection_obj_arr.Count; $_nats_closed_connection_obj_arr_pos++) 1240 | #{ 1241 | # $_nats_closed_connection_obj_arr_item = $_nats_closed_connection_obj_arr[$_nats_closed_connection_obj_arr_pos] 1242 | # ##Not used currently 1243 | # #Write-Host "_nats_closed_connection_obj_arr_item = " $_nats_closed_connection_obj_arr_item 1244 | #} 1245 | ##NOT USED - above lines 1246 | # 1247 | # send alerts 1248 | if ($_b_cluster_alert_triggered) 1249 | { 1250 | fGenAlertNotifications $script:_custom_alert_text 1251 | } 1252 | # 1253 | } 1254 | --------------------------------------------------------------------------------