Documentation ¶
Index ¶
- Constants
- type DB
- func (db *DB) ActionByID(id float64) (a mig.Action, err error)
- func (db *DB) ActionMetaByID(id float64) (a mig.Action, err error)
- func (db *DB) ActiveAgentsByQueue(queueloc string, pointInTime time.Time) (agents []mig.Agent, err error)
- func (db *DB) ActiveAgentsByTarget(target string) (agents []mig.Agent, err error)
- func (db *DB) ActiveInvestigatorsPubKeys() (keys [][]byte, err error)
- func (db *DB) AgentByID(id float64) (agent mig.Agent, err error)
- func (db *DB) AgentByQueueAndPID(queueloc string, pid int) (agent mig.Agent, err error)
- func (db *DB) AgentsActiveSince(pointInTime time.Time) (agents []mig.Agent, err error)
- func (db *DB) AllLoadersFromManifestID(mid float64) (ret []mig.LoaderEntry, err error)
- func (db *DB) Close()
- func (db *DB) CommandByID(id float64) (cmd mig.Command, err error)
- func (db *DB) CommandsByActionID(actionid float64) (commands []mig.Command, err error)
- func (db *DB) CompareLoaderExpectEnv(lid float64) error
- func (db *DB) CountDisappearedEndpoints(pointInTime time.Time) (sum float64, err error)
- func (db *DB) CountDoubleAgents() (sum float64, err error)
- func (db *DB) CountFlappingEndpoints() (sum float64, err error)
- func (db *DB) CountIdleEndpoints() (sum float64, err error)
- func (db *DB) CountNewEndpoints(recent, old time.Time) (sum float64, err error)
- func (db *DB) CountOnlineEndpoints() (sum float64, err error)
- func (db *DB) FinishAction(a mig.Action) (err error)
- func (db *DB) FinishCommand(cmd mig.Command) (err error)
- func (db *DB) GetActionCounters(aid float64) (counters mig.ActionCounters, err error)
- func (db *DB) GetAgentsStats(limit int) (stats []mig.AgentsStats, err error)
- func (db *DB) GetDisappearedEndpoints(oldest time.Time) (queues []string, err error)
- func (db *DB) GetLoaderAuthDetails(prefix string) (lad mig.LoaderAuthDetails, err error)
- func (db *DB) GetLoaderEntryID(key string) (ret float64, err error)
- func (db *DB) GetLoaderFromID(lid float64) (ret mig.LoaderEntry, err error)
- func (db *DB) GetLoaderName(id float64) (ret string, err error)
- func (db *DB) GetManifestFromID(mid float64) (ret mig.ManifestRecord, err error)
- func (db *DB) GetSchedulerInvestigator() (inv mig.Investigator, err error)
- func (db *DB) GetSchedulerPrivKey() (key []byte, err error)
- func (db *DB) InsertAction(a mig.Action) (err error)
- func (db *DB) InsertAgent(agt mig.Agent, useTx *sql.Tx) (err error)
- func (db *DB) InsertCommand(cmd mig.Command, agt mig.Agent) (err error)
- func (db *DB) InsertCommands(cmds []mig.Command) (insertCount int64, err error)
- func (db *DB) InsertInvestigator(inv mig.Investigator) (iid float64, err error)
- func (db *DB) InsertOrUpdateAction(a mig.Action) (inserted bool, err error)
- func (db *DB) InsertSchedulerInvestigator(inv mig.Investigator) (iid float64, err error)
- func (db *DB) InsertSignature(aid, iid float64, sig string) (err error)
- func (db *DB) InvestigatorAPIKeyAuthHelpers() (ret []mig.InvestigatorAPIAuthHelper, err error)
- func (db *DB) InvestigatorByActionID(aid float64) (invs []mig.Investigator, err error)
- func (db *DB) InvestigatorByFingerprint(fp string) (inv mig.Investigator, err error)
- func (db *DB) InvestigatorByID(iid float64) (inv mig.Investigator, err error)
- func (db *DB) LastActions(limit int) (actions []mig.Action, err error)
- func (db *DB) ListMultiAgentsQueues(pointInTime time.Time) (queues []string, err error)
- func (db *DB) LoaderAdd(le mig.LoaderEntry, hashkey []byte, salt []byte) (newle mig.LoaderEntry, err error)
- func (db *DB) LoaderUpdateExpect(lid float64, eenv string) (err error)
- func (db *DB) LoaderUpdateKey(lid float64, hashkey []byte, salt []byte) (err error)
- func (db *DB) LoaderUpdateStatus(lid float64, status bool) (err error)
- func (db *DB) ManifestAdd(mr mig.ManifestRecord) (err error)
- func (db *DB) ManifestAddSignature(mid float64, sig string, invid float64, reqsig int) (err error)
- func (db *DB) ManifestClearSignatures(mid float64) (err error)
- func (db *DB) ManifestDisable(mid float64) (err error)
- func (db *DB) ManifestIDFromLoaderID(lid float64) (ret float64, err error)
- func (db *DB) ManifestUpdateStatus(mid float64, reqsig int) (err error)
- func (db *DB) MarkAgentDestroyed(agent mig.Agent) (err error)
- func (db *DB) MarkIdleAgents(pointInTime time.Time) (err error)
- func (db *DB) MarkOfflineAgents(pointInTime time.Time) (err error)
- func (db *DB) ReplaceRefreshedAgent(agt mig.Agent) (err error)
- func (db *DB) SearchActions(p search.Parameters) (actions []mig.Action, err error)
- func (db *DB) SearchAgents(p search.Parameters) (agents []mig.Agent, err error)
- func (db *DB) SearchCommands(p search.Parameters, doFoundAnything bool) (commands []mig.Command, err error)
- func (db *DB) SearchInvestigators(p search.Parameters) (investigators []mig.Investigator, err error)
- func (db *DB) SearchLoaders(p search.Parameters) (lrecords []mig.LoaderEntry, err error)
- func (db *DB) SearchManifests(p search.Parameters) (mrecords []mig.ManifestRecord, err error)
- func (db *DB) SetMaxOpenConns(n int)
- func (db *DB) SetupRunnableActions() (actions []mig.Action, err error)
- func (db *DB) StoreAgentsStats(stats mig.AgentsStats) (err error)
- func (db *DB) SumIdleAgentsByVersion() (sum []mig.AgentsVersionsSum, err error)
- func (db *DB) SumOnlineAgentsByVersion() (sum []mig.AgentsVersionsSum, err error)
- func (db *DB) UpdateAction(a mig.Action) (err error)
- func (db *DB) UpdateActionStatus(a mig.Action) (err error)
- func (db *DB) UpdateAgentHeartbeat(agt mig.Agent) (err error)
- func (db *DB) UpdateInvestigatorAPIKey(inv mig.Investigator, key []byte, salt []byte) (err error)
- func (db *DB) UpdateInvestigatorPerms(inv mig.Investigator) (err error)
- func (db *DB) UpdateInvestigatorStatus(inv mig.Investigator) (err error)
- func (db *DB) UpdateLoaderEntry(lid float64, agt mig.Agent) (err error)
- func (db *DB) UpdateRunningAction(a mig.Action) (err error)
- func (db *DB) UpdateSentCommand(cmd mig.Command) (err error)
- type IDs
Constants ¶
const MAXFLOAT64 float64 = 9007199254740991 // 2^53-1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) ActionByID ¶
ActionByID retrieves an action from the database using its ID If the query fails, the returned action will have ID -1
func (*DB) ActionMetaByID ¶
ActionMetaByID retrieves the metadata fields of an action from the database using its ID
func (*DB) ActiveAgentsByQueue ¶
func (db *DB) ActiveAgentsByQueue(queueloc string, pointInTime time.Time) (agents []mig.Agent, err error)
ActiveAgentsByQueue retrieves an array of agents identified by their QueueLoc value
func (*DB) ActiveAgentsByTarget ¶
ActiveAgentsByTarget runs a search for all agents that match a given target string. For safety, it does so in a transaction that runs as a readonly user.
func (*DB) ActiveInvestigatorsPubKeys ¶
ActiveInvestigators returns a slice of investigators keys marked as active
func (*DB) AgentByQueueAndPID ¶
AgentByQueueAndPID returns a single agent that is located at a given queueloc and has a given PID
func (*DB) AgentsActiveSince ¶
AgentsActiveSince returns an array of Agents that have sent a heartbeat between a point in time and now
func (*DB) AllLoadersFromManifestID ¶
func (db *DB) AllLoadersFromManifestID(mid float64) (ret []mig.LoaderEntry, err error)
Return all the loader entries that match the targeting string for manifest mid
func (*DB) CommandByID ¶
CommandByID retrieves a command from the database using its ID
func (*DB) CommandsByActionID ¶
func (*DB) CompareLoaderExpectEnv ¶
If any expected environment has been set on a loader entry, this function validates the environment submitted by the loader matches that expected query string; returns an error if not
func (*DB) CountDisappearedEndpoints ¶
CountDisappearedEndpoints a count of endpoints that have disappeared over a given period
func (*DB) CountDoubleAgents ¶
CountDoubleAgents counts the number of endpoints that run more than one agent
func (*DB) CountFlappingEndpoints ¶
CountFlappingEndpoints a count of endpoints that have restarted their agent recently
func (*DB) CountIdleEndpoints ¶
CountIdleEndpoints retrieves a count of unique endpoints that have idle agents and do not have an online agent
func (*DB) CountNewEndpoints ¶
CountNewEndpointsretrieves a count of new endpoints that started after `pointInTime`
func (*DB) CountOnlineEndpoints ¶
CountOnlineEndpoints retrieves a count of unique endpoints that have online agents
func (*DB) FinishAction ¶
FinishAction updates the action fields to mark it as done
func (*DB) FinishCommand ¶
FinishCommand updates a command into the database unless its status is already set to 'success'. If the status has already been set to "success" (maybe by a concurrent scheduler), do not update further. this prevents scheduler A from expiring a command that has already succeeded and been returned to scheduler B.
func (*DB) GetActionCounters ¶
func (db *DB) GetActionCounters(aid float64) (counters mig.ActionCounters, err error)
func (*DB) GetAgentsStats ¶
func (db *DB) GetAgentsStats(limit int) (stats []mig.AgentsStats, err error)
GetAgentsStats retrieves the latest agents statistics. limit controls how many rows of statistics are returned
func (*DB) GetDisappearedEndpoints ¶
GetDisappearedEndpoints retrieves a list of queues from endpoints that are no longer active
func (*DB) GetLoaderAuthDetails ¶
func (db *DB) GetLoaderAuthDetails(prefix string) (lad mig.LoaderAuthDetails, err error)
Return a loader ID and hashed key given a prefix string
func (*DB) GetLoaderEntryID ¶
Return a loader entry ID given a loader key
func (*DB) GetLoaderFromID ¶
func (db *DB) GetLoaderFromID(lid float64) (ret mig.LoaderEntry, err error)
Return a loader entry given an ID
func (*DB) GetLoaderName ¶
Return a loader name given an ID
func (*DB) GetManifestFromID ¶
func (db *DB) GetManifestFromID(mid float64) (ret mig.ManifestRecord, err error)
Return the entire contents of manifest ID mid from the database
func (*DB) GetSchedulerInvestigator ¶
func (db *DB) GetSchedulerInvestigator() (inv mig.Investigator, err error)
GetSchedulerInvestigator returns the first active scheduler investigator
func (*DB) GetSchedulerPrivKey ¶
GetSchedulerPrivKey returns the first active private key found for user migscheduler
func (*DB) InsertAction ¶
InsertAction writes an action into the database.
func (*DB) InsertAgent ¶
InsertAgent creates a new agent in the database
If useTx is not nil, the transaction will be used instead of the standard connection
func (*DB) InsertCommand ¶
InsertCommand writes a command into the database
func (*DB) InsertCommands ¶
InsertCommands writes an array of commands into the database
func (*DB) InsertInvestigator ¶
func (db *DB) InsertInvestigator(inv mig.Investigator) (iid float64, err error)
InsertInvestigator creates a new investigator in the database and returns its ID, or an error if the insertion failed, or if the investigator already exists
func (*DB) InsertOrUpdateAction ¶
InsertOrUpdateAction looks for an existing action in DB and update it, or insert a new one if none is found
func (*DB) InsertSchedulerInvestigator ¶
func (db *DB) InsertSchedulerInvestigator(inv mig.Investigator) (iid float64, err error)
InsertSchedulerInvestigator creates a new migscheduler investigator in the database and returns its ID, or an error if the insertion failed, or if the investigator already exists
func (*DB) InsertSignature ¶
InsertSignature create an entry in the signatures tables that map an investigator to an action and a signature
func (*DB) InvestigatorAPIKeyAuthHelpers ¶
func (db *DB) InvestigatorAPIKeyAuthHelpers() (ret []mig.InvestigatorAPIAuthHelper, err error)
Returns a set of InvestigatorAPIAuthHelper structs that the API can utilize to authorize requests containing the X-MIGAPIKEY header
func (*DB) InvestigatorByActionID ¶
func (db *DB) InvestigatorByActionID(aid float64) (invs []mig.Investigator, err error)
InvestigatorByActionID returns the list of investigators that signed a given action
func (*DB) InvestigatorByFingerprint ¶
func (db *DB) InvestigatorByFingerprint(fp string) (inv mig.Investigator, err error)
InvestigatorByFingerprint searches the database for an investigator that has a given fingerprint
func (*DB) InvestigatorByID ¶
func (db *DB) InvestigatorByID(iid float64) (inv mig.Investigator, err error)
InvestigatorByID searches the database for an investigator with a given ID
func (*DB) LastActions ¶
LastActions retrieves the last X actions by time from the database
func (*DB) ListMultiAgentsQueues ¶
ListMultiAgentsQueues retrieves an array of queues that have more than one active agent
func (*DB) LoaderAdd ¶
func (db *DB) LoaderAdd(le mig.LoaderEntry, hashkey []byte, salt []byte) (newle mig.LoaderEntry, err error)
Add a new loader entry to the database; the hashed loader key should be provided as hashkey
func (*DB) LoaderUpdateExpect ¶
Update loader expect fields
func (*DB) LoaderUpdateKey ¶
Change loader key, hashkey should be the hashed version of the key component
func (*DB) LoaderUpdateStatus ¶
Enable or disable a loader entry in the database
func (*DB) ManifestAdd ¶
func (db *DB) ManifestAdd(mr mig.ManifestRecord) (err error)
Add a new manifest record to the database
func (*DB) ManifestAddSignature ¶
Add a signature to the database for an existing manifest
func (*DB) ManifestClearSignatures ¶
Clear existing signatures for a manifest record
func (*DB) ManifestDisable ¶
Disable a manifest record
func (*DB) ManifestIDFromLoaderID ¶
Given a loader ID, identify which manifest is applicable to return to this loader in a manifest request
func (*DB) ManifestUpdateStatus ¶
Update the status of a manifest based on the number of signatures it has, reqsig is passed as an argument that indicates the number of signatures a manifest must have to be considered active
func (*DB) MarkAgentDestroyed ¶
MarkAgentDestroyed updated the status and destructiontime of an agent in the database
func (*DB) MarkIdleAgents ¶
MarkIdleAgents updates the status of online agents that have not sent a heartbeat since pointInTime
func (*DB) MarkOfflineAgents ¶
MarkOfflineAgents updates the status of idle agents that have not sent a heartbeat since pointInTime
func (*DB) ReplaceRefreshedAgent ¶
Replace an existing agent in the database with newer environment information. This should be called when we receive a heartbeat for an active agent, but the refresh time indicates newer environment information exists.
func (*DB) SearchActions ¶
SearchActions returns an array of actions that match search parameters
func (*DB) SearchAgents ¶
SearchAgents returns an array of agents that match search parameters
func (*DB) SearchCommands ¶
func (db *DB) SearchCommands(p search.Parameters, doFoundAnything bool) (commands []mig.Command, err error)
SearchCommands returns an array of commands that match search parameters
func (*DB) SearchInvestigators ¶
func (db *DB) SearchInvestigators(p search.Parameters) (investigators []mig.Investigator, err error)
SearchInvestigators returns an array of investigators that match search parameters
func (*DB) SearchLoaders ¶
func (db *DB) SearchLoaders(p search.Parameters) (lrecords []mig.LoaderEntry, err error)
func (*DB) SearchManifests ¶
func (db *DB) SearchManifests(p search.Parameters) (mrecords []mig.ManifestRecord, err error)
func (*DB) SetMaxOpenConns ¶
func (*DB) SetupRunnableActions ¶
SetupRunnableActions retrieves actions that are ready to run. This function is designed to run concurrently across multiple schedulers, by update the status of the action at the same time as retrieving it. It returns an array of actions rady to be run.
func (*DB) StoreAgentsStats ¶
func (db *DB) StoreAgentsStats(stats mig.AgentsStats) (err error)
StoreAgentsStats store a new row of agents statistics and sets the timestamp to the current time
func (*DB) SumIdleAgentsByVersion ¶
func (db *DB) SumIdleAgentsByVersion() (sum []mig.AgentsVersionsSum, err error)
SumIdleAgentsByVersion retrieves a sum of idle agents grouped by version and excludes endpoints where an online agent is running
func (*DB) SumOnlineAgentsByVersion ¶
func (db *DB) SumOnlineAgentsByVersion() (sum []mig.AgentsVersionsSum, err error)
SumOnlineAgentsByVersion retrieves a sum of online agents grouped by version
func (*DB) UpdateAction ¶
UpdateAction stores updated action fields into the database.
func (*DB) UpdateActionStatus ¶
UpdateActionStatus updates the status of an action
func (*DB) UpdateAgentHeartbeat ¶
UpdateAgentHeartbeat updates the heartbeat timestamp of an agent in the database unless the agent has been marked as destroyed
func (*DB) UpdateInvestigatorAPIKey ¶
UpdateInvestigatorAPIKey enables or disabled a standard API key for an investigator
func (*DB) UpdateInvestigatorPerms ¶
func (db *DB) UpdateInvestigatorPerms(inv mig.Investigator) (err error)
func (*DB) UpdateInvestigatorStatus ¶
func (db *DB) UpdateInvestigatorStatus(inv mig.Investigator) (err error)
UpdateInvestigatorStatus updates the status of an investigator
func (*DB) UpdateLoaderEntry ¶
Update a given loader entry using supplied agent information (e.g., provided during a manifest request by a loader instance
func (*DB) UpdateRunningAction ¶
UpdateRunningAction stores updated time and counters on a running action