sysinfo

package
v0.0.0-...-9f55086 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sysinfo implements functions for gathering system information via the https://github.com/shirou/gopsutil/ package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPIRoutes

func GetAPIRoutes(c *fiber.Ctx) ([]string, error)

GetAPIRoutes collects active Fiber routes, parses them, and returns the data or as JSON or error.

Returned data example:

{
  "apiRoutes": [
    "/",
    "/api/v1",
    "/api/v1/docs",
    "/api/v1/metrics",
    "/api/v1/resource/",
    "/api/v1/resource/all",
    "/api/v1/resource/cpu",
    "/api/v1/resource/host",
    "/api/v1/resource/load",
    "/api/v1/resource/memory",
    "/api/v1/resource/network"
  ]
}

func GetCPUInfo

func GetCPUInfo(debug bool) ([]cpu.InfoStat, error)

GetCPUInfo collects local system cpu info, parses it, and returns the data as JSON or an error.

Returned data example (truncated ...):

{
  cpuInfo: {
    [
      {
        "cpu": 0,
        "vendorId": "GenuineIntel",
        "family": "6",
        "model": "76",
        "stepping": 4,
        "physicalId": "0",
        "coreId": "0",
        "cores": 1,
        "modelName": "Intel(R) Pentium(R) CPU  N3710  @ 1.60GHz",
        "mhz": 2560,
        "cacheSize": 1024,
        "flags": [
          "fpu",
          "vme",
          "de",
          ...
        ],
      }
    ]
  }
}

func GetHostInfo

func GetHostInfo(debug bool) (*host.InfoStat, error)

GetHostInfo collects local system host info, parses it, and returns the data as JSON or an error.

Returned data example:

{
  hostInfo: {
    uptime: 1386790,
    bootTime: 1669484114,
    procs: 193,
    os: "linux",
    platform: "ubuntu",
    platformFamily: "debian",
    platformVersion: "20.04",
    kernelVersion: "5.4.0-110-generic",
    kernelArch: "x86_64",
    virtualizationSystem: "kvm",
    virtualizationRole: "host",
    hostId: "3a114467-105a-48a5-9419-32654a9b2076"
  }
}

func GetLoadInfo

func GetLoadInfo(debug bool) (*load.AvgStat, error)

GetLoadInfo collects local system load info, parses it, and returns the data as JSON or an error.

Returned data example:

{
  loadInfo: {
    load1: 0.58,
    load5: 0.87,
    load15: 0.9
  }
}

func GetMemInfo

func GetMemInfo(debug bool) (*mem.VirtualMemoryStat, error)

GetMemInfo collects local system memory info, parses it, and returns the data as JSON or an error.

Returned data example (truncated ...):

{
  memInfo: {
  total: 8247103488,
  available: 5860028416,
  used: 2075901952,
  usedPercent: 25.171285349099282,
  ...
  }
}

func GetNetInfo

func GetNetInfo(debug bool) ([]net.InterfaceStat, error)

GetNetInfo collects local system network info, parses it, and returns the data as JSON or an error.

Returned data example (truncated ...):

{
  netInfo: [
    {
      index: 1,
      mtu: 65536,
      name: "lo",
      hardwareAddr: "",
      flags: [
        "up",
        "loopback"
      ],
      addrs: [
        {
          addr: "127.0.0.1/8"
        },
        {
          addr: "::1/128"
        }
      ]
    },
    ...
  ]
}

func TestTLS

func TestTLS() (errors int)

TestTLS checks to see if the certificates were properly included in the docker multi-stage build.

This is only executed when 'debug' is set to 'true' in 'config/appConfig.yml'.

Example
package main

import (
	"github.com/mwiater/golangdocker/sysinfo"
)

func main() {
	sysinfo.TestTLS()
}
Output:

[ ✓ SUCCESS ] Successfully established https connection to: https://google.com

func TestTZ

func TestTZ() (errors int)

TestTZ checks to see if the timezone data was properly included in the docker multi-stage build.

This is only executed when 'debug' is set to 'true' in 'config/appConfig.yml'.

Example
package main

import (
	"github.com/mwiater/golangdocker/sysinfo"
)

func main() {
	sysinfo.TestTZ()
}
Output:

[ ✓ SUCCESS ] Successfully loaded: America/Los_Angeles

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL