datastore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package datastore : データ保存

Package datastore : データ保存

Package datastore : データ保存

Index

Constants

View Source
const (
	// MaxDispLog : ログの検索結果の最大値
	MaxDispLog = 20000
	// MaxDelLog : ログ削除処理の最大削除数
	MaxDelLog = 500000
)
View Source
const (
	LogModeNone = iota
	LogModeAlways
	LogModeOnChange
	LogModeAI
)

Variables

View Source
var (

	// Conf Data on Memory
	MapConf      MapConfEnt
	NotifyConf   NotifyConfEnt
	InfluxdbConf InfluxdbConfEnt
	DiscoverConf DiscoverConfEnt
	Backup       DBBackupEnt
	DBStats      DBStatsEnt
	DBStatsLog   []DBStatsLogEnt
	Yasumi       string

	//
	MIBDB *gomibdb.MIBDB
)
View Source
var (
	ErrNoPayload     = fmt.Errorf("no payload")
	ErrInvalidNode   = fmt.Errorf("invalid node")
	ErrInvalidParams = fmt.Errorf("invald params")
	ErrDBNotOpen     = fmt.Errorf("db not open")
	ErrInvalidID     = fmt.Errorf("invalid id")
)

Define errors

View Source
var MIBTree = []*MIBTreeEnt{}

Functions

func AddDevice

func AddDevice(d *DeviceEnt)

func AddEventLog

func AddEventLog(e *EventLogEnt)

func AddFlow

func AddFlow(f *FlowEnt)

func AddLine

func AddLine(l *LineEnt) error

func AddNode

func AddNode(n *NodeEnt) error

func AddPolling

func AddPolling(p *PollingEnt) error

AddPolling : ポーリングを追加する

func AddPollingLog

func AddPollingLog(p *PollingEnt) error

func AddServer

func AddServer(s *ServerEnt)

func AddUser

func AddUser(u *UserEnt)

func CheckDBBackup

func CheckDBBackup()

func ClearAllReport

func ClearAllReport() error

func ClearPollingLog

func ClearPollingLog(pollingID string) error

func CloseDataStore

func CloseDataStore()

CloseDataStore : DBをクローズする

func DeleteAIResult

func DeleteAIResult(id string) error

func DeleteAllLogs

func DeleteAllLogs()

func DeleteArp

func DeleteArp()

func DeleteDevice

func DeleteDevice(id string)

func DeleteFlow

func DeleteFlow(id string)

func DeleteGeoIP

func DeleteGeoIP()

DeleteGeoIP : GeoIP DBを削除する

func DeleteGrokEnt

func DeleteGrokEnt(id string) error

func DeleteLine

func DeleteLine(lineID string) error

func DeleteNode

func DeleteNode(nodeID string) error

func DeleteNodeStateChanged

func DeleteNodeStateChanged(id string)

func DeletePolling

func DeletePolling(pollingID string) error

func DeleteReport

func DeleteReport(report, id string) error

func DeleteServer

func DeleteServer(id string)

func DeleteUser

func DeleteUser(id string)

func FindVendor

func FindVendor(mac string) string

FindVendor : Find Vendor Name from MAC Address

func ForEachArp

func ForEachArp(f func(*ArpEnt) bool) error

func ForEachDevices

func ForEachDevices(f func(*DeviceEnt) bool)

func ForEachEventLog

func ForEachEventLog(st, et int64, f func(*EventLogEnt) bool) error

func ForEachFlows

func ForEachFlows(f func(*FlowEnt) bool)

func ForEachGrokEnt

func ForEachGrokEnt(f func(*GrokEnt) bool)

func ForEachLastEventLog

func ForEachLastEventLog(skey string, f func(*EventLogEnt) bool) error

func ForEachLines

func ForEachLines(f func(*LineEnt) bool)

ForEachLines : Line毎の処理

func ForEachLog

func ForEachLog(st, et int64, t string, f func(*LogEnt) bool) error

func ForEachNodes

func ForEachNodes(f func(*NodeEnt) bool)

func ForEachPollingLog

func ForEachPollingLog(st, et int64, pollingID string, f func(*PollingLogEnt) bool) error

func ForEachPollingTemplate

func ForEachPollingTemplate(f func(*PollingTemplateEnt) bool)

func ForEachPollings

func ForEachPollings(f func(*PollingEnt) bool)

ForEachPollings : ポーリング毎の処理

func ForEachServers

func ForEachServers(f func(*ServerEnt) bool)

func ForEachStateChangedNodes

func ForEachStateChangedNodes(f func(string) bool)

func ForEachUsers

func ForEachUsers(f func(*UserEnt) bool)

func GetBackImage

func GetBackImage() ([]byte, error)

