scriptul de reproting in HTML

This commit is contained in:
2025-12-14 00:41:32 +02:00
parent fd801c1dff
commit 9b7861f0d2
2 changed files with 272 additions and 0 deletions

129
html_report.sh Executable file
View File

@@ -0,0 +1,129 @@
#!/bin/bash
REPORT="system_report.html"
# ---------- HTML HEADER ----------
html_header()
{
cat <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>System Report</title>
<style>
body
{
font-family: monospace;
background: #0f172a;
color: #e5e7eb;
padding: 20px;
}
h1
{
color: #38bdf8;
}
.section
{
margin-bottom: 30px;
border: 1px solid #334155;
border-radius: 8px;
background: #020617;
}
.section h2
{
margin: 0;
padding: 10px;
background: #1e293b;
color: #fbbf24;
border-bottom: 1px solid #334155;
}
pre
{
margin: 0;
padding: 15px;
color: #a7f3d0;
overflow-x: auto;
}
</style>
</head>
<body>
<h1>System Report</h1>
EOF
}
# ---------- HTML FOOTER ----------
html_footer()
{
cat <<EOF
</body>
</html>
EOF
}
# ---------- FUNCTiONS ----------
# ---------- RUNNING PORCESSES -----------
list_processes()
{
cat <<EOF
<div class="section">
<h2>Top Processes by CPU</h2>
<pre>
$(ps aux --sort=-%cpu | head -10)
</pre>
</div>
EOF
}
# ---------- DISK USAGE --------------
disk_usage()
{
cat <<EOF
<div class="section">
<h2>Disk Usage</h2>
<pre>
$(df -h)
</pre>
</div>
EOF
}
# --------- MEMORY USAGE -------------
memory_usage()
{
cat <<EOF
<div class="section">
<h2>Memory Usage</h2>
<pre>
$(free -h)
</pre>
</div>
EOF
}
# ........... SYSTEM INFO -----------
sys_info()
{
cat <<EOF
<div class="section">
<h2>System info</h2>
<pre>
$(lscpu)
</pre>
</div>
EOF
}
# ---------- BUILD THE ACTUAL REPORT ----------
{
html_header
sys_info
list_processes
disk_usage
memory_usage
html_footer
} > "$REPORT"
echo "HTML report generated: $REPORT"