diff --git a/app/components/charts/databaseMemoryChart.tsx b/app/components/charts/databaseMemoryChart.tsx index 5527beb..620db34 100644 --- a/app/components/charts/databaseMemoryChart.tsx +++ b/app/components/charts/databaseMemoryChart.tsx @@ -133,7 +133,7 @@ export const MemoryChart = ({ url }: { url: string }) => { if (!chart) { return; } - console.log(usageFetcher.data?.database); + const chartData = { datasets: [ { @@ -192,7 +192,6 @@ export const MemoryChart = ({ url }: { url: string }) => { ], }; setOptions(getOptions()); - console.log(chartData); setChartData(chartData); }, [usageFetcher.data]); diff --git a/app/components/logTable/columns.tsx b/app/components/logTable/columns.tsx index 14aa398..3c453d5 100644 --- a/app/components/logTable/columns.tsx +++ b/app/components/logTable/columns.tsx @@ -1,5 +1,5 @@ import type { ColumnDef } from '@tanstack/react-table'; -import { Activity, AlertTriangle } from 'lucide-react'; +import { Activity, AlertCircle, AlertTriangle } from 'lucide-react'; import { DataTableColumnHeader } from '~/components/table/data-table-column-header'; import { format } from 'date-fns'; import { Link } from '@remix-run/react'; @@ -20,6 +20,8 @@ export const columns: ColumnDef[] = [
{row.getValue('type') == 'error' ? ( + ) : row.getValue('type') == 'warning' ? ( + ) : ( )} diff --git a/app/models/monitor.server.ts b/app/models/monitor.server.ts index dadaf5e..1ba80da 100644 --- a/app/models/monitor.server.ts +++ b/app/models/monitor.server.ts @@ -209,6 +209,7 @@ export function getMonitor({ id }: Pick) { httpDomain: true, httpWorkstation: true, sqlConnectionString: true, + lastBootTime: true, drives: { select: { id: true, diff --git a/app/monitors/ubuntu.server.ts b/app/monitors/ubuntu.server.ts index 7f664d3..4f5ef09 100644 --- a/app/monitors/ubuntu.server.ts +++ b/app/monitors/ubuntu.server.ts @@ -1,5 +1,6 @@ import { Monitor, + getMonitor, getMonitorDisabledDrives, monitorError, setDriveDays, @@ -86,7 +87,7 @@ export default async function UbuntuMonitor({ monitor }: { monitor: Monitor }) { let lastBootTime = null; try { - lastBootTime = new Date(lastBoot).toString(); + lastBootTime = new Date(lastBoot).toISOString(); } catch (e) {} /* @@ -124,7 +125,7 @@ export default async function UbuntuMonitor({ monitor }: { monitor: Monitor }) { ).length == 0; return l; }); - + const oldMonitor = await getMonitor({ id: monitor.id }); const data = await updateMonitor({ id: monitor.id, data: { @@ -207,7 +208,7 @@ export default async function UbuntuMonitor({ monitor }: { monitor: Monitor }) { disposeSsh(ssh); - await Notifier({ job: monitor.id }); + await Notifier({ job: monitor.id, oldMonitor }); console.log(`successfully ran ${monitor.type} monitor: ${monitor.id}`); } catch (e) { diff --git a/app/monitors/windows.server.ts b/app/monitors/windows.server.ts index dda42c7..45db060 100644 --- a/app/monitors/windows.server.ts +++ b/app/monitors/windows.server.ts @@ -2,6 +2,7 @@ import { decrypt } from '@/lib/utils'; import { NodeSSH } from 'node-ssh'; import { Monitor, + getMonitor, getMonitorDisabledDrives, monitorError, setDriveDays, @@ -214,6 +215,7 @@ export default async function WindowsMonitor({ return l; }); + const oldMonitor = await getMonitor({ id: monitor.id }); const data = await updateMonitor({ id: monitor.id, data: { @@ -224,7 +226,7 @@ export default async function WindowsMonitor({ model: cs.Model, os: os.Caption, osVersion: os.Version, - lastBootTime: lastBoot, + lastBootTime: lastBoot.toISOString(), cpuManufacturer: pc.Manufacturer, cpuModel: pc.Caption, cpuCores: pc.NumberOfCores.toString(), @@ -236,7 +238,7 @@ export default async function WindowsMonitor({ memoryFree: (os.FreePhysicalMemory * 1000).toString(), memoryTotal: (os.TotalVisibleMemorySize * 1000).toString(), - cpuLoad: pc.LoadPercentage.toString(), + cpuLoad: pc.LoadPercentage ? pc.LoadPercentage.toString() : null, cpuSpeed: pc.CurrentClockSpeed.toString(), }, drives: updateableDrives.map( @@ -293,7 +295,7 @@ export default async function WindowsMonitor({ disposeSsh(ssh); - await Notifier({ job: monitor.id }); + await Notifier({ job: monitor.id, oldMonitor }); console.log(`successfully ran ${monitor.type} monitor: ${monitor.id}`); } catch (e) { diff --git a/app/notifications/checks/monitors/reboot.ts b/app/notifications/checks/monitors/reboot.ts index bf87481..645d158 100644 --- a/app/notifications/checks/monitors/reboot.ts +++ b/app/notifications/checks/monitors/reboot.ts @@ -8,26 +8,21 @@ import { sendNotification } from '~/notifications/notifier'; export default async function rebootNotifier({ monitor, + oldMonitor, }: { monitor: Monitor; + oldMonitor: Monitor; }) { + console.log('reboot notifier!'); // don't notify if disabled. if (!monitor.rebootNotify) return; - // get last reboot time - const lastBootTime = await getMonitorBootTime({ id: monitor.id }); + console.log(monitor.lastBootTime, oldMonitor.lastBootTime); - // if new , update time and skip notification - if (!monitor.rebootNotifySentAt) { - return setMonitorRebootSentAt({ - id: monitor.id, - rebootNotifySentAt: new Date(), - }); - } - - if (monitor.lastBootTime != lastBootTime) { - const subject = `[${monitor.host}] Rebooted.`; - const message = `[${monitor.host}] Rebooted.`; + // send notification if it has changed + if (monitor.lastBootTime != oldMonitor.lastBootTime) { + const subject = `⏰ [${monitor.host}] Reboot time changed.`; + const message = `[${monitor.host}] Reboot time changed.`; monitor.rebootNotifyTypes.map(async (notification: Notification) => { try { diff --git a/app/notifications/notifier.tsx b/app/notifications/notifier.tsx index 9ead0bb..cced0c6 100644 --- a/app/notifications/notifier.tsx +++ b/app/notifications/notifier.tsx @@ -17,17 +17,19 @@ import collectionNotifier from './checks/monitors/collection'; export default async function Notifier({ job, message, + oldMonitor, }: { job: string; message?: string; + oldMonitor?: Monitor; }) { const monitor = await getMonitor({ id: job }); - return collectionNotifier({ monitor, message }); + await collectionNotifier({ monitor, message }); if (monitor.type === 'windows' || monitor.type === 'ubuntu') { // reboot notifier - await rebootNotifier({ monitor }); + await rebootNotifier({ monitor, oldMonitor }); // drive notifications monitor?.drives?.map(async (drive: Drive & { usage: DriveUsage[] }) => { diff --git a/app/routes/_auth.$monitorType_.$monitorId.database.$databaseId/filesTable.tsx b/app/routes/_auth.$monitorType_.$monitorId.database.$databaseId/filesTable.tsx index 944e28a..cf526ef 100644 --- a/app/routes/_auth.$monitorType_.$monitorId.database.$databaseId/filesTable.tsx +++ b/app/routes/_auth.$monitorType_.$monitorId.database.$databaseId/filesTable.tsx @@ -35,7 +35,6 @@ export const FilesTable = ({ const [rowSelection, setRowSelection] = React.useState({}); const [columnVisibility, setColumnVisibility] = React.useState({ - title: false, recoveryModel: false, compatLevel: false, backupLogDate: false, @@ -45,7 +44,7 @@ export const FilesTable = ({ ); const [sorting, setSorting] = React.useState([ - { id: 'name', desc: true }, + { id: 'fileName', desc: true }, ]); const table = useReactTable({