Documentation ¶
Overview ¶
package lib - common routines for pstop
logger - minimal logger shared by everyone
Index ¶
- func Copyright() string
- func FormatAmount(amount uint64) string
- func FormatPct(pct float64) string
- func FormatTime(picoseconds uint64) string
- func MyDivide(a uint64, b uint64) float64
- func MyName() string
- func SelectAllGlobalVariablesByVariableName(dbh *sql.DB) (error, map[string]string)
- func SelectGlobalStatusByVariableName(dbh *sql.DB, variable_name string) (error, int)
- func SelectGlobalVariableByVariableName(dbh *sql.DB, variable_name string) (error, string)
- func SelectGlobalVariablesByVariableName(dbh *sql.DB, wanted []string) (error, map[string]string)
- func Uptime(uptime int) string
- type MyLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatAmount ¶
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 ¶
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 ¶
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 SelectAllGlobalVariablesByVariableName ¶
Return all global variables as a hashref
func SelectGlobalStatusByVariableName ¶
** mysql> select VARIABLE_VALUE from global_status where VARIABLE_NAME = 'UPTIME'; * +----------------+ * | VARIABLE_VALUE | * +----------------+ * | 251107 | * +----------------+ * 1 row in set (0.00 sec) *
func SelectGlobalVariableByVariableName ¶
** 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 ¶
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.
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