-
Notifications
You must be signed in to change notification settings - Fork 4
/
sysinfo.sh
136 lines (107 loc) · 5.24 KB
/
sysinfo.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
#!/bin/bash
# SYSINFO
# System Information Analyser Remote Over Network
# Copyright (C) 2016 Aurélien DESBRIÈRES <[email protected]>
# 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
# 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 program. If not, see <http://www.gnu.org/licenses/>.
# SYSINFO is part of MAAS
# https://github.com/aurelien-git/MAAS
# Bring back system information from remote machines
tput clear # clear the terminal
# command
the_user="$(whoami)"
#the_machine="$(hostname)"
ip="$(ip a | grep inet | grep 192)"
network="$(ip addr show | awk '/inet.*brd/{print $NF; exit}')"
ip_only="$(ip addr show "$network" | grep 'inet\b' | grep 192 | awk '{print $2}' | cut -d/ -f\
1)"
fire_wall="$(sudo iptables -L)"
printf "\n\033[1;32mWelcome to SYSINFO - SYSTEM INFORMATION\033[0m\n"
printf "\033[1;32mSYSINFO is made to run as a MAAS dependencie\033[0m\n"
# Vefify and install the dependencies if needed
printf "%s\nThe software will now get the needed dependencies for your%s\noperating system $the_user %s\n"
# Register the user identification during process
printf "\033[1;32m%s\nRegistering you identification during the MAAS process\033[0m%s\n"
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval "$(ssh-agent)"
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l | grep "The agent has no identities" && ssh-add
# sysinfo request the need to install dependencies on remote target
# dependencies
command_exists () {
type "$1" &> /dev/null ;
}
# For Debian / Ubuntu / Trisquel / gNewSense and derivatives
if command_exists apt-get ; then
sudo apt-get install gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
# For Archlinux / Parabola and derivatives
if command_exists pacman ; then
sudo pacman -Sy iw gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
# For Android / Cyanogen / Replicant and derivatives
if command_exists apt ; then
sudo apt install gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
# For Fedora and derivatives
if command_exists dnf ; then
sudo dnf install -y gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
# For Gentoo
if command_exists emerge ; then
sudo emerge --ask -y gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
# For Sabayon
if command_exit equo ; then
sudo equo install -y gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
# For RedHat / CentOS and derivatives
if command_exists yum ; then
sudo yum install -y gawk df nethogs sysstat lshw lsscsi hdparm dmidecode ; exit
fi
sudo mkdir MAAS-REPORT
# Load the analysis
### Print Harddrive informations
touch MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive || exit
truncate -s 0 MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
printf "%s\n\033[1;32mHere is the information of the Harddrive:\033[0m%s\n"
df -h | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
sudo lshw -short | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
lsblk | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
lsusb | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
lspci | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
lsscsi -s | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
sudo fdisk -l | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
sudo dmidecode -t memory | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
sudo dmidecode -t processor | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
sudo dmidecode -t system | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
sudo dmidecode -t bios | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-harddrive
### Program Communication on Network analysis
touch MAAS-REPORT/sysinfo-report-"$ip_only"-program_analysis || exit
truncate -s 0 MAAS-REPORT/sysinfo-report-"$ip_only"-program_analysis
printf "%s\n\033[1;32mHere is the information of the Program Communication Analysis:\033[0m%s\n"
sudo nethogs -c 30; echo "$ip" | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-program_analysis
### System information
### sar - from sysstat package
touch MAAS-REPORT/sysinfo-report-"$ip_only"-system_information || exit
truncate -s 0 MAAS-REPORT/sysinfo-report-"$ip_only"-system_information
printf "%s\n\033[1;32mHere is the System Information Analysis:\033[0m%s\n"
export S_COLORS=&& sar -A 1 1; echo "$ip" | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-system_information
### Firewall information
touch MAAS-REPORT/sysinfo-report-"$ip_only"-firewall_information || exit
truncate -s 0 MAAS-REPORT/sysinfo-report-"$ip_only"-firewall_information
printf "%s\n\033[1;32mHere is the Firewall Information Analysis:\033[0m%s\n"
"$fire_wall"; echo "$ip" | tee -a MAAS-REPORT/sysinfo-report-"$ip_only"-system_information
## Bring back all log to the admin
### log of SYSINFO
#sudo mkdir -p ~/MAAS-REPORT/LOG/
sudo tar czvf maas-sysinfo-log"$ip_only".tar.gz ~/MAAS-REPORT/