-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysinfo_page
More file actions
executable file
·138 lines (98 loc) · 1.6 KB
/
sysinfo_page
File metadata and controls
executable file
·138 lines (98 loc) · 1.6 KB
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
#!/bin/bash
# sysinfo_page - A script to produce an system information HTML file
##### Constants
TITLE="System Information for $HOSTNAME"
RIGHT_NOW="$(date +"%x %r %Z")"
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
ROOT="root"
##### Functions
system_info()
{
echo "<h2>System Info</h2>
<pre>"
uname -a
echo "</pre>"
}
free_memory()
{
echo "<h2>Free memory</h2>
<pre>"
free
echo "</pre>"
}
disk_info()
{
echo "<h2>Disk Information</h2>
<pre>"
fdisk -l
echo "</pre>"
}
show_uptime()
{
echo "<h2>System uptime</h2>
<pre>"
uptime
echo "</pre>"
}
drive_space()
{
echo "<h2>Filesystem Space</h2>
<pre>"
df
echo "</pre>"
}
home_space()
{
echo "<h2>Home directory space by user</h2>
<pre>
Bytes Directory"
du -s /home/* | sort -nr
echo "</pre>"
}
user_info()
{
echo "<h2>Users</h2>
<pre>"
for i in $(cat /etc/passwd | grep bash | cut -d ":" -f 1 ); do groups $i; done
echo "</pre>"
}
ip_info()
{
echo "<h2>Ip Information</h2>
<pre>"
hostname -I
echo "</pre>"
}
cpu_info()
{
echo "<h2>CPU</h2>
<pre>"
lshw | grep product | cut -d ":" -f 2 | head -4
echo "</pre>"
}
##### Main
if ((EUID!=0))
then
echo "Must Run as Root"
exit 1
fi
cat <<- _EOF_
<html>
<head>
<title>$TITLE</title>
</head>
<body>
<h1>$TITLE</h1>
<p>$TIME_STAMP</p>
$(system_info)
$(show_uptime)
$(drive_space)
$(home_space)
$(free_memory)
$(disk_info)
$(user_info)
$(ip_info)
$(cpu_info)
</body>
</html>
_EOF_