lib

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2014 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

package lib - common routines for pstop

logger - minimal logger shared by everyone

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copyright() string

Copyright provides a copyright message for pstop

func FormatAmount

func FormatAmount(amount uint64) string

FormatAmount() convert numbers to k = 1024 , M = 1024 x 1024, G = 1024 x 1024 x 1024, P = 1024x1024x1024x1024. For values = 0 return an empty string. For values < 1000 show 6,2 decimal places. For values >= 1000 show 6,1 decimal place.

func FormatPct

func FormatPct(pct float64) string

FormatPct() formats a floating point number as a percentage including the trailing % sign. Print the value as a %5.1f with a % suffix if there's a value. If the value is 0 print as 6 spaces. if the value is > 999.9 then show +++.+% to indicate an overflow.

func FormatTime

func FormatTime(picoseconds uint64) string

FormatTime is based on sys.format_time. It formats to 10 characters including space and suffix. All values have 2 decimal places. Zero is returned as an empty string.

func MyDivide

func MyDivide(a uint64, b uint64) float64

MyDivide() divides a by b except if b is 0 in which case we return 0.

func MyName

func MyName() string

MyName returns the program's name.

func SelectAllGlobalVariablesByVariableName

func SelectAllGlobalVariablesByVariableName(dbh *sql.DB) (error, map[string]string)

Return all global variables as a hashref

func SelectGlobalStatusByVariableName

func SelectGlobalStatusByVariableName(dbh *sql.DB, variable_name string) (error, int)

** mysql> select VARIABLE_VALUE from global_status where VARIABLE_NAME = 'UPTIME'; * +----------------+ * | VARIABLE_VALUE | * +----------------+ * | 251107 | * +----------------+ * 1 row in set (0.00 sec) *

func SelectGlobalVariableByVariableName

func SelectGlobalVariableByVariableName(dbh *sql.DB, variable_name string) (error, string)

** mysql> select VARIABLE_VALUE from information_schema.global_variables where variable_name = 'hostname'; * +----------------+ * | VARIABLE_VALUE | * +----------------+ * | myhostname | * +----------------+ * 1 row in set (0.00 sec) *

func SelectGlobalVariablesByVariableName

func SelectGlobalVariablesByVariableName(dbh *sql.DB, wanted []string) (error, map[string]string)

Provide a slice of string and get back a hash of variable_name to value. - note the query is case insensitive for variable names. - they key values are lower-cased.

func Uptime

func Uptime(uptime int) string

Uptime() provides a usable form of uptime. Note: this doesn't return a string of a fixed size! Minimum value: 1s. Maximum value: 100d 23h 59m 59s (sort of).

Types

type MyLogger

type MyLogger struct {
	// contains filtered or unexported fields
}

just add an extra field to enable or not

var Logger *MyLogger

public visible interface

func (*MyLogger) EnableLogging

func (logger *MyLogger) EnableLogging(enable_logging bool) bool

func (*MyLogger) Println

func (logger *MyLogger) Println(v ...interface{})

pass Println() calls downstream if we have a valid logger setup

Jump to

Keyboard shortcuts

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