func GetCipherSuiteName

func GetCipherSuiteName(id string) (string, bool)

func GetLoc

func GetLoc(sip string) string

func GetPrivateKey

func GetPrivateKey() string

func GetServiceName

func GetServiceName(prot, port int) (string, bool)

func Init

func Init(ctx context.Context, path string, fs http.FileSystem) error

func InitInfluxdb

func InitInfluxdb() error

func IsGlobalUnicast

func IsGlobalUnicast(ips string) bool

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

func LaodReportConf

func LaodReportConf() error

LaodReportConf :

func LoadReport

func LoadReport() error

func ResetArpTable

func ResetArpTable() error

func SaveAIResult

func SaveAIResult(res *AIResult) error

func SaveBackImage

func SaveBackImage(img []byte) error

func SaveBackup

func SaveBackup() error

func SaveDiscoverConf

func SaveDiscoverConf() error

func SaveInfluxdbConf

func SaveInfluxdbConf() error

func SaveLogBuffer

func SaveLogBuffer(logBuffer []*LogEnt)

func SaveMapConf

func SaveMapConf() error

func SaveNotifyConf

func SaveNotifyConf() error

func SaveReport

func SaveReport(last int64) error

func SaveReportConf

func SaveReportConf() error

func SendAIScoreToInfluxdb

func SendAIScoreToInfluxdb(pe *PollingEnt, res *AIResult) error

func SendPollingLogToInfluxdb

func SendPollingLogToInfluxdb(pe *PollingEnt) error

func SetNodeStateChanged

func SetNodeStateChanged(id string)

SetNodeStateChanged :

func UpdateArpEnt

func UpdateArpEnt(ip, mac string) error

func UpdateDBStats

func UpdateDBStats()

func UpdateGeoIP

func UpdateGeoIP(path string) error

UpdateGeoIP : GeoIP DBを更新する

func UpdateGrokEnt

func UpdateGrokEnt(g *GrokEnt) error

UpdateGrokEnt : Add or Replace GrokEnt

func UpdateLine

func UpdateLine(l *LineEnt) error

func UpdateNode

func UpdateNode(n *NodeEnt) error

func UpdatePolling

func UpdatePolling(p *PollingEnt) error

Types

type AIResult

type AIResult struct {
	PollingID string
	LastTime  int64
	ScoreData [][]float64
}

func GetAIReesult

func GetAIReesult(id string) (*AIResult, error)

type ArpEnt

type ArpEnt struct {
	IP  string
	MAC string
}

type DBBackupEnt

type DBBackupEnt struct {
	Mode       string
	ConfigOnly bool
	Generation int
}

type DBStatsEnt

type DBStatsEnt struct {
	Time       int64
	Duration   float64
	Size       int64
	TotalWrite int64
	Write      int64
	PeakWrite  int64
	Speed      float64
	AvgSpeed   float64
	PeakSpeed  float64
	BackupTime int64
}

type DBStatsLogEnt

type DBStatsLogEnt struct {
	Time  int64
	Size  int64
	Speed float64
}

type DeviceEnt

type DeviceEnt struct {
	ID         string // MAC Addr
	Name       string
	IP         string
	NodeID     string
	Vendor     string
	Score      float64
	ValidScore bool
	Penalty    int64
	FirstTime  int64
	LastTime   int64
	UpdateTime int64
}

func GetDevice

func GetDevice(id string) *DeviceEnt

type DiscoverConfEnt

type DiscoverConfEnt struct {
	StartIP         string
	EndIP           string
	AutoAddPollings []string
	Timeout         int
	Retry           int
	X               int
	Y               int
}

type EventLogEnt

type EventLogEnt struct {
	Time     int64 // UnixNano()
	Type     string
	Level    string
	NodeName string
	NodeID   string
	Event    string
}

type FlowEnt

type FlowEnt struct {
	ID           string // ID Client:Server
	Client       string
	Server       string
	Services     map[string]int64
	Count        int64
	Bytes        int64
	ClientName   string
	ClientNodeID string
	ClientLoc    string
	ServerName   string
	ServerNodeID string
	ServerLoc    string
	Score        float64
	ValidScore   bool
	Penalty      int64
	FirstTime    int64
	LastTime     int64
	UpdateTime   int64
}

func GetFlow

func GetFlow(id string) *FlowEnt

type GrokEnt

type GrokEnt struct {
	ID    string
	Name  string
	Descr string
	Pat   string
	Ok    string
}

func GetGrokEnt

func GetGrokEnt(id string) *GrokEnt

type InfluxdbConfEnt

type InfluxdbConfEnt struct {
	URL        string
	User       string
	Password   string
	DB         string
	Duration   string
	PollingLog string
	AIScore    string
}

