-
Notifications
You must be signed in to change notification settings - Fork 0
/
inspector.sh
executable file
·1400 lines (958 loc) · 53 KB
/
inspector.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
# TITLE: Inspector Gadget
# AUTHOR: michael mcdonald
# CONTACT: [email protected]
# PURPOSE: to examine various aspects of a Linux system and provide
# quick access to that information in a clean format
# Special thanks to James Dooley for peer reviewing my work and offering
# numerous suggestions on how to improve / speed up my bash scripting
# within this script and the predecessor of it.
##################################################################################
# Quick place to set the script's version number (adjusts the header version too)
SCRIPTVERSION="v1.6.19"
##################################################################################
# BEGIN VARIABLES #
##################################################################################
# Various color variables used throughout the script
HEADERINFO=$(tput setaf 2)
MEMORYINFO=$(tput setaf 180)
SYSTEMINFO=$(tput setaf 124)
DISKINFO=$(tput setaf 100)
TRAFFICINFO=$(tput setaf 210)
CPANELINFO=$(tput setaf 172)
MYSQLINFO=$(tput setaf 74)
APACHEINFO=$(tput setaf 5)
NGINXINFO=$(tput setaf 34)
VARNISHINFO=$(tput setaf 117)
PHPINFO=$(tput setaf 140)
RECOMMENDATIONS=$(tput setaf 42)
SECURITYINFO=$(tput setaf 227)
ISSUE=$(tput setaf 196)
ITEMOK=$(tput setaf 2)
IGNORE=$(tput setaf 32)
UNDERLINE=$(tput smul)
ORANGE=$(tput setaf 202)
YELLOW=$(tput setaf 226)
RESET=$(tput sgr0)
# Logic to test the PHP binary so that we can get the information we need on a cPanel or none server
#ACTUALPHPINI=$(/usr/local/bin/php -i 2>/dev/null | grep "Loaded Configuration File" | awk '{print $5}')
PHPBINARYTEST=$(/usr/local/bin/php -i 2>/dev/null)
if [[ "$PHPBINARYTEST" == "" ]]; then
ACTUALPHPINI=$(php -i 2>/dev/null | grep "Loaded Configuration File" | awk '{print $5}')
else
ACTUALPHPINI=$(/usr/local/bin/php -i 2>/dev/null | grep "Loaded Configuration File" | awk '{print $5}')
fi
##################################################################################
# END VARIABLES #
##################################################################################
##################################################################################
# BEGIN PRINTLOG FUNCTIONS #
##################################################################################
function printLog {
if [[ printLog.log ]]; then
echo "[$(date +%s.%N)] $@" >> printLog.log
fi
}
function getTime {
date +%s.%N
}
function getDelta {
awk -vs="$1" -ve="$2" 'BEGIN{printf "%.3f", (e - s)}'
}
##################################################################################
# END PRINTLOG FUNCTION #
##################################################################################
##################################################################################
# BEGIN SOFTWARE CHECKS #
##################################################################################
CENTOSCHECK=$(cat /etc/redhat-release 2>/dev/null)
if [[ -z $CENTOSCHECK ]]; then
APACHETEST=$(cat /etc/apache2/apache2.conf 2>/dev/null)
# All else fails, we presume we're on a base CentOS install and display accordingly
else
APACHETEST=$(cat /etc/httpd/conf/httpd.conf 2>/dev/null)
fi
## Quick check against a file that will verify if Apache IS installed or is NOT installed. This is stored in a variable
#APACHETEST=$(cat /etc/httpd/conf/httpd.conf 2>/dev/null)
# Quick check against a file that will verify if MySQL IS installed or is NOT installed. This is stored in a variable
#MYSQLTEST=$(mysql -e ' SELECT VERSION(); ' 2>/dev/null)
MYSQLTEST=$(mysql -V 2>/dev/null)
PHPTEST=$(php -i 2>/dev/null | grep "Loaded Configuration File" | awk '{print $5}')
# Quick check against a file that will verify if cPanel IS or is NOT installed. This is stored in a variable
CPANELTEST=$(cat /usr/local/cpanel/version 2>/dev/null)
##################################################################################
# END SOFTWARE CHECKS #
##################################################################################
# Deprecated CentOS 4 check. Keeping it in case I ever get fed up with fixing
# issues on CentOS 4 boxes because they keep cropping up
##################################################################################
# CENTOS 4 CHECK #
##################################################################################
##Check for CentOS 4 since it does not play well with regex in bash
#CENTOS4CHECK=$(cat /etc/redhat-release | awk '{print $3}' | cut -d"." -f1)
#
#if [ "$CENTOS4CHECK" == "4" ]; then
#
# echo
#
# echo "!!! CentOS 4 is ${ISSUE}${UNDERLINE}NOT${RESET} supported !!!"
#
# echo && exit 1
#
#fi
##################################################################################
# END CENTOS 4 CHECK #
##################################################################################
##################################################################################
# BEGIN HEADER FUNCTION #
##################################################################################
# The header display function (color version; not sure if I'm going to make a bnw version)
function header_color {
echo
echo " ${ORANGE} ___ _ "
echo " |_ _|_ __ ___ _ __ ___ ___| |_ ___ _ __ "
echo " | || '_ \/ __| '_ \ / _ \/ __| __/ _ \| '__| "
echo " | || | | \__ \ |_) | __/ (__| || (_) | | "
echo " |___|_| |_|___/ .__/ \___|\___|\__\___/|_|${RESET} "
echo " ${YELLOW} ____${RESET} ${ORANGE}|_|${RESET}${YELLOW}_ _ ${RESET} _ "
echo " ${YELLOW} / ___| __ _ __| | __ _ ___| |_ ${RESET}/ \ "
echo " ${YELLOW}| | _ / _\` |/ _\` |/ _\` |/ _ \ __| ${RESET}\_/ "
echo " ${YELLOW}| |_| | (_| | (_| | (_| | __/ |_ ${RESET} / "
echo " ${YELLOW} \____|\__,_|\__,_|\__, |\___|\__| ${RESET} / $SCRIPTVERSION "
echo " ${YELLOW} |___/ ${RESET} "
echo
}
##################################################################################
# END HEADER FUNCTION #
##################################################################################
##################################################################################
# BEGIN SYSTEM INFO FUNCTION #
##################################################################################
# Function for all System Info related information
function systeminfo {
# This is currently deprecated. Leaving for historical purposes
## Capture the relevant information for the CPUs on the system
#CPUINFO=$(cat /proc/cpuinfo)
# Identify the specific processor model
#PROCESSORTYPE=$(awk -F":" ' {gsub(/^[ \t]+|[ \t]+$/, "", $2)} /model name/ {print $2;exit;}' /proc/cpuinfo)
PROCESSORTYPE=$(awk -F":" ' {gsub(/^[ \t]+|[ \t]+$/, "", $2)} /model name/ {print $2;exit;}' /proc/cpuinfo | sed 's/ \+/ /g')
# This is currently deprecated. Leaving for historical purposes
## Count how many cores are on the system
#PROCESSORCOUNT=$(awk '$1 ~ /processor/ {++c} END {print c}' FS=: <<< $CPUINFO)
PROCESSORCOUNT=$(getconf _NPROCESSORS_ONLN)
# Record the current 1 min load average
LOADAVERAGE=$(cat /proc/loadavg | awk '{print $1}')
echo "------------\\${SYSTEMINFO} ${UNDERLINE}SYSTEM INFO${RESET} \\-------------------------------"
echo
echo "${SYSTEMINFO}System Processor:${RESET} $PROCESSORTYPE"
echo "${SYSTEMINFO}Total # of Cores:${RESET} $PROCESSORCOUNT"
echo "${SYSTEMINFO}Current Load Avg:${RESET} $LOADAVERAGE"
# Capturing the OS version strings
CENTOSVERSION=$(cat /etc/redhat-release 2>/dev/null)
UBUNTUVERSION=$(cat /etc/lsb-release 2>/dev/null)
# Centos version number variables. The first line is running the regex against the text string, identifying
# the line has "release" in it, and then grabs the numerical components, separating them into three distinct
# variables: the whole version: #.#, the major and then minor version numbers (BASH_REMATCH[1] - [3] respectively
# and then those numbers are assigned their own variable that can be called / printed to screen. Technically
# this is all one command / execution, for readability sake it's broken across multiple lines.
CENTOSREGEX="^.*release\ (([0-9])\.([0-9]+)).*$"
#[[ $CENTOSVERSION =~ ^.*release\ (([0-9])\.([0-9])).*$ ]] &&
[[ $CENTOSVERSION =~ $CENTOSREGEX ]] &&
CENTOSENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: xx.xx
CENTOSMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: x
CENTOSMINORVERSION=${BASH_REMATCH[3]} # The minor version #: x
## Same as above, only for Cloud Linux
## This could probably be re-worked to fit BOTH CentOS and CloudLinux. Will need to investigate.
#[[ $(< /root/scripts/inspector/parts/oscheck/cloudlinux) =~ CloudLinux.*\ (([0-9])\.([0-9])).*$ ]] &&
#CLOUDENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: xx.xx
#CLOUDMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: x
#CLOUDMINORVERSION=${BASH_REMATCH[3]} # The minor version #: x
# Same as above, only for Ubuntu
UBUNTUREGEX="DISTRIB_DESCRIPTION.*\ (([0-9][0-9])\.([0-9][0-9])).*$"
#[[ $UBUNTUVERSION =~ DISTRIB_DESCRIPTION.*\ (([0-9][0-9])\.([0-9][0-9])).*$ ]] &&
[[ $UBUNTUVERSION =~ $UBUNTUREGEX ]] &&
UBUNTUENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: xx.xx
UBUNTUMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: x
UBUNTUMINORVERSION=${BASH_REMATCH[3]} # The minor version #: x
# Checking to see if the variable $CENTOSVERSION is empty or not. If it IS empty we proceed to believe we're on Ubuntu
if [[ -z $CENTOSVERSION ]]; then
FULLTIMEZONE=$(</etc/timezone)
echo "${SYSTEMINFO}Operating System:${RESET} Ubuntu $UBUNTUENTIREVERSION"
echo "${SYSTEMINFO}Server Time Zone:${RESET}" `date +%Z` $FULLTIMEZONE
# If it's NOT empty, we examine the contents of the varible for the string "CloudLinux". If present, we presume we're on CL, if not, continue
elif [[ $CENTOSVERSION == *CloudLinux* ]]; then
FULLTIMEZONE=$(cat /etc/sysconfig/clock | awk -F"\"" '{print $2}')
echo "${SYSTEMINFO}Operating System:${RESET} CloudLinux $CENTOSENTIREVERSION"
echo "${SYSTEMINFO}Server Time Zone:${RESET}" `date +%Z` $FULLTIMEZONE
elif [[ $CENTOSMAJORVERSION == "7" ]]; then
FULLTIMEZONE=$(timedatectl | awk '/Timezone:/ {print $2}')
echo "${SYSTEMINFO}Operating System:${RESET} CentOS $CENTOSENTIREVERSION"
echo "${SYSTEMINFO}Server Time Zone:${RESET}" `date +%Z` $FULLTIMEZONE
# All else fails, we presume we're on a base CentOS install and display accordingly
else
FULLTIMEZONE=$(cat /etc/sysconfig/clock | awk -F"\"" '{print $2}')
echo "${SYSTEMINFO}Operating System:${RESET} CentOS $CENTOSENTIREVERSION"
echo "${SYSTEMINFO}Server Time Zone:${RESET}" `date +%Z` $FULLTIMEZONE
fi
NUMBERUSERS=$(users | wc -w)
DISPLAYUSERS=$(echo "$NUMBERUSERS-1" | bc 2>/dev/null)
if [[ "$NUMBERUSERS" == "1" ]]; then
echo "${SYSTEMINFO}Current Users On:${RESET} 1 (just you)"
elif [[ "$NUMBERUSERS" == "2" ]]; then
echo "${SYSTEMINFO}Current Users On:${RESET} 2 (you and 1 other)"
elif [[ "$NUMBERUSERS" -gt "2" ]]; then
echo "${SYSTEMINFO}Current Users On:${RESET} $NUMBERUSERS (you and $DISPLAYUSERS others)"
fi
}
##################################################################################
# END SYSTEN INFO FUNCTION #
##################################################################################
##################################################################################
# BEGIN MEMORY INFO FUNCTION #
##################################################################################
# Function for all Memory related information
function memoryinfo {
# This captures that information we'll use to display the total GB of memory on the system
MEMINFOGB=$(free -g)
# This captures the rest of the memory related information we'll pull from
MEMINFOMB=$(cat /proc/meminfo)
# This captures the total # of GBs on a system
TOTALMEMMB=$(awk '/Mem:/ {print $2}' <<< "$MEMINFOGB")
# Adds +1 since the actual value displayed does not round up. I'm basically doing the rounding for it
TOTALMEMGB=$(($TOTALMEMMB+1))
# The following capture the total amount of memory, the fre amount and calculates the amount used, all in MB
MEMTOTAL=$(awk -F":" '/MemTotal/{ printf "%.0f", $2/1024 ; exit}' <<< "$MEMINFOMB")
MEMFREE=$(awk -F":" '/MemFree/{ printf "%.0f", $2/1024 ; exit}' <<< "$MEMINFOMB")
MEMUSED=$(($MEMTOTAL-$MEMFREE))
# In order to get an accurate value of how much memory is actually free we need to know how much is being used for buffers / cache
BUFFERS=$(awk -F":" '/Buffers/{ printf "%.0f", $2/1024 ; exit}' <<< "$MEMINFOMB")
CACHED=$(awk -F":" '/Cached/{ printf "%.0f", $2/1024 ; exit}' <<< "$MEMINFOMB")
BUFFERCACHETOTAL=$(($BUFFERS+$CACHED))
# Determine the actual amount of free memory (since buffer / cache usage gives way to application usage when requested)
MEMTRUEFREE=$(($MEMFREE+$BUFFERCACHETOTAL))
# Calculates the total, free, and actually used swap values
SWAPTOTAL=$(awk -F":" '/SwapTotal/{ printf "%.0f", $2/1024 ; exit}' <<< "$MEMINFOMB")
SWAPFREE=$(awk -F":" '/SwapFree/ { printf "%.0f", $2/1024 ; exit}' <<< "$MEMINFOMB")
SWAPUSED=$(($SWAPTOTAL-$SWAPFREE))
echo
echo "------------\\${MEMORYINFO} ${UNDERLINE}MEMORY INFO${RESET} \\-------------------------------"
echo
echo "${MEMORYINFO}System Total:${RESET} $TOTALMEMGB G"
echo "${MEMORYINFO}Current Used:${RESET} $MEMUSED M"
echo "${MEMORYINFO}Current Free:${RESET} $MEMTRUEFREE M"
echo "${MEMORYINFO}Current Swap:${RESET} $SWAPUSED M"
}
##################################################################################
# END MEMORY INFO FUNCTION #
##################################################################################
##################################################################################
# BEGIN MYSQL INFO FUNCTION #
##################################################################################
# Function for all MySQL related information
function mysqlinfo {
echo
echo "------------\\${MYSQLINFO} ${UNDERLINE}MYSQL INFO${RESET} \\--------------------------------"
echo
# Acquire the MySQL related information that we'll be working with (specifically the version stuff)
MYSQLOUTPUT=$(mysql -V 2>/dev/null)
# Parse the output of $MYSQLOUTPUT and acquire just the version information
MYSQLVERSION=$(awk '{gsub(/,/,""); print $5}'i <<< "$MYSQLOUTPUT")
# Examines the version of MySQL as gathered from the $MYSQLVERSION variable, then captures into individual groups the
# major, minor, and build values. The individual breakdown of the version number is there in case any type of logic
# needs to be used to examine version numbers against one another. More for historical / future uses than anything.
MYSQLREGEX="(([0-9]+)\.([0-9]+)\.([0-9][0-9])).*$"
[[ $MYSQLVERSION =~ $MYSQLREGEX ]] &&
MYSQLENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: x.x.xx
MYSQLMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: x
MYSQLMINORVERSION=${BASH_REMATCH[3]} && # The minor version #: x
MYSQLBUILDVERSION=${BASH_REMATCH[4]} # The build version #: xx
# Display the MySQL version (full version number)
echo "${MYSQLINFO}Version In Use:${RESET} $MYSQLENTIREVERSION"
#######################################################
# Display the buffers header / separation:
echo "${MYSQLINFO}${UNDERLINE}BUFFER VALUE(s)${RESET}${MYSQLINFO} ↓↓↓${RESET}"
# Acquire the contents of the my.cnf file for parsing
MYSQLCONF=$(cat /etc/my.cnf 2>/dev/null)
########## INNODB BUFFER POOL SIZE LOGIC ##############
# Search the $MYSQLCONF variable for the InnoDB Buufer Pool variable. This is just goign to identify if it's there or not
INNODBPRESENT=$(awk '/innodb_buffer_pool_size/' <<< "$MYSQLCONF")
# This will take the value that's assigned to the InnoDB Buffer Pool (should it exist) and store the value
INNODBVALUE=$(awk -F"=" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /innodb_buffer_pool_size/ {print $2}'i <<< "$MYSQLCONF")
# Grabs just the value for the buffer pool
INNODBVALNUMREGEX="(([0-9]+)).*$"
[[ $INNODBVALUE =~ $INNODBVALNUMREGEX ]] &&
INNODBNUMVALUE=${BASH_REMATCH[1]} # Only the value
#Grabs just the alpha character denoting the memory denomination
INNODBVALALPHREGEX="([A-Za-z]).*$"
[[ $INNODBVALUE =~ $INNODBVALALPHREGEX ]] &&
INNODBDENOM=${BASH_REMATCH[1]} # The memory denomination being used
# This calculates what the value would be in MiB since it may be written out in bytes
MYSQLINNODB=$(awk '{size = $1 / 1024 / 1024 ; print size " M"} ' <<< "$INNODBVALUE")
# Examines the my.cnf file, specifically for the InnoDB Buffer Pool Size line. If the line is NOT present it echos the default value
# associated with MySQL, otherwise it reviews to see if the value is set in MiB or bytes. If Bytes it displays the appropriate value
# in MiB through the $MYSQLINNODB variable, if already in MiB it displays that value per the $INNODBVALUE variable
if [[ "$INNODBPRESENT" == "" ]];then
echo "${MYSQLINFO}Current InnoDB:${RESET} 128 MB (default)"
elif [[ $INNODBVALUE == *M ]] || [[ $INNODBVALUE == *G ]]; then
echo "${MYSQLINFO}Current InnoDB:${RESET} $INNODBNUMVALUE $INNODBDENOM"
else
echo "${MYSQLINFO}Current InnoDB:${RESET} $MYSQLINNODB"
fi
########## MYISAM KEY BUFFER SIZE LOGIC ###############
# Search the $MYSQLCONF variable for the InnoDB Buufer Pool variable. This is just going to identify if it's there or not
MYISAMPRESENT=$(awk '/^key_buffer/' <<< "$MYSQLCONF")
# This will take the value that's assigned to the InnoDB Buffer Pool (should it exist) and store the value
MYISAMVALUE=$(awk -F"=" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /^key_buffer/ {print $2}'i <<< "$MYSQLCONF")
#MYISAMVALUE=$(awk -F"=" '/^key_buffer/ {print $2}'i <<< "$MYSQLCONF")
# Grabs just the value for the buffer pool
MYISAMVALNUMREGEX="(([0-9]+)).*$"
[[ $MYISAMVALUE =~ $MYISAMVALNUMREGEX ]] &&
MYISAMNUMVALUE=${BASH_REMATCH[1]} # Only the value
#Grabs just the alpha character denoting the memory denomination
MYISAMVALALPHREGEX="([A-Za-z]).*$"
[[ $MYISAMVALUE =~ $MYISAMVALALPHREGEX ]] &&
MYISAMDENOM=${BASH_REMATCH[1]} # The memory denomination being used
# This calculates what the value would be in MiB since it may be written out in bytes
MYSQLMYISAM=$(awk '{size = $1 / 1024 / 1024 ; print size " M"} ' <<< "$MYISAMVALUE")
# Examines the my.cnf file, specifically for the Key Buffer Pool Size line. If the line is NOT present it echos the default value
# associated with MySQL, otherwise it reviews to see if the value is set in MiB or bytes. If Bytes it displays the appropriate value
# in MiB through the $MYSQLMYISAM variable, if already in MiB it displays that value per the $MYISAMVALUE variable
if [[ "$MYISAMPRESENT" == "" ]];then
echo "${MYSQLINFO}Current MyISAM:${RESET} 8 M (default)"
elif [[ $MYISAMVALUE == *M ]] || [[ $MYISAMVALUE == *G ]];then
echo "${MYSQLINFO}Current MyISAM:${RESET} $MYISAMNUMVALUE $MYISAMDENOM"
else
echo "${MYSQLINFO}Current MyISAM:${RESET} $MYSQLMYISAM"
fi
}
##################################################################################
# END MYSQL INFO FUNCTION #
##################################################################################
##################################################################################
# BEGIN PHP INFO FUNCTION #
##################################################################################
# Function for all PHP Info related information
function phpinfo {
# Capture the output of the command php -v for later use
PHPVOUTPUT=$(php -v 2>/dev/null)
# Capture the memory_limit line from the global php.ini
#PHPGLOBALCONF=$(awk -F"=" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /memory_limit/ {print $2}' /usr/local/lib/php.ini)
PHPGLOBALCONF=$(awk -F"=" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /memory_limit/ {print $2}' $ACTUALPHPINI)
echo "------------\\${PHPINFO} ${UNDERLINE}PHP INFO${RESET} \\----------------------------------"
echo
## Grab the version of PHP currently installed on the system
PHPREGEX="(([0-9])\.([0-9]+)\.([0-9]+)).*$"
[[ $PHPVOUTPUT =~ $PHPREGEX ]] &&
PHPENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: x.x.xx
PHPMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: x
PHPMINORVERSION=${BASH_REMATCH[3]} && # The minor version #: x
PHPBUILDVERSION=${BASH_REMATCH[4]} # The build version #: xx
# Display the PHP version
echo "${PHPINFO}Version In Use:${RESET} $PHPENTIREVERSION"
# Quick check against a file that will verify if cPanel IS or is NOT installed. This is stored in a variable
CPANELTEST=$(cat /usr/local/cpanel/version 2>/dev/null)
# Check against that variable. If cPanel IS installed, grab the various PHP handlers from the location cPanel sets
if [[ ! -z "$CPANELTEST" ]]; then
PHPCONF=$(cat /usr/local/apache/conf/php.conf 2>/dev/null)
CGIHANDLER=$(awk 'match($0,/cgi-sys/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
SUPHPHANDLER=$(awk 'match($0,/suphp/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
DSOHANDLER=$(awk 'match($0,/libphp5/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
FCGIHANDLER=$(awk 'match($0,/fcgid/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
if [[ ! -z "$FCGIHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} fCGI"
elif [[ ! -z "$SUPHPHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} SuPHP"
elif [[ ! -z "$DSOHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} DSO"
elif [[ ! -z "$CGIHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} CGI"
fi
# If cPanel is NOT installed, grab the handlers from the default location Apache sets / uses
else
PHPCONF=$(cat /etc/httpd/conf.d/php.conf 2>/dev/null)
CGIHANDLER=$(awk 'match($0,/cgi-sys/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
SUPHPHANDLER=$(awk 'match($0,/suphp/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
DSOHANDLER=$(awk 'match($0,/libphp5/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
FCGIHANDLER=$(awk 'match($0,/fcgid/) {print substr($0,RSTART,RLENGTH)}' <<< "$PHPCONF")
if [[ ! -z "$FCGIHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} fCGI"
elif [[ ! -z "$SUPHPHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} SuPHP"
elif [[ ! -z "$DSOHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} DSO"
elif [[ ! -z "$CGIHANDLER" ]]; then
echo "${PHPINFO}Handler In Use:${RESET} CGI"
fi
fi
# Grabs just the value for the memory_limit
PHPCONFVALREGEX="([0-9]+).*$"
[[ $PHPGLOBALCONF =~ $PHPCONFVALREGEX ]] &&
PHPMEMLIMIT=${BASH_REMATCH[1]} # Only the value for the PHP memory_limit
PHPCONFALPHREGEX="([A-Za-z]).*$"
[[ $PHPGLOBALCONF =~ $PHPCONFALPHREGEX ]] &&
PHPMEMLIMITDENOM=${BASH_REMATCH[1]} # The memory denomination being used
# Display the PHP memory_limit value
echo "${PHPINFO}Memory Limit #:${RESET} $PHPMEMLIMIT $PHPMEMLIMITDENOM"
}
##################################################################################
# END PHP INFO FUNCTION #
##################################################################################
##################################################################################
# BEGIN APACHE INFO FUNCTION #
##################################################################################
# Function for all Apache Info related information
function apacheinfo {
if [[ -z $CENTOSCHECK ]]; then
APACHEFULLINFO=$(apache2ctl -V 2>/dev/null)
# All else fails, we presume we're on a base CentOS install and display accordingly
else
APACHEFULLINFO=$(httpd -V)
fi
# Grabs / stores the contents of the http -V command for later parsing
#APACHEFULLINFO=$(httpd -V)
# Grabs the netstat info for later parsing to find the number of active connections
NETSTATINFO=$(netstat -nap 2>/dev/null)
# Not including this under Apache. Will examine adding it to a "Traffic" section later on
## Parses the netstat info and provides us with only the number of TCP connections
#NUMOFCONNS=$(awk '/:80/ {++c} END {print c}' <<< "$NETSTATINFO")
# Get the entire Apache version number from the string in the $APACHEINFO variable
APACHEVERSION=$(/etc/init.d/httpd status | awk '/Server Version/ {print}')
#APACHEVERSION=$(awk -F[/\ ] '/Server version/ {print $4}'i <<< $APACHEFULLINFO)
# Get the currently used MPM
APACHEMPM=$(awk -F[:] '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /Server MPM/ {print $2}'x <<< "$APACHEFULLINFO")
# This parses the Apache version and breaks it down into the individual components of the version number with each part
# being stored as a separate variable. These individual components are not being utilized but provide the ability to
# easily compare the major / minor version numbers for version checking.
#[[ $APACHEVERSION =~ (([0-9])\.([0-9])\.([0-9][0-9])).*$ ]] &&
APACHEREGEX="(([0-9])\.([0-9])\.([0-9]+)).*$"
#[[ $APACHEVERSION =~ (([0-9])\.([0-9])\.([0-9]+)).*$ ]] &&
[[ $APACHEVERSION =~ $APACHEREGEX ]] &&
APACHEENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: x.x.xx
APACHEMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: x
APACHEMINORVERSION=${BASH_REMATCH[3]} && # The minor version #: x
APACHEBUILDVERSION=${BASH_REMATCH[4]} # The build version #: xx
echo "------------\\${APACHEINFO} ${UNDERLINE}APACHE INFO${RESET} \\-------------------------------"
echo
echo "${APACHEINFO}Version In Use:${RESET} $APACHEENTIREVERSION"
echo "${APACHEINFO}MPM Being Used:${RESET} $APACHEMPM"
#echo "${APACHEINFO}Connections In:${RESET} $NUMOFCONNS"
echo
}
##################################################################################
# END APACHE INFO FUNCTION #
##################################################################################
##################################################################################
# BEGIN CPANEL INFO FUNCTION #
##################################################################################
# Function for all cPanel Info related information
function cpanelinfo {
# Grab the cPanel version number
CPANELVERSION=$(</usr/local/cpanel/version)
# Inspects the cPanel release tier, if the variables in the cpupdate.conf file is number, the release is set to LTS
# and we identify that, otherwise we display what is there since it will match the appropriate release
RELEASEREGEX="^[0-9]+([.][0-9]+)?$"
CPANELRELEASE=$(awk -F"=" ' /CPANEL/ {print $2}' /etc/cpupdate.conf)
if [[ $CPANELRELEASE =~ $RELEASEREGEX ]]; then
CPANELRELEASE="LTS";
fi
# A cPanel update (around March 2015) created a new file for storing the setting of Legacy Backups. Need to create a quick check to see
# if we're running the new(er) version or not so that we examine the correct file
LEGACYCHECK=$(cat /etc/cpbackup.conf 2>/dev/null)
# This parses the cPanel version and breaks it down into the individual components of the version number with each part
# being stored as a separate variable. These individual components are not being utilized but provide the ability to
# easily compare the major / minor version numbers for version checking.
CPANELREGEX="(([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)).*$"
#[[ $CPANELVERSION =~ (([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)).*$ ]] &&
[[ $CPANELVERSION =~ $CPANELREGEX ]] &&
CPANELENTIREVERSION=${BASH_REMATCH[1]} && # The whole version #: xx.xx.x.xx
CPANELMAJORVERSION=${BASH_REMATCH[2]} && # The major version #: xx
CPANELMINORVERSION=${BASH_REMATCH[3]} && # The minor version #: xx
CPANELBUILDVERSION=${BASH_REMATCH[4]} && # The build version #: x
CPANELREVISIONVERSION=${BASH_REMATCH[5]} # The revision version #: xx
# Because older versions of cPanel set the backup status in a different file
if [[ "$CPANELMINORVERSION" -le "32" ]]; then
CPANELLEGACY=$(awk -F" " ' /BACKUPACCTS/ {print $2}' /etc/cpbackup.conf)
else
if [[ -z $LEGACYCHECK ]]; then
CPANELLEGACY=$(awk -F" " ' /BACKUPENABLE/ {print $2}' /etc/cpbackup.public.conf)
else
# Determines if legacy cPanel backups are enabled
CPANELLEGACY=$(awk -F" " ' /BACKUPENABLE/ {print $2}' /etc/cpbackup.conf 2>/dev/null)
fi
fi
# Determines if the new cPanel backups are enabled
CPANELBACKUP=$(awk -F" " ' {gsub(/^[ \t]+|[ \t]+$/, "", $2)} /BACKUPENABLE/ {gsub( "['\'']","" ); print $2}' /var/cpanel/backups/config 2>/dev/null)
echo
echo "------------\\${CPANELINFO} ${UNDERLINE}CPANEL INFO${RESET} \\-------------------------------"
echo
echo "${CPANELINFO}Version In Use:${RESET} $CPANELVERSION"
echo "${CPANELINFO}Release Set To:${RESET} $CPANELRELEASE"
# Logic to review the status of the different backups systems to depending on if they're enabled or disabled
# display an appropriate message
if [ "$CPANELMINORVERSION" == "32" ] && [ "$CPANELLEGACY" == "yes" ]; then
echo "${CPANELINFO}Backups Status:${RESET} Enabled"
elif [ "$CPANELMINORVERSION" == "32" ] && [ "$CPANELLEGACY" == "no" ]; then
echo "${CPANELINFO}Backups Status:${RESET} Disabled"
else
if [ "$CPANELLEGACY" == "no" ] && [ "$CPANELBACKUP" == "no" ]; then
echo "${CPANELINFO}Backups Status:${RESET} Disabled"
elif [ "$CPANELLEGACY" == "no" ] && [ "$CPANELBACKUP" == "yes" ]; then
echo "${CPANELINFO}Backups Status:${RESET} Enabled"
elif [ "$CPANELLEGACY" == "yes" ] && [ "$CPANELBACKUP" == "no" ]; then
echo "${CPANELINFO}Backups Status:${RESET} Legacy Enabled"
elif [ "$CPANELLEGACY" == "yes" ] && [ "$CPANELBACKUP" == "yes" ]; then
echo "${CPANELINFO}Backups Status:${RESET} BOTH Systems Enabled"
fi
fi
}
##################################################################################
# END CPANEL INFO FUNCTION #
##################################################################################
##################################################################################
# BEGIN RAID ARRAY TEST FUNCTION #
##################################################################################
# Function for all RAID array tests
function arraytest {
# Logic to examine if the current array is on an LSI controller, if so it proceeds
if [[ "$RAIDBRAND" == "LSI" ]];then
# Counts the number of arrays on the controller and assigns to variable
#NUMARRAYS=$(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -L"$lsicontroller" -aAll | awk '/Virtual Drive/ { count++ } END { print count }')
#NUMARRAYS=$(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -a"$lsicontroller" | awk '/Virtual Drive/ { count++ } END { print count }')
NUMARRAYS=$(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -a"$lsicontroller" 2>/dev/null | awk '/Target Id/ { count++ } END { print count }')
# Because arrays start at 0, we subtract 1 from the # of arrays and create a counter for our iterations
ARRAYITERATIONS=$(echo "$NUMARRAYS-1" | bc)
# Also want to know how what array we're looking at if there are multiple, created empty counter for this
CURRENTARRAY=0
# For loop that runs through the arrays, increasing the iteration counter each time, and gathers the various
# pieces of information relating to each array and displaying it accordingly.
for (( array=0; array<=$ARRAYITERATIONS; array++ )); do
# Gathers the general information about each array and stores it in a variable. We'll use this repeatedly
#ARRAYINFO=$(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -L"$lsicontroller" -a"$CURRENTARRAY")
ARRAYINFO=$(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -L"$CURRENTARRAY" -a"$lsicontroller" 2>/dev/null)
# Determines the number of disks on a span, and the number of spans for an array. We'll use this to calculate the
# RAID level that array is setup for in a moment
LSIDISKS=$(awk -F":" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /Number Of Drives/ {print $2}' <<< "$ARRAYINFO")
LSISPANS=$(awk -F":" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /Span/ {print $2}' <<< "$ARRAYINFO")
# Calculates the total number of disks that comprise the array
LSINUMBERDISKS=$((LSIDISKS * LSISPANS))
# Grabs the "Primary" RAID level. Based on the number of disks / spans we can get the actual RAID level
LSIRAIDPRIMARY=$(awk -F"-" '/Primary/ {gsub(/,.*/,""); print $2}' <<< "$ARRAYINFO")
# Let us know what array this information applies to. This is NOT the logical array position.
echo "${DISKINFO}${UNDERLINE}RAID Array #$CURRENTARRAY"${RESET}
#echo "${DISKINFO}RAID Array:${RESET} #$CURRENTARRAY"
# Displays the number of disks, spans, and the actual RAID level
echo "${DISKINFO}# of Disks:${RESET}" $LSINUMBERDISKS
if [[ "$LSIRAIDPRIMARY" == "1" && "$LSISPANS" -gt "1" ]]; then
echo "${DISKINFO}RAID Level:${RESET} 10"
elif [[ "$LSIRAIDPRIMARY" == "1" && "$LSISPANS" == "1" ]];then
echo "${DISKINFO}RAID Level:${RESET} 1"
else
echo "${DISKINFO}Raid Level:${RESET} $LSIRAIDPRIMARY"
fi
echo
# Increases the counter for what array we just examined
((CURRENTARRAY+=1))
done
# Logic to examine if the current array is on an Adaptec controller, if so it proceeds
elif [[ "$RAIDBRAND" == "Adaptec" ]];then
# Counts the number of arrays on the controller and assigns to variable
NUMARRAYS=$(/usr/StorMan/arcconf getconfig $controller ld | awk '/Logical device number/ { count++ } END { print count }')
# Because arrays start at 0, we subtract 1 from the # of arrays and create a counter for our iterations
ARRAYITERATIONS=$(echo "$NUMARRAYS-1" | bc)
# Also want to know how what array we're looking at if there are multiple, created empty counter for this
#CURRENTARRAY=0
firstarray=$(/usr/StorMan/arcconf getconfig $controller ld | awk '/Logical device number/ {print; count++; if (count=1) exit}')
firstarrayregex="([0-9])\.*$"
[[ $firstarray =~ $firstarrayregex ]] &&
CURRENTARRAY=${BASH_REMATCH[1]}
# For loop that runs through the arrays, increasing the iteration counter each time, and gathers the various
# pieces of information relating to each array and displaying it accordingly.
for (( array=0; array<=$ARRAYITERATIONS; array++ )); do
# Gathers the general information about each array and stores it in a variable. We'll use this repeatedly
#ARRAYINFO=$(/usr/StorMan/arcconf getconfig "$adapteccontroller" ld "$CURRENTARRAY")
ARRAYINFO=$(/usr/StorMan/arcconf getconfig "$controller" ld "$CURRENTARRAY")
# Counter the number of disks involved and the RAID level of the array
#ADAPTECDISKS=$(awk '/Device #/ {++c} END {print c}' <<< "$ARRAYINFO")
ADAPTECDISKS=$(awk '/Segment [0-9]/ {++c} END {print c}' <<< "$ARRAYINFO")
ADAPTECRAID=$(awk -F":" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /RAID level/ {print $2}' <<< "$ARRAYINFO")
# Let us know what array this information applies to. This is NOT the logical array position.
echo "${DISKINFO}${UNDERLINE}RAID Array #$CURRENTARRAY"${RESET}
# Displays the number of disks involved in the array and the RAID level
echo "${DISKINFO}# of Disks:${RESET}" $ADAPTECDISKS
echo "${DISKINFO}RAID Level:${RESET}" $ADAPTECRAID
echo
# Increases the counter for what array we just examined
((CURRENTARRAY+=1))
done
fi
}
##################################################################################
# END RAID ARRAY TEST FUNCTION #
##################################################################################
##################################################################################
# BEGIN DISK INFO FUNCTION #
##################################################################################
# Function for all Disk Info related information
function diskinfo {
# Identify the BRAND of the RAID controller currently being used
#RAIDBRAND=$(lspci 2>/dev/null | awk '/Adaptec|LSI/{for(i=1;i<=NF;++i)if($i~/Adaptec|LSI/)print $i}')
# Ran into an issue on older machines (CentOS 5.1...I presume due to the Bash version) where the single line (commented out directly above) was
# breaking. I seperated it into two parts and that works just fine.
CONTROLLERCOUNT=$(lspci 2>/dev/null | grep -i RAID)
RAIDBRAND=$(sed -n 's/^.*\(LSI\|Adaptec\).*$/\1/p' <<< "$CONTROLLERCOUNT")
#RAIDBRAND=$(awk '/Adaptec|LSI/{for(i=1;i<=NF;++i)if($i~/Adaptec|LSI/)print $i}' <<< "$CONTROLLERCOUNT")
# Controller counters. Identifies the physical controller being queries, and sets the counters for the
# brand specific versioning of what controller is being queried
controller=1
adapteccontroller=1
lsicontroller=0
ADAPTERS=$RAIDBRAND
CARDARRAY=( ${ADAPTERS} )
NUMCARDS=$(echo ${#CARDARRAY[@]})
## I'm sure this could be better accomplished with some regex and more of it handled within Bash itself. For now this works
## and is extremely fast (not to mention it formats how I want). It stays. Will likely be reviewed at a later date.
#DISKUSAGE=$(paste <(df -h | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | awk '{print substr($0, index($0, $5))}' | column -t))
echo
echo "------------\\${DISKINFO} ${UNDERLINE}DISK INFO${RESET} \\---------------------------------"
echo
echo "${DISKINFO}Disk Usage:${RESET}"
COLORSANDF=$(paste <(df -h | grep -v "$(awk '/\#zbind/ {print $1}' /etc/fstab)" | grep -v '^ ' | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | sed 's/on//' | grep -v "$(awk '/\#zbind/ {print $1}' /etc/fstab)" | grep -v '^ ' | awk '{print substr($0, index($0, $5))}' | column -t) | egrep --color -B 50 -A 50 '[8-9][0-9]\%|100\%')
COLORDF=$(paste <(df -h | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | sed 's/on//' | awk '{print substr($0, index($0, $5))}' | column -t) | egrep --color -B 50 -A 50 '[8-9][0-9]\%|100\%')
# I'm not concerned with showing all the SAN mounts. This examines the fstab file and uses the SAN mount entries there as a list
# for what to remove from the actual disk usage display
if grep -q \#zbind "/etc/fstab"; then
# Some gnarly uses of the paste and column commands that allow me to interject the inode usage % inline with the disk usage display
if [[ "$COLORSANDF" == "" ]]; then
paste <(df -h | grep -v "$(awk '/\#zbind/ {print $1}' /etc/fstab)" | grep -v '^ ' | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | sed 's/on//' | grep -v "$(awk '/\#zbind/ {print $1}' /etc/fstab)" | grep -v '^ ' | awk '{print substr($0, index($0, $5))}' | column -t)
else
paste <(df -h | grep -v "$(awk '/\#zbind/ {print $1}' /etc/fstab)" | grep -v '^ ' | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | sed 's/on//' | grep -v "$(awk '/\#zbind/ {print $1}' /etc/fstab)" | grep -v '^ ' | awk '{print substr($0, index($0, $5))}' | column -t) | egrep --color -B 50 -A 50 '[8-9][0-9]\%|100\%'
fi
else
if [[ "$COLORDF" == "" ]]; then
paste <(df -h | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | sed 's/on//' | awk '{print substr($0, index($0, $5))}' | column -t)
else
paste <(df -h | awk '{ $6=""; $7=""; print }' | column -t) <(df -hi | sed 's/on//' | awk '{print substr($0, index($0, $5))}' | column -t) | egrep --color -B 50 -A 50 '[8-9][0-9]\%|100\%'
fi
fi
echo
# If there is no RAID card installed present "N/A" to indicate no RAID setup
if [[ "$RAIDBRAND" == "" ]];then
echo "${DISKINFO}Controller:${RESET} N/A"
echo
# Examines how many RAID controller cards are installed on the system. If equal to one, only examines
# the number of arrays involved with that controller. If more than one card exists it examines their
# brand to see how many iterations of the arraytest function it needs to perform for each controller
elif [[ "$NUMCARDS" == "1" ]];then
RAIDBRAND=${CARDARRAY[$I]}
if [[ "$RAIDBRAND" == "Adaptec" ]]; then
ADAPTECMODEL=$(/usr/StorMan/arcconf getconfig "$adapteccontroller" | awk -F":" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /Controller Model/ {print $2}')
echo "${DISKINFO}Model Used:${RESET} $ADAPTECMODEL"
echo
elif [[ "$RAIDBRAND" == "LSI" ]]; then
LSIMODEL=$(/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -a"$lsicontroller" 2>/dev/null | awk -F ":" '/Product Name/ {print $2}' | sed -e 's/^[ \t]*//')
echo "${DISKINFO}Model Used:${RESET} $LSIMODEL"
echo
fi
arraytest
#echo
elif [[ "$NUMCARDS" -gt "1" ]]; then
# For loop that identifies if the first controller is an Adaptec or LSI controller, then proceeds with the
# logic to grab the model before calling the arraytest function to examine for multiple RAID arrays
# on the particular controller. Finally it increments the various counter variables to examine if there are
# any additional controllers to be examined
for I in ${!CARDARRAY[*]}; do
RAIDBRAND=${CARDARRAY[$I]}
#echo "${DISKINFO}Controller:${RESET} #$controller"
if [[ "$RAIDBRAND" == "Adaptec" ]]; then
ADAPTECMODEL=$(/usr/StorMan/arcconf getconfig "$adapteccontroller" | awk -F":" '{gsub(/^[ \t]+|[ \t]+$/, "", $2)} /Controller Model/ {print $2}')
echo "${DISKINFO}Controller:${RESET} #$controller"
echo "${DISKINFO}Model Used:${RESET} $ADAPTECMODEL"
((adapteccontroller+=1))
echo