update findValue
This commit is contained in:
parent
6022621b44
commit
ee14dbda74
|
|
@ -11,7 +11,7 @@ const ListLog = () => {
|
||||||
const [value, setValue] = useState("");
|
const [value, setValue] = useState("");
|
||||||
const getListFile = async () => {
|
const getListFile = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(getListLog);
|
const res = await axios.get(getListLog,{value: value});
|
||||||
setListFile(res.data);
|
setListFile(res.data);
|
||||||
setStatus(res.status);
|
setStatus(res.status);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ import { sendDeviceInfora } from "App/utils/sendDeviceInfor";
|
||||||
import InfoDevice from "App/Models/InfoDevice";
|
import InfoDevice from "App/Models/InfoDevice";
|
||||||
import LogReport from "App/Models/LogReport";
|
import LogReport from "App/Models/LogReport";
|
||||||
import Cache from "@ioc:Kaperskyguru/Adonis-Cache";
|
import Cache from "@ioc:Kaperskyguru/Adonis-Cache";
|
||||||
import { exec } from 'child_process';
|
const util = require('util');
|
||||||
|
const exec = util.promisify(require('child_process').exec);
|
||||||
|
|
||||||
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
|
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
|
||||||
|
|
||||||
|
|
@ -179,23 +180,17 @@ Route.post("/api/private-log/readFile", async ({ request, response }) => {
|
||||||
|
|
||||||
Route.post("/api/find-value", async ({ request, response }) => {
|
Route.post("/api/find-value", async ({ request, response }) => {
|
||||||
try {
|
try {
|
||||||
let result = "";
|
const { value } = request.all();
|
||||||
let value = request.all().value;
|
|
||||||
console.log("value ", value)
|
|
||||||
|
|
||||||
exec("grep -nr "+value+" /home/logs", (error, stdout, stderr) => {
|
const { stdout, stderr } = await exec(`grep -nr "${value}" /home/logs`);
|
||||||
if (error) {
|
|
||||||
// console.error(`Error executing command: ${error.message}`);
|
|
||||||
return "Error:"+ error;
|
|
||||||
}
|
|
||||||
console.log("stdout ", stdout)
|
|
||||||
|
|
||||||
response.status(300).send("blabla"+JSON.stringify(stdout) );
|
|
||||||
});
|
response.status(200).send(JSON.stringify(stdout));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
|
response.status(500).send(`Error: ${error.message}`);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
Route.post("/api/test", async () => {
|
Route.post("/api/test", async () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue