Frank Kaumba commited on
Commit
e2da246
Β·
unverified Β·
1 Parent(s): 837fe1d

Update plugins

Browse files
Files changed (1) hide show
  1. plugins/uptime2.js +101 -0
plugins/uptime2.js ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const config = require('../config');
2
+ const { cmd, commands } = require('../command');
3
+ const os = require('os');
4
+ const { runtime } = require('../lib/functions');
5
+ const disk = require('disk-space');
6
+ const moment = require('moment');
7
+
8
+ cmd({
9
+ pattern: "system2",
10
+ react: "⚑",
11
+ alias: ["uptime2", "status2", "runtime2", "stats"],
12
+ desc: "Display comprehensive system statistics",
13
+ category: "main",
14
+ filename: __filename
15
+ }, async (conn, mek, m, {
16
+ from,
17
+ quoted,
18
+ body,
19
+ isCmd,
20
+ command,
21
+ args,
22
+ q,
23
+ isGroup,
24
+ sender,
25
+ senderNumber,
26
+ botNumber2,
27
+ botNumber,
28
+ pushname,
29
+ isMe,
30
+ isOwner,
31
+ groupMetadata,
32
+ groupName,
33
+ participants,
34
+ groupAdmins,
35
+ isBotAdmins,
36
+ isAdmins,
37
+ reply
38
+ }) => {
39
+ try {
40
+ const loadAvg = os.loadavg();
41
+ const cpuUsage = process.cpuUsage();
42
+ const cpuPercent = ((cpuUsage.user + cpuUsage.system) / (os.cpus().length * 1000000)).toFixed(2);
43
+ const networkInterfaces = os.networkInterfaces();
44
+ const primaryInterface = Object.values(networkInterfaces)[0][0];
45
+ const uptimeTotal = process.uptime();
46
+ const uptimeDays = Math.floor(uptimeTotal / (24 * 60 * 60));
47
+ const uptimeHours = Math.floor((uptimeTotal % (24 * 60 * 60)) / (60 * 60));
48
+ const uptimeMinutes = Math.floor((uptimeTotal % (60 * 60)) / 60);
49
+ const diskUsage = await new Promise((resolve) => {
50
+ disk.check('/', (err, result) => {
51
+ resolve(result || { free: 0, total: 0 });
52
+ });
53
+ });
54
+ const diskTotal = (diskUsage.total / (1024 * 1024 * 1024)).toFixed(2);
55
+ const diskFree = (diskUsage.free / (1024 * 1024 * 1024)).toFixed(2);
56
+ const diskUsed = (diskTotal - diskFree).toFixed(2);
57
+
58
+ ```let status = `*╭─────── SYSTEM STATUS ───────*
59
+ ```
60
+ _SUBZERO BOT STATISTICS_
61
+ ⏰ _Uptime:_ ${uptimeDays}d ${uptimeHours}h ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB / ${Math.round(require('os').totalmem / 1024 / 1024)}MB
62
+ _Disk Space:_ ${diskUsed}GB used of ${diskTotal}GB
63
+ _CPU Load:_ ${cpuPercent}%
64
+ _Load Average:_ ${loadAvg[0].toFixed(2)} (1m) ${loadAvg[1].toFixed(2)} (5m) ${os.type()} ${os.release()}
65
+ β”œ Architecture: ${os.arch()}
66
+ β”œ Platform: ${os.platform()}
67
+ β”œ Hostname: ${os.hostname()}
68
+ β”” IP: ${primaryInterface.address}
69
+ _Bot Info:_
70
+ β”œ Owner: MR FRANK
71
+ β”œ Last Restart: ${moment().format('YYYY-MM-DD HH:mm:ss')}
72
+ β”œ Node Version: ${process.version}
73
+ β”” Active Since: ${moment().subtract(uptimeTotal, 'seconds').format('YYYY-MM-DD HH:mm:ss')}
74
+ _╰─────────────────_`;
75
+
76
+ ```await conn.sendMessage(from, {
77
+ image: {
78
+ url: config.ALIVE_IMG
79
+ },
80
+ caption: status,
81
+ contextInfo: {
82
+ externalAdReply: {
83
+ title: "SubZero Bot Status",
84
+ body: "System Statistics & Performance Metrics",
85
+ mediaType: 1,
86
+ thumbnail: {
87
+ url: config.ALIVE_IMG
88
+ },
89
+ mediaUrl: config.WEBSITE_URL,
90
+ sourceUrl: config.WEBSITE_URL
91
+ }
92
+ }
93
+ }, {
94
+ quoted: mek
95
+ });
96
+ ```
97
+ } catch (e) {
98
+ console.error('System status error:', e);
99
+ reply(`Error fetching system status: ${e.message}`);
100
+ }
101
+ });