Skip to content

Commit

Permalink
fix(notification): fixed drive latest values, fixed notification for …
Browse files Browse the repository at this point in the history
…sql files with growth disabled
  • Loading branch information
christopherpickering committed Sep 15, 2023
1 parent 726178d commit a29757a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions app/notifications/checks/monitors/sqlFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export default async function sqlFilePercentFreeNotifier({
(1 - Number(usage.currentSize) / Number(usage.maxSize)) * 100;

let message, subject: string;

if (
Number(file.growth) == 0 &&
percFree < (monitor.sqlFileSizePercentFreeValue || 0)
Expand All @@ -141,7 +140,7 @@ export default async function sqlFilePercentFreeNotifier({
monitor.sqlFileSizePercentFreeValue
}%.`;
subject = `💔 [${monitor.name}.${database.name} file ${file.fileName}] Alert: free space limit exceeded.`;
} else if (percFreeMax < (monitor.sqlFileSizePercentFreeValue || 0)) {
} else if (Number(usage?.maxSize) > 0 && percFreeMax < (monitor.sqlFileSizePercentFreeValue || 0)) {
// alert for max file size
message = `(Max file size) Percentage of free space (${Math.round(
percFreeMax,
Expand Down
16 changes: 8 additions & 8 deletions app/routes/_auth.$monitorType_.$monitorId._index/drive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ export const MiniDrive = ({
data={{
labels: [
`Used ${bytes(
Number(usageFetcher.data?.drive?.usage?.[0]?.used),
Number([...usageFetcher.data?.drive?.usage]?.pop()?.used),
)}`,
`Free ${bytes(
Number(usageFetcher.data?.drive?.usage?.[0]?.free),
Number([...usageFetcher.data?.drive?.usage]?.pop()?.free),
)}`,
],
datasets: [
{
label: 'Drive Usage',
data: [
Number(usageFetcher.data?.drive?.usage?.[0]?.used),
Number(usageFetcher.data?.drive?.usage?.[0]?.used) +
Number(usageFetcher.data?.drive?.usage?.[0]?.free) ==
Number([...usageFetcher.data?.drive?.usage]?.pop()?.used),
Number([...usageFetcher.data?.drive?.usage]?.pop()?.used) +
Number([...usageFetcher.data?.drive?.usage]?.pop()?.free) ==
0
? 100
: Number(usageFetcher.data?.drive?.usage?.[0]?.free),
: Number([...usageFetcher.data?.drive?.usage]?.pop()?.free),
],
},
],
Expand Down Expand Up @@ -119,7 +119,7 @@ export const MiniDrive = ({
<TableCell className="py-1">Used</TableCell>
<TableCell className="py-1 text-slate-800">
{usageFetcher.data ? (
bytes(Number(usageFetcher?.data?.drive?.usage?.[0]?.used)) ||
bytes(Number([...usageFetcher.data?.drive?.usage]?.pop()?.used)) ||
'-1'
) : (
<Skeleton className="h-3 w-full max-w-[60px] rounded-sm" />
Expand All @@ -130,7 +130,7 @@ export const MiniDrive = ({
<TableCell className="py-1 font-medium">Free</TableCell>
<TableCell className="py-1 text-slate-800">
{usageFetcher.data ? (
bytes(Number(usageFetcher?.data?.drive?.usage?.[0]?.free)) ||
bytes(Number([...usageFetcher.data?.drive?.usage]?.pop()?.free)) ||
'-1'
) : (
<Skeleton className="h-3 w-full max-w-[60px] rounded-sm" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export default function Index() {
<TableCell className="py-1 text-slate-700">
{usageFetcher.data ? (
bytes(
Number(usageFetcher?.data?.database?.usage?.[0]?.memory),
Number([...usageFetcher.data?.database?.usage]?.pop()?.memory),
) || '-1'
) : (
<Skeleton className="h-3 w-full max-w-[60px] rounded-sm" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function Index() {
<TableCell className="py-1">
{usageFetcher.data ? (
bytes(
Number(usageFetcher?.data?.drive?.usage?.[0]?.used),
Number([...usageFetcher.data?.drive?.usage]?.pop()?.used),
) || '-1'
) : (
<Skeleton className="h-3 w-full max-w-[60px] rounded-sm" />
Expand All @@ -165,7 +165,7 @@ export default function Index() {
<TableCell className="py-1">
{usageFetcher.data ? (
bytes(
Number(usageFetcher?.data?.drive?.usage?.[0]?.free),
Number([...usageFetcher.data?.drive?.usage]?.pop()?.free),
) || '-1'
) : (
<Skeleton className="h-3 w-full max-w-[60px] rounded-sm" />
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth.monitor.new/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export async function action({ request }: ActionArgs) {
sqlConnectionString: values.sqlConnectionString
? values.sqlConnectionString.toString()
: null,
sqlDisableDbMemory: values.sqlDisableDbMemory.toString() == 'true',
sqlDisableDbMemory: values.sqlDisableDbMemory?.toString() == 'true',
});

return json({ monitor });
Expand Down Expand Up @@ -262,7 +262,7 @@ export async function action({ request }: ActionArgs) {
sqlConnectionString: values.sqlConnectionString
? values.sqlConnectionString.toString()
: null,
sqlDisableDbMemory: values.sqlDisableDbMemory.toString() == 'true',
sqlDisableDbMemory: values.sqlDisableDbMemory?.toString() == 'true',
});
}
return json({ monitor });
Expand Down

0 comments on commit a29757a

Please sign in to comment.