type LineEnt

type LineEnt struct {
	ID         string
	NodeID1    string
	PollingID1 string
	State1     string
	NodeID2    string
	PollingID2 string
	State2     string
}

func GetLine

func GetLine(lineID string) *LineEnt

type LogEnt

type LogEnt struct {
	Time int64 // UnixNano()
	Type string
	Log  string
}

type LogFilterEnt

type LogFilterEnt struct {
	StartTime string
	EndTime   string
	Filter    string
	LogType   string
}

type MIBTreeEnt

type MIBTreeEnt struct {
	OID      string        `json:"oid"`
	Name     string        `json:"name"`
	Children []*MIBTreeEnt `json:"children"`
}

type MapConfEnt

type MapConfEnt struct {
	MapName      string
	BackImage    backImage
	UserID       string
	Password     string
	PollInt      int
	Timeout      int
	Retry        int
	LogDays      int
	LogDispSize  int
	SnmpMode     string
	Community    string
	SnmpUser     string
	SnmpPassword string
	PublicKey    string
	PrivateKey   string
	//	TLSCert        string
	EnableSyslogd  bool
	EnableTrapd    bool
	EnableNetflowd bool
	EnableArpWatch bool
	AILevel        string
	AIThreshold    int
	GeoIPInfo      string
}

MapConfEnt : マップ設定

type NodeEnt

type NodeEnt struct {
	ID        string
	Name      string
	Descr     string
	Icon      string
	State     string
	X         int
	Y         int
	IP        string
	MAC       string
	SnmpMode  string
	Community string
	User      string
	Password  string
	PublicKey string
	URL       string
	Type      string
	AddrMode  string
}

func FindNodeFromIP

func FindNodeFromIP(ip string) *NodeEnt

func FindNodeFromMAC

func FindNodeFromMAC(mac string) *NodeEnt

func GetNode

func GetNode(nodeID string) *NodeEnt

type NotifyConfEnt

type NotifyConfEnt struct {
	MailServer         string
	User               string
	Password           string
	InsecureSkipVerify bool
	MailTo             string
	MailFrom           string
	Subject            string
	Interval           int
	Level              string
	Report             bool
	CheckUpdate        bool
	NotifyRepair       bool
}

type PollingEnt

type PollingEnt struct {
	ID        string
	Name      string
	NodeID    string
	Type      string
	Mode      string
	Params    string
	Filter    string
	Extractor string
	Script    string
	Level     string
	PollInt   int
	Timeout   int
	Retry     int
	LogMode   int
	NextTime  int64
	LastTime  int64
	Result    map[string]interface{}
	State     string
}

func GetPolling

func GetPolling(id string) *PollingEnt

GetPolling : ポーリングを取得する

type PollingLogEnt

type PollingLogEnt struct {
	Time      int64 // UnixNano()
	PollingID string
	State     string
	Result    map[string]interface{}
}

func GetAllPollingLog

func GetAllPollingLog(pollingID string) []PollingLogEnt

GetAllPollingLog :全てのポーリングログを取得する

type PollingTemplateEnt

type PollingTemplateEnt struct {
	ID        string
	Name      string
	Level     string
	Type      string
	Mode      string
	Params    string
	Filter    string
	Extractor string
	Script    string
	Descr     string
	AutoMode  string
}

func GetPollingTemplate

func GetPollingTemplate(id string) *PollingTemplateEnt

type ReportConfEnt

type ReportConfEnt struct {
	DenyCountries        []string
	DenyServices         []string
	AllowDNS             string
	AllowDHCP            string
	AllowMail            string
	AllowLDAP            string
	AllowLocalIP         string
	JapanOnly            bool
	DropFlowThTCPPacket  int
	RetentionTimeForSafe int
}
var ReportConf ReportConfEnt

type ServerEnt

type ServerEnt struct {
	ID           string //  ID Server
	Server       string
	Services     map[string]int64
	Count        int64
	Bytes        int64
	ServerName   string
	ServerNodeID string
	Loc          string
	Score        float64
	ValidScore   bool
	Penalty      int64
	FirstTime    int64
	LastTime     int64
	UpdateTime   int64
}

func GetServer

func GetServer(id string) *ServerEnt

type UserEnt

type UserEnt struct {
	ID           string // User ID + Server
	UserID       string
	Server       string
	ServerName   string
	ServerNodeID string
	Clients      map[string]int64
	Total        int
	Ok           int
	Score        float64
	ValidScore   bool
	Penalty      int64
	FirstTime    int64
	LastTime     int64
	UpdateTime   int64
}

func GetUser

func GetUser(id string) *UserEnt

Jump to

Keyboard shortcuts

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