-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo
executable file
·118 lines (92 loc) · 2.13 KB
/
info
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
#!/bin/bash
set -e
os="$(uname)"
linux=false
darwin=false
if [ "$os" == "Linux" ]; then
linux=true
elif [ "$os" == "Darwin" ]; then
darwin=true
fi
if [ "$(type -t perlbrew || true)" != "function" ]; then
function perlbrew {
if [ -z "$PERLBREW_ROOT" ]; then
if [ -e "$HOME/perl5/perlbrew/etc/bashrc" ]; then
export PERLBREW_ROOT="$HOME/perl5/perlbrew"
fi
fi
unset -f perlbrew
source "$PERLBREW_ROOT/etc/bashrc"
perlbrew "$@"
}
fi
sudo=
if sudo -v 2>/dev/null; then
sudo=1
fi
function _indent {
sed -e's/^/ /'
}
echo "
# Machine Info
Generated at $(date).
## Hostname
$(hostname -f)
## sudo
$( [ -n "$sudo" ] && echo "Available" || echo "Unavailable" )
"
$darwin && echo "
## OS X Version
$(sw_vers | _indent)
"
$linux && echo "
## Kernel
$(cat /proc/version | _indent)
## Distro Info
$([ -e /etc/lsb-release ] && cat /etc/lsb-release | _indent)
$([ -e /etc/debian_version ] && cat /etc/debian_version | _indent)
"
echo "
## Free memory
$( (free -t -m 2>/dev/null || vm_stat ) | _indent)
## Filesystem Info
$(df -h | _indent)
$(mount | grep '^/' | _indent)
## Network Configuration
$( (ip addr 2>/dev/null || ifconfig ) | _indent)
## Environment
$(perl -e'my ($length) = sort { $b <=> $a } map { length } keys %ENV; printf "%${length}s = %s\n", $_, $ENV{$_} for sort grep { $_ ne "SSH_KEY_PASS" } keys %ENV' | _indent)
## CPU Info
Processor count: $(
if [ -e /proc/cpuinfo ]; then
grep -E '^processor\s*:' /proc/cpuinfo | wc -l
else
sysctl -n hw.ncpu
fi
)
$(
( [ -e /proc/cpuinfo ] && perl -0777 -p -e 's/\n\n.*/\n/s' /proc/cpuinfo || sysctl -a | grep '^machdep\.cpu\.' ) | _indent
)
## Processes
$(ps="$(ps fuxawww 2>/dev/null || ps uxawww)"; echo "$ps" | _indent)
"
[ -n "$sudo" ] && ( which service &>/dev/null ) && echo "
## Services
$(sudo service --status-all 2>&1 | _indent)
"
echo "
## Perls
$(perlbrew list | _indent)
## Packages
"
$linux && echo "$(dpkg -l | _indent)"
$darwin && echo "$(brew list | _indent)"
[ -e /proc/1/cgroup ] && echo "
## cgroups
$(cat /proc/1/cgroup | _indent)
"
$darwin && echo "
## System Profile
$(system_profiler 2>/dev/null | _indent)
"
exit 0