Documentation
¶
Overview ¶
web100 provides tools for reading web100 snapshot logs, and parsing snapshots.
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func IPFromBytes(data []byte) (net.IP, error)
- func MustAsset(name string) []byte
- func NormalizeIPv6(ipStr string) (string, error)
- func ParseIPFamily(ipStr string) int64
- func ParseWeb100Definitions(tcpKis io.Reader) (map[string]string, error)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func ValidateIP(ipStr string) error
- type IntArraySaver
- type Saver
- type SnapLog
- func (sl *SnapLog) ChangeIndices(fieldName string) ([]int, error)
- func (sl *SnapLog) ConnectionSpecValues(saver Saver)
- func (sl *SnapLog) SliceIntField(fieldName string, indices []int) []int64
- func (sl *SnapLog) SnapCount() int
- func (sl *SnapLog) Snapshot(n int) (Snapshot, error)
- func (sl *SnapLog) SnapshotNumBytes() int
- func (sl *SnapLog) SnapshotNumFields() int
- func (sl *SnapLog) ValidateSnapshots() error
- type Snapshot
- type Variable
Constants ¶
const ( BEGIN_SNAP_DATA = "----Begin-Snap-Data----\n" END_OF_HEADER = "\x00----End-Of-Header---- -1 -1\n" GROUPNAME_LEN_MAX = 32 VARNAME_LEN_MAX = 32 )
=================================================================================
const ( // The ordering here is important, as it reflects the type values // defined by the web100 libraries. Do not change ordering. WEB100_TYPE_INTEGER varType = iota WEB100_TYPE_INTEGER32 WEB100_TYPE_INET_ADDRESS_IPV4 WEB100_TYPE_COUNTER32 WEB100_TYPE_GAUGE32 WEB100_TYPE_UNSIGNED32 WEB100_TYPE_TIME_TICKS WEB100_TYPE_COUNTER64 WEB100_TYPE_INET_PORT_NUMBER WEB100_TYPE_INET_ADDRESS WEB100_TYPE_INET_ADDRESS_IPV6 WEB100_TYPE_STR32 WEB100_TYPE_OCTET WEB100_NUM_TYPES )
const ( // The ordering here is important, as it reflects the type values // defined by the web100 libraries. Do not change ordering. WEB100_ADDRTYPE_UNKNOWN addrType = iota WEB100_ADDRTYPE_IPV4 WEB100_ADDRTYPE_IPV6 WEB100_ADDRTYPE_DNS = 16 )
Variables ¶
var ( ErrIPIsUnparseable = errors.New("IP not parsable") ErrIPIsUnconvertible = errors.New("IP not convertible to ipv4 or ipv6") ErrIPIsZero = errors.New("IP is zero/unspecified") ErrIPIsUnroutable = errors.New("IP is nonroutable") ErrIPv4IsPrivate = errors.New("private IPv4") ErrIPv6IsPrivate = errors.New("private IPv6") ErrIPv4IsUnroutable = errors.New("unroutable IPv4") ErrIPv6IsUnroutable = errors.New("unroutable IPv6") ErrIPv6MultipleTripleColon = errors.New("more than one ::: in an ip address") ErrIPv6QuadColon = errors.New("IP address contains :::: ") )
IP validation errors.
var CanonicalNames map[string]string
CanonicalNames provides the mapping from old names (in snaplog files) to new canonical names. This is exported so that SideStream parser can use it easily.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/
foo.txt
img/
a.png
b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func IPFromBytes ¶
IPFromBytes handles the 17 byte web100 IP address fields.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NormalizeIPv6 ¶
NormalizeIPv6 fixes triple colon ::: which is produced by sidestream. This error is produced by older versions of the c-web100 library, which is still used by sidestream.
func ParseIPFamily ¶
ParseIPFamily determines whether an IP string is v4 or v6
func ParseWeb100Definitions ¶
ParseWeb100Definitions reads all web100 variable definitions from tcpKis and returns a mapping from legacy names to canonical names. This mapping is necessary for translating variable names in archived web100 snapshots to canonical variable names.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func ValidateIP ¶
ValidateIP validates (and possibly repairs) IP addresses. Return nil if it is a valid IPv4 or IPv6 address (or can be repaired), non-nil otherwise.
Types ¶
type IntArraySaver ¶
type IntArraySaver struct {
Integers []int64
}
func NewIntArraySaver ¶
func NewIntArraySaver(n int) IntArraySaver
func (*IntArraySaver) SetBool ¶
func (s *IntArraySaver) SetBool(name string, val bool)
func (*IntArraySaver) SetInt64 ¶
func (s *IntArraySaver) SetInt64(name string, val int64)
func (*IntArraySaver) SetString ¶
func (s *IntArraySaver) SetString(name string, val string)
type Saver ¶
type Saver interface {
SetInt64(name string, value int64)
SetString(name string, value string)
SetBool(name string, value bool)
}
The Saver interface decouples reading data from the web100 log files and saving those values.
type SnapLog ¶
type SnapLog struct {
Version string
LogTime uint32
GroupName string
// contains filtered or unexported fields
}
SnapLog encapsulates the raw data and all elements of the header.
func NewSnapLog ¶
NewSnapLog creates a SnapLog from a byte array. Returns error if there are problems.
func (*SnapLog) ChangeIndices ¶
ChangeIndices finds all snapshot indices where the specified field changes value.
func (*SnapLog) ConnectionSpecValues ¶
func (*SnapLog) SliceIntField ¶
about 40 nsec per field.
func (*SnapLog) Snapshot ¶
Snapshot returns the snapshot at index n, or error if n is not a valid index, or data is corrupted.
func (*SnapLog) SnapshotNumBytes ¶
SnapshotNumBytes returns the length of snapshot records, including preamble. Used only for testing.
func (*SnapLog) SnapshotNumFields ¶
SnapshotNumFields returns the total number of snapshot fields. Used only for testing.
func (*SnapLog) ValidateSnapshots ¶
ValidateSnapshots checks whether the first and last snapshots are valid and complete.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot represents a complete snapshot from a snapshot log.
func (*Snapshot) SnapshotDeltas ¶
SnapshotDeltas writes changed values into the provided Saver.
func (*Snapshot) SnapshotValues ¶
SnapshotValues writes all values into the provided Saver.
type Variable ¶
type Variable struct {
Name string // Encoded field name (before conversion to canonicalName)
Offset int // Offset, beyond the BEGIN_SNAP_HEADER
Type varType // Web100 type of the field
Size int // Size, in bytes, of the raw data field.
}
Variable is a representation of a Web100 field specifications, as they appear in snaplog headers.
func NewVariable ¶
NewVariable creates a new variable based on web100 definition string