Skip to content

Commit

Permalink
Merge pull request #13 from LittleJake/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
LittleJake authored Jan 22, 2024
2 parents edf3d32 + f69a757 commit 01e2bc8
Show file tree
Hide file tree
Showing 17 changed files with 262 additions and 127 deletions.
110 changes: 93 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
Server Monitor
==========

![Apache2.0](https://img.shields.io/badge/License-Apache2.0-green)
<img alt="Apache 2.0" src="https://img.shields.io/github/license/LittleJake/server-monitor?style=for-the-badge"> <img src="https://img.shields.io/packagist/php-v/topthink/think/v5.1.41?style=for-the-badge">

![think v5.1.40](https://img.shields.io/packagist/php-v/topthink/think/v5.1.40)

![GitHub Repo stars](https://img.shields.io/github/stars/LittleJake/server-monitor?style=social)

![GitHub followers](https://img.shields.io/github/followers/LittleJake?style=social)
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/LittleJake/server-monitor-script?style=for-the-badge">

基于ThinkPHP5.1的服务器监控平台,需要配合服务端python脚本,使用Redis存储相关数据。

Expand All @@ -22,7 +18,7 @@ composer install
cp .env.example .env
```

#### 上报节点密钥操作(增/删/查)
#### API上报节点密钥操作(增/删/查)(TODO

```bash
php think token help
Expand All @@ -34,38 +30,118 @@ php think token help
vim .env
```

#### 刷新数据源缓存(加速网站访问)
#### 刷新数据缓存

```bash
php think refresh:cache
```

### 界面演示

![首页](img/20230113152258.png)
![首页](img/1705648177498.png)

![Node](img/1705648247270.png)

![CPU](img/20230113152320.png)
![Node2](img/1705648323851.png)

![Thermal](img/20230113152437.png)
![Other](img/1705648396126.png)

### Demo

[测试网站](https://monitor.littlejake.net)
[Demo](https://monitor.littlejake.net)

### 数据结构

#### Collection

```json
{
"Disk": {
// Based on different mountpoint.
"mountpoint": {
"total": "0.00",
"used": "0.00",
"free": "0.00",
"percent": 0
},
},
"Memory": {
"Mem": {
"total": "0.00",
"used": "0.00",
"free": "0.00",
"percent": 0.0
},
"Swap": {
"total": "0.00",
"used": "0.00",
"free": "0.00",
"percent": 0.0
}
},
"Load": {
// Metrics based on platform.
"metric": 0.0
},
"Network": {
"RX": {
"bytes": 0,
"packets": 0
},
"TX": {
"bytes": 0,
"packets": 0
}
},
"Thermal": {
// Celsius
"sensor": 0.0,
},
"Battery": {
"percent": 0.0,
}
}
```

#### Info

```json
{
"CPU": "",
"System Version": "",
"IPV4": "masked ipv4",
"IPV6": "masked ipv6",
"Uptime": "time in readable form",
"Connection": "",
"Process": "",
"Load Average": "",
"Update Time": "",
"Country": "extract from ip-api.com",
"Country Code": "extract from ip-api.com",
"Throughput": "Gigabytes",
}
```

### 开源协议

[Apache 2.0](LICENSE)

### 鸣谢

MDUI
[MDUI](https://mdui.org)

ThinkPHP
[ThinkPHP](https://www.thinkphp.cn/)

ip-api.com
[ip-api.com](https://ip-api.com)

### Sponsors

Thanks for the free VM server (opensource) provided by [DartNode](https://dartnode.com?via=1).
Thanks for the amazing VM server provided by [DartNode](https://dartnode.com?via=1).

<a href="https://dartnode.com?via=1"><img src="https://raw.githubusercontent.com/LittleJake/LittleJake/master/images/dartnode.png" width="150"></a>

Thanks for the open source project license provided by [JetBrains](https://www.jetbrains.com/).

<a href="https://www.jetbrains.com/"><img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" width="150" alt="JetBrains Logo (Main) logo."></a>


<a href="https://dartnode.com?via=1"><img src="https://raw.githubusercontent.com/LittleJake/LittleJake/master/images/dartnode.png" width="150" align='left' ></a>
25 changes: 25 additions & 0 deletions application/api/controller/Battery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace app\api\controller;

use app\common\lib\SystemMonitor;
use think\Controller;
use think\Exception;
use think\Response;

class Battery extends Controller
{
protected $middleware = ['FlowControl', 'CheckUUID', 'CheckJson'];

/**
* 显示资源列表
*
* @param string $uuid
* @return Response
* @throws Exception
*/
public function get($uuid = '')
{
return json(SystemMonitor::collectionFormat(SystemMonitor::getCollection($uuid), 'Battery'));
}
}
2 changes: 1 addition & 1 deletion application/api/controller/Disk.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Disk extends Controller
*/
public function get($uuid = '')
{
return json(SystemMonitor::diskFormat(SystemMonitor::getCollection($uuid)));
return json(SystemMonitor::collectionFormat(SystemMonitor::getCollection($uuid), 'Disk'));
}
}
2 changes: 1 addition & 1 deletion application/api/controller/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Memory extends Controller
*/
public function get($uuid = '')
{
return json(SystemMonitor::memoryFormat(SystemMonitor::getCollection($uuid)));
return json(SystemMonitor::collectionFormat(SystemMonitor::getCollection($uuid), "Memory"));
}
}
2 changes: 1 addition & 1 deletion application/api/controller/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Network extends Controller
*/
public function get($uuid = '')
{
return json(SystemMonitor::networkFormat(SystemMonitor::getCollection($uuid)));
return json(SystemMonitor::collectionFormat(SystemMonitor::getCollection($uuid), "Network"));
}
}
Loading

0 comments on commit 01e2bc8

Please sign in to comment.