Update function sendDeviceInfor to mail
This commit is contained in:
parent
297ca11585
commit
3c91f9b5cf
|
|
@ -1,12 +1,10 @@
|
||||||
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 nodeMailer from "nodemailer";
|
import nodeMailer from "nodemailer";
|
||||||
import LogDetectFile from "App/Models/LogDetectFile";
|
import LogDetectFile from "App/Models/LogDetectFile";
|
||||||
import InfoDevice from "App/Models/InfoDevice";
|
import InfoDevice from "App/Models/InfoDevice";
|
||||||
import KeyValue from "App/Models/KeyValue";
|
import KeyValue from "App/Models/KeyValue";
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
export const sendDeviceInfora = async () => {
|
export const sendDeviceInfora = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -21,12 +19,12 @@ export const sendDeviceInfora = async () => {
|
||||||
.map((obj) => obj.$attributes.value);
|
.map((obj) => obj.$attributes.value);
|
||||||
const listInformation = [];
|
const listInformation = [];
|
||||||
let dataFile = await LogDetectFile.all();
|
let dataFile = await LogDetectFile.all();
|
||||||
// console.log(dataFile)
|
|
||||||
// console.log(dataFile)
|
|
||||||
let html = "";
|
let html = "";
|
||||||
//List file today
|
//List file today
|
||||||
const listFile = fs.readdirSync(Env.get("FOLDER_LOGS"));
|
const listFile = fs
|
||||||
|
.readdirSync(Env.get("FOLDER_LOGS"))
|
||||||
|
.filter((f) => f.includes(date) && f.split(".")[f.split(".").length - 1]);
|
||||||
//Configure mail
|
//Configure mail
|
||||||
const transporter = nodeMailer.createTransport({
|
const transporter = nodeMailer.createTransport({
|
||||||
pool: true,
|
pool: true,
|
||||||
|
|
@ -167,30 +165,6 @@ export const sendDeviceInfora = async () => {
|
||||||
// let memory =
|
// let memory =
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
if (PID !== "" && SN !== "") {
|
if (PID !== "" && SN !== "") {
|
||||||
// let RAM =
|
|
||||||
// showVersion
|
|
||||||
// .filter((line) => line.includes("bytes of memory"))
|
|
||||||
// .join("<br>")
|
|
||||||
// .match(regexMemory) !== null
|
|
||||||
// ? (
|
|
||||||
// parseInt(
|
|
||||||
// showVersion
|
|
||||||
// .filter((line) =>
|
|
||||||
// line.includes("bytes of memory")
|
|
||||||
// )
|
|
||||||
// .join("<br>")
|
|
||||||
// .match(regexMemory)[0]
|
|
||||||
// ) /
|
|
||||||
// 1024 /
|
|
||||||
// 1024
|
|
||||||
// ).toFixed(2) + "G"
|
|
||||||
// : "";
|
|
||||||
|
|
||||||
// let flash = showVersion
|
|
||||||
// .filter((line) =>
|
|
||||||
// line.toLocaleLowerCase().includes("compactflash")
|
|
||||||
// )
|
|
||||||
// .join("<br>");
|
|
||||||
listInformation.push({
|
listInformation.push({
|
||||||
PID: PID,
|
PID: PID,
|
||||||
VID: VID,
|
VID: VID,
|
||||||
|
|
@ -378,9 +352,6 @@ export const sendDeviceInfora = async () => {
|
||||||
await InfoDevice.createMany(listInformation);
|
await InfoDevice.createMany(listInformation);
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
// const match = "show inventory".match(regexInventory);
|
|
||||||
|
|
||||||
// console.log(match)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue