Skip to content

Commit 9ccbea1

Browse files
committed
Added a bash as a new language, also added a category and a snippet
1 parent b0c00df commit 9ccbea1

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed

public/consolidated/_index.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[
2+
{
3+
"name": "BASH",
4+
"icon": "/icons/bash.svg",
5+
"subLanguages": []
6+
},
27
{
38
"name": "C",
49
"icon": "/icons/c.svg",

public/consolidated/bash.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"name": "System",
4+
"snippets": [
5+
{
6+
"title": "System Resource Monitor",
7+
"description": "Monitors system resources (CPU, RAM, disk, users) at specified intervals",
8+
"author": "sponkurtus2",
9+
"tags": [
10+
"file",
11+
"system"
12+
],
13+
"contributors": [],
14+
"code": "monitor_resources() {\n local interval=\"${1:-5}\" # Seconds between checks\n local checks=\"${2:-12}\" # Number of checks to perform\n local log_file=\"system_stats.log\"\n\n for ((i = 1; i <= checks; i++)); do\n {\n echo \"=== Check $i of $checks ===\"\n date \"+%Y-%m-%d %H:%M:%S\"\n echo \"CPU Load: $(top -bn1 | grep \"Cpu(s)\" | awk '{print $2}')%\"\n echo \"Memory Used: $(free -m | awk 'NR==2{printf \"%.2f%%\", $3*100/$2}')\"\n echo \"Disk Used: $(df -h / | awk 'NR==2{print $5}')\"\n echo \"Active Users: $(who | wc -l)\"\n } >>\"$log_file\"\n\n sleep \"$interval\"\n done\n\n echo \"Log saved to $log_file\"\n}\n\nmonitor_resources\n\n// Usage:\n./system-resource-monitor.sh 3 12 // First argument is the seconds between checks, and second parameter is the number of checks you want to perform\n"
15+
}
16+
]
17+
}
18+
]

public/icons/bash.svg

Lines changed: 1 addition & 0 deletions
Loading

snippets/bash/icon.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: System Resource Monitor
3+
description: Monitors system resources (CPU, RAM, disk, users) at specified intervals
4+
author: sponkurtus2
5+
tags: file,system
6+
---
7+
8+
```bash
9+
monitor_resources() {
10+
local interval="${1:-5}" # Seconds between checks
11+
local checks="${2:-12}" # Number of checks to perform
12+
local log_file="system_stats.log"
13+
14+
for ((i = 1; i <= checks; i++)); do
15+
{
16+
echo "=== Check $i of $checks ==="
17+
date "+%Y-%m-%d %H:%M:%S"
18+
echo "CPU Load: $(top -bn1 | grep "Cpu(s)" | awk '{print $2}')%"
19+
echo "Memory Used: $(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2}')"
20+
echo "Disk Used: $(df -h / | awk 'NR==2{print $5}')"
21+
echo "Active Users: $(who | wc -l)"
22+
} >>"$log_file"
23+
24+
sleep "$interval"
25+
done
26+
27+
echo "Log saved to $log_file"
28+
}
29+
30+
monitor_resources
31+
32+
// Usage:
33+
./system-resource-monitor.sh 3 12 // First argument is the seconds between checks, and second parameter is the number of checks you want to perform
34+
```

0 commit comments

Comments
 (0)