undefined array key 1 return Carbon::createFromFormat('D M d H:i:s , $matches[1]); - laravel-8

When i run laravel project using Git Bash
"php artisan serve --host 192.168.1.8 --port 80" Application will run.. but when I access two or three times in link using another PC or android device in same network.. error popup... and cancel automatically
php artisan serve --host 192.168.1.8 --port 80
INFO Server running on [http://192.168.1.8:80].
Press Ctrl+C to stop the server
2022-11-01 11:33:52 ................................................... ~ 0s
2022-11-01 11:33:53 ................................................... ~ 0s
2022-11-01 11:33:52 /assets/css/bootstrap.min.css ..................... ~ 1s
2022-11-01 11:33:53 ................................................... ~ 0s
2022-11-01 11:33:53 /assets/css/now-ui-dashboard.css?v=1.0.1 .......... ~ 0s
2022-11-01 11:33:53 /assets/js/core/popper.min.js ..................... ~ 0s
2022-11-01 11:33:53 /assets/js/core/bootstrap.min.js .................. ~ 0s
2022-11-01 11:33:53 /assets/js/plugins/perfect-scrollbar.jquery.min.js ~ 0s
2022-11-01 11:33:53 /assets/js/core/jquery.min.js ..................... ~ 0s
2022-11-01 11:33:53 /assets/js/plugins/bootstrap-notify.js ............ ~ 0s
2022-11-01 11:33:53 /assets/js/now-ui-dashboard.js?v=1.0.1 ............ ~ 0s
2022-11-01 11:33:53 ................................................... ~ 0s
2022-11-01 11:33:53 /assets/js/plugins/chartjs.min.js ................. ~ 0s
2022-11-01 11:33:53 /assets/fonts/nucleo-outline.woff2 ................ ~ 0s
2022-11-01 11:33:54 /assets/img/favicon.png ........................... ~ 0s
2022-11-01 11:34:00 ................................................... ~ 0s
2022-11-01 11:34:00 /assets/css/bootstrap.min.css ..................... ~ 1s
2022-11-01 11:34:01 ................................................... ~ 0s
2022-11-01 11:34:01 ................................................... ~ 0s
2022-11-01 11:34:01 /assets/css/now-ui-dashboard.css?v=1.0.1 .......... ~ 0s
WARN 192.168.1.1.
2022-11-01 11:34:01
ErrorException
Undefined array key 1
at C:\xampp2\htdocs\final_laravel\pgrcdata\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:308
304▕ : '/^[([^]]+)]/';
305▕
306▕ preg_match($regex, $line, $matches);
307▕
308▕ return Carbon::createFromFormat('D M d H:i:s Y', $matches1);
309▕ }
310▕
311▕ /**
312▕ * Get the request port from the given PHP server output.
1 C:\xampp2\htdocs\final_laravel\pgrcdata\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:308
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap{closure}("Undefined array key 1", "C:\xampp2\htdocs\final_laravel\pgrcdata\vendor\laravel\framework\src
\Illuminate\Foundation\Console\ServeCommand.php")
2 C:\xampp2\htdocs\final_laravel\pgrcdata\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:275
Illuminate\Foundation\Console\ServeCommand::getDateFromLine("0:45656 Closing")
Screenshot
What can i do.. Please help.. Thank you.
I try to change Carbon Date format but its not working....

Your RegExp should be: '/^\[([^]]+)]/' (i.e. the first bracket needs to be escaped) so you captures things in actual bracket and not an range of characters.

Related

I want to print only the last log between'=====' and'====='

Below is status log of linux server.
I only want to print the last log between'=====' and'====='.
-- Below is that log.
# cat /var/log/server-status/status.log
~~ snip ~~
==============================================
2020-08-13_23:49:21_KST UnixTime=1597330161
1 Min Average Load::2.45(CPUS:2)
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 31394 99.4 0.0 7312 96 pts/4 R+ 21:41 127:11 stress -c 2
root 31395 99.3 0.0 7312 96 pts/4 R+ 21:41 127:08 stress -c 2
root 2838 0.2 0.0 157500 2344 pts/0 S+ Aug06 25:55 watch -d -n1 uptime
rpc 904 0.0 0.0 69280 1004 ? Ss Aug06 0:00 /sbin/rpcbind -w
root 935 0.0 0.2 550668 11180 ? Ssl Aug06 0:07 /usr/sbin/NetworkManager --no-daemon
----------------------------------------------
==============================================
==============================================
2020-08-13_23:51:38_KST UnixTime=1597330298
MEM USAGE::41.20(ThreadHold:41)
----------------------------------------------
==============================================
==============================================
2020-08-13_23:52:41_KST UnixTime=1597330361
----------------------------------------------
MEM USAGE::41.21(ThreadHold:41)
----------------------------------------------
==============================================
==============================================
2020-08-13_23:53:03_KST UnixTime=1597330383
----------------------------------------------
1 Min Average Load::2.22(CPUS:2)
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 31394 99.4 0.0 7312 96 pts/4 R+ 21:41 130:52 stress -c 2
root 31395 99.3 0.0 7312 96 pts/4 R+ 21:41 130:49 stress -c 2
root 2838 0.2 0.0 157500 2344 pts/0 S+ Aug06 25:56 watch -d -n1 uptime
rpc 904 0.0 0.0 69280 1004 ? Ss Aug06 0:00 /sbin/rpcbind -w
root 935 0.0 0.2 550668 11180 ? Ssl Aug06 0:07 /usr/sbin/NetworkManager --no-daemon
----------------------------------------------
MEM USAGE::41.18(ThreadHold:41)
----------------------------------------------
==============================================
-- I used the method below.
However, this result is not accurate.
# tail -n 20 /var/log/server-status/status.log | sed -n -e '/UnixTime/,/==/ p'
2020-08-14_00:24:49_KST UnixTime=1597332289
----------------------------------------------
1 Min Average Load::2.24 (CPUS:2)
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 31395 99.4 0.0 7312 96 pts/4 R+ Aug13 162:25 stress -c 2
root 31394 99.4 0.0 7312 96 pts/4 R+ Aug13 162:27 stress -c 2
root 2838 0.2 0.0 157500 2344 pts/0 S+ Aug06 26:00 watch -d -n1 uptime
root 9713 0.1 0.1 161536 6088 ? Ss 00:24 0:00 sshd: root#pts/6
rpc 904 0.0 0.0 69280 1004 ? Ss Aug06 0:00 /sbin/rpcbind -w
----------------------------------------------
==============================================
This is because sometimes the log below may be the last.
==============================================
2020-08-13_23:51:38_KST UnixTime=1597330298
MEM USAGE::41.20(ThreadHold:41)
----------------------------------------------
==============================================
--> That is, because the line can be variable.
# tail -n 20 /var/log/server-status/status.log | sed -n -e '/UnixTime/,/==/ p'
2020-08-13_23:51:38_KST UnixTime=1597330298
MEM USAGE::41.20(ThreadHold:41)
----------------------------------------------
==============================================
2020-08-13_23:52:58_KST UnixTime=1597330298
MEM USAGE::41.20(ThreadHold:41)
----------------------------------------------
==============================================
--> This is not the result I want.
How can I print properly only the last log between'=====' and'====='?
Thanks
GNU sed will do the trick:
sed -n '/UnixTime/h;//!H;$!d;x;//p' /var/log/server-status/status.log
Background: This will replace anything in the hold space by the line containing "UnixTime" (aka last occurrence), then will append all following lines to the hold space. Once it's reached the bottom it will swap the pattern space for the hold space and then print out the result (as long as there is a match).
Depending on the content, you could pipe the content from cat as well, but I don't believe this will be necessary.
For scenario #1 will give:
2020-08-13_23:53:03_KST UnixTime=1597330383
----------------------------------------------
1 Min Average Load::2.22(CPUS:2)
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 31394 99.4 0.0 7312 96 pts/4 R+ 21:41 130:52 stress -c 2
root 31395 99.3 0.0 7312 96 pts/4 R+ 21:41 130:49 stress -c 2
root 2838 0.2 0.0 157500 2344 pts/0 S+ Aug06 25:56 watch -d -n1 uptime
rpc 904 0.0 0.0 69280 1004 ? Ss Aug06 0:00 /sbin/rpcbind -w
root 935 0.0 0.2 550668 11180 ? Ssl Aug06 0:07 /usr/sbin/NetworkManager --no-daemon
----------------------------------------------
MEM USAGE::41.18(ThreadHold:41)
----------------------------------------------
==============================================
For scenario #2 will give:
2020-08-13_23:51:38_KST UnixTime=1597330298
MEM USAGE::41.20(ThreadHold:41)
----------------------------------------------
==============================================
Could you please try following. Using tac + awk combination here. Reading Input_file in reverse do that we need not to read whole Input_file. Just read last stanza from 2nd last occurrence of = to last occurrence of =(which becomes first occurrence to second occurrence reading because tac reads Input_file reverse). So once awk processes it, it will be in reverse format hence using again one more tac to print lines in actual format. Written on mobile so yet to test it should work but.
tac Input_file |
awk '
/^=/{
if(++count==1){ found=1 }
if(count>1) { exit }
}
found' |
tac
$ tac file | awk '/^=/{c++} c; c==2{exit}' | tac
==============================================
2020-08-13_23:53:03_KST UnixTime=1597330383
----------------------------------------------
1 Min Average Load::2.22(CPUS:2)
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 31394 99.4 0.0 7312 96 pts/4 R+ 21:41 130:52 stress -c 2
root 31395 99.3 0.0 7312 96 pts/4 R+ 21:41 130:49 stress -c 2
root 2838 0.2 0.0 157500 2344 pts/0 S+ Aug06 25:56 watch -d -n1 uptime
rpc 904 0.0 0.0 69280 1004 ? Ss Aug06 0:00 /sbin/rpcbind -w
root 935 0.0 0.2 550668 11180 ? Ssl Aug06 0:07 /usr/sbin/NetworkManager --no-daemon
----------------------------------------------
MEM USAGE::41.18(ThreadHold:41)
----------------------------------------------
==============================================
With GNU sed (relying on === on the last line and removing that line):
sed -rz 's/.*===\n(.+)\n==*/\1/' file
Without deleting the last line with ==== the answer is easier:
sed -rz 's/.*===\n(.+)/\1/' file

Gurobi Warning and Inconsistency in Optimal Value [some integer variables take values larger than the maximum supported value (2000000000)]

I am using Gurobi version 8.1.0 and Python API version 3.6 to solve MIP problems. I have two models in which I believe that their global optima are equal. However, I found out that they are not equal in one of my simulations. I then tried to warm-start the model that I believe the solution is incorrect (model-1) with the solution from another model (model-2). In other words, the problem is to maximize the objective function and the objective value of model-1 is 42.3333, but I believe it should be 42.8333. Therefore, I use the solution from model-2 with the objective value of 42.8333 to warm-start to model-1.
What is weird is that the solution from model-2 should not be feasible to model-1 since the objective value is greater than 42.3333 and the problem is maximization. However, it turns out that it is a feasible warm start and now the optimal value of model-1 is 42.8333. How can the same model have multiple optima?
Changed value of parameter timeLimit to 10800.0
Prev: 1e+100 Min: 0.0 Max: 1e+100 Default: 1e+100
Changed value of parameter LogFile to output/inconsistent_Model-1.log
Prev: gurobi.log Default:
Optimize a model with 11277 rows, 15150 columns and 165637 nonzeros
Model has 5050 general constraints
Variable types: 0 continuous, 15150 integer (5050 binary)
Coefficient statistics:
Matrix range [1e+00, 1e+00]
Objective range [1e-02, 1e+00]
Bounds range [1e+00, 1e+00]
RHS range [1e+00, 5e+01]
Presolve removed 6167 rows and 7008 columns
Presolve time: 0.95s
Presolved: 5110 rows, 8142 columns, 37608 nonzeros
Presolved model has 3058 SOS constraint(s)
Variable types: 0 continuous, 8142 integer (4403 binary)
Warning: Markowitz tolerance tightened to 0.0625
Warning: Markowitz tolerance tightened to 0.125
Warning: Markowitz tolerance tightened to 0.25
Warning: Markowitz tolerance tightened to 0.5
Root relaxation: objective 4.333333e+01, 4856 iterations, 2.15 seconds
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 43.33333 0 587 - 43.33333 - - 3s
0 0 43.26667 0 243 - 43.26667 - - 4s
0 0 43.20000 0 1282 - 43.20000 - - 4s
0 0 43.20000 0 567 - 43.20000 - - 4s
0 0 43.18333 0 1114 - 43.18333 - - 5s
0 0 43.16543 0 2419 - 43.16543 - - 5s
0 0 43.15556 0 1575 - 43.15556 - - 5s
0 0 43.15333 0 2271 - 43.15333 - - 5s
0 0 43.13333 0 727 - 43.13333 - - 5s
0 0 43.12778 0 1698 - 43.12778 - - 5s
0 0 43.12500 0 1146 - 43.12500 - - 5s
0 0 43.12500 0 1911 - 43.12500 - - 6s
0 0 43.11927 0 1859 - 43.11927 - - 6s
0 0 43.11845 0 2609 - 43.11845 - - 7s
0 0 43.11845 0 2631 - 43.11845 - - 7s
0 0 43.11845 0 2642 - 43.11845 - - 7s
0 0 43.11845 0 2462 - 43.11845 - - 8s
0 0 43.11845 0 2529 - 43.11845 - - 8s
0 0 43.11845 0 2529 - 43.11845 - - 9s
0 2 43.11845 0 2531 - 43.11845 - - 14s
41 35 43.09874 17 957 - 43.09874 - 29.4 15s
94 84 42.93207 33 716 - 43.09874 - 22.1 31s
117 101 42.91940 40 2568 - 43.09874 - 213 37s
264 175 infeasible 92 - 43.09874 - 133 73s
273 181 infeasible 97 - 43.09874 - 277 77s
293 191 42.42424 17 1828 - 43.09874 - 280 90s
369 249 42.40111 52 2633 - 43.09874 - 311 105s
383 257 42.39608 59 3062 - 43.09874 - 329 152s
408 265 42.39259 65 2819 - 43.09874 - 386 162s
419 274 41.51399 66 2989 - 43.09874 - 401 170s
454 282 41.29938 71 3000 - 43.09874 - 390 182s
462 280 infeasible 74 - 43.09874 - 423 192s
479 287 infeasible 78 - 43.09874 - 419 204s
498 293 40.51287 81 2564 - 43.09874 - 435 207s
526 307 40.16638 86 2619 - 43.09874 - 419 227s
584 330 42.63100 33 621 - 43.09874 - 404 236s
628 333 infeasible 37 - 43.09874 - 394 252s
661 345 42.37500 26 25 - 43.09874 - 396 288s
684 353 infeasible 30 - 43.09874 - 426 290s
842 370 infeasible 69 - 43.09874 - 348 306s
944 379 infeasible 86 - 43.09874 - 321 370s
1009 395 42.36667 22 25 - 43.09874 - 350 409s
* 1031 243 3 42.3333333 43.09874 1.81% 343 409s
1056 203 43.00000 19 141 42.33333 43.09874 1.81% 362 411s
1194 222 cutoff 23 42.33333 43.00000 1.57% 325 430s
1199 219 cutoff 25 42.33333 43.00000 1.57% 349 450s
1202 212 cutoff 29 42.33333 43.00000 1.57% 361 472s
1211 200 infeasible 47 42.33333 42.91851 1.38% 380 498s
1226 169 infeasible 43 42.33333 42.91471 1.37% 395 511s
Cutting planes:
Gomory: 2
Cover: 15
Implied bound: 1
Clique: 26
MIR: 17
Inf proof: 1
Zero half: 8
Explored 1426 nodes (502432 simplex iterations) in 512.68 seconds
Thread count was 4 (of 4 available processors)
Solution count 1: 42.3333
Optimal solution found (tolerance 1.00e-04)
Warning: some integer variables take values larger than the maximum
supported value (2000000000)
Best objective 4.233333333333e+01, best bound 4.233333333333e+01, gap 0.0000%
In addition to the above, I also received this warning:
"Optimal solution found (tolerance 1.00e-04)
Warning: some integer variables take values larger than the maximum
supported value (2000000000)". What does it mean? Thank you so much!
It looks like you are encountering some numerical troubles. The root relaxation required an increased Markowitz tolerance, which indicates an ill-conditioned matrix. This may lead to inconsistencies as you have observed in the two different "optimal" solutions.
The warning about too large values means that there are integer variables with solution values so large that the integer feasibility tolerance can not reliably be checked anymore. If you have a variable with solution value in the range of 1e+9 it probably doesn't matter anymore whether they are integer or not. So you could probably also simplify your model by making them continuous variables.
You should check for violations in the two solutions for both models (see here) to see how feasible the solutions actually are.

Tensorboard shows nothing in chrome

I'm new to use the tensorflow. when I start to use the tensorboard,I run the demo code mnist_with_summaries.py, it runs with no error.but when I input tensorboard --logdir=/tmp/mnist/logs and open the chrome it shows nothing. So I follow the guide to find the error.
I input
find /tmp/mnist/logs | grep tfevents
it shows
/tmp/mnist/logs/test/events.out.tfevents.1487988017.wangxiaoyu
/tmp/mnist/logs/train/events.out.tfevents.1487988016.wangxiaoyu
I input
tensorboard --inspect --logdir=/tmp/mnist/logs
it shows
======================================================================
Processing event files... (this can take a few minutes)
======================================================================
Found event files in:
/tmp/mnist/logs/test
/tmp/mnist/logs/train
These tags are in /tmp/mnist/logs/test:
audio -
histograms
layer1/Wx_plus_b/pre_activations
layer1/activations
layer1/biases/summaries/histogram
layer1/weights/summaries/histogram
layer2/Wx_plus_b/pre_activations
layer2/activations
layer2/biases/summaries/histogram
layer2/weights/summaries/histogram
images
input_reshape/input/image/0
input_reshape/input/image/1
input_reshape/input/image/2
input_reshape/input/image/3
input_reshape/input/image/4
input_reshape/input/image/5
input_reshape/input/image/6
input_reshape/input/image/7
input_reshape/input/image/8
input_reshape/input/image/9
scalars
accuracy_1
cross_entropy_1
dropout/dropout_keep_probability
layer1/biases/summaries/max
layer1/biases/summaries/mean
layer1/biases/summaries/min
layer1/biases/summaries/stddev_1
layer1/weights/summaries/max
layer1/weights/summaries/mean
layer1/weights/summaries/min
layer1/weights/summaries/stddev_1
layer2/biases/summaries/max
layer2/biases/summaries/mean
layer2/biases/summaries/min
layer2/biases/summaries/stddev_1
layer2/weights/summaries/max
layer2/weights/summaries/mean
layer2/weights/summaries/min
layer2/weights/summaries/stddev_1
======================================================================
Event statistics for /tmp/mnist/logs/test:
audio -
graph -
histograms
first_step 0
last_step 990
max_step 990
min_step 0
num_steps 100
outoforder_steps []
images
first_step 0
last_step 990
max_step 990
min_step 0
num_steps 100
outoforder_steps []
scalars
first_step 0
last_step 990
max_step 990
min_step 0
num_steps 100
outoforder_steps []
sessionlog:checkpoint -
sessionlog:start -
sessionlog:stop -
======================================================================
These tags are in /tmp/mnist/logs/train:
audio -
histograms
layer1/Wx_plus_b/pre_activations
layer1/activations
layer1/biases/summaries/histogram
layer1/weights/summaries/histogram
layer2/Wx_plus_b/pre_activations
layer2/activations
layer2/biases/summaries/histogram
layer2/weights/summaries/histogram
images
input_reshape/input/image/0
input_reshape/input/image/1
input_reshape/input/image/2
input_reshape/input/image/3
input_reshape/input/image/4
input_reshape/input/image/5
input_reshape/input/image/6
input_reshape/input/image/7
input_reshape/input/image/8
input_reshape/input/image/9
scalars
accuracy_1
cross_entropy_1
dropout/dropout_keep_probability
layer1/biases/summaries/max
layer1/biases/summaries/mean
layer1/biases/summaries/min
layer1/biases/summaries/stddev_1
layer1/weights/summaries/max
layer1/weights/summaries/mean
layer1/weights/summaries/min
layer1/weights/summaries/stddev_1
layer2/biases/summaries/max
layer2/biases/summaries/mean
layer2/biases/summaries/min
layer2/biases/summaries/stddev_1
layer2/weights/summaries/max
layer2/weights/summaries/mean
layer2/weights/summaries/min
layer2/weights/summaries/stddev_1
======================================================================
Event statistics for /tmp/mnist/logs/train:
audio -
graph
first_step 0
last_step 0
max_step 0
min_step 0
num_steps 1
outoforder_steps []
histograms
first_step 1
last_step 999
max_step 999
min_step 1
num_steps 900
outoforder_steps []
images
first_step 1
last_step 999
max_step 999
min_step 1
num_steps 900
outoforder_steps []
scalars
first_step 1
last_step 999
max_step 999
min_step 1
num_steps 900
outoforder_steps []
sessionlog:checkpoint -
sessionlog:start -
sessionlog:stop -
but when I input
tensorboard --logdir=/tmp/mnist/logs
it shows
Starting TensorBoard 46 on port 6006
(You can navigate to http://127.0.1.1:6006)
* Running on http://0.0.0.0:6006/ (Press CTRL+C to quit)
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /polymer/polymer-mini.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /iron-icon/iron-icon.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /iron-iconset-svg/iron-iconset-svg.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /iron-flex-layout/iron-flex-layout.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /iron-resizable-behavior/iron-resizable-behavior.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /paper-styles/color.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /iron-menu-behavior/iron-menubar-behavior.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /paper-tabs/paper-tabs-icons.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /paper-tabs/paper-tab.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /neon-animation/neon-animation-runner-behavior.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /paper-dialog-behavior/paper-dialog-behavior.html HTTP/1.1" 200 -
127.0.0.1 - - [25/Feb/2017 10:20:17] "GET /paper-dialog-behavior/paper-dialog-shared-styles.html HTTP/1.1" 200 -
*** Error in `/home/wangxiaoyu/anaconda2/envs/tensorflow/bin/python': double free or corruption (!prev): 0x000000000085efa0 ***
已放弃 (核心已转储)
So I can't watch anything in the chrome.
Could anyone help me?
Thank you so much!

Using awk to format an output for nstats

I would like to get a complete hostname with their server up-time using "nstats" command. The script appears to be working ok. I need help with the 1st column with a "complete" hostname and the 7th column (server up-time) printed.
This following command only give me their partial hostnames:
for host in $(cat servers.txt); do nstats $host -H | awk 'BEGIN {IFS="\t"} {$2=$3=$4=$5=$6=$9="" ; print}' ; done
BAD Output: (host-names got cut off after the 12th characters)
linux_server 223 days
linux_server 123 days
windows_serv 23 days
windows_serv 23 days
EXPECTED Output:
linux_server1 223 days
linux_server2 123 days
windows_server1 23 days
windows_server2 123 days
The contents of servers.txt file are as follows:
linux_server1
linux_server2
windows_server1
windows_server2
Output without awk
LINXSERVE10% for host in $(cat servers.txt); do nstats $host -H ; done
linux_server 0.01 47% 22% 56 05:08 20 days 17:21:00
linux_server 0.00 23% 8% 45 05:08 24 days 04:16:46
windows_serv 0.04 72% 30% 58 05:09 318 days 23:32:17
windows_serv 0.00 20% 8% 40 05:09 864 days 12:23:10
windows_serv 0.00 51% 17% 41 05:09 442 days 05:30:14
Note: for host in $(cat servers.txt); do nstats $host -H | awk -v server=$host 'BEGIN {IFS="\t"} {$2=$3=$4=$5=$6=$9="" ; print server }' ; done *** this works ok but it will list only a complete hostname with no server uptime.
Any help you can give would be greatly appreciated.
Do you know you may choose the fields to print in awk?
for host in $(cat servers.txt); do
nstats $host -H |
awk 'BEGIN {IFS="\t"} {print $1,$7,$8}';
done
These will print only three fields you are interested.
The awk code labeled as a "note" is totally useless -- It is equivalent to
for host in $(cat servers.txt); do
echo "$host"
done
UPDATE: after realizing the problem was the nstats command, the awk line command would be
awk -v server="$host" 'BEGIN {IFS="\t"} {print server,$7,$8}';
then the output looked like this (server uptime overwrote the hostnames)
20 daysrver
24 daysrver
318 daysver
864 dayserv
442 dayserv
So I put that server variable at the end, it looked much better and i can extract that and play with it in excel. THANKS SO Much Jdamian!
for host in $(cat servers.txt); do nstats $host -H | awk -v server="$host" 'BEGIN {IFS="\t"} {print $7,$8,server}'; done
20 days linux_server1
24 days linux_server2
318 days windows_server1
864 days windows_server2
442 days windows_server3

Detect time range duplication in Excel worksheet

I have a schedule table in excel that contain :
Task - Begine Time - End Time
A - 10:00 - 10:30
B - 10:35 - 11:44
C - 10:20 - 11:15
D - 12:00 - 13:12
I want to create a formula that detect if a task is scheduled in another task time ;
Eg : Task C begin when Task B is running.
Thanks
Best way to solve this would be to sort the tasks into order of start time then by finish time, then you can just check for each start time whetehr the finish time in the row above is later than the start time for the current row, then you have an overlap.
(Col)(A) (B) (C)
(Row) Task - Begin Time - End Time - Okay?
(1) A - 10:00 - 10:30 -
(2) C - 10:20 - 11:15 - =B2 > C1
(3) B - 10:35 - 11:44 - =B3 > C2
(4) D - 12:00 - 13:12 - =B4 > C3
From your question I am not sure whether you want SQL, VBA or a formula solution so offer a chart for consideration:
Add another column to your table to check whether your begin times for each task occur before the end of any other tasks AND after the start of those tasks:
Task Start End Clash?
a 10:00 10:30 0
b 10:35 11:44 1
c 10:20 11:15 1
d 12:00 13:12 0
The formula I have put in the 'Clash?' column is as follows:
=SUMPRODUCT(N([Start]<[#Start]),N([End]>[#Start]))
Hope that helps!