Documentation ¶
Overview ¶
Package cmd Code generated by go-bindata. (@generated) DO NOT EDIT. sources: templates/index.html templates/load_log_form.go.html templates/searchpage.go.html
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetFile() http.FileSystem
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func CheckAuthorizedDomain(email string) bool
- func CheckAuthorizedUser(email string) bool
- func CreateHash(key string) string
- func DatabaseMaintenance()
- func DecodeJenkinsConsoleNote(msg string) string
- func DeleteConfig(key string)
- func DoNagiosACK(Host, Service, User, Comment string) int
- func DoNagiosDeleteAllComment(Host, Service string) int
- func DoSQLSearch(q string, o *strings.Builder) (int, error)
- func DoUploadLog(w http.ResponseWriter, r *http.Request)
- func DumpPost(w http.ResponseWriter, r *http.Request)
- func FilterPassword(text string, passPtns []*regexp.Regexp) string
- func GenerateDefaultConfig(opt ...interface{}) (e error)
- func GenerateJWT() (string, error)
- func GetConfig(key ...string) string
- func GetConfigSave(key ...string) string
- func GetDBConn() *sqlite3.Conn
- func GetFormValue(r *http.Request, key ...string) string
- func GetMuxValue(r *http.Request, key ...string) string
- func GetQueryValue(r *http.Request, key ...string) string
- func GetRequestValue(r *http.Request, key ...string) string
- func GetTwilioCall(myCallId string) (string, string)
- func GetUserDataFromGoogle(code string) ([]byte, error)
- func HandleMakeTwilioCall(w http.ResponseWriter, r *http.Request)
- func HandleNagiosDeleteAllComment(w *http.ResponseWriter, r *http.Request)
- func HandleNagiosHostACK(w *http.ResponseWriter, r *http.Request)
- func HandleNagiosServiceACK(w *http.ResponseWriter, r *http.Request)
- func HandlePagerDutyEvent(w http.ResponseWriter, r *http.Request)
- func HandleRequests()
- func HandleSNSEvent(w http.ResponseWriter, r *http.Request)
- func InsertLog(data []byte)
- func IsBasicAuth(endpoint func(http.ResponseWriter, *http.Request), ...) http.Handler
- func IsEOF(filename string, seek int64) bool
- func LoadConfig(fPath string) (e error)
- func LoadTailPosition(tailFileName string, cfg *TailLogConfig) int64
- func LoadTemplate(tFilePath string) string
- func MakeTwilioCall(myCallId, reqAction, Body, From, To, Host, Service, gatherMenuStr string) error
- func MsToTime(ms int64) time.Time
- func MustAsset(name string) []byte
- func NsToTime(ns int64) time.Time
- func OauthGoogleCallback(w http.ResponseWriter, r *http.Request)
- func OauthGoogleLogin(w http.ResponseWriter, r *http.Request)
- func ParseAWSCloudWatchLogEvent(appNameStr string)
- func ParseAlertKey(alertKey string) (string, string, string)
- func ParseTimeAdjust(adjustStr string) string
- func ParseTimeRange(durationStr, tz string) (time.Time, time.Time)
- func ProcessACKEvent(w *http.ResponseWriter, bodyDataByte []byte)
- func ProcessCommand(w http.ResponseWriter, r *http.Request)
- func ProcessLog(w http.ResponseWriter, r *http.Request)
- func ProcessNagiosCommand(w http.ResponseWriter, r *http.Request)
- func ProcessResolvedEvent(w *http.ResponseWriter, bodyDataByte []byte)
- func ProcessSearchLog(w http.ResponseWriter, r *http.Request)
- func ProcessSearchLogByID(w http.ResponseWriter, r *http.Request)
- func ProcessTailLines(cfg *TailLogConfig, tail *tail.Tail)
- func ProcessTwilioCallEvent(w http.ResponseWriter, r *http.Request)
- func ProcessTwilioGatherEvent(w http.ResponseWriter, r *http.Request)
- func ReadUserIP(r *http.Request) string
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func RunCommand(cmdName ...string) string
- func RunNagiosCheckCommand(cmdName string)
- func SaveTailPosition(t *tail.Tail, cfg *TailLogConfig)
- func SearchLog(keyword string, o *strings.Builder, sortorder, duration, tz string) (int, error)
- func SendAWSLogEvents(evts []*cloudwatchlogs.FilteredLogEvent, appNameStr string, timeMark int64, ...) int64
- func SendLine(timeHarvest, timeParsed time.Time, hostStr, appNameStr, logFile, msgStr string) bool
- func SendProcessCommand(w http.ResponseWriter, r *http.Request)
- func SetConfig(key, val string)
- func SetUpLogDatabase()
- func StartAWSCloudwatchLogOnePrefix(logGroupName string, cl *cloudwatchlogs.CloudWatchLogs, ...)
- func StartAWSCloudwatchLogPolling(cfg *AWSLogConfig)
- func StartAllAWSCloudwatchLogPolling(c chan os.Signal)
- func StartServer()
- func TailLog(cfg *TailLogConfig, c chan os.Signal)
- func TailOneGlob(cfg *TailLogConfig, globPtn string, c chan os.Signal)
- func TailOnePath(cfg *TailLogConfig, logFile string, c chan os.Signal)
- func Ternary(cond bool, first, second interface{}) interface{}
- func TestTailLog(cfg tail.Config, logFile string)
- type AWSLogConfig
- type AppConfig
- type Command
- type LogData
- type LogFile
- type TailLogConfig
Constants ¶
const ( TimeISO8601LayOut = "2006-01-02T15:04:05-0700" AUTimeLayout = "02/01/2006 15:04:05 MST" )
TimeISO8601LayOut
const ( MillisPerSecond = int64(time.Second / time.Millisecond) NanosPerMillisecond = int64(time.Millisecond / time.Nanosecond) NanosPerSecond = int64(time.Second / time.Nanosecond) )
Time handling
const MaxUploadSize = 4 * 1024 * 1024 * 1024
const MaxUploadSizeInMemory = 4 * 1024 * 1024 // 4 MB
const OauthGoogleUrlAPI = "https://www.googleapis.com/oauth2/v2/userinfo?access_token="
const Version = "79f27a5"
Variables ¶
var CurrentYear, CurrentZone string
CurrentYear - CurrentZone - Used for timeadjust
var GoogleOauthConfig oauth2.Config
Scopes: OAuth 2.0 scopes provide a way to limit the amount of access that is granted to an access token.
var JenkinsLogDataPattern *regexp.Regexp
var PasswordFilterPtns []*regexp.Regexp
var ServerProtocol string
ServerProtocol -
var SessionStore *sessions.CookieStore
SessionStore -
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 AssetFile ¶
func AssetFile() http.FileSystem
AssetFile return a http.FileSystem instance that data backend by asset
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 DatabaseMaintenance ¶
func DatabaseMaintenance()
DatabaseMaintenance - all maintenance routine spawn off from here. Currently just delete the records older than the retention period to keep disk space usage managable. User can always use the sqlite command to export data into csv format and save it somewhere.
func DecodeJenkinsConsoleNote ¶
DecodeJenkinsConsoleNote - See https://github.com/LarrysGIT/Extract-Jenkins-Raw-Log/blob/master/README.md. Testing
func DoNagiosACK ¶
func DoSQLSearch ¶
DoSQLSearch - Execute the search in the database. Return the record counts and fill the string builder object.
func DoUploadLog ¶
func DoUploadLog(w http.ResponseWriter, r *http.Request)
Present a simple form to allow user to create a log entry. Or upload a text file and parse log
func FilterPassword ¶
FilterPassword -
func GenerateDefaultConfig ¶
func GenerateDefaultConfig(opt ...interface{}) (e error)
GenerateDefaultConfig -
func GenerateJWT ¶
func GetRequestValue ¶
GetRequestValue - Attempt to get a val by key from the request in all cases. First from the mux variables in the route path such as /dosomething/{var1}/{var2} Then check the query string values such as /dosomething?var1=x&var2=y Then check the form values if any Then check the default value if supplied to use as return value For performance we split each type into each function so it can be called independantly
func GetTwilioCall ¶
GetTwilioCall - Get call info from the trace of events log. We utilize the field logfile to add the nagios host and service info for the Gather Action or anything later on to use.
func GetUserDataFromGoogle ¶
GetUserDataFromGoogle -
func HandleMakeTwilioCall ¶
func HandleMakeTwilioCall(w http.ResponseWriter, r *http.Request)
func HandleNagiosDeleteAllComment ¶
func HandleNagiosDeleteAllComment(w *http.ResponseWriter, r *http.Request)
func HandleNagiosHostACK ¶
func HandleNagiosHostACK(w *http.ResponseWriter, r *http.Request)
func HandleNagiosServiceACK ¶
func HandleNagiosServiceACK(w *http.ResponseWriter, r *http.Request)
func HandlePagerDutyEvent ¶
func HandlePagerDutyEvent(w http.ResponseWriter, r *http.Request)
func HandleSNSEvent ¶
func HandleSNSEvent(w http.ResponseWriter, r *http.Request)
HandleSNSEvent - From/To/action
func IsBasicAuth ¶
func LoadConfig ¶
LoadConfig - Load all config/global regex pattern required
func LoadTailPosition ¶
func LoadTailPosition(tailFileName string, cfg *TailLogConfig) int64
LoadTailPosition -
func LoadTemplate ¶
LoadTemplate - Run this command to create the bindata.go go-bindata -fs -pkg cmd -o cmd/bindata.go -nomemcopy templates go get -u github.com/go-bindata/go-bindata/...
func MakeTwilioCall ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func OauthGoogleCallback ¶
func OauthGoogleCallback(w http.ResponseWriter, r *http.Request)
OauthGoogleCallback -
func OauthGoogleLogin ¶
func OauthGoogleLogin(w http.ResponseWriter, r *http.Request)
OauthGoogleLogin -
func ParseAWSCloudWatchLogEvent ¶
func ParseAWSCloudWatchLogEvent(appNameStr string)
ParseAWSCloudWatchLogEvent - Input from os.stdin as a json string with the format describe in aws cloudwatch logevent. It is the output of command such as aws logs get-log-events --log-group-name /aws/ecs/int --log-stream-name errcd-wa-int/errcd-wa-task/1bd0169e-2013-4964-96fa-8c18819ffa62 --profile errcd_wa --region ap-southeast-2 We parse it and ship it to out log server.
func ParseTimeAdjust ¶
ParseTimeAdjust - take a timeadjust and parse its meaning. Use the go time formatting eg. if it hits '2006' then it will replace it with current year. Similar. If string is not any of the go date layout then it is pass though as is. There are 5 tokens: Jan 02 15:04:05 2006 MST that we support
func ParseTimeRange ¶
ParseTimeRange - return a time range start/end based on now back to the Duration.
func ProcessACKEvent ¶
func ProcessACKEvent(w *http.ResponseWriter, bodyDataByte []byte)
func ProcessCommand ¶
func ProcessCommand(w http.ResponseWriter, r *http.Request)
func ProcessLog ¶
func ProcessLog(w http.ResponseWriter, r *http.Request)
func ProcessNagiosCommand ¶
func ProcessNagiosCommand(w http.ResponseWriter, r *http.Request)
ProcessNagiosCommand - entry point taken for /nagios/{command}. We will route each command to the real handler
func ProcessResolvedEvent ¶
func ProcessResolvedEvent(w *http.ResponseWriter, bodyDataByte []byte)
func ProcessSearchLog ¶
func ProcessSearchLog(w http.ResponseWriter, r *http.Request)
ProcessSearchLog -
func ProcessSearchLogByID ¶
func ProcessSearchLogByID(w http.ResponseWriter, r *http.Request)
ProcessSearchLogByID - Take an ID and search for record surrounding including the current rec with time span of 10 minutes
func ProcessTailLines ¶
func ProcessTailLines(cfg *TailLogConfig, tail *tail.Tail)
ProcessTailLines -
func ProcessTwilioCallEvent ¶
func ProcessTwilioCallEvent(w http.ResponseWriter, r *http.Request)
func ProcessTwilioGatherEvent ¶
func ProcessTwilioGatherEvent(w http.ResponseWriter, r *http.Request)
func ReadUserIP ¶
ReadUserIP - parse the userIP:port from the request
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func RunNagiosCheckCommand ¶
func RunNagiosCheckCommand(cmdName string)
RunNagiosCheckCommand - This will return based on nagios plugin specs
func SendAWSLogEvents ¶
func SendAWSLogEvents(evts []*cloudwatchlogs.FilteredLogEvent, appNameStr string, timeMark int64, conn *sqlite3.Conn) int64
SendAWSLogEvents - Store the last End time in the event list
func SendProcessCommand ¶
func SendProcessCommand(w http.ResponseWriter, r *http.Request)
func StartAWSCloudwatchLogOnePrefix ¶
func StartAWSCloudwatchLogOnePrefix(logGroupName string, cl *cloudwatchlogs.CloudWatchLogs, filterEvtInput cloudwatchlogs.FilterLogEventsInput, sleepDuration time.Duration)
StartAWSCloudwatchLogOnePrefix -
func StartAWSCloudwatchLogPolling ¶
func StartAWSCloudwatchLogPolling(cfg *AWSLogConfig)
StartAWSCloudwatchLogPolling -
func TailOneGlob ¶
func TailOneGlob(cfg *TailLogConfig, globPtn string, c chan os.Signal)
TailOneGlob -
func TailOnePath ¶
func TailOnePath(cfg *TailLogConfig, logFile string, c chan os.Signal)
TailOnePath -
Types ¶
type AWSLogConfig ¶
type AWSLogConfig struct { LoggroupName string StreamPrefix []string FilterPtn string Profile string Region string Period string }
AWSLogConfig -
type AppConfig ¶
type AppConfig struct { Serverdomain string Port int //Server mode - Port to listen for web gui, log harvesting and Command executor Commands []Command JwtKey string Logfiles []LogFile Serverurl string //Client mode - URL to ship log to or to send command to be executed Logdbpath string Dbtimeout string Sslcert string Sslkey string PasswordFilterPatterns []string `yaml:"passwordfilterpatterns"` AppGoogleClientID string AppGoogleClientSecret string Sessionkey string AuthorizedDomain map[string]bool AWSLogs []AWSLogConfig IgnoreCertificateCheck bool LogRetention string LetsEncryptEnabled bool LetsEncryptEmail string }
AppConfig -
var Config AppConfig
Config - Global
type LogData ¶
type LogData struct { Timestamp int64 Datelog int64 Host string Application string Logfile string Message string }
LogData -
func SaveDumpData ¶
For debugging purposes only. The endpoint handler can temporary call this to examine the data structure
type LogFile ¶
type LogFile struct { Name string //Must be unique within a host running this app. Used to save the tail pos Paths []string Timelayout string //Parse the match below into go time object Timepattern string //extract the timestamp part into a timeStr which is fed into the Timelayout Timeadjust string //If the time extracted string miss some info (like year or zone etc) this string will be appended to the string. If it contains a golang timelayout token with one extra space at the end of the string (eg. '2004 ') then these token will be parsed as the current for example year. Timestrreplace []string //Do search/replace the capture before parse time. As go does not support , aas sec fraction this is to work around for this case. Pattern string //will be matched to extract the HOSTNAME APP-NAME MSG part of the line. Multilineptn string //detect if the line is part of the previous line Excludepatterns []string //If log line match this pattern it will be excluded Includepatterns []string Appname string //Overrite the appname of the logfile if not empty }
LogFile -