mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Added new GET route to check
total RAM
This commit is contained in:
parent
5caeff0f25
commit
1458b35bf5
@ -23,6 +23,7 @@ import monitoring from '../monitoring'
|
||||
import ErrorResponse from './error-response'
|
||||
import { Parser } from 'json2csv';
|
||||
import getConfiguration from '../lib/get-configuration'
|
||||
import { totalmem } from 'os'
|
||||
|
||||
const blueWazuh = colors.blue('wazuh');
|
||||
|
||||
@ -386,7 +387,7 @@ export default class WazuhApi {
|
||||
if(req.payload.method !== 'GET' && req.payload.body && req.payload.body.devTools){
|
||||
const configuration = getConfiguration();
|
||||
if(!configuration || (configuration && !configuration['devtools.allowall'])){
|
||||
return ErrorResponse('Allowed method: [GET]', 3023, 400, reply);
|
||||
return ErrorResponse('Allowed method: [GET]', 3029, 400, reply);
|
||||
}
|
||||
}
|
||||
if(req.payload.body.devTools) {
|
||||
@ -528,4 +529,14 @@ export default class WazuhApi {
|
||||
return res({ error: error.message || error }).code(500)
|
||||
}
|
||||
}
|
||||
|
||||
async totalRam(req,reply) {
|
||||
try{
|
||||
// RAM in MB
|
||||
const ram = Math.ceil(totalmem()/1024/1024);
|
||||
return reply({ statusCode: 200, error: 0, ram });
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3030, 500, reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,4 +41,7 @@ export default (server, options) => {
|
||||
|
||||
// Returns data from the Wazuh API on CSV readable format
|
||||
server.route({ method: 'POST', path: '/api/wazuh-api/csv', handler: (req,res) => ctrl.csv(req,res)})
|
||||
|
||||
// Returns total RAM available from the current machine where Kibana is being executed
|
||||
server.route({ method: 'GET', path: '/api/wazuh-api/ram', handler: (req,res) => ctrl.totalRam(req,res)})
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user