mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
renamed label field in message to directory
This commit is contained in:
parent
3368448cd7
commit
23b6b58439
9 changed files with 28 additions and 31 deletions
|
@ -277,7 +277,7 @@ Example JSON for appending a message of type command into the `socket` file
|
|||
```json
|
||||
[
|
||||
{
|
||||
"label":"cli-command-executed-result",
|
||||
"directory":"cli-command-executed-result",
|
||||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
|
@ -293,7 +293,7 @@ To send specify more messages at once do
|
|||
```json
|
||||
[
|
||||
{
|
||||
"label":"cli-command-executed-result",
|
||||
"directory":"cli-command-executed-result",
|
||||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
|
@ -302,7 +302,7 @@ To send specify more messages at once do
|
|||
"methodTimeout": 4
|
||||
},
|
||||
{
|
||||
"label":"cli-command-executed-result",
|
||||
"directory":"cli-command-executed-result",
|
||||
"toNode": "ship2",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
|
@ -318,7 +318,7 @@ To send a message with custom timeout and amount of retries
|
|||
```json
|
||||
[
|
||||
{
|
||||
"label":"opcommand_logs",
|
||||
"directory":"opcommand_logs",
|
||||
"toNode": "ship1",
|
||||
"data": ["ps"],
|
||||
"method":"REQOpCommand",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"label": "random_text_log",
|
||||
"directory": "random_text_log",
|
||||
"toNode": "central",
|
||||
"data": ["some message sent from a ship for testing\n"],
|
||||
"commandOrEvent":"EventACK",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"label":"cli_command__result",
|
||||
"directory":"cli_command__result",
|
||||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"label":"metrics/network/sniffer",
|
||||
"directory":"metrics/network/sniffer",
|
||||
"toNode": "ship1",
|
||||
"data": ["http://vg.no"],
|
||||
"method":"REQHttpGet",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"label":"opcommand_logs",
|
||||
"directory":"opcommand_logs",
|
||||
"toNode": "ship1",
|
||||
"data": ["ps"],
|
||||
"method":"REQOpCommand",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"label": "ping",
|
||||
"directory": "ping",
|
||||
"toNode": "ship1",
|
||||
"data": [""],
|
||||
"method":"REQPing",
|
||||
|
|
|
@ -11,14 +11,11 @@ import (
|
|||
// --- Message
|
||||
|
||||
type Message struct {
|
||||
// Label is a word without white spaces that can be used to
|
||||
// desribe what kind of service the message is for. For
|
||||
// example syslog, web_log, prometheus_scraper, metrics.
|
||||
// The intentention is that it can be used to add some extra
|
||||
// information that can be used on the subscriber side to for
|
||||
// example create specific folders using the Format name to
|
||||
// logically group data recevied.
|
||||
Label string `json:"label" yaml:"label"`
|
||||
// Directory is a string that can be used to create the
|
||||
//directory structure when saving the result of some method.
|
||||
// For example "syslog","metrics", or "metrics/mysensor"
|
||||
// The type is typically used in the handler of a method.
|
||||
Directory string `json:"directory" yaml:"directory"`
|
||||
// The node to send the message to
|
||||
ToNode node `json:"toNode" yaml:"toNode"`
|
||||
// The Unique ID of the message
|
||||
|
|
10
server.go
10
server.go
|
@ -181,11 +181,11 @@ func createErrorMsgContent(FromNode node, theError error) subjectAndMessage {
|
|||
sam := subjectAndMessage{
|
||||
Subject: newSubject(REQErrorLog, "errorCentral"),
|
||||
Message: Message{
|
||||
Label: "errorLog",
|
||||
ToNode: "errorCentral",
|
||||
FromNode: FromNode,
|
||||
Data: []string{er},
|
||||
Method: REQErrorLog,
|
||||
Directory: "errorLog",
|
||||
ToNode: "errorCentral",
|
||||
FromNode: FromNode,
|
||||
Data: []string{er},
|
||||
Method: REQErrorLog,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -296,13 +296,13 @@ func (m methodREQTextToLogFile) handler(proc process, message Message, node stri
|
|||
// If this was a direct request there are no previous message to take
|
||||
// information from, so we use the one that are in the current mesage.
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.ToNode, message.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Label, string(message.FromNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode))
|
||||
case message.PreviousMessage.ToNode != "":
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.PreviousMessage.ToNode, message.PreviousMessage.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Label, string(message.PreviousMessage.ToNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
case message.PreviousMessage.ToNode == "":
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.FromNode, message.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Label, string(message.PreviousMessage.ToNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
}
|
||||
|
||||
// Check if folder structure exist, if not create it.
|
||||
|
@ -358,15 +358,15 @@ func (m methodREQTextToFile) handler(proc process, message Message, node string)
|
|||
// If this was a direct request there are no previous message to take
|
||||
// information from, so we use the one that are in the current mesage.
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.ToNode, message.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Label, string(message.FromNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode))
|
||||
fmt.Printf(" ** DEBUG1: foldertree: %v\n", folderTree)
|
||||
case message.PreviousMessage.ToNode != "":
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.PreviousMessage.ToNode, message.PreviousMessage.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Label, string(message.PreviousMessage.ToNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fmt.Printf(" ** DEBUG2: foldertree: %v\n", folderTree)
|
||||
case message.PreviousMessage.ToNode == "":
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.FromNode, message.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Label, string(message.PreviousMessage.ToNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fmt.Printf(" ** DEBUG3: foldertree: %v\n", folderTree)
|
||||
}
|
||||
|
||||
|
@ -447,13 +447,13 @@ func (m methodREQErrorLog) handler(proc process, message Message, node string) (
|
|||
// If this was a direct request there are no previous message to take
|
||||
// information from, so we use the one that are in the current mesage.
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.ToNode, message.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Label, string(message.FromNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode))
|
||||
case message.PreviousMessage.ToNode != "":
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.PreviousMessage.ToNode, message.PreviousMessage.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Label, string(message.PreviousMessage.ToNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
case message.PreviousMessage.ToNode == "":
|
||||
fileName = fmt.Sprintf("%v.%v.log", message.FromNode, message.Method)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Label, string(message.PreviousMessage.ToNode))
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
}
|
||||
|
||||
// Check if folder structure exist, if not create it.
|
||||
|
|
Loading…
Reference in a new issue