dStats 0.1.0__py3-none-any.whl → 1.0.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
dStats/server.py ADDED
@@ -0,0 +1,27 @@
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ from daphne.cli import CommandLineInterface
5
+
6
+ def main():
7
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dStats.settings')
8
+
9
+ # Construct the command to run Daphne
10
+ command = [
11
+ 'daphne',
12
+ '-b', '0.0.0.0',
13
+ '-p', '2743',
14
+ 'dStats.asgi:application'
15
+ ]
16
+ try:
17
+ # Run the command
18
+ subprocess.run(command)
19
+ except KeyboardInterrupt:
20
+ print("\ndStats server stopped by user.")
21
+ print("Bye bye!")
22
+ sys.exit(0)
23
+ except Exception as e:
24
+ print(f"Error: {e}")
25
+
26
+ if __name__ == '__main__':
27
+ main()
@@ -0,0 +1,189 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Docker Stats</title>
5
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
6
+ <style>
7
+ body {
8
+ font-family: Arial, sans-serif;
9
+ margin: 0;
10
+ padding: 20px;
11
+ background-color: #f5f5f5;
12
+ }
13
+
14
+ .container {
15
+ display: flex;
16
+ gap: 20px;
17
+ }
18
+
19
+ .stats-panel, .graph-panel {
20
+ flex: 1;
21
+ background: white;
22
+ padding: 20px;
23
+ border-radius: 8px;
24
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
25
+ }
26
+
27
+ table {
28
+ width: 100%;
29
+ border-collapse: collapse;
30
+ }
31
+
32
+ th, td {
33
+ padding: 12px;
34
+ text-align: left;
35
+ border-bottom: 1px solid #ddd;
36
+ }
37
+
38
+ th {
39
+ background-color: #f8f9fa;
40
+ font-weight: bold;
41
+ }
42
+
43
+ tr:hover {
44
+ background-color: #f5f5f5;
45
+ }
46
+
47
+ .graph-image {
48
+ width: 100%;
49
+ height: auto;
50
+ }
51
+
52
+ .button-group {
53
+ margin-bottom: 20px;
54
+ }
55
+
56
+ .button-group button {
57
+ padding: 10px 20px;
58
+ margin-right: 10px;
59
+ border: none;
60
+ border-radius: 5px;
61
+ background-color: #007bff;
62
+ color: white;
63
+ cursor: pointer;
64
+ }
65
+
66
+ .button-group button:hover {
67
+ background-color: #0056b3;
68
+ }
69
+ </style>
70
+ </head>
71
+ <body>
72
+ <div class="button-group">
73
+ <button id="showStats">Show Stats Only</button>
74
+ <button id="showGraph">Show Graph Only</button>
75
+ <button id="showBoth">Show Both</button>
76
+ </div>
77
+
78
+ <div class="container">
79
+ <div class="stats-panel" id="statsPanel">
80
+ <h2>Container Stats</h2>
81
+ <table id="statsTable">
82
+ <thead>
83
+ <tr>
84
+ <th>Container Name</th>
85
+ <th>CPU Usage</th>
86
+ <th>Memory Usage</th>
87
+ <th>Network I/O</th>
88
+ </tr>
89
+ </thead>
90
+ <tbody>
91
+ </tbody>
92
+ </table>
93
+ </div>
94
+
95
+ <div class="graph-panel" id="graphPanel">
96
+ <h2>Network Visualization</h2>
97
+ <img id="networkGraph" class="graph-image" src="" alt="Docker Network Graph">
98
+ </div>
99
+ </div>
100
+
101
+ <script>
102
+ let updateStatsInterval = null;
103
+ let updateGraphInterval = null;
104
+
105
+ function updateStats() {
106
+ $.get('{% url "stats" %}', { type: 'stats' })
107
+ .done(function(data) {
108
+ const tbody = $('#statsTable tbody');
109
+ tbody.empty();
110
+
111
+ data.stats.forEach(function(container) {
112
+ tbody.append(`
113
+ <tr>
114
+ <td>${container.name}</td>
115
+ <td>${container.cpu_percent}</td>
116
+ <td>${container.memory_usage}</td>
117
+ <td>${container.network_io}</td>
118
+ </tr>
119
+ `);
120
+ });
121
+ })
122
+ .fail(function(error) {
123
+ console.error('Error fetching stats:', error);
124
+ });
125
+ }
126
+
127
+ function updateGraph() {
128
+ $.get('{% url "stats" %}', { type: 'graph' })
129
+ .done(function(data) {
130
+ $('#networkGraph').attr('src', 'data:image/png;base64,' + data.graph);
131
+ })
132
+ .fail(function(error) {
133
+ console.error('Error fetching graph:', error);
134
+ });
135
+ }
136
+
137
+ function startStats() {
138
+ if (!updateStatsInterval) {
139
+ updateStats();
140
+ updateStatsInterval = setInterval(updateStats, 1000);
141
+ }
142
+ }
143
+
144
+ function startGraph() {
145
+ if (!updateGraphInterval) {
146
+ updateGraph();
147
+ updateGraphInterval = setInterval(updateGraph, 1000);
148
+ }
149
+ }
150
+
151
+ function stopStats() {
152
+ clearInterval(updateStatsInterval);
153
+ updateStatsInterval = null;
154
+ }
155
+
156
+ function stopGraph() {
157
+ clearInterval(updateGraphInterval);
158
+ updateGraphInterval = null;
159
+ }
160
+
161
+ $(document).ready(function() {
162
+ // Button handlers
163
+ $('#showStats').on('click', function() {
164
+ $('#statsPanel').show();
165
+ $('#graphPanel').hide();
166
+ stopGraph();
167
+ startStats();
168
+ });
169
+
170
+ $('#showGraph').on('click', function() {
171
+ $('#statsPanel').hide();
172
+ $('#graphPanel').show();
173
+ stopStats();
174
+ startGraph();
175
+ });
176
+
177
+ $('#showBoth').on('click', function() {
178
+ $('#statsPanel').show();
179
+ $('#graphPanel').show();
180
+ startStats();
181
+ startGraph();
182
+ });
183
+
184
+ // Initialize with both panels visible
185
+ $('#showBoth').click();
186
+ });
187
+ </script>
188
+ </body>
189
+ </html>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dStats
3
- Version: 0.1.0
3
+ Version: 1.0.1
4
4
  Summary: A real-time web-based monitoring tool that provides performance stats for Docker containers and visualizes their network connectivity graph
