import useSWR from "swr"; import { FaMemory } from "react-icons/fa"; import { BiError } from "react-icons/bi"; import { formatBytes } from "utils/stats-helpers"; export default function Memory() { const { data, error } = useSWR(`/api/widgets/resources?type=memory`, { refreshInterval: 1500, }); if (error || data?.error) { return (
API Error
); } if (!data) { return (
-
); } const percent = Math.round((data.memory.usedMemMb / data.memory.totalMemMb) * 100); return (
{formatBytes(data.memory.freeMemMb * 1024 * 1024)} Free {formatBytes(data.memory.usedMemMb * 1024 * 1024)} Used
); }