-
Notifications
You must be signed in to change notification settings - Fork 12
/
sos_analyze.sh
executable file
·1452 lines (1136 loc) · 41.8 KB
/
sos_analyze.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# Created ....: 03/04/2019
# Developer ..: Waldirio M Pinheiro <[email protected] / [email protected]>
# Purpose ....: Analyze sosreport and summarize the information (focus on Satellite info)
#
FOREMAN_REPORT="/tmp/$$.log"
# the following while block captures three flags from the command line
# -c copies the output file from the /tmp directory to the current directory
# -l opens the output file from the current directory
# -t opens the output file from the /tmp directory
while getopts "clt" opt "${NULL[@]}"; do
case $opt in
c )
COPY_TO_CURRENT_DIR=true
;;
l ) # open copy from local directory. Requires option 'c' above.
OPEN_IN_VIM_RO_LOCAL_DIR=true
# echo "This is l"
;;
t ) # open copy from /tmp/directory
OPEN_IN_EDITOR_TMP_DIR=true
# echo "This is t"
;;
\? )
;;
esac
done
shift "$(($OPTIND -1))"
MYPWD=`pwd`
main()
{
> $FOREMAN_REPORT
sos_path=$1
base_dir=$sos_path
final_name=$(echo $base_dir | sed -e 's#/$##g' | grep -o sos.* | awk -F"/" '{print $NF}')
if [ ! -f $base_dir/version.txt ]; then
echo "This is not a sosreport dir, please inform the path to the correct one."
exit 1
fi
if [ -d $base_dir/sos_commands/foreman/foreman-debug ]; then
base_foreman="/sos_commands/foreman/foreman-debug/"
sos_version="old"
else
sos_version="new"
base_foreman="/"
fi
if which rg &>/dev/null; then
# ripgrep is installed.
RGOPTS=" -N "
GREP="$(which rg) $RGOPTS"
EGREP="$GREP"
else
# ripgrep is not installed; use good old GNU grep instead.
GREP="$(which grep)"
EGREP="$(which egrep || echo 'grep -E')"
fi
echo "The sosreport is: $base_dir" | tee -a $FOREMAN_REPORT
#report $base_dir $sub_dir $base_foreman $sos_version
report $base_dir $base_foreman $sos_version
}
log_tee()
{
echo $1 | tee -a $FOREMAN_REPORT
}
log()
{
echo "$1" >> $FOREMAN_REPORT
}
log_cmd()
{
echo "$@" | bash &>> $FOREMAN_REPORT
}
# ref: https://unix.stackexchange.com/questions/44040/a-standard-tool-to-convert-a-byte-count-into-human-kib-mib-etc-like-du-ls1
# Converts bytes value to human-readable string [$1: bytes value]
bytesToHumanReadable() {
local i=${1:-0} d="" s=0 S=("Bytes" "KiB" "MiB" "GiB" "TiB" "PiB" "EiB" "YiB" "ZiB")
while ((i > 1024 && s < ${#S[@]}-1)); do
printf -v d ".%02d" $((i % 1024 * 100 / 1024))
i=$((i / 1024))
s=$((s + 1))
done
echo "$i$d ${S[$s]}"
}
report()
{
base_dir=$1
# sub_dir=$2
# base_foreman=$base_dir/$3
# sos_version=$4
base_foreman=$base_dir/$2
sos_version=$3
#base_foreman="$1/sos_commands/foreman/foreman-debug/"
log_tee "### Welcome to Report ###"
log_tee "### CEE/SysMGMT ###"
log
log
log_tee "## Naming Resolution"
log
log "// hosts entries"
log "cat $base_dir/etc/hosts"
log "---"
log_cmd "cat $base_dir/etc/hosts"
log "---"
log
log "// resolv.conf"
log "cat $base_dir/etc/resolv.conf"
log "---"
log_cmd "cat $base_dir/etc/resolv.conf"
log "---"
log
log "// hostname"
log "cat $base_dir/etc/hostname"
log "---"
log_cmd "cat $base_dir/etc/hostname"
log "---"
log
log_tee "## Hardware"
log
log "// baremetal or vm?"
log "cat $base_dir/dmidecode | $EGREP '(Vendor|Manufacture)' | head -n3"
log "---"
log_cmd "cat $base_dir/dmidecode | $EGREP '(Vendor|Manufacture)' | head -n3"
log "---"
log
log_tee "## Network Information"
log
log "// ip address"
log "cat $base_dir/ip_addr"
log "---"
log_cmd "cat $base_dir/ip_addr"
log "---"
log
log "// current route"
log "cat $base_dir/ip_route"
log "---"
log_cmd "cat $base_dir/ip_route"
log "---"
log
log_tee "## Selinux"
log
log "// selinux conf"
log "cat $base_dir/etc/selinux/config"
log "---"
log_cmd "cat $base_dir/etc/selinux/config"
log "---"
log
log "// setroubleshoot package"
log "$GREP setroubleshoot $base_dir/installed-rpms"
log "---"
log_cmd "$GREP setroubleshoot $base_dir/installed-rpms"
log "---"
log
log "// sealert information"
log "$GREP -o sealert.* $base_dir/var/log/messages | sort -u"
log "---"
log_cmd "$GREP -o sealert.* $base_dir/var/log/messages | sort -u"
log "---"
log
log_tee "## Installed Packages (satellite)"
log
log "// all installed packages which contain satellite"
log "$GREP satellite $base_dir/installed-rpms"
log "---"
log_cmd "$GREP satellite $base_dir/installed-rpms"
log "---"
log
log "// packages provided by 3rd party vendors"
log "cat $base_dir/sos_commands/rpm/package-data | cut -f1,4 | $GREP -v -e \"Red Hat\" -e katello-ca-consumer- | sort -k2"
log "---"
log_cmd "cat $base_dir/sos_commands/rpm/package-data | cut -f1,4 | $GREP -v -e \"Red Hat\" -e katello-ca-consumer- | sort -k2"
log "---"
log
log_tee "## Subscriptions"
log
log "// subscription identity"
log "cat $base_dir/sos_commands/subscription_manager/subscription-manager_identity"
log "---"
log_cmd "cat $base_dir/sos_commands/subscription_manager/subscription-manager_identity"
log "---"
log
log "// installed katello-agent and/or gofer"
log "$EGREP '(^katello-agent|^gofer)' $base_dir/installed-rpms"
log "---"
log_cmd "$EGREP '(^katello-agent|^gofer)' $base_dir/installed-rpms"
log "---"
log
log "// goferd service"
log "$EGREP '(^katello-agent|^gofer)' $base_dir/installed-rpms"
log "cat $base_dir/sos_commands/systemd/systemctl_list-units | $GREP goferd"
log "---"
log_cmd "cat $base_dir/sos_commands/systemd/systemctl_list-units | $GREP goferd"
log "---"
log
log "// subsman list installed"
log "cat $base_dir/sos_commands/subscription_manager/subscription-manager_list_--installed"
log "---"
log_cmd "cat $base_dir/sos_commands/subscription_manager/subscription-manager_list_--installed"
log "---"
log
log "// subsman list consumed"
log "cat $base_dir/sos_commands/subscription_manager/subscription-manager_list_--consumed"
log "---"
log_cmd "cat $base_dir/sos_commands/subscription_manager/subscription-manager_list_--consumed"
log "---"
log
log_tee "## Repos"
log
log "// enabled repos"
log "cat $base_dir/sos_commands/dnf/dnf_-C_repolist_--verbose"
log "---"
log_cmd "cat $base_dir/sos_commands/dnf/dnf_-C_repolist_--verbose"
log "---"
log
log "// yum history"
log "cat $base_dir/sos_commands/dnf/dnf_history"
log "---"
log_cmd "cat $base_dir/sos_commands/dnf/dnf_history"
log "---"
log
# TODO
# improve this one, once the dnf.log has too much info
#
# log "// yum.log info"
# log "cat $base_dir/var/log/dnf.log"
# log "---"
# log_cmd "cat $base_dir/var/log/dnf.log"
# log "---"
# log
log_tee "## Upgrade"
log
# grep "Running installer with args" /var/log/foreman-installer/satellite.log
log "// Last flag used with satellite-installer"
if [ "$sos_version" == "old" ];then
cmd="$EGREP \"(Running installer with args|signal was)\" $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.log"
else
cmd="$EGREP \"(Running installer with args|signal was)\" $base_dir/var/log/foreman-installer/satellite.log"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// All the flags used with satellite-installer"
if [ "$sos_version" == "old" ];then
cmd="$GREP \"Running installer with args\" $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.* | sort -rk3 | cut -d: -f2-"
else
cmd="$GREP \"Running installer with args\" $base_dir/var/log/foreman-installer/satellite.* | sort -rk3 | cut -d: -f2-"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// # of error on the upgrade file"
if [ "$sos_version" == "old" ];then
cmd="$GREP '^\[ERROR' $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.log -c"
else
cmd="$GREP '^\[ERROR' $base_dir/var/log/foreman-installer/satellite.log -c"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// Error on the upgrade file (full info)"
if [ "$sos_version" == "old" ];then
cmd="$GREP '^\[ERROR' $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.log"
else
cmd="$GREP '^\[ERROR' $base_dir/var/log/foreman-installer/satellite.log"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// Upgrade Completed? (6.4 or greater)"
if [ "$sos_version" == "old" ];then
#cmd="grep \"Upgrade completed\" $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.log | wc -l"
cmd="$GREP \"Upgrade completed\" $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.log -c"
else
#cmd="grep \"Upgrade completed\" $base_dir/var/log/foreman-installer/satellite.log | wc -l"
cmd="$GREP \"Upgrade completed\" $base_dir/var/log/foreman-installer/satellite.log -c"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// last 20 lines from upgrade log"
if [ "$sos_version" == "old" ];then
cmd="tail -20 $base_dir/sos_commands/foreman/foreman-debug/var/log/foreman-installer/satellite.log"
else
cmd="tail -20 $base_dir/var/log/foreman-installer/satellite.log"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log_tee "## Disk"
log
log "// full disk info"
log "cat $base_dir/df"
log "---"
log_cmd "cat $base_dir/df"
log "---"
log
# log "// disk space output"
# log "cat $base_dir/sos_commands/foreman/foreman-debug/disk_space_output"
# log "---"
# log_cmd "cat $base_dir/sos_commands/foreman/foreman-debug/disk_space_output"
# log "---"
# log
log "// no space left on device"
log "$GREP \"No space left on device\" $base_dir/* 2>/dev/null"
log "---"
log_cmd "$GREP \"No space left on device\" $base_dir/* 2>/dev/null"
log "---"
log
log_tee "## Memory"
log
log "// memory usage"
log "cat $base_dir/free"
log "---"
log_cmd "cat $base_dir/free"
log "---"
log
log "// TOP 5 memory consumers"
log "cat $base_dir/ps | sort -nrk6 | head -n5"
log "---"
log_cmd "cat $base_dir/ps | sort -nrk6 | head -n5"
log "---"
log
log "// users memory consumers"
log "cat $base_dir/ps | sort -nr | awk '{print \$1, \$6}' | $GREP -v ^USER | $GREP -v ^COMMAND | $GREP -v \"^ $\" | awk '{a[\$1] += \$2} END{for (i in a) print i, a[i]}' | sort -nrk2"
log "and"
log "memory_usage=\$(cat $base_dir/ps | sort -nr | awk '{print \$6}' | grep -v ^-$ | $GREP -v ^RSS | $GREP -v ^$ | paste -s -d+ | bc)"
log "and"
log "memory_usage_gb=\$(echo \"scale=2;$memory_usage/1024/1024\" | bc)"
log "---"
log_cmd "cat $base_dir/ps | sort -nr | awk '{print \$1, \$6}' | $GREP -v ^USER | $GREP -v ^COMMAND | $GREP -v \"^ $\" | awk '{a[\$1] += \$2} END{for (i in a) print i, a[i]}' | sort -nrk2"
log
memory_usage=$(cat $base_dir/ps | sort -nr | awk '{print $6}' | grep -v ^-$ | $GREP -v ^RSS | $GREP -v ^$ | paste -s -d+ | bc)
memory_usage_gb=$(echo "scale=2;$memory_usage/1024/1024" | bc)
log "Total Memory Consumed in KiB: $memory_usage"
log "Total Memory Consumed in GiB: $memory_usage_gb"
log "---"
log
log "// Postgres idle process (candlepin)"
log "cat $base_dir/ps | $GREP ^postgres | $GREP idle$ | $GREP \"candlepin candlepin\" | wc -l"
log "---"
log_cmd "cat $base_dir/ps | $GREP ^postgres | $GREP idle$ | $GREP \"candlepin candlepin\" | wc -l"
log "---"
log
log "// Postgres idle process (foreman)"
log "cat $base_dir/ps | $GREP ^postgres | $GREP idle$ | $GREP \"foreman foreman\" | wc -l"
log "---"
log_cmd "cat $base_dir/ps | $GREP ^postgres | $GREP idle$ | $GREP \"foreman foreman\" | wc -l"
log "---"
log
log "// Postgres idle process (everything)"
log "cat $base_dir/ps | $GREP ^postgres | $GREP idle$ | wc -l"
log "---"
log_cmd "cat $base_dir/ps | $GREP ^postgres | $GREP idle$ | wc -l"
log "---"
log
log "// Processes running for a while (TOP 5 per time)"
log "cat $base_dir/ps | sort -nr -k10 | head -n5"
log "---"
log_cmd "cat $base_dir/ps | sort -nr -k10 | head -n5"
log "---"
log
log_tee "## CPU"
log
log "// cpu's number"
log "cat $base_dir/proc/cpuinfo | $GREP processor | wc -l"
log "---"
log_cmd "cat $base_dir/proc/cpuinfo | $GREP processor | wc -l"
log "---"
log
log_tee "## Messages"
log
log "// error on message file"
log "$GREP ERROR $base_dir/var/log/messages"
log "---"
log_cmd "$GREP ERROR $base_dir/var/log/messages"
log "---"
log
log_tee "## Out of Memory"
log
log "// out of memory"
log "$GREP \"Out of memory\" $base_dir/var/log/messages"
log "---"
log_cmd "$GREP \"Out of memory\" $base_dir/var/log/messages"
log "---"
log
log "Pavel Moravec Script to check the memory usage during the oom killer"
log " - https://gitlab.cee.redhat.com/mna-emea/oom-process-stats"
log ""
log "// Memory Consumption"
log "/usr/bin/python3 /tmp/script/oom-process-stats.py $base_dir/var/log/messages"
log "---"
log_cmd "/usr/bin/python3 /tmp/script/oom-process-stats.py $base_dir/var/log/messages"
log "---"
log
log_tee "## Performance"
log
log "// Analyzing '/var/log/sa/sa' files and checking for values with low time"
log "for b in \$(ls \$base_dir/var/log/sa/sa[0-9]*); do echo - \$b;sar -f \$b | grep -E '(CPU|all)' | grep -E '( [0-9].[0-9]2\$)'; done"
log "---"
log_cmd "for b in \$(ls \$base_dir/var/log/sa/sa[0-9]*); do echo - \$b;sar -f \$b | grep -E '(CPU|all)' | grep -E '( [0-9].[0-9]2\$)'; done"
log "---"
log
log_tee "## Foreman Tasks"
log
if [ "$sos_version" == "old" ];then
cmd="cat $base_dir/sos_commands/foreman/foreman-debug/foreman_tasks_tasks.csv | wc -l"
else
cmd="cat $base_dir/sos_commands/foreman/foreman_tasks_tasks | wc -l"
fi
log "// total # of foreman tasks"
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
if [ "$sos_version" == "old" ];then
cmd="cat $base_dir/sos_commands/foreman/foreman-debug/foreman_tasks_tasks.csv | cut -d, -f3 | $GREP Actions | sort | uniq -c | sort -nr"
else
cmd="cat $base_dir/sos_commands/foreman/foreman_tasks_tasks | sed '1,3d' | cut -d, -f3 | $GREP Actions | sort | uniq -c | sort -nr"
fi
log "// Tasks TOP"
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
if [ "$sos_version" == "old" ];then
cmd="cat $base_dir/etc/cron.d/foreman-tasks"
else
cmd="cat $base_dir/etc/cron.d/foreman-tasks"
fi
log "// foreman tasks cleanup script"
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// paused foreman tasks"
log "$GREP '(^ id|paused)' $base_dir/sos_commands/foreman/foreman_tasks_tasks | sed 's/ //g' | sed -e 's/ |/|/g' | sed -e 's/| /|/g' | sed -e 's/^ //g' | sed -e 's/|/,/g'"
log "---"
log_cmd "$GREP '(^ id|paused)' $base_dir/sos_commands/foreman/foreman_tasks_tasks | sed 's/ //g' | sed -e 's/ |/|/g' | sed -e 's/| /|/g' | sed -e 's/^ //g' | sed -e 's/|/,/g'"
log "---"
log
# log_tee "## Pulp"
# log
#
# log "// number of tasks not finished"
# log "$GREP '\"task_id\"' $base_dir/sos_commands/pulp/pulp-running_tasks -c"
# log "---"
# log_cmd "$GREP '\"task_id\"' $base_dir/sos_commands/pulp/pulp-running_tasks -c"
# log "---"
# log
#
#
##grep "\"task_id\"" 02681559/0050-sosreport-pc1ustsxrhs06-2020-06-26-kfmgbpf.tar.xz/sosreport-pc1ustsxrhs06-2020-06-26-kfmgbpf/sos_commands/pulp/pulp-running_tasks | wc -l
#
# log "// pulp task not finished"
# log "$EGREP '(\"finish_time\" : null|\"start_time\"|\"state\"|\"pulp:|^})' $base_dir/sos_commands/pulp/pulp-running_tasks"
# log "---"
# log_cmd "$EGREP '(\"finish_time\" : null|\"start_time\"|\"state\"|\"pulp:|^})' $base_dir/sos_commands/pulp/pulp-running_tasks"
# log "---"
# log
log_tee "## Hammer Ping"
log
log "// hammer ping output"
if [ "$sos_version" == "old" ];then
cmd="cat $base_dir/sos_commands/foreman/foreman-debug/hammer-ping"
else
cmd="cat $base_dir/sos_commands/foreman/hammer_ping"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "## Katello service status"
log
log "// katello-service status output"
if [ "$sos_version" == "old" ];then
cmd="cat $base_dir/sos_commands/foreman/foreman-debug/katello_service_status"
else
cmd="cat $base_dir/sos_commands/foreman_installer/foreman-maintain_service_status"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log "// katello-service status output - condensed"
if [ "$sos_version" == "old" ];then
cmd="$EGREP '(^\*|Active)' $base_dir/sos_commands/foreman/foreman-debug/katello_service_status | tr '^\*' '\n'"
else
cmd="$EGREP '(^\*|Active)' $base_dir/sos_commands/foreman_installer/foreman-maintain_service_status | tr '^\*' '\n'"
fi
log "$cmd"
log "---"
log_cmd "$cmd"
log "---"
log
log_tee "## Puppet Server"
log
log "// Puppet Server Error"
log "$GREP ERROR $base_dir/var/log/puppetlabs/puppetserver/puppetserver.log"
log "---"
log_cmd "$GREP ERROR $base_dir/var/log/puppetlabs/puppetserver/puppetserver.log"
log "---"
log
log_tee "## Audit"
log
log "// denied in audit.log"
log "$GREP -o denied.* $base_dir/var/log/audit/audit.log | sort -u"
log "---"
log_cmd "$GREP -o denied.* $base_dir/var/log/audit/audit.log | sort -u"
log "---"
log
log_tee "## PostgreSQL"
log
log "// Checking the process/path"
log "cat $base_dir/ps | grep postgres | grep data"
log "---"
log_cmd "cat $base_dir/ps | grep postgres | grep data"
log "---"
log
log "// postgres storage consumption - /var/lib/psql"
log "cat $base_dir/sos_commands/postgresql/du_-sh_.var.lib.pgsql"
log "---"
log_cmd "cat $base_dir/sos_commands/postgresql/du_-sh_.var.lib.pgsql"
log "---"
log
log "// postgres storage consumption - /var/opt/rh/rh-postgresql12/lib/pgsql/data"
log "cat $base_dir/sos_commands/postgresql/du_-sh_.var..opt.rh.rh-postgresql12.lib.pgsql"
log "---"
log_cmd "cat $base_dir/sos_commands/postgresql/du_-sh_.var..opt.rh.rh-postgresql12.lib.pgsql"
log "---"
log
log "// TOP foreman tables consumption"
log "head -n30 $base_dir/sos_commands/foreman/foreman_db_tables_sizes"
log "---"
log_cmd "head -n30 $base_dir/sos_commands/foreman/foreman_db_tables_sizes"
log "---"
log
log_tee "## PostgreSQL Log - /var/lib/pgsql/"
log
log "// Deadlock count"
log "$GREP -I -i deadlock $base_foreman/var/lib/pgsql/data/log/*.log -c"
log "---"
log_cmd "$GREP -I -i deadlock $base_foreman/var/lib/pgsql/data/log/*.log -c"
log "---"
log
log "// Deadlock"
log "$GREP -I -i deadlock $base_foreman/var/lib/pgsql/data/log/*.log"
log "---"
log_cmd "$GREP -I -i deadlock $base_foreman/var/lib/pgsql/data/log/*.log"
log "---"
log
log "// ERROR count"
log "$GREP -F ERROR $base_foreman/var/lib/pgsql/data/log/*.log -c"
log "---"
log_cmd "$GREP -F ERROR $base_foreman/var/lib/pgsql/data/log/*.log -c"
log "---"
log
log "// ERROR"
log "$GREP -I ERROR $base_foreman/var/lib/pgsql/data/log/*.log"
log "---"
log_cmd "$GREP -I ERROR $base_foreman/var/lib/pgsql/data/log/*.log"
log "---"
log
log "// Current Configuration"
log "cat $base_foreman/var/lib/pgsql/data/postgresql.conf | $GREP -v ^# | $GREP -v ^$ | $GREP -v ^\"\\t\\t\".*#"
log "---"
log_cmd "cat $base_foreman/var/lib/pgsql/data/postgresql.conf | $GREP -v ^# | $GREP -v ^$ | $GREP -v ^\"\\t\\t\".*#"
log "---"
log
log_tee "## PostgreSQL Log - /var/opt/rh/rh-postgresql12/lib/pgsql/data"
log
log "// Deadlock count"
log "$GREP -I -i deadlock $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log -c"
log "---"
log_cmd "$GREP -I -i deadlock $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log -c"
log "---"
log
log "// Deadlock"
log "$GREP -I -i deadlock $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log"
log "---"
log_cmd "$GREP -I -i deadlock $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log"
log "---"
log
log "// ERROR count"
log "$GREP -F ERROR $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log -c"
log "---"
log_cmd "$GREP -F ERROR $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log -c"
log "---"
log
log "// ERROR"
log "$GREP -I ERROR $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log"
log "---"
log_cmd "$GREP -I ERROR $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/log/*.log"
log "---"
log
log "// Current Configuration"
log "cat $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf | $GREP -v ^# | $GREP -v ^$ | $GREP -v ^\"\\t\\t\".*#"
log "---"
log_cmd "cat $base_foreman/var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf | $GREP -v ^# | $GREP -v ^$ | $GREP -v ^\"\\t\\t\".*#"
log "---"
log
log_tee "## Foreman Tasks"
log
log "// dynflow running"
log "cat $base_dir/ps | $GREP dynflow_executor\$"
log "---"
log_cmd "cat $base_dir/ps | $GREP dynflow_executor$"
log "---"
log
log_tee "## Foreman logs (error)"
log
# Note: `grep -I` differs from `rg -I` but the difference in behavior is not causing differences in output here. So I'm leaving `$GREP -I`.
log "// total number of errors found on production.log - TOP 40"
log "$GREP -I -F \"[E\" $base_foreman/var/log/foreman/production.log* | awk '{print \$4, \$5, \$6, \$7, \$8, \$9, \$10, \$11, \$12, \$13}' | sort | uniq -c | sort -nr | head -n40"
log "---"
log_cmd "$GREP -I -F \"[E\" $base_foreman/var/log/foreman/production.log* | awk '{print \$4, \$5, \$6, \$7, \$8, \$9, \$10, \$11, \$12, \$13}' | sort | uniq -c | sort -nr | head -n40"
log "---"
log
log_tee "## Foreman cron"
log
log "// last 20 entries from foreman/cron.log"
log "tail -20 $base_foreman/var/log/foreman/cron.log"
log "---"
log_cmd "tail -20 $base_foreman/var/log/foreman/cron.log"
log "---"
log
log_tee "## Httpd"
log
log "// queues on error_log means the # of requests crossed the border. Satellite inaccessible"
log "$GREP -F 'Request queue is full' $base_foreman/var/log/httpd/error_log | wc -l"
log "---"
log_cmd "$GREP -F 'Request queue is full' $base_foreman/var/log/httpd/error_log | wc -l"
log "---"
log
log "// when finding something on last step, we will here per date"
log "$GREP -F queue $base_foreman/var/log/httpd/error_log | awk '{print \$2, \$3}' | cut -d: -f1,2 | uniq -c"
log "---"
log_cmd "$GREP -F queue $base_foreman/var/log/httpd/error_log | awk '{print \$2, \$3}' | cut -d: -f1,2 | uniq -c"
log "---"
log
log "// TOP 20 of ip address requesting the satellite via https"
log "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$1}' | sort | uniq -c | sort -nr | head -n20"
log "---"
log_cmd "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$1}' | sort | uniq -c | sort -nr | head -n20"
log "---"
log
log "// TOP 20 of ip address requesting the satellite via https (detailed)"
log "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$1,\$4}' | cut -d: -f1,2,3 | sort | uniq -c | sort -nr | head -n20"
log "---"
log_cmd "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$1,\$4}' | cut -d: -f1,2,3 | sort | uniq -c | sort -nr | head -n20"
log "---"
log
log "// TOP 50 of uri requesting the satellite via https"
log "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$1, \$6, \$7}' | sort | uniq -c | sort -nr | head -n 50"
log "---"
log_cmd "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$1, \$6, \$7}' | sort | uniq -c | sort -nr | head -n 50"
log "---"
log
log "// Possible scanner queries"
log "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | grep \" 404 \" | grep -E '(\"-\" \"-\")' | head -n10"
log "---"
log_cmd "cat $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | grep \" 404 \" | grep -E '(\"-\" \"-\")' | head -n10"
log "---"
log
log "// General 2XX errors on httpd logs"
log "$GREP '\" 2\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log_cmd "$GREP '\" 2\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log
log "// General 3XX errors on httpd logs"
log "$GREP '\" 3\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log_cmd "$GREP '\" 3\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log
log "// General 4XX errors on httpd logs"
log "$GREP '\" 4\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log_cmd "$GREP '\" 4\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log
log "// General 5XX errors on httpd logs"
log "$GREP '\" 5\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log_cmd "$GREP '\" 5\d\d ' $base_foreman/var/log/httpd/foreman-ssl_access_ssl.log | awk '{print \$9}' | sort | uniq -c | sort -nr"
log "---"
log
log_tee "## RHSM"
log
log "// RHSM Proxy"
log "$GREP -F proxy $base_dir/etc/rhsm/rhsm.conf | $GREP -v ^#"
log "---"
log_cmd "$GREP -F proxy $base_dir/etc/rhsm/rhsm.conf | $GREP -v ^#"
log "---"
log
log "// Satellite Proxy"
log "$EGREP '(^ proxy_url|^ proxy_port|^ proxy_username|^ proxy_password)' $base_dir/etc/foreman-installer/scenarios.d/satellite-answers.yaml"
log "---"
log_cmd "$EGREP '(^ proxy_url|^ proxy_port|^ proxy_username|^ proxy_password)' $base_dir/etc/foreman-installer/scenarios.d/satellite-answers.yaml"
log "---"
log
log "// Virt-who Proxy"
log "$GREP -F -i proxy $base_dir/etc/sysconfig/virt-who"
log "---"
log_cmd "$GREP -F -i proxy $base_dir/etc/sysconfig/virt-who"
log "---"
log
log "// RHSM errors"
log "$GREP -F ERROR $base_dir/var/log/rhsm/rhsm.log"
log "---"
log_cmd "$GREP -F ERROR $base_dir/var/log/rhsm/rhsm.log"
log "---"
log
log "// RHSM Warnings"
log "$GREP -F WARNING $base_dir/var/log/rhsm/rhsm.log"
log "---"
log_cmd "$GREP -F WARNING $base_dir/var/log/rhsm/rhsm.log"
log "---"
log
log "// duplicated hypervisors #"
log "$GREP -F \"is assigned to 2 different systems\" $base_dir/var/log/rhsm/rhsm.log | awk '{print \$9}' | sed -e \"s/'//g\" | sort -u | wc -l"
log "---"
log_cmd "$GREP -F \"is assigned to 2 different systems\" $base_dir/var/log/rhsm/rhsm.log | awk '{print \$9}' | sed -e \"s/'//g\" | sort -u | wc -l"
log "---"
log
log "// duplicated hypervisors list"
log "$GREP -F \"is assigned to 2 different systems\" $base_dir/var/log/rhsm/rhsm.log | awk '{print \$9}' | sed -e \"s/'//g\" | sort -u"
log "---"
log_cmd "$GREP -F \"is assigned to 2 different systems\" $base_dir/var/log/rhsm/rhsm.log | awk '{print \$9}' | sed -e \"s/'//g\" | sort -u"
log "---"
log
log "// Sending updated Host-to-guest"
log "$GREP -F \"Sending updated Host-to-guest\" $base_dir/var/log/rhsm/rhsm.log"
log "---"
log_cmd "$GREP -F \"Sending updated Host-to-guest\" $base_dir/var/log/rhsm/rhsm.log"
log "---"
log
log_tee "## Virt-who"
log
log "// virt-who status"
log "cat $base_dir/sos_commands/systemd/systemctl_list-units | $GREP -F virt-who"
log "---"
log_cmd "cat $base_dir/sos_commands/systemd/systemctl_list-units | $GREP -F virt-who"
log "---"
log
log "// virt-who default configuration"
log "cat $base_dir/etc/sysconfig/virt-who | $GREP -v ^# | $GREP -v ^$"
log "---"
log_cmd "cat $base_dir/etc/sysconfig/virt-who | $GREP -v ^# | $GREP -v ^$"
log "---"
log
log "// virt-who configuration"
log "ls -l $base_dir/etc/virt-who.d"
log "---"
log_cmd "ls -l $base_dir/etc/virt-who.d"
log "---"
log
log "// duplicated server entries on virt-who configuration"
log "$GREP -I ^server $base_dir/etc/virt-who.d/*.conf | sort | uniq -c"
log "---"
log_cmd "$GREP -I ^server $base_dir/etc/virt-who.d/*.conf | sort | uniq -c"
log "---"
log