dhcpdleasesreader

package module
v0.0.0-...-eb2d646 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

README

dhcpdleasesreader

A very simple golang wrapper around the dhcpd.leases file (see man page). The wrapper can be created with two parameters: info, err := NewDhcpdInfo(file string, debug bool)

Parameters:

  • file - The path on the filesystem to the dhcpd.leases file. This is usually /var/lib/dhcpd/dhcpd.leases.
  • debug - Whether to print verbose debugging information as the file is parsed

Return:

  • DhcpdInfo structure - a structure with stats and the list of clients
  • err - usually only occurs if there is an issue reading the file parameter

Notes The Read() function can be called any time to refresh the list of clients and regenerate stats. At least, this will be only as expensive as a stat() check of the file because if it has not changed since last read, the function returns immediately.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DhcpdInfo

type DhcpdInfo struct {
	ModTime time.Time
	Leases  map[string]*DhcpdLease
	Expired int
	Valid   int
	// contains filtered or unexported fields
}

func NewDhcpdInfo

func NewDhcpdInfo(i_file string, i_debug bool) (*DhcpdInfo, error)

func (*DhcpdInfo) Read

func (info *DhcpdInfo) Read() error

type DhcpdLease

type DhcpdLease struct {
	Hostname         string
	Starts           time.Time
	Ends             time.Time
	Cltt             time.Time
	Uid              string
	State            string
	Next             string
	Rewind           string
	Hardware_type    string
	Hardware_address string
	Ddns_fwd_name    string
	Ddns_rev_name    string
	Ddns_dhcid       string
	Identifier       string
}

Jump to

Keyboard shortcuts

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