-
Notifications
You must be signed in to change notification settings - Fork 9
/
audit_linux_system.sh
executable file
·670 lines (669 loc) · 57.9 KB
/
audit_linux_system.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
#!/bin/bash
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this file. If not, see <http://www.gnu.org/licenses/>.
##
#
# Script installation:
#echo "cd /etc/bacula/scripts && git clone https://github.com/MykolaPerehinets/auditlinuxsystem.git"
#
# Script function:
# Audit and Inventory All Configurations files/Services on Linux servers/hosts (for Bacula Bare-Metal Recovery)
# Please use for this action root account!
#
# Script requirements 1:
#yum update && yum install bacula-client vim parted pciutils yum-plugin-security yum-plugin-verify yum-plugin-changelog lsusb lshw usbutils lsscsi pigz mlocate time glances tuned redhat-lsb-core etckeeper firewalld mailx policycoreutils-python policycoreutils-newrole policycoreutils-restorecond setools-console lsof iotop htop tree mutt psacct hdparm
#
# Script requirements 2:
# for initial setup the etckeeper, please run next command from root user
#cd /etc
#sudo etckeeper init
#sudo etckeeper commit "Initial import"
#git config --global user.name "root"
#git config --global user.email [email protected]
#
# Additional requirements and enhancement for production use:
# for initial setup the bacula scripts, please run next command from root user
#cd /etc/bacula/scripts
#setenforce 0
#tail -fn 0 /var/log/audit/audit.log | grep bacula > /etc/bacula/bacula-audit.log
#
# Run the simple backup job that has a pre-script
#
#chcon system_u:object_r:bacula_exec_t:s0 /etc/bacula/scripts
#semanage fcontext -a -t bacula_exec_t "/etc/bacula/scripts(/.*)?"
#restorecon -R -v /etc/bacula/scripts
#restorecon reset /etc/bacula/scripts/audit_linux_system.sh context unconfined_u:object_r:bacula_etc_t:s0->unconfined_u:object_r:bacula_exec_t:s0
#restorecon reset /etc/bacula/scripts/make_dumpall_pgsql.sh context unconfined_u:object_r:bacula_etc_t:s0->unconfined_u:object_r:bacula_exec_t:s0
#restorecon reset /etc/bacula/scripts/verify_dumpall_pgsql.sh context unconfined_u:object_r:bacula_etc_t:s0->unconfined_u:object_r:bacula_exec_t:s0
#restorecon reset /etc/bacula/scripts/delete_dumpall_pgsql.sh context unconfined_u:object_r:bacula_etc_t:s0->unconfined_u:object_r:bacula_exec_t:s0
#restorecon reset /etc/bacula/scripts/recovery_dumpall_pgsql.sh context unconfined_u:object_r:bacula_etc_t:s0->unconfined_u:object_r:bacula_exec_t:s0
#ls -lZ /etc/bacula/scripts
#
#cd /etc/bacula
#cat /etc/bacula/bacula-audit.log | audit2allow -M bacula_policy
#audit2allow -a
#audit2allow -a -M bacula_policy
# ...
# TEST REVIEW: bacula_policy.te
# INSTALL new POLICY:
#semodule -i bacula_policy.pp
# TEST: run another backup job, ensure you get no more AVC DENIED messages in /var/log/audit/audit.log
# ...
# TEST REVIEW: bacula_policy.te
# INSTALL new POLICY:
#semodule -i bacula_policy.pp
# TEST: run another backup job, ensure you get no more AVC DENIED messages in /var/log/audit/audit.log
# ...
# TEST REVIEW: bacula_policy.te
# INSTALL new POLICY:
#semodule -i bacula_policy.pp
# TEST: run another backup job, ensure you get no more AVC DENIED messages in /var/log/audit/audit.log
# ...
# TEST DONE
#setenforce 1
#
#
# Script Submitted and Deployment in Production environments by:
# Mykola Perehinets (mperehin)
# Tel: +380 67 772 6910
# Mailto: [email protected]
#
#######################################################################################################################
# Script modified date
Version=27012022
#
#######################################################################################################################
# Exit code status
ERR=0
#
# Basic Script Configuration, deploy needed parameters, variables, mail, etc.
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
#
# DevOps MailGroup
#ADMIN="[email protected]"
ADMIN="[email protected]"
#
#HOSTNAME=`hostname -s`
HOSTNAME=`hostname`
#
DATE=$(date +%Y-%m-%d_%H:%M)
DATE_START=$(date +%Y-%m-%d_%H:%M)
#
# Stored inventory logs files in this folder
#auditlogdir=/root
#auditlogdir=/var/log
auditlogdir=/etc/bacula/scripts
#auditlogdirR=/OUTPUT
#auditlogdirR=/RESTORE
auditlogdirR=/RECOVERY
#
#######################################################################################################################
# Verifying all needed folders/directories
if [[ ! -e $auditlogdir ]]; then
mkdir -p $auditlogdir
elif [[ ! -d $auditlogdir ]]; then
echo "ERROR: $auditlogdir already exists but is not a directory... Please fix..." 1>&2
fi
#
if [[ ! -e $auditlogdirR ]]; then
mkdir -p $auditlogdirR
elif [[ ! -d $auditlogdirR ]]; then
echo "ERROR: $auditlogdirR already exists but is not a directory... Please fix..." 1>&2
fi
#
#######################################################################################################################
# Run script
cd $auditlogdir
echo "WARNING: Please verify Script Version on your server HOST: $HOSTNAME"
echo "OK... Audit your system has been STARTING... Script Version in this server #$Version... "
echo "####################################################################################"
echo "OK... Audit your system has been starting at $DATE_START... Script Version in this server #$Version..." > $auditlogdir/server_inventory_$HOSTNAME.log
echo "#################################################################################################################" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "Inventory audit for server/hostname:" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
hostname >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
ifconfig | grep inet >> $auditlogdir/server_inventory_$HOSTNAME.log
ifconfig | grep ether >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "This script was started from user $USER" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "Your home directory is $HOME" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "Your mail INBOX is located in $MAIL" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "#################################################################################################################" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/redhat-release:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/redhat-release >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/lsb-release:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/lsb-release >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsb_release -a:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsb_release -a >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /boot/grub/device.map:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /boot/grub/device.map >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /boot/grub/menu.lst:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /boot/grub/menu.lst >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /boot/grub/grub.*:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /boot/grub/grub.* >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /boot/grub2/device.map:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /boot/grub2/device.map >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /boot/grub2/grubenv:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /boot/grub2/grubenv >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /boot/grub2/grub.*:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /boot/grub2/grub.* >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "uname -a:" >> $auditlogdir/server_inventory_$HOSTNAME.log
uname -a >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "mount -v:" >> $auditlogdir/server_inventory_$HOSTNAME.log
mount -v | grep "^/" | awk '{print "\nPartition identifier: " $1 "\n Mountpoint: " $3}' >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "mount:" >> $auditlogdir/server_inventory_$HOSTNAME.log
mount >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/fstab:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/fstab >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/mtab:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/mtab >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "df -Th:" >> $auditlogdir/server_inventory_$HOSTNAME.log
df -Th >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsblk:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsblk >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsblk -f:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsblk -f >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "fdisk -l:" >> $auditlogdir/server_inventory_$HOSTNAME.log
fdisk -l >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "parted -l:" >> $auditlogdir/server_inventory_$HOSTNAME.log
parted -l >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "blkid:" >> $auditlogdir/server_inventory_$HOSTNAME.log
blkid >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -Rhal /dev/disk/by-*:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -Rhal /dev/disk/by-* >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "pvs:" >> $auditlogdir/server_inventory_$HOSTNAME.log
pvs >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "pvdisplay:" >> $auditlogdir/server_inventory_$HOSTNAME.log
pvdisplay >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "vgdisplay:" >> $auditlogdir/server_inventory_$HOSTNAME.log
vgdisplay >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lvdisplay:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lvdisplay >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/partitions:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/partitions >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -i /dev/sda:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -i /dev/sda >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -Tt /dev/sda2:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -Tt /dev/sda2 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -t --direct /dev/sda1:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -t --direct /dev/sda1 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -t --direct --offset 512 /dev/sda2:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -t --direct --offset 512 /dev/sda2 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -i /dev/sdb:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -i /dev/sdb >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -Tt /dev/sdb1:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -Tt /dev/sdb1 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -t --direct /dev/sdb1:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -t --direct /dev/sdb1 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hdparm -t --direct --offset 512 /dev/sdb1:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hdparm -t --direct --offset 512 /dev/sdb1 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/block/sda/queue/scheduler:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/block/sda/queue/scheduler >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/block/sdb/queue/scheduler:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/block/sdb/queue/scheduler >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/block/sd*/queue/scheduler:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/block/sd*/queue/scheduler >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/block/sda/queue/nr_requests:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/block/sda/queue/nr_requests >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/block/sdb/queue/nr_requests:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/block/sdb/queue/nr_requests >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/block/sd*/queue/nr_requests:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/block/sd*/queue/nr_requests >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/cpuinfo:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/cpuinfo >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/meminfo:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/meminfo >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "free -h:" >> $auditlogdir/server_inventory_$HOSTNAME.log
free -h >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "grep -i Page /proc/meminfo:" >> $auditlogdir/server_inventory_$HOSTNAME.log
grep -i Page /proc/meminfo >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/sys/kernel/shmmax:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/sys/kernel/shmmax >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "sysctl -a | grep shm:" >> $auditlogdir/server_inventory_$HOSTNAME.log
sysctl -a | grep shm >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "grep -i Huge /proc/meminfo:" >> $auditlogdir/server_inventory_$HOSTNAME.log
grep -i Huge /proc/meminfo >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat cat /proc/cpuinfo | grep pdpe1gb:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/cpuinfo | grep pdpe1gb >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/kernel/mm/transparent_hugepage/enabled:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/kernel/mm/transparent_hugepage/enabled >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /sys/kernel/mm/transparent_hugepage/defrag:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /sys/kernel/mm/transparent_hugepage/defrag >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ipcs -m:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ipcs -m >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ipcs -pm:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ipcs -pm >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "fgrep dba /etc/group:" >> $auditlogdir/server_inventory_$HOSTNAME.log
fgrep dba /etc/group >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "numactl --show:" >> $auditlogdir/server_inventory_$HOSTNAME.log
numactl --show >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "numactl --hardware:" >> $auditlogdir/server_inventory_$HOSTNAME.log
numactl --hardware >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "numastat -m:" >> $auditlogdir/server_inventory_$HOSTNAME.log
numastat -m >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/devices:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/devices >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/swaps:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/swaps >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "swap -s:" >> $auditlogdir/server_inventory_$HOSTNAME.log
swap -s >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "swap -l:" >> $auditlogdir/server_inventory_$HOSTNAME.log
swap -l >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/mdstat:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/mdstat >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lspci:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lspci >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsusb:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsusb >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsmod:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsmod >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lshw:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lshw >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "egrep '(vmx|svm)' /proc/cpuinfo:" >> $auditlogdir/server_inventory_$HOSTNAME.log
egrep '(vmx|svm)' /proc/cpuinfo >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lslogins:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lslogins >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsinitrd:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsinitrd >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "chkconfig --list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
chkconfig --list >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "chkconfig --list | grep on:" >> $auditlogdir/server_inventory_$HOSTNAME.log
chkconfig --list | grep on >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "systemctl list-unit-files | grep enabled:" >> $auditlogdir/server_inventory_$HOSTNAME.log
systemctl list-unit-files | grep enabled >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/selinux/config:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/selinux/config >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/audit/rules.d/audit.rules:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/audit/rules.d/audit.rules >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "multipath -ll -v3:" >> $auditlogdir/server_inventory_$HOSTNAME.log
multipath -ll -v3 >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/iscsi/initiatorname.iscsi:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/iscsi/initiatorname.iscsi >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "iscsiadm -m session:" >> $auditlogdir/server_inventory_$HOSTNAME.log
iscsiadm -m session >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsscsi -l:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsscsi -l >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "crontab -l:" >> $auditlogdir/server_inventory_$HOSTNAME.log
crontab -l >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -tulp:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -tulp >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -at:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -at >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -au:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -au >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -ntulp:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -ntulp >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -rn:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -rn >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -lnptux:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -lnptux >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -s:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -s >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "netstat -ate:" >> $auditlogdir/server_inventory_$HOSTNAME.log
netstat -ate | grep -v LISTEN | grep -v CONNECTED | awk '{print$5}' | sed 's/[0-9]\+$//' | sort | uniq -c >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ss -ntulp:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ss -ntulp >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsof -i -n:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsof -i -n | egrep 'COMMAND|LISTEN|UDP' >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lsof -d mem:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lsof -d mem >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "lsof:" >> $auditlogdir/server_inventory_$HOSTNAME.log
#lsof >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "iptables --list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
iptables --list >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ip6tables --list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ip6tables --list >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "firewall-cmd --list-all-zones:" >> $auditlogdir/server_inventory_$HOSTNAME.log
firewall-cmd --list-all-zones >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ifconfig:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ifconfig >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "route:" >> $auditlogdir/server_inventory_$HOSTNAME.log
route >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/resolv.conf:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/resolv.conf >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/hosts:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/hosts >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -l /etc/sysctl.d/:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -l /etc/sysctl.d/ >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/sysctl.conf:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/sysctl.conf >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "sysctl -p:" >> $auditlogdir/server_inventory_$HOSTNAME.log
sysctl -p >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "sysctl -a:" >> $auditlogdir/server_inventory_$HOSTNAME.log
sysctl -a >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ulimit -a:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ulimit -a >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -l /etc/security/limits.d/:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -l /etc/security/limits.d/ >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/security/limits.conf:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/security/limits.conf >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/rc.local:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/rc.local >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/rsyslog.conf:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/rsyslog.conf >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /var/log/yum.log:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /var/log/yum.log >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /var/log/dnf.log:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /var/log/dnf.log >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/sysctl.ktune:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/sysctl.ktune >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tuned-adm list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tuned-adm list >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tuned-adm active:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tuned-adm active >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tuned-adm recommend:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tuned-adm recommend >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/interrupts:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/interrupts >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/interrupts | grep -E "CPU|em1" :" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/interrupts | grep -E "CPU|em1" | sed -r "s/ +/ /g" | sed -r "s/CPU//g" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/interrupts | grep -E "CPU|em2" :" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/interrupts | grep -E "CPU|em2" | sed -r "s/ +/ /g" | sed -r "s/CPU//g" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /proc/interrupts | grep -E "CPU|bond0" :" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /proc/interrupts | grep -E "CPU|bond0" | sed -r "s/ +/ /g" | sed -r "s/CPU//g" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh nodinfo:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh nodinfo >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh list --all:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh list --all >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh list >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh pool-list --all:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh pool-list --all >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh pool-list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh pool-list >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh vol-list --pool default:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh vol-list --pool default >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh net-list --all:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh net-list --all >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "virsh net-list:" >> $auditlogdir/server_inventory_$HOSTNAME.log
virsh net-list >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "virt-top --csv >>:" >> $auditlogdir/server_inventory_$HOSTNAME.log
#virt-top --csv >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "docker ps:" >> $auditlogdir/server_inventory_$HOSTNAME.log
docker ps >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "docker ps -a:" >> $auditlogdir/server_inventory_$HOSTNAME.log
docker ps -a >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "docker images:" >> $auditlogdir/server_inventory_$HOSTNAME.log
docker images >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "docker volume ls:" >> $auditlogdir/server_inventory_$HOSTNAME.log
docker volume ls >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "docker stats:" >> $auditlogdir/server_inventory_$HOSTNAME.log
docker stats >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "docker version:" >> $auditlogdir/server_inventory_$HOSTNAME.log
docker version >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "java -version:" >> $auditlogdir/server_inventory_$HOSTNAME.log
java -version >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "javac -version:" >> $auditlogdir/server_inventory_$HOSTNAME.log
javac -version >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /root/.ssh/authorized_keys:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /root/.ssh/authorized_keys >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/ssh/sshd_config:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/ssh/sshd_config >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/ssh/ssh_config:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/ssh/ssh_config >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ac -p:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ac -p >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ac -d -y:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ac -d -y >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "sa --print-users:" >> $auditlogdir/server_inventory_$HOSTNAME.log
#sa --print-users >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "egrep -v '.*:\*|:\!' /etc/shadow:" >> $auditlogdir/server_inventory_$HOSTNAME.log
egrep -v '.*:\*|:\!' /etc/shadow | awk -F: '{print $1}' >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "grep -v ':x:' /etc/passwd:" >> $auditlogdir/server_inventory_$HOSTNAME.log
grep -v ':x:' /etc/passwd >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "lastb:" >> $auditlogdir/server_inventory_$HOSTNAME.log
lastb >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/xinetd.d/check-mk-agent:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/xinetd.d/check-mk-agent >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/bacula/bacula-fd.conf:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/bacula/bacula-fd.conf >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "cat /etc/bacula/bconsole.conf:" >> $auditlogdir/server_inventory_$HOSTNAME.log
cat /etc/bacula/bconsole.conf >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -l /etc/bacula/scripts/:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -l /etc/bacula/scripts/ >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -lZ /etc/bacula/scripts/:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -lZ /etc/bacula/scripts/ >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -l /etc/yum.repos.d/:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -l /etc/yum.repos.d/ >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -l /:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -l / >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "ls -l /var/log/:" >> $auditlogdir/server_inventory_$HOSTNAME.log
ls -l /var/log/ >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "dmesg:" >> $auditlogdir/server_inventory_$HOSTNAME.log
dmesg >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tail -n 1000 /var/log/messages:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tail -n 1000 /var/log/messages >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tail -n 1000 /var/log/kern.log:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tail -n 1000 /var/log/kern.log >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tail -n 1000 /var/log/auth.log:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tail -n 1000 /var/log/auth.log >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "tail -n 1000 /var/syslog:" >> $auditlogdir/server_inventory_$HOSTNAME.log
tail -n 1000 /var/syslog >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "w:" >> $auditlogdir/server_inventory_$HOSTNAME.log
w >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "who:" >> $auditlogdir/server_inventory_$HOSTNAME.log
who >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "hostname:" >> $auditlogdir/server_inventory_$HOSTNAME.log
hostname >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "uptime:" >> $auditlogdir/server_inventory_$HOSTNAME.log
uptime >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "etckeeper daily commit:" >> $auditlogdir/server_inventory_$HOSTNAME.log
etckeeper commit "Update detail information about all files and configurations in /etc folder... State at $DATE" >> $auditlogdir/server_inventory_$HOSTNAME.log
sleep 5
echo "-----------------------------------------------------------------------------------------------------------------" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "End of File" >> $auditlogdir/server_inventory_$HOSTNAME.log
echo "#################################################################################################################" >> $auditlogdir/server_inventory_$HOSTNAME.log
#echo "" >> $auditlogdir/server_inventory_$HOSTNAME.log
#
echo "####################################################################################"
#
# Create and verify other parameters
/bin/chmod 0644 $auditlogdir/server_inventory_$HOSTNAME.log
echo "Creating the backup inventory data and storing in $auditlogdir/server_inventory_$HOSTNAME.log"
echo "This audit/data file is needed for the Disaster Recovery Plan using with Corporate Backup System Bacula"
#
# Sending copy of audit/data to DevOps MailGroup
msg="This is copy of inventory data from HOST: $HOSTNAME, verify at $DATE_START. This audit/data file is needed for bare metal recovery procedures... -->"
#echo $msg
#sed -e 's/$/\r/' $auditlogdir/server_inventory_$HOSTNAME.log | pigz --best --independent > $auditlogdir/server_inventory_$HOSTNAME.log.win.txt.gz
sed -e 's/$/\r/' $auditlogdir/server_inventory_$HOSTNAME.log > $auditlogdir/server_inventory_$HOSTNAME.log.win.txt
#msg_body=`cat $auditlogdir/server_inventory_$HOSTNAME.log | sed "s/'/\n/g` > $auditlogdir/server_inventory_$HOSTNAME.log.win.txt
msg_body=`cat $auditlogdir/server_inventory_$HOSTNAME.log.win.txt`
#echo $msg_body
/bin/chmod 0644 $auditlogdir/server_inventory_$HOSTNAME.log.win.txt
/bin/chmod 0644 $auditlogdir/server_inventory_$HOSTNAME.log
cd /
#echo "$msg" | mail -s "WARNING: inventory of HOST: $HOSTNAME -->" -a $auditlogdir/server_inventory_$HOSTNAME.log.win.txt $ADMIN
#echo -n $msg $msg_body | mail -s "WARNING: inventory of HOST: $HOSTNAME -->" $ADMIN
echo -n $msg | mutt -s "WARNING: inventory of HOST: $HOSTNAME -->" -a $auditlogdir/server_inventory_$HOSTNAME.log.win.txt $ADMIN
echo "Sending copy of this audit/data file to DevOps MailGroup: $ADMIN "
echo "OK... Very well... Please start up the next Corporate Bacula Backup System procedures..."
#
# Rial exit code status
if [ "${ERR}" == "0" ]; then
exit 0;
else
exit 1;
fi
#
#echo "OK... Audit your system has been DONE... Thank you..."