Documentation ¶
Index ¶
- Constants
- Variables
- func DateQuotaFull(history []History) (time.Time, time.Time)
- func MergeDBs(pathA, pathB, outputPath string) (err error)
- type BaseDirReader
- func (b *BaseDirReader) Close() error
- func (b *BaseDirReader) GroupSubDirUsageTable(gid uint32, basedir string, age summary.DirGUTAge) (string, error)
- func (b *BaseDirReader) GroupSubDirs(gid uint32, basedir string, age summary.DirGUTAge) ([]*SubDir, error)
- func (b *BaseDirReader) GroupUsage(age summary.DirGUTAge) ([]*Usage, error)
- func (b *BaseDirReader) GroupUsageTable(age summary.DirGUTAge) (string, error)
- func (b *BaseDirReader) History(gid uint32, path string) ([]History, error)
- func (b *BaseDirReader) SetMountPoints(mountpoints []string)
- func (b *BaseDirReader) UserSubDirUsageTable(uid uint32, basedir string, age summary.DirGUTAge) (string, error)
- func (b *BaseDirReader) UserSubDirs(uid uint32, basedir string, age summary.DirGUTAge) ([]*SubDir, error)
- func (b *BaseDirReader) UserUsage(age summary.DirGUTAge) ([]*Usage, error)
- func (b *BaseDirReader) UserUsageTable(age summary.DirGUTAge) (string, error)
- type BaseDirs
- type Config
- type ConfigAttrs
- type DBInfo
- type Error
- type GroupCache
- type History
- type Quotas
- type SubDir
- type Usage
- type UsageBreakdownByType
- type UserCache
Constants ¶
const (
DefaultSplits = 1
)
Variables ¶
var ( ErrInvalidBasePath = errors.New("invalid base path") ErrNoBaseDirHistory = errors.New("no base dir history found") )
var (
ErrBadTSV = errors.New("bad TSV")
)
var ErrInvalidOwnersFile = errors.New("invalid owners file format")
Functions ¶
func DateQuotaFull ¶
DateQuotaFull returns our estimate of when the quota will fill based on the history of usage over time. Returns date when size full, and date when inodes full.
Returns a zero time value if the estimate is infinite.
Types ¶
type BaseDirReader ¶
type BaseDirReader struct {
// contains filtered or unexported fields
}
BaseDirReader is used to read the information stored in a BaseDir database.
func NewReader ¶
func NewReader(dbPath, ownersPath string) (*BaseDirReader, error)
NewReader returns a BaseDirReader that can return the summary information stored in a BaseDir database. It takes an owners file (gid,name csv) to associate groups with their owners in certain output.
func (*BaseDirReader) Close ¶
func (b *BaseDirReader) Close() error
func (*BaseDirReader) GroupSubDirUsageTable ¶
func (b *BaseDirReader) GroupSubDirUsageTable(gid uint32, basedir string, age summary.DirGUTAge) (string, error)
GroupSubDirUsageTable returns GroupSubDirs() information formatted with the following tab separated columns:
base_directory_path sub_directory num_files size last_modified filetypes
Any error returned is from GroupSubDirs().
func (*BaseDirReader) GroupSubDirs ¶
func (b *BaseDirReader) GroupSubDirs(gid uint32, basedir string, age summary.DirGUTAge) ([]*SubDir, error)
GroupSubDirs returns a slice of SubDir, one for each subdirectory of the given basedir, owned by the given group. If basedir directly contains files, one of the SubDirs will be for ".".
func (*BaseDirReader) GroupUsage ¶
func (b *BaseDirReader) GroupUsage(age summary.DirGUTAge) ([]*Usage, error)
GroupUsage returns the usage for every GID-BaseDir combination in the database.
func (*BaseDirReader) GroupUsageTable ¶
func (b *BaseDirReader) GroupUsageTable(age summary.DirGUTAge) (string, error)
GroupUsageTable returns GroupUsage() information formatted with the following tab separated columns:
group_name owner_name directory_path last_modified (number of days ago) used size (used bytes) quota size (maximum allowed bytes) used inodes (number of files) quota inodes (maximum allowed number of bytes) warning ("OK" or "Not OK" if quota is estimated to have run out in 3 days)
Any error returned is from GroupUsage().
func (*BaseDirReader) History ¶
func (b *BaseDirReader) History(gid uint32, path string) ([]History, error)
History returns a slice of History values for the given gid and path, one value per Date the information was calculated.
func (*BaseDirReader) SetMountPoints ¶
func (b *BaseDirReader) SetMountPoints(mountpoints []string)
SetMountPoints can be used to manually set your mountpoints, if the automatic discovery of mountpoints on your system doesn't work.
func (*BaseDirReader) UserSubDirUsageTable ¶
func (b *BaseDirReader) UserSubDirUsageTable(uid uint32, basedir string, age summary.DirGUTAge) (string, error)
UserSubDirUsageTable returns UserSubDirs() information formatted with the following tab separated columns:
base_directory_path sub_directory num_files size last_modified filetypes
Any error returned is from UserSubDirUsageTable().
func (*BaseDirReader) UserSubDirs ¶
func (b *BaseDirReader) UserSubDirs(uid uint32, basedir string, age summary.DirGUTAge) ([]*SubDir, error)
UserSubDirs returns a slice of SubDir, one for each subdirectory of the given basedir, owned by the given user. If basedir directly contains files, one of the SubDirs will be for ".".
func (*BaseDirReader) UserUsage ¶
func (b *BaseDirReader) UserUsage(age summary.DirGUTAge) ([]*Usage, error)
UserUsage returns the usage for every UID-BaseDir combination in the database.
func (*BaseDirReader) UserUsageTable ¶
func (b *BaseDirReader) UserUsageTable(age summary.DirGUTAge) (string, error)
UserUsageTable returns UserUsage() information formatted with the following tab separated columns:
user_name owner_name (always blank) directory_path last_modified (number of days ago) used size (used bytes) quota size (always 0) used inodes (number of files) quota inodes (always 0) warning (always "OK")
Any error returned is from UserUsage().
type BaseDirs ¶
type BaseDirs struct {
// contains filtered or unexported fields
}
BaseDirs is used to summarise disk usage information by base directory and group or user.
func NewCreator ¶
NewCreator returns a BaseDirs that lets you create a database summarising usage information by base directory, taken from the given tree and quotas.
Choose splits and minDirs based on how many directories deep you expect data for different groups/users to appear. Eg. if your file structure is `/mounts/[group name]`, that's 2 directories deep and splits 1, minDirs 2 might work well. If it's 5 directories deep, splits 4, minDirs 4 might work well.
func (*BaseDirs) CreateDatabase ¶
CreateDatabase creates a database containing usage information for each of our groups and users by calculated base directory.
func (*BaseDirs) SetMountPoints ¶
SetMountPoints can be used to manually set your mountpoints, if the automatic discovery of mountpoints on your system doesn't work.
type Config ¶
type Config []ConfigAttrs
type DBInfo ¶
type DBInfo struct { GroupDirCombos int GroupMountCombos int GroupHistories int GroupSubDirCombos int GroupSubDirs int UserDirCombos int UserSubDirCombos int UserSubDirs int }
DBInfo holds summary information about the database file produced by NewCreator().CreateDatabase().
type GroupCache ¶
type GroupCache struct {
// contains filtered or unexported fields
}
func NewGroupCache ¶
func NewGroupCache() *GroupCache
func (*GroupCache) GroupName ¶
func (g *GroupCache) GroupName(gid uint32) string
type History ¶
type History struct { Date time.Time UsageSize uint64 QuotaSize uint64 UsageInodes uint64 QuotaInodes uint64 }
History contains actual usage and quota max information for a particular point in time.
type Quotas ¶
type Quotas struct {
// contains filtered or unexported fields
}
Quotas stores information about group disk quotas.
func ParseQuotas ¶
ParseQuotas parses the given quotas csv file (gid,disk,quota) and returns a Quotas struct.
type SubDir ¶
type SubDir struct { SubDir string NumFiles uint64 SizeFiles uint64 LastModified time.Time FileUsage UsageBreakdownByType }
SubDir contains information about a sub-directory of a base directory.
type Usage ¶
type Usage struct { GID uint32 UID uint32 GIDs []uint32 UIDs []uint32 Name string // the group or user name Owner string BaseDir string UsageSize uint64 QuotaSize uint64 UsageInodes uint64 QuotaInodes uint64 Mtime time.Time // DateNoSpace is an estimate of when there will be no space quota left. DateNoSpace time.Time // DateNoFiles is an estimate of when there will be no inode quota left. DateNoFiles time.Time Age summary.DirGUTAge }
Usage holds information summarising usage by a particular GID/UID-BaseDir.
Only one of GID or UID will be set, and Owner will always be blank when UID is set. If GID is set, then UIDs will be set, showing which users own files in the BaseDir. If UID is set, then GIDs will be set, showing which groups own files in the BaseDir.
type UsageBreakdownByType ¶
type UsageBreakdownByType map[summary.DirGUTAFileType]uint64
UsageBreakdownByType is a map of file type to total size of files in bytes with that type.
func (UsageBreakdownByType) String ¶
func (u UsageBreakdownByType) String() string