5
5
  Home-page: https://github.com/Arifcse21/dStats
6
6
  Author: Abdullah Al Arif
@@ -32,6 +32,17 @@ Dynamic: summary
32
32
  **dStats** is a real-time web-based monitoring tool that provides performance stats for Docker containers and visualizes their network connectivity graph.
33
33
 
34
34
  ---
35
+ ## Run the Python pip package
36
+ ```bash
37
+ pip install dStats
38
+ ```
39
+ Run the server:
40
+ ```bash
41
+ dstats.server
42
+ ```
43
+ Open your browser and go to:
44
+ **http://localhost:2743**
45
+ ---
35
46
 
36
47
  ## **Deploy Container Directly**
37
48
  Pull and run the container from Docker Hub:
@@ -0,0 +1,14 @@
1
+ dStats/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ dStats/asgi.py,sha256=MSQjGWX7GgrxE5_GvTsz8PRIiXwgCcx3PIkkUsQ1_tU,389
3
+ dStats/server.py,sha256=ryTsnYssq3uDYAEknd79M_5PTVqENiFahKzUdX4ULc4,623
4
+ dStats/settings.py,sha256=D73YEbwOWk54QosU21YvjSTVJvxkHTqUXiel76Nxpl4,3379
5
+ dStats/urls.py,sha256=R7CHnIif6hO8wr-C_HH7ew3-ZT8KtnE31YO9XT1Q8kU,816
6
+ dStats/views.py,sha256=mjxkwpwwZcS2rAemyaLzfrEOx3WmMHTj3LFGW5ruUwI,9427
7
+ dStats/wsgi.py,sha256=5CVIfhfO5NEUV3gXOmrPPjLNkeararRk6fCzkghNI_Q,389
8
+ dStats/templates/dStats/index.html,sha256=s2qwoPYon9wXERgcfoZ2GxoAV9nhlGMDv_KatoTrPxs,5254
9
+ dStats-1.0.1.dist-info/LICENSE,sha256=qjNhYHFWgrHF5vENj51WBRO85HtL38pwfTIg8huGj08,483
10
+ dStats-1.0.1.dist-info/METADATA,sha256=QI02lMnO4-MyNE26_yfVv8dfwwoSKfmbRXHS20SL8HU,3971
11
+ dStats-1.0.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
12
+ dStats-1.0.1.dist-info/entry_points.txt,sha256=6qO7FbB1d_Tp79tZ7gVU5T87g0C-anmdBlJcNEmsBng,53
13
+ dStats-1.0.1.dist-info/top_level.txt,sha256=ZqX7qLq-LiHI4j3UAw9S9kHfeD094Jtxc5sdnrcNhU8,7
14
+ dStats-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ dStats.server = dStats.server:main
@@ -1,11 +0,0 @@
1
- dStats/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- dStats/asgi.py,sha256=MSQjGWX7GgrxE5_GvTsz8PRIiXwgCcx3PIkkUsQ1_tU,389
3
- dStats/settings.py,sha256=D73YEbwOWk54QosU21YvjSTVJvxkHTqUXiel76Nxpl4,3379
4
- dStats/urls.py,sha256=R7CHnIif6hO8wr-C_HH7ew3-ZT8KtnE31YO9XT1Q8kU,816
5
- dStats/views.py,sha256=mjxkwpwwZcS2rAemyaLzfrEOx3WmMHTj3LFGW5ruUwI,9427
6
- dStats/wsgi.py,sha256=5CVIfhfO5NEUV3gXOmrPPjLNkeararRk6fCzkghNI_Q,389
7
- dStats-0.1.0.dist-info/LICENSE,sha256=qjNhYHFWgrHF5vENj51WBRO85HtL38pwfTIg8huGj08,483
8
- dStats-0.1.0.dist-info/METADATA,sha256=dkOcRoxHFYkSXru_0xTWsarzPLLS8XdZIHlr7Qsn8_c,3805
9
- dStats-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- dStats-0.1.0.dist-info/top_level.txt,sha256=ZqX7qLq-LiHI4j3UAw9S9kHfeD094Jtxc5sdnrcNhU8,7
11
- dStats-0.1.0.dist-info/RECORD,,
File without changes