Documentation ¶
Index ¶
- func DurationToHoursAndMinutes(duration time.Duration) string
- func FormatDate(date time.Time, timeZone string) string
- func GetDirSize(path string) (float64, error)
- func GetDurationTillTime(start time.Time, duration time.Duration) (time.Duration, error)
- func GetVolumeSize(volumeName string) (float64, error)
- func ParseEpochTime(epoch string) (*time.Time, error)
- func ParseIntFromString(str string) (int, error)
- func StringMsToDuration(durationString string) (time.Duration, error)
- type NetworkUsage
- type UsageData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationToHoursAndMinutes ¶
DurationToHoursAndMinutes converts a duration in milliseconds to a formatted string representing hours and minutes.
func FormatDate ¶
FormatDate formats a time.Time value to a string using a specific date and time layout string and the specified time zone.
func GetDirSize ¶
GetDirSize returns the size of the directory at the specified path. It takes the path of the directory as input and returns the size of the directory in gigabytes and an error if any. It walks through the directory and sums up the size of all the files within it. If an error occurs during the process, it returns the error.
func GetDurationTillTime ¶
GetDurationTillTime calculates the duration between a specified start time and the current time and returns it as a time.Duration value.
func GetVolumeSize ¶
GetVolumeSize returns the size of the specified volume. It takes the volumeName as input and returns the size of the volume in gigabytes and an error if any. It uses the Docker client to inspect the volume and retrieve its size. If the volume does not exist or if there is an error during the process, it returns the error.
func ParseEpochTime ¶
ParseEpochTime parses a string representing an epoch time and returns a pointer to a time.Time value.
func ParseIntFromString ¶
ParseIntFromString extracts the integer part from a string that may have a suffix. The suffix can be any non-digit characters at the end of the string. If the string cannot be parsed, an error is returned.
Types ¶
type NetworkUsage ¶
func GetNetworkUsage ¶
func GetNetworkUsage() (*NetworkUsage, error)
GetNetworkUsage returns the network usage statistics. It retrieves the number of bytes received and sent over the network interface. It returns a pointer to NetworkUsage and an error if any. It uses the net package to fetch the network I/O counters.
type UsageData ¶
func GetCPUUsage ¶
GetCPUUsage returns the CPU usage statistics. It retrieves the total number of CPU cores and the percentage of CPU usage. It returns a pointer to UsageData and an error if any.
func GetDiskUsage ¶
GetDiskUsage returns the disk usage information for the root directory. It calculates the total, free, used, and percentage used space on the disk. It returns a pointer to UsageData and an error if any.
func GetMemoryUsage ¶
GetMemoryUsage returns the memory usage statistics. It retrieves the total, free, used memory in gigabytes, and the percentage of memory used. It returns a pointer to UsageData and an error if any. It uses the mem package to fetch the virtual memory statistics.