mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 06:03:34 +01:00
Added metrics to Etherpad
This commit is contained in:
parent
4891243c27
commit
0722a7ed7c
4 changed files with 40 additions and 3 deletions
|
@ -6,7 +6,7 @@ import {NavLink, Outlet, useNavigate} from "react-router-dom";
|
||||||
import {useStore} from "./store/store.ts";
|
import {useStore} from "./store/store.ts";
|
||||||
import {LoadingScreen} from "./utils/LoadingScreen.tsx";
|
import {LoadingScreen} from "./utils/LoadingScreen.tsx";
|
||||||
import {Trans, useTranslation} from "react-i18next";
|
import {Trans, useTranslation} from "react-i18next";
|
||||||
import {Cable, Construction, Crown, NotepadText, Wrench, PhoneCall} from "lucide-react";
|
import {Cable, Construction, Crown, NotepadText, Wrench, PhoneCall, Box} from "lucide-react";
|
||||||
|
|
||||||
const WS_URL = import.meta.env.DEV? 'http://localhost:9001' : ''
|
const WS_URL = import.meta.env.DEV? 'http://localhost:9001' : ''
|
||||||
export const App = ()=> {
|
export const App = ()=> {
|
||||||
|
@ -100,6 +100,7 @@ export const App = ()=> {
|
||||||
<li><NavLink to={"/pads"}><NotepadText/><Trans
|
<li><NavLink to={"/pads"}><NotepadText/><Trans
|
||||||
i18nKey="ep_admin_pads:ep_adminpads2_manage-pads"/></NavLink></li>
|
i18nKey="ep_admin_pads:ep_adminpads2_manage-pads"/></NavLink></li>
|
||||||
<li><NavLink to={"/shout"}><PhoneCall/>Communication</NavLink></li>
|
<li><NavLink to={"/shout"}><PhoneCall/>Communication</NavLink></li>
|
||||||
|
<li><NavLink to={"/metrics"}><Box/>Metrics</NavLink></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import i18n from "./localization/i18n.ts";
|
||||||
import {PadPage} from "./pages/PadPage.tsx";
|
import {PadPage} from "./pages/PadPage.tsx";
|
||||||
import {ToastDialog} from "./utils/Toast.tsx";
|
import {ToastDialog} from "./utils/Toast.tsx";
|
||||||
import {ShoutPage} from "./pages/ShoutPage.tsx";
|
import {ShoutPage} from "./pages/ShoutPage.tsx";
|
||||||
|
import {MetricsPage} from "./pages/MetricsPage.tsx";
|
||||||
|
|
||||||
const router = createBrowserRouter(createRoutesFromElements(
|
const router = createBrowserRouter(createRoutesFromElements(
|
||||||
<><Route element={<App/>}>
|
<><Route element={<App/>}>
|
||||||
|
@ -22,6 +23,7 @@ const router = createBrowserRouter(createRoutesFromElements(
|
||||||
<Route path="/help" element={<HelpPage/>}/>
|
<Route path="/help" element={<HelpPage/>}/>
|
||||||
<Route path="/pads" element={<PadPage/>}/>
|
<Route path="/pads" element={<PadPage/>}/>
|
||||||
<Route path="/shout" element={<ShoutPage/>}/>
|
<Route path="/shout" element={<ShoutPage/>}/>
|
||||||
|
<Route path="metrics" element={<MetricsPage/>}/>
|
||||||
</Route><Route path="/login">
|
</Route><Route path="/login">
|
||||||
<Route index element={<LoginScreen/>}/>
|
<Route index element={<LoginScreen/>}/>
|
||||||
</Route></>
|
</Route></>
|
||||||
|
|
22
admin/src/pages/MetricsPage.tsx
Normal file
22
admin/src/pages/MetricsPage.tsx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import {useEffect} from "react";
|
||||||
|
import {useStore} from "../store/store.ts";
|
||||||
|
|
||||||
|
export const MetricsPage = ()=> {
|
||||||
|
const socket = useStore(state=>state.settingsSocket)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (socket === undefined) return
|
||||||
|
|
||||||
|
socket?.on('metrics:result', (d)=>{
|
||||||
|
console.log(d)
|
||||||
|
})
|
||||||
|
|
||||||
|
socket?.emit('metrics')
|
||||||
|
}, [socket]);
|
||||||
|
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<h1>Metrics</h1>
|
||||||
|
|
||||||
|
</>
|
||||||
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
import {PadQueryResult, PadSearchQuery} from "../../types/PadSearchQuery";
|
import {PadQueryResult, PadSearchQuery} from "../../types/PadSearchQuery";
|
||||||
import {PadType} from "../../types/PadType";
|
import {PadType} from "../../types/PadType";
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
|
import {freemem, totalmem, loadavg} from 'node:os'
|
||||||
const eejs = require('../../eejs');
|
const eejs = require('../../eejs');
|
||||||
const fsp = require('fs').promises;
|
const fsp = require('fs').promises;
|
||||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||||
|
@ -14,7 +14,6 @@ const UpdateCheck = require('../../utils/UpdateCheck');
|
||||||
const padManager = require('../../db/PadManager');
|
const padManager = require('../../db/PadManager');
|
||||||
const api = require('../../db/API');
|
const api = require('../../db/API');
|
||||||
|
|
||||||
|
|
||||||
const queryPadLimit = 12;
|
const queryPadLimit = 12;
|
||||||
const logger = log4js.getLogger('adminSettings');
|
const logger = log4js.getLogger('adminSettings');
|
||||||
|
|
||||||
|
@ -259,6 +258,19 @@ exports.socketio = (hookName: string, {io}: any) => {
|
||||||
await hooks.aCallAll('loadSettings', {settings});
|
await hooks.aCallAll('loadSettings', {settings});
|
||||||
await hooks.aCallAll('restartServer');
|
await hooks.aCallAll('restartServer');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
socket.on('metrics', async()=>{
|
||||||
|
|
||||||
|
const memory = process.memoryUsage()
|
||||||
|
const freememTotal = freemem()
|
||||||
|
const totalAvailableMem = totalmem()
|
||||||
|
const cpu = loadavg()
|
||||||
|
socket.emit('metrics:response',{
|
||||||
|
cpu, memory,freememTotal, totalAvailableMem
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue