0

Get system status

by
Published today

Get basic system status of the FortiGate (monitor API system/status), including the serial number, FortiOS version and build. Leave vdom empty for the management VDOM.

Script fortigate Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 hours ago
1
//native
2

3
/**
4
 * Get system status
5
 * Get basic system status of the FortiGate (monitor API system/status), including the serial number, FortiOS version and build. Leave vdom empty for the management VDOM.
6
 */
7
export async function main(auth: RT.Fortigate, vdom: string | undefined) {
8
  const url = new URL(
9
    `${auth.base_url.replace(/\/+$/, "")}/api/v2/monitor/system/status`
10
  )
11
  if (vdom != null && vdom !== "") {
12
    url.searchParams.append("vdom", vdom)
13
  }
14

15
  const response = await fetch(url, {
16
    headers: {
17
      Authorization: `Bearer ${auth.token}`,
18
      Accept: "application/json",
19
    },
20
  })
21

22
  if (!response.ok) {
23
    throw new Error(`${response.status} ${await response.text()}`)
24
  }
25

26
  return await response.json()
27
}
28