-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit_neo.run
59 lines (52 loc) · 3.28 KB
/
audit_neo.run
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
#!/bin/bash
#Philipp 11.01.2016
#v.0.1.7.1 rewrited with functions. v.0.1.6 +report file #v.0.1.5 +esxi inventory #v.0.1.4 Inventory files introduced. #v.1.1 esxi + nasgw #v.1.0 LINUX and AIX hosts
# Getting start time for benchark
start=`date +%s`;
if [ ! -n "$1" ]; then
printf "\n Runs Hardware Inventory checks across all onsite units.\n Usage: ./audit.run SITE_ID\n Where SITE_ID is short site name. AIX and LINUX inventory scripts will be updated with this short name on first audit.run execution.\n Examples:\n ./audit.run MSK\n ./audit.run YEKATERINBURG\n ./audit.run ROSTOV_PAPA\n Prerequisites:\n aix_hw_au.sh - runs Hardware Inventory checks against any AIX-based servers.\n linux_hw_au.sh - runs Hardware Inventory checks against any Linux-based servers.\n\n Be aware that SANbox and EMCds FCSs checks is depricated in this version, as obsolete HW\n\n";
exit;
fi;
SITE_ID=$1
# PROGRESS BAR FUNCTION
function progress_bar {
local progress=$1
local total=$2
local bar_length=50
local bar=$(printf "%-${bar_length}s" "")
local progress_bar=$(printf "%-${bar_length}s" "")
bar=$(echo "$bar" | sed "s/ /#/g")
progress_bar=$(echo "$progress_bar" | sed "s/ /#/g")
local percent=$((100 * progress / total))
local progress_string=$(echo "$progress_bar" | cut -c 1-$((percent * bar_length / 100)))
printf "\r PROGRESS: %3d%% [%-${bar_length}s] RUNNING ON: %s" $percent "$progress_string" "$3"
}
#REPORT FILES NAME DEFINITION
LNX_REPORT_FILE=$SITE_ID.LINUX-HW.`date +%d%m%y`.csv
AIX_REPORT_FILE=$SITE_ID.AIX-HW.`date +%d%m%y`.csv
#INVENTORY
if [ ! -e inventory.$SITE_ID ] ; then
printf ' Site inventory file is empty!\n Update Site inventory with necessary IP list and run audit again.\n'
printf "#$SITE_ID INVENTORY FILE\n#V.01\n#Used to run HW INVENTORY AUDIT\n\n### UPM/OAM ###\n256.256.256.256 upm1a_example\n256.256.256.257 upmdb1a_example\n256.256.256.258 oam1a_example\n\n### SDP ###\n256.256.256.259 sdp10a #lnxsdp\n256.256.256.260 sdp13a #aixsdp\n\n### RCS ###\n\n### SGU ###\n\n### SLU ###\n\n### OSA ###\n\n### ECI ###\n\n### NOTIF ###\n\n### OFR ###\n\n### SAPI/AJMS/FEADMIN ###\n\n### DTR ###\n\n### SYSRV ###\n\n### NASGW ###\n\n### VCENTER ###\n256.256.256.259 VCENTER vcenter\n256.256.256.260 vp-x86-esxi-1\n\n### CISCO JUNIPER ARUBA ###\n\n### LBA ###\n\n### MAU ###\n\n### OTHER ###\n\n" > inventory.$SITE_ID
exit;
fi
#SITE FIX
sed -i "s/PROD_SITE/$SITE_ID/g" linux_hw_au.sh; sed -i "s/PROD_SITE/$SITE_ID/g" aix_hw_au.sh; sed -i "s/PROD_SITE/$SITE_ID/g" esxi_hw_au.sh;
# LINUX COLLECT
units=("sgu" "dtr" "slu" "osa" "eci" "notif" "ofr" "sapi" "ajms" "feadmin" "upm" "oam" "oem" "rcs" "sysrv" "nasgw" "spve" "esxi" "smsne_app" "lnxsdp" "AIX_SDP + SMSNE_DB")
counter=1
total=${#units[@]}
for cmd in "${units[@]}"; do
progress_bar $counter $total "$cmd"
if [ "$cmd" = "AIX_SDP + SMSNE_DB" ]; then
./aix_hw_au.sh "aixsdp" $SITE_ID | grep -v FILE-MAX > $AIX_REPORT_FILE
else
./linux_hw_au.sh "$cmd" $SITE_ID | grep -v FILE-MAX >> $LNX_REPORT_FILE
fi
((counter++))
done
printf " COMPLETED 100%%[########################################] IN $((($(date +%s)-$start))) SECONDS. \r\n\n"
#OLD REPORTS CLEANUP
find . -name "*LINUX-HW.*.csv" -mtime +15 -exec rm {} \;
find . -name "*AIX-HW.*.csv" -mtime +15 -exec rm {} \;
#EOShit-codding