-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor.sh
More file actions
executable file
·190 lines (163 loc) · 5.3 KB
/
Copy pathmonitor.sh
File metadata and controls
executable file
·190 lines (163 loc) · 5.3 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
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
#!/bin/bash
# --- 1. Collect System Information ---
DATE=$(date '+%d.%m.%Y - %H:%M:%S')
CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8"%"}')
# Cleaning up RAM output for cleaner display
RAM_USED=$(free -m | awk 'NR==2{print $3}')
RAM_TOTAL=$(free -m | awk 'NR==2{print $2}')
RAM_PERCENT=$(awk "BEGIN {printf \"%.1f\", ($RAM_USED/$RAM_TOTAL)*100}")
# Cleaning up Disk output
DISK_USED=$(df -h / | awk 'NR==2{print $3}')
DISK_TOTAL=$(df -h / | awk 'NR==2{print $2}')
USERS=$(who | wc -l)
UPTIME=$(uptime -p | sed 's/up //')
# --- 2. Generate HTML (Modern Dashboard) ---
cat > /var/www/html/index.html << EOF
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="60">
<title>Sistem Durum Paneli</title>
<style>
:root {
--bg-color: #f3f4f6;
--card-bg: #ffffff;
--text-main: #1f2937;
--text-muted: #6b7280;
--accent: #2563eb;
--border-radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: var(--bg-color);
color: var(--text-main);
padding: 2rem;
min-height: 100vh;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
header {
margin-bottom: 2rem;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #e5e7eb;
padding-bottom: 1rem;
}
h1 {
font-size: 1.5rem;
font-weight: 700;
color: #111827;
display: flex;
align-items: center;
gap: 10px;
}
.status-badge {
background: #d1fae5;
color: #065f46;
font-size: 0.85rem;
padding: 4px 12px;
border-radius: 20px;
font-weight: 600;
}
.last-update {
font-size: 0.9rem;
color: var(--text-muted);
}
/* Grid Layout */
.dashboard-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.5rem;
}
.card {
background: var(--card-bg);
padding: 1.5rem;
border-radius: var(--border-radius);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
transition: transform 0.2s ease;
border-left: 4px solid var(--accent);
}
.card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.card-label {
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
margin-bottom: 0.5rem;
display: flex;
align-items: center;
gap: 8px;
}
.card-value {
font-size: 2rem;
font-weight: 700;
color: var(--text-main);
}
.card-sub {
font-size: 0.9rem;
color: var(--text-muted);
margin-top: 4px;
}
footer {
text-align: center;
margin-top: 3rem;
font-size: 0.85rem;
color: #9ca3af;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>
<span style="color:var(--accent);">●</span> Server Monitörü
<span class="status-badge">Online</span>
</h1>
<div class="last-update">Son Güncelleme: $DATE</div>
</header>
<div class="dashboard-grid">
<div class="card">
<div class="card-label">⚙️ İşlemci (CPU)</div>
<div class="card-value">$CPU</div>
<div class="card-sub">Anlık Yük</div>
</div>
<div class="card">
<div class="card-label">🧠 Bellek (RAM)</div>
<div class="card-value">%$RAM_PERCENT</div>
<div class="card-sub">$RAM_USED MB / $RAM_TOTAL MB</div>
</div>
<div class="card">
<div class="card-label">💾 Disk Alanı</div>
<div class="card-value">$DISK_USED</div>
<div class="card-sub">Toplam: $DISK_TOTAL</div>
</div>
<div class="card">
<div class="card-label">⏱️ Çalışma Süresi</div>
<div class="card-value" style="font-size: 1.4rem;">$UPTIME</div>
<div class="card-sub">Kesintisiz Süre</div>
</div>
<div class="card">
<div class="card-label">👥 Aktif Kullanıcılar</div>
<div class="card-value">$USERS</div>
<div class="card-sub">Şu an bağlı</div>
</div>
</div>
<footer>
Bilişim Sistemleri Mühendisliği © 2025<br>
Otomatik İzleme Sistemi
</footer>
</div>
</body>
</html>
EOF
echo "Dashboard updated at $DATE"