create function sendDeviceInfor to mail
This commit is contained in:
parent
1aa8acc161
commit
f941cc615b
|
|
@ -1,4 +1,4 @@
|
||||||
import Env from '@ioc:Adonis/Core/Env';
|
import Env from "@ioc:Adonis/Core/Env";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import moment from "moment/moment";
|
import moment from "moment/moment";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
|
|
@ -17,7 +17,7 @@ export const sendDeviceInfora = async () => {
|
||||||
let html = "";
|
let html = "";
|
||||||
//List file today
|
//List file today
|
||||||
const listFile = fs
|
const listFile = fs
|
||||||
.readdirSync(Env.get('FOLDER_LOGS'))
|
.readdirSync(Env.get("FOLDER_LOGS"))
|
||||||
.filter((f) => f.includes("TEST01"));
|
.filter((f) => f.includes("TEST01"));
|
||||||
|
|
||||||
//Configure mail
|
//Configure mail
|
||||||
|
|
@ -34,7 +34,7 @@ export const sendDeviceInfora = async () => {
|
||||||
|
|
||||||
//Read file in listFile
|
//Read file in listFile
|
||||||
await listFile.map((file) => {
|
await listFile.map((file) => {
|
||||||
fs.readFile(Env.get('FOLDER_LOGS') + "/" + file, "utf8", (err, data) => {
|
fs.readFile(Env.get("FOLDER_LOGS") + "/" + file, "utf8", (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(`Error reading file: ${err}`);
|
console.log(`Error reading file: ${err}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -123,16 +123,23 @@ export const sendDeviceInfora = async () => {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
if (PID !== "" && SN !== "") {
|
if (PID !== "" && SN !== "") {
|
||||||
let RAM =
|
let RAM =
|
||||||
(
|
showVersion
|
||||||
parseInt(
|
.filter((line) => line.includes("bytes of memory"))
|
||||||
showVersion
|
.join("<br>")
|
||||||
.filter((line) => line.includes("bytes of memory"))
|
.match(regexMemory) !== null
|
||||||
.join("<br>")
|
? (
|
||||||
.match(regexMemory)[0]
|
parseInt(
|
||||||
) /
|
showVersion
|
||||||
1024 /
|
.filter((line) =>
|
||||||
1024
|
line.includes("bytes of memory")
|
||||||
).toFixed(2) + "G";
|
)
|
||||||
|
.join("<br>")
|
||||||
|
.match(regexMemory)[0]
|
||||||
|
) /
|
||||||
|
1024 /
|
||||||
|
1024
|
||||||
|
).toFixed(2) + "G"
|
||||||
|
: "";
|
||||||
|
|
||||||
let flash = showVersion
|
let flash = showVersion
|
||||||
.filter((line) =>
|
.filter((line) =>
|
||||||
|
|
@ -173,16 +180,23 @@ export const sendDeviceInfora = async () => {
|
||||||
} else {
|
} else {
|
||||||
if (PID !== "" && SN !== "") {
|
if (PID !== "" && SN !== "") {
|
||||||
let RAM =
|
let RAM =
|
||||||
(
|
showVersion
|
||||||
parseInt(
|
.filter((line) => line.includes("bytes of memory"))
|
||||||
showVersion
|
.join("<br>")
|
||||||
.filter((line) => line.includes("bytes of memory"))
|
.match(regexMemory) !== null
|
||||||
.join("<br>")
|
? (
|
||||||
.match(regexMemory)[0]
|
parseInt(
|
||||||
) /
|
showVersion
|
||||||
1024 /
|
.filter((line) =>
|
||||||
1024
|
line.includes("bytes of memory")
|
||||||
).toFixed(2) + "G";
|
)
|
||||||
|
.join("<br>")
|
||||||
|
.match(regexMemory)[0]
|
||||||
|
) /
|
||||||
|
1024 /
|
||||||
|
1024
|
||||||
|
).toFixed(2) + "G"
|
||||||
|
: "";
|
||||||
|
|
||||||
let flash = showVersion
|
let flash = showVersion
|
||||||
.filter((line) =>
|
.filter((line) =>
|
||||||
|
|
@ -312,4 +326,4 @@ export const sendDeviceInfora = async () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue