package sprigx import ( `net` `net/netip` `os` `os/user` `path` `path/filepath` `runtime` `time` `github.com/davecgh/go-spew/spew` `github.com/shirou/gopsutil/v4/cpu` `github.com/shirou/gopsutil/v4/disk` `github.com/shirou/gopsutil/v4/host` `github.com/shirou/gopsutil/v4/load` `github.com/shirou/gopsutil/v4/mem` psnet `github.com/shirou/gopsutil/v4/net` `github.com/shirou/gopsutil/v4/process` `github.com/shirou/gopsutil/v4/sensors` `go4.org/netipx` `r00t2.io/goutils/netx` `r00t2.io/goutils/netx/dnsx` `r00t2.io/goutils/stringsx` `r00t2.io/goutils/timex` `r00t2.io/sysutils` ) var ( // genericMap holds functions usable/intended for use in either an [html/template.FuncMap] or [text/template.FuncMap]. genericMap map[string]any = map[string]any{ // Debugging "dump": spew.Sdump, /* "Meta"/Template-Helpers */ "metaIsNil": metaIsNil, /* Networking (net) */ "netCidrMask": net.CIDRMask, "netExtractAddr": netExtractAddr, "netExtractHost": netExtractHost, "netExtractIpnet": netExtractIpnet, "netExtractPort": netExtractPort, "netIfaces": net.Interfaces, "netIp4Mask": netIp4Mask, "netJoinHostPort": net.JoinHostPort, "netParseIP": net.ParseIP, /* Networking (net/netip) */ "netipAddrPort": netip.AddrPortFrom, "netipParseAddr": netip.ParseAddr, "netipParseAddrPort": netip.ParseAddrPort, "netipParsePrefix": netip.ParsePrefix, "netipPrefix": netip.PrefixFrom, /* Networking (go4.org/netipx) */ "netipxAddrIpNet": netipx.AddrIPNet, "netipxCmpPfx": netipx.ComparePrefix, "netipxFromStdAddr": netipxFromStdAddr, "netipxFromIp": netipxFromIp, "netipxFromIpNet": netipxFromIpNet, "netipxParseRange": netipx.ParseIPRange, "netipxPfxAddr": netipx.ParsePrefixOrAddr, "netipxPfxIpNet": netipx.PrefixIPNet, "netipxPfxLast": netipx.PrefixLastIP, "netipxPfxRange": netipx.RangeOfPrefix, "netipxRange": netipx.IPRangeFrom, /* Networking (r00t.io/goutils/netx) */ "netxAddrRfc": netx.AddrRfc, "netxCidr4IpMask": netx.Cidr4ToIPMask, "netxCidr4Mask": netx.Cidr4ToMask, "netxCidr4Str": netx.Cidr4ToStr, "netxFamilyVer": netx.FamilyToVer, "netxGetAddrFam": netx.GetAddrFamily, "netxGetIpFam": netx.GetIpFamily, "netxIpRfc": netx.IpRfc, "netxIpRfcStr": netx.IpRfcStr, "netxIpStripRfc": netx.IpStripRfcStr, "netxIp4MaskCidr": netx.IPMask4ToCidr, "netxIp4MaskMask": netx.IPMask4ToMask, "netxIp4MaskStr": netx.IPMask4ToStr, "netxIpVerStr": netx.IpVerStr, "netxIsBrktd6": netx.IsBracketedIp6, "netxIsIp": netx.IsIpAddr, "netxIsPfx": netx.IsPrefixNet, "netxMask4Cidr": netx.Mask4ToCidr, "netxMask4StrCidr": netx.Mask4StrToCidr, "netxMask4StrIpMask": netx.Mask4StrToIPMask, "netxMask4StrMask": netx.Mask4StrToMask, "netxVerFamily": netx.VerToFamily, /* Networking (r00t.io/goutils/netx/dnsx) */ "dnsxPtrAddr": dnsx.AddrFromPtr, "dnsxAddrPtr": dnsx.AddrToPtr, "dnsxStrWire": dnsx.DnsStrToWire, "dnsxWireStr": dnsx.DnsWireToStr, "dnsxPtrIp": dnsx.IpFromPtr, "dnsxIpPtr": dnsx.IpToPtr, "dnsxIsFqdn": dnsx.IsFqdn, "dnsxIsTxt": dnsx.IsFqdnDefinedTxt, "dnsxIsNsec3": dnsx.IsFqdnNsec3, "dnsxIsSrv": dnsx.IsFqdnSrv, "dnsxIsWild": dnsx.IsFqdnWildcard, "dnsxIsLbl": dnsx.IsLabel, "dnsxIsPtr": dnsx.IsPtr, /* Numbers/Math */ "numFloat32Str": numFloat32Str, "numFloat64": numFloat64, "numFloat64Str": numFloat64Str, "numFloatStr": numFloatStr, /* OS */ "osFQDN": osFQDN, "osGroupById": osGroupById, "osGroupByName": user.LookupGroup, "osHost": osHost, "osHostname": os.Hostname, "osIdState": sysutils.GetIDState, "osUser": user.Current, "osUserById": osUserById, "osUserByName": user.Lookup, /* Paths */ // Paths: Generic "pathJoin": path.Join, "pathPipeJoin": pathPipeJoin, "pathSliceJoin": pathSliceJoin, "pathSlicePipeJoin": pathSlicePipeJoin, "pathSubJoin": pathSubJoin, // Paths: OS/Platform "osPathJoin": filepath.Join, "osPathPipeJoin": osPathPipeJoin, "osPathSep": osPathSep, "osPathSliceJoin": osPathSliceJoin, "osPathSlicePipeJoin": osPathSlicePipeJoin, "osPathSubJoin": osPathSubJoin, /* PSUtil (https://pkg.go.dev/github.com/shirou/gopsutil/v4) */ // .../cpu "psCpuCnts": cpu.Counts, "psCpuInfo": cpu.Info, "psCpuPct": cpu.Percent, "psCpuTimes": cpu.Times, // .../disk "psDiskIoCnts": disk.IOCounters, "psDiskLabel": disk.Label, "psDiskParts": disk.Partitions, "psDiskSerial": disk.SerialNumber, "psDiskUsage": disk.Usage, // .../host "psHostBoot": host.BootTime, "psHostId": host.HostID, "psHostInfo": host.Info, "psHostKernArch": host.KernelArch, "psHostKernVer": host.KernelVersion, "psHostPlatInfo": psHostPlatInfo, "psHostUptime": host.Uptime, "psHostUsers": host.Users, "psHostVirt": psHostVirt, // .../load "psLoadAvg": load.Avg, "psLoadMisc": load.Misc, // .../mem "psMemSwap": mem.SwapMemory, "psMemSwapDevs": mem.SwapDevices, "psMemVMem": mem.VirtualMemory, // .../net "psNetConns": psnet.Connections, "psNetConnsMax": psnet.ConnectionsMax, "psNetConnsPid": psnet.ConnectionsPid, "psNetConnsPidMax": psnet.ConnectionsPidMax, "psNetCTStats": psnet.ConntrackStats, "psNetCTStatList": psnet.NewConntrackStatList, "psNetFilterCnts": psnet.FilterCounters, "psNetIoCnts": psnet.IOCounters, "psNetIoCntsFile": psnet.IOCountersByFile, "psNetIfaces": psnet.Interfaces, "psNetPids": psnet.Pids, "psNetProtoCnt": psnet.ProtoCounters, // .../process "psProcs": process.Processes, "psProcNew": process.NewProcess, "psProcPids": process.Pids, "psProcPidExists": process.PidExists, // .../sensors "psSensorTemps": sensors.SensorsTemperatures, /* Strings (Standalone) */ "extIndent": extIndent, // PR in: https://github.com/Masterminds/sprig/pull/468 /* Strings (r00t.io/goutils/stringsx) */ "strsxIsAscii": stringsx.IsAscii, "strsxIsAsciiBuf": stringsx.IsAsciiBuf, "strsxIsAsciiSpcl": stringsx.IsAsciiSpecial, "strsxIsAsciiBufSpcl": stringsx.IsAsciiBufSpecial, "strsxLenSpl": stringsx.LenSplit, "strsxLenSplStr": stringsx.LenSplitStr, "strsxPad": stringsx.Pad, "strsxRedact": stringsx.Redact, "strsxRev": stringsx.Reverse, "strsxTrimLns": stringsx.TrimLines, "strsxTrimSpcLft": stringsx.TrimSpaceLeft, "strsxTrimSpcRt": stringsx.TrimSpaceRight, /* System/Platform */ "sysArch": sysArch, "sysNumCpu": runtime.NumCPU, "sysOsName": sysOsNm, "sysRuntime": sysRuntime, /* Time/Dates/Timestamps */ "tmDate": time.Date, "tmFmt": tmFmt, "tmFloatMicro": timex.F64Microseconds, "tmFloatMilli": timex.F64Milliseconds, "tmFloatNano": timex.F64Nanoseconds, "tmFloat": timex.F64Seconds, "tmNow": time.Now, "tmParseDur8n": time.ParseDuration, "tmParseMonth": tmParseMonth, "tmParseMonthInt": tmParseMonthInt, "tmParseMonthStr": tmParseMonthStr, "tmParseTime": time.Parse, } // htmlMap holds functions usable/intended for use in only an [html/template.FuncMap]. htmlMap map[string]any = map[string]any{} // txtMap holds functions usable/intended for use in only a [text/template.FuncMap]. txtMap map[string]any = map[string]any{} )