diff --git a/.DS_Store b/.DS_Store index 81ae35b..76c3154 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index d7c04f9..6bb306b 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ venv # Nix and Nix flake files result result-* + +# Ignore WASM generated files +*.wasm diff --git a/Bindings/Client.go b/Bindings/Client.go index ef88700..ff0127e 100644 --- a/Bindings/Client.go +++ b/Bindings/Client.go @@ -1,3 +1,5 @@ +//go:build cgo + package main import "C" @@ -16,23 +18,23 @@ import ( // --------------------------------- Container Control ---------------------------------------- -//export StartContainer -func StartContainer(IP string) (output *C.char) { - container, err := abstractions.StartContainer(IP) - if err != nil { - return C.CString(err.Error()) - } - return ConvertStructToJSONString(container) -} - -//export RemoveContainer -func RemoveContainer(IP string, ID string) (output *C.char) { - err := abstractions.RemoveContainer(IP, ID) - if err != nil { - return C.CString(err.Error()) - } - return C.CString("Success") -} +////export StartContainer +//func StartContainer(IP string) (output *C.char) { +// container, err := abstractions.StartContainer(IP) +// if err != nil { +// return C.CString(err.Error()) +// } +// return ConvertStructToJSONString(container) +//} +// +////export RemoveContainer +//func RemoveContainer(IP string, ID string) (output *C.char) { +// err := abstractions.RemoveContainer(IP, ID) +// if err != nil { +// return C.CString(err.Error()) +// } +// return C.CString("Success") +//} // --------------------------------- Plugin Control ---------------------------------------- diff --git a/abstractions/base.go b/abstractions/base.go index e32ba6f..106dd2b 100644 --- a/abstractions/base.go +++ b/abstractions/base.go @@ -1,6 +1,5 @@ package abstractions -import "C" import ( "github.com/Akilan1999/p2p-rendering-computation/client" "github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable" @@ -8,7 +7,6 @@ import ( "github.com/Akilan1999/p2p-rendering-computation/config/generate" "github.com/Akilan1999/p2p-rendering-computation/p2p" "github.com/Akilan1999/p2p-rendering-computation/server" - "github.com/Akilan1999/p2p-rendering-computation/server/docker" "github.com/gin-gonic/gin" "os" ) @@ -57,17 +55,17 @@ func MapPort(port string, domainName string, serverAddress string) (response *cl return } -// StartContainer Starts docker container on the remote machine -func StartContainer(IP string) (container *docker.DockerVM, err error) { - container, err = client.StartContainer(IP, 0, false, "", "") - return -} - -// RemoveContainer Removes docker container based on the IP address and ID -// provided -func RemoveContainer(IP string, ID string) error { - return client.RemoveContianer(IP, ID) -} +//// StartContainer Starts docker container on the remote machine +//func StartContainer(IP string) (container *docker.DockerVM, err error) { +// container, err = client.StartContainer(IP, 0, false, "", "") +// return +//} +// +//// RemoveContainer Removes docker container based on the IP address and ID +//// provided +//func RemoveContainer(IP string, ID string) error { +// return client.RemoveContianer(IP, ID) +//} // GetSpecs Get spec information about the remote server func GetSpecs(IP string) (specs *server.SysInfo, err error) { diff --git a/client/GroupTrackContainer.go b/client/GroupTrackContainer.go index 99f8710..47ea224 100644 --- a/client/GroupTrackContainer.go +++ b/client/GroupTrackContainer.go @@ -1,310 +1,301 @@ package client -import ( - "encoding/json" - "errors" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/google/uuid" - "io/ioutil" - "os" -) - // Groups Data Structure type -type Groups struct { - GroupList []*Group `json:"Groups"` -} - -// Group Information about a single group -type Group struct { - ID string `json:"ID"` - TrackContainerList []*TrackContainer `json:"TrackContainer"` - // Sneaky as required only when removing the element - // Set when GetGroup function is called - index int -} - -// CreateGroup Creates a new group to add a set of track containers -func CreateGroup() (*Group, error) { - // Creating variable of type new group - var NewGroup Group - // Generate new UUID for group ID - id := uuid.New() - // Add new group id and prepend with the string "grp" - // The reason this is done is to differentiate between a - // group ID and docker container ID - NewGroup.ID = "grp" + id.String() - // Adding the new group to the - // GroupTrackContainer File - err := NewGroup.AddGroupToFile() - if err != nil { - return nil, err - } - - return &NewGroup, nil -} - -// RemoveGroup Removes group based on the group ID provided -func RemoveGroup(GroupID string) error { - // Read group information from the - //grouptrackcontainer json file - groups, err := ReadGroup() - if err != nil { - return err - } - // Gets Group struct based on group ID - // provided - group, err := GetGroup(GroupID) - if err != nil { - return err - } - // Remove Group struct from the groups variable - groups.GroupList = append(groups.GroupList[:group.index], groups.GroupList[group.index+1:]...) - - // Write new groups to the grouptrackcontainer json file - err = groups.WriteGroup() - if err != nil { - return err - } - - return nil -} - -// AddContainerToGroup Adds container information to the Group based on the Group ID -func AddContainerToGroup(ContainerID string, GroupID string) (*Group, error) { - // Gets container information based on container ID provided - containerInfo, err := GetContainerInformation(ContainerID) - if err != nil { - return nil, err - } - // Gets group information based on the group ID provided - group, err := GetGroup(GroupID) - if err != nil { - return nil, err - } - // Adds container information the group - group.AddContainer(containerInfo) - - // Get Groups information from reading the grouptrackcontainer.json file - groups, err := ReadGroup() - if err != nil { - return nil, err - } - // Updating specific element in the group list with the added container - groups.GroupList[group.index] = group - // Write groups information on the grouptrackcontainer.json file - err = groups.WriteGroup() - if err != nil { - return nil, err - } - - return group, nil -} - -// RemoveContainerGroup Remove Container from the group ID specified -func RemoveContainerGroup(ContainerID string, GroupID string) (*Group, error) { - // Get container information based on container ID provided - containerInfo, err := GetContainerInformation(ContainerID) - if err != nil { - return nil, err - } - // Gets group information based on the group ID provided - group, err := GetGroup(GroupID) - if err != nil { - return nil, err - } - // Remove container from the appropriate group - err = group.RemoveContainerGroup(containerInfo) - if err != nil { - return nil, err - } - // Get Groups information from reading the grouptrackcontainer.json file - groups, err := ReadGroup() - if err != nil { - return nil, err - } - // Updating specific element in the group list with the remove container - groups.GroupList[group.index] = group - // Write groups information on the grouptrackcontainer.json file - err = groups.WriteGroup() - if err != nil { - return nil, err - } - - return group, nil -} - -// RemoveContainerGroups Remove Container from groups (i.e which ever groups has information -// about that container). This is mostly called when a container is deleted or removed from -// the tracked container list -func RemoveContainerGroups(ContainerID string) error { - // Get container information based on container ID provided - containerInfo, err := GetContainerInformation(ContainerID) - if err != nil { - return err - } - // Get Groups information from reading the grouptrackcontainer.json file - groups, err := ReadGroup() - if err != nil { - return err - } - // Removes container information from all groups it is found in - err = groups.RemoveContainerGroups(containerInfo) - if err != nil { - return err - } - // Write groups information on the grouptrackcontainer.json file - err = groups.WriteGroup() - if err != nil { - return err - } - - return nil -} - -// GetGroup Gets group information based on -// group id provided -func GetGroup(GroupID string) (*Group, error) { - // Read group information from the - //grouptrackcontainer json file - groups, err := ReadGroup() - if err != nil { - return nil, err - } - // Iterate through the set of groups and - // if the group ID matches then return it - for i, group := range groups.GroupList { - if group.ID == GroupID { - group.index = i - return group, nil - } - } - - return nil, errors.New("Group not found. ") -} - -// AddGroupToFile Adds Group struct to the GroupTrackContainer File -func (grp *Group) AddGroupToFile() error { - // Gets all group information from the - // GroupTrackContainer JSON file - groups, err := ReadGroup() - if err != nil { - return err - } - // Appending the newly created group - groups.GroupList = append(groups.GroupList, grp) - // Writing Group information to the GroupTrackContainer - // JSON file - err = groups.WriteGroup() - if err != nil { - return err - } - - return nil -} +//type Groups struct { +// GroupList []*Group `json:"Groups"` +//} +// +//// Group Information about a single group +//type Group struct { +// ID string `json:"ID"` +// TrackContainerList []*TrackContainer `json:"TrackContainer"` +// // Sneaky as required only when removing the element +// // Set when GetGroup function is called +// index int +//} +// +//// CreateGroup Creates a new group to add a set of track containers +//func CreateGroup() (*Group, error) { +// // Creating variable of type new group +// var NewGroup Group +// // Generate new UUID for group ID +// id := uuid.New() +// // Add new group id and prepend with the string "grp" +// // The reason this is done is to differentiate between a +// // group ID and docker container ID +// NewGroup.ID = "grp" + id.String() +// // Adding the new group to the +// // GroupTrackContainer File +// err := NewGroup.AddGroupToFile() +// if err != nil { +// return nil, err +// } +// +// return &NewGroup, nil +//} +// +//// RemoveGroup Removes group based on the group ID provided +//func RemoveGroup(GroupID string) error { +// // Read group information from the +// //grouptrackcontainer json file +// groups, err := ReadGroup() +// if err != nil { +// return err +// } +// // Gets Group struct based on group ID +// // provided +// group, err := GetGroup(GroupID) +// if err != nil { +// return err +// } +// // Remove Group struct from the groups variable +// groups.GroupList = append(groups.GroupList[:group.index], groups.GroupList[group.index+1:]...) +// +// // Write new groups to the grouptrackcontainer json file +// err = groups.WriteGroup() +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// AddContainerToGroup Adds container information to the Group based on the Group ID +//func AddContainerToGroup(ContainerID string, GroupID string) (*Group, error) { +// // Gets container information based on container ID provided +// containerInfo, err := GetContainerInformation(ContainerID) +// if err != nil { +// return nil, err +// } +// // Gets group information based on the group ID provided +// group, err := GetGroup(GroupID) +// if err != nil { +// return nil, err +// } +// // Adds container information the group +// group.AddContainer(containerInfo) +// +// // Get Groups information from reading the grouptrackcontainer.json file +// groups, err := ReadGroup() +// if err != nil { +// return nil, err +// } +// // Updating specific element in the group list with the added container +// groups.GroupList[group.index] = group +// // Write groups information on the grouptrackcontainer.json file +// err = groups.WriteGroup() +// if err != nil { +// return nil, err +// } +// +// return group, nil +//} +// +//// RemoveContainerGroup Remove Container from the group ID specified +//func RemoveContainerGroup(ContainerID string, GroupID string) (*Group, error) { +// // Get container information based on container ID provided +// containerInfo, err := GetContainerInformation(ContainerID) +// if err != nil { +// return nil, err +// } +// // Gets group information based on the group ID provided +// group, err := GetGroup(GroupID) +// if err != nil { +// return nil, err +// } +// // Remove container from the appropriate group +// err = group.RemoveContainerGroup(containerInfo) +// if err != nil { +// return nil, err +// } +// // Get Groups information from reading the grouptrackcontainer.json file +// groups, err := ReadGroup() +// if err != nil { +// return nil, err +// } +// // Updating specific element in the group list with the remove container +// groups.GroupList[group.index] = group +// // Write groups information on the grouptrackcontainer.json file +// err = groups.WriteGroup() +// if err != nil { +// return nil, err +// } +// +// return group, nil +//} +// +//// RemoveContainerGroups Remove Container from groups (i.e which ever groups has information +//// about that container). This is mostly called when a container is deleted or removed from +//// the tracked container list +//func RemoveContainerGroups(ContainerID string) error { +// // Get container information based on container ID provided +// containerInfo, err := GetContainerInformation(ContainerID) +// if err != nil { +// return err +// } +// // Get Groups information from reading the grouptrackcontainer.json file +// groups, err := ReadGroup() +// if err != nil { +// return err +// } +// // Removes container information from all groups it is found in +// err = groups.RemoveContainerGroups(containerInfo) +// if err != nil { +// return err +// } +// // Write groups information on the grouptrackcontainer.json file +// err = groups.WriteGroup() +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// GetGroup Gets group information based on +//// group id provided +//func GetGroup(GroupID string) (*Group, error) { +// // Read group information from the +// //grouptrackcontainer json file +// groups, err := ReadGroup() +// if err != nil { +// return nil, err +// } +// // Iterate through the set of groups and +// // if the group ID matches then return it +// for i, group := range groups.GroupList { +// if group.ID == GroupID { +// group.index = i +// return group, nil +// } +// } +// +// return nil, errors.New("Group not found. ") +//} +// +//// AddGroupToFile Adds Group struct to the GroupTrackContainer File +//func (grp *Group) AddGroupToFile() error { +// // Gets all group information from the +// // GroupTrackContainer JSON file +// groups, err := ReadGroup() +// if err != nil { +// return err +// } +// // Appending the newly created group +// groups.GroupList = append(groups.GroupList, grp) +// // Writing Group information to the GroupTrackContainer +// // JSON file +// err = groups.WriteGroup() +// if err != nil { +// return err +// } +// +// return nil +//} // ReadGroup Function reads grouptrackcontainers.json and converts // result to Groups -func ReadGroup() (*Groups, error) { - // Get Path from config - config, err := config.ConfigInit(nil, nil) - if err != nil { - return nil, err - } - jsonFile, err := os.Open(config.GroupTrackContainersPath) - // if we os.Open returns an error then handle it - if err != nil { - return nil, err - } - // defer the closing of our jsonFile so that we can parse it later on - defer jsonFile.Close() - // read our opened xmlFile as a byte array. - byteValue, _ := ioutil.ReadAll(jsonFile) - // we initialize our Users array - var groups Groups - // we unmarshal our byteArray which contains our - // jsonFile's content into 'users' which we defined above - json.Unmarshal(byteValue, &groups) - return &groups, nil -} - -// WriteGroup Function to write type Groups to the grouptrackcontainers.json file -func (grp *Groups) WriteGroup() error { - file, err := json.MarshalIndent(grp, "", " ") - if err != nil { - return err - } - // Get Path from config - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } - // Writes to the appropriate file - err = ioutil.WriteFile(config.GroupTrackContainersPath, file, 0644) - if err != nil { - return err - } - return nil -} - -// AddContainer Adds a container to the Tracked container list of the group -func (grp *Group) AddContainer(Container *TrackContainer) error { - grp.TrackContainerList = append(grp.TrackContainerList, Container) - return nil -} - -// RemoveContainerGroup Removes container information from the group -func (grp *Group) RemoveContainerGroup(Container *TrackContainer) error { - // Iterating through all container in the Group of Tracked Container - for i, container := range grp.TrackContainerList { - // If the container ID matches then remove the container from the group - if container.Id == Container.Id { - grp.TrackContainerList = append(grp.TrackContainerList[:i], grp.TrackContainerList[i+1:]...) - } - } - return nil -} - -// RemoveContainerGroups removes container found in all groups -func (grp *Groups) RemoveContainerGroups(Container *TrackContainer) error { - // Iterating through all groups - for i, group := range grp.GroupList { - // Removes the container in the following group - // if it exists - err := group.RemoveContainerGroup(Container) - if err != nil { - return err - } - // Set group information to list groups - grp.GroupList[i] = group - } - return nil -} - -// ModifyContainerGroups Modifies container information is all groups -// available -func (TC *TrackContainer) ModifyContainerGroups() error { - group, err := ReadGroup() - if err != nil { - return err - } - // Iterate though all groups and modify the container - // information in groups where the modified container - // ID matches - for i, _ := range group.GroupList { - // Checking in each group if the modified container ID exists - for j, _ := range group.GroupList[i].TrackContainerList { - // If there is match then change them - if group.GroupList[i].TrackContainerList[j].Id == TC.Id { - group.GroupList[i].TrackContainerList[j] = TC - } - } - } - - // Write modified result to the Groups track container JSON file - err = group.WriteGroup() - if err != nil { - return err - } - - return nil -} +//func ReadGroup() (*Groups, error) { +// // Get Path from config +// config, err := config.ConfigInit(nil, nil) +// if err != nil { +// return nil, err +// } +// jsonFile, err := os.Open(config.GroupTrackContainersPath) +// // if we os.Open returns an error then handle it +// if err != nil { +// return nil, err +// } +// // defer the closing of our jsonFile so that we can parse it later on +// defer jsonFile.Close() +// // read our opened xmlFile as a byte array. +// byteValue, _ := ioutil.ReadAll(jsonFile) +// // we initialize our Users array +// var groups Groups +// // we unmarshal our byteArray which contains our +// // jsonFile's content into 'users' which we defined above +// json.Unmarshal(byteValue, &groups) +// return &groups, nil +//} +// +//// WriteGroup Function to write type Groups to the grouptrackcontainers.json file +//func (grp *Groups) WriteGroup() error { +// file, err := json.MarshalIndent(grp, "", " ") +// if err != nil { +// return err +// } +// // Get Path from config +// config, err := config.ConfigInit(nil, nil) +// if err != nil { +// return err +// } +// // Writes to the appropriate file +// err = ioutil.WriteFile(config.GroupTrackContainersPath, file, 0644) +// if err != nil { +// return err +// } +// return nil +//} +// +//// AddContainer Adds a container to the Tracked container list of the group +//func (grp *Group) AddContainer(Container *TrackContainer) error { +// grp.TrackContainerList = append(grp.TrackContainerList, Container) +// return nil +//} +// +//// RemoveContainerGroup Removes container information from the group +//func (grp *Group) RemoveContainerGroup(Container *TrackContainer) error { +// // Iterating through all container in the Group of Tracked Container +// for i, container := range grp.TrackContainerList { +// // If the container ID matches then remove the container from the group +// if container.Id == Container.Id { +// grp.TrackContainerList = append(grp.TrackContainerList[:i], grp.TrackContainerList[i+1:]...) +// } +// } +// return nil +//} +// +//// RemoveContainerGroups removes container found in all groups +//func (grp *Groups) RemoveContainerGroups(Container *TrackContainer) error { +// // Iterating through all groups +// for i, group := range grp.GroupList { +// // Removes the container in the following group +// // if it exists +// err := group.RemoveContainerGroup(Container) +// if err != nil { +// return err +// } +// // Set group information to list groups +// grp.GroupList[i] = group +// } +// return nil +//} +// +//// ModifyContainerGroups Modifies container information is all groups +//// available +//func (TC *TrackContainer) ModifyContainerGroups() error { +// group, err := ReadGroup() +// if err != nil { +// return err +// } +// // Iterate though all groups and modify the container +// // information in groups where the modified container +// // ID matches +// for i, _ := range group.GroupList { +// // Checking in each group if the modified container ID exists +// for j, _ := range group.GroupList[i].TrackContainerList { +// // If there is match then change them +// if group.GroupList[i].TrackContainerList[j].Id == TC.Id { +// group.GroupList[i].TrackContainerList[j] = TC +// } +// } +// } +// +// // Write modified result to the Groups track container JSON file +// err = group.WriteGroup() +// if err != nil { +// return err +// } +// +// return nil +//} diff --git a/client/TrackContainers.go b/client/TrackContainers.go index 7310951..ccdfb7a 100644 --- a/client/TrackContainers.go +++ b/client/TrackContainers.go @@ -1,220 +1,210 @@ package client -import ( - "encoding/json" - "errors" - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/Akilan1999/p2p-rendering-computation/server/docker" - "io/ioutil" - "os" -) - -// TrackContainers This struct stores arrays of current containers running -type TrackContainers struct { - TrackContainerList []TrackContainer `json:"TrackContainer"` -} - -// TrackContainer Stores information of current containers -type TrackContainer struct { - Id string `json:"ID"` - Container *docker.DockerVM `json:"Container"` - IpAddress string `json:"IpAddress"` -} - -// AddTrackContainer Adds new container which has been added to the track container -func AddTrackContainer(d *docker.DockerVM, ipAddress string) error { - // Checking if pointer d is null - if d == nil { - return errors.New("d is nil") - } - //Get config information to derive paths for track containers json file - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } - - // Getting information about the file trackcontainers.json file - stat, err := os.Stat(config.TrackContainersPath) - if err != nil { - return err - } - // Initialize variable for TrackContainers - var trackContainers TrackContainers - // If the trackcontainers.json file is not empty then - // Read from that file - if stat.Size() != 0 { - // Reads tracked container file - trackContainersFile, err := ReadTrackContainers(config.TrackContainersPath) - if err != nil { - return err - } - trackContainers = *trackContainersFile - } - - // Initialize new variable with type struct TrackContainers and - // add container struct and ip address - var trackContainer TrackContainer - trackContainer.Id = d.ID - trackContainer.Container = d - trackContainer.IpAddress = ipAddress - - // Adds new container as passed in the parameter to the struct - if &trackContainer == nil { - return errors.New("trackContainer variable is nil") - } - trackContainers.TrackContainerList = append(trackContainers.TrackContainerList, trackContainer) - - // write modified information to the tracked json file - data, err := json.MarshalIndent(trackContainers, "", "\t") - if err != nil { - return err - } - err = ioutil.WriteFile(config.TrackContainersPath, data, 0777) - if err != nil { - return err - } - - return nil -} - -// RemoveTrackedContainer This function removos tracked container from the trackcontainer JSON file -func RemoveTrackedContainer(id string) error { - //Get config information to derive paths for track containers json file - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } - // Getting tracked container struct - trackedContainers, err := ReadTrackContainers(config.TrackContainersPath) - // Storing index of element to remove - var removeElement int - removeElement = -1 - for i := range trackedContainers.TrackContainerList { - if trackedContainers.TrackContainerList[i].Id == id { - removeElement = i - break - } - } - // Checks if the element to be removed has been detected - if removeElement == -1 { - return errors.New("Container ID not found in the tracked list") - } - // Remove the detected element from the struct - trackedContainers.TrackContainerList = append(trackedContainers.TrackContainerList[:removeElement], trackedContainers.TrackContainerList[removeElement+1:]...) - - // write modified information to the tracked json file - data, err := json.MarshalIndent(trackedContainers, "", "\t") - if err != nil { - return err - } - err = ioutil.WriteFile(config.TrackContainersPath, data, 0777) - if err != nil { - return err - } - - return nil -} - -// ViewTrackedContainers View Containers currently tracked -func ViewTrackedContainers() (error, *TrackContainers) { - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err, nil - } - trackedContianers, err := ReadTrackContainers(config.TrackContainersPath) - if err != nil { - return err, nil - } - - return nil, trackedContianers -} - -// ReadTrackContainers Reads containers which are currently tracked -func ReadTrackContainers(filename string) (*TrackContainers, error) { - buf, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - - c := &TrackContainers{} - err = json.Unmarshal(buf, c) - if err != nil { - return nil, fmt.Errorf("in file %q: %v", filename, err) - } - - return c, nil -} - -//func ModifyTrackContainers() - -// GetContainerInformation gets information about container based on -// container ID provided -func GetContainerInformation(ID string) (*TrackContainer, error) { - // Getting the current containers - err, CurrentContainers := ViewTrackedContainers() - if err != nil { - return nil, err - } - // Iterating through all tracked containers to get the container information - // of the ID passed through the function parameter - for _, container := range CurrentContainers.TrackContainerList { - if container.Container.ID == ID { - return &container, nil - } - } - return nil, errors.New("Container not found. ") -} - -// ModifyContainerInformation Modifies information inside the container -func (TC *TrackContainer) ModifyContainerInformation() error { - // Gets all the information of tracker containers - err, t := ViewTrackedContainers() - if err != nil { - return err - } - // Find the element where the containers match and - // change them - for i, container := range t.TrackContainerList { - if TC.Id == container.Id { - t.TrackContainerList[i] = *TC - break - } - } - // Write the modified information to the file - // write modified information to the tracked json file - err = t.WriteContainers() - if err != nil { - return err - } - - return nil -} - -// WriteContainers Write information back to the config file -func (TC *TrackContainers) WriteContainers() error { - // Initialize config file - config, err := config.ConfigInit(nil, nil) - // write modified information to the tracked json file - data, err := json.MarshalIndent(TC, "", "\t") - if err != nil { - return err - } - err = ioutil.WriteFile(config.TrackContainersPath, data, 0777) - if err != nil { - return err - } - - return nil -} - -// CheckID Checks if the ID belongs to a group or a single container -func CheckID(ID string) (string, error) { - // For group checks if the 1st characters is "grp" - if ID[0:3] == "grp" { - return "group", nil - } else { - return "container", nil - } - return "", nil -} +//// TrackContainers This struct stores arrays of current containers running +//type TrackContainers struct { +// TrackContainerList []TrackContainer `json:"TrackContainer"` +//} +// +//// TrackContainer Stores information of current containers +//type TrackContainer struct { +// Id string `json:"ID"` +// Container *docker.DockerVM `json:"Container"` +// IpAddress string `json:"IpAddress"` +//} +// +//// AddTrackContainer Adds new container which has been added to the track container +//func AddTrackContainer(d *docker.DockerVM, ipAddress string) error { +// // Checking if pointer d is null +// if d == nil { +// return errors.New("d is nil") +// } +// //Get config information to derive paths for track containers json file +// config, err := config.ConfigInit(nil, nil) +// if err != nil { +// return err +// } +// +// // Getting information about the file trackcontainers.json file +// stat, err := os.Stat(config.TrackContainersPath) +// if err != nil { +// return err +// } +// // Initialize variable for TrackContainers +// var trackContainers TrackContainers +// // If the trackcontainers.json file is not empty then +// // Read from that file +// if stat.Size() != 0 { +// // Reads tracked container file +// trackContainersFile, err := ReadTrackContainers(config.TrackContainersPath) +// if err != nil { +// return err +// } +// trackContainers = *trackContainersFile +// } +// +// // Initialize new variable with type struct TrackContainers and +// // add container struct and ip address +// var trackContainer TrackContainer +// trackContainer.Id = d.ID +// trackContainer.Container = d +// trackContainer.IpAddress = ipAddress +// +// // Adds new container as passed in the parameter to the struct +// if &trackContainer == nil { +// return errors.New("trackContainer variable is nil") +// } +// trackContainers.TrackContainerList = append(trackContainers.TrackContainerList, trackContainer) +// +// // write modified information to the tracked json file +// data, err := json.MarshalIndent(trackContainers, "", "\t") +// if err != nil { +// return err +// } +// err = ioutil.WriteFile(config.TrackContainersPath, data, 0777) +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// RemoveTrackedContainer This function removos tracked container from the trackcontainer JSON file +//func RemoveTrackedContainer(id string) error { +// //Get config information to derive paths for track containers json file +// config, err := config.ConfigInit(nil, nil) +// if err != nil { +// return err +// } +// // Getting tracked container struct +// trackedContainers, err := ReadTrackContainers(config.TrackContainersPath) +// // Storing index of element to remove +// var removeElement int +// removeElement = -1 +// for i := range trackedContainers.TrackContainerList { +// if trackedContainers.TrackContainerList[i].Id == id { +// removeElement = i +// break +// } +// } +// // Checks if the element to be removed has been detected +// if removeElement == -1 { +// return errors.New("Container ID not found in the tracked list") +// } +// // Remove the detected element from the struct +// trackedContainers.TrackContainerList = append(trackedContainers.TrackContainerList[:removeElement], trackedContainers.TrackContainerList[removeElement+1:]...) +// +// // write modified information to the tracked json file +// data, err := json.MarshalIndent(trackedContainers, "", "\t") +// if err != nil { +// return err +// } +// err = ioutil.WriteFile(config.TrackContainersPath, data, 0777) +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// ViewTrackedContainers View Containers currently tracked +//func ViewTrackedContainers() (error, *TrackContainers) { +// config, err := config.ConfigInit(nil, nil) +// if err != nil { +// return err, nil +// } +// trackedContianers, err := ReadTrackContainers(config.TrackContainersPath) +// if err != nil { +// return err, nil +// } +// +// return nil, trackedContianers +//} +// +//// ReadTrackContainers Reads containers which are currently tracked +//func ReadTrackContainers(filename string) (*TrackContainers, error) { +// buf, err := ioutil.ReadFile(filename) +// if err != nil { +// return nil, err +// } +// +// c := &TrackContainers{} +// err = json.Unmarshal(buf, c) +// if err != nil { +// return nil, fmt.Errorf("in file %q: %v", filename, err) +// } +// +// return c, nil +//} +// +////func ModifyTrackContainers() +// +//// GetContainerInformation gets information about container based on +//// container ID provided +//func GetContainerInformation(ID string) (*TrackContainer, error) { +// // Getting the current containers +// err, CurrentContainers := ViewTrackedContainers() +// if err != nil { +// return nil, err +// } +// // Iterating through all tracked containers to get the container information +// // of the ID passed through the function parameter +// for _, container := range CurrentContainers.TrackContainerList { +// if container.Container.ID == ID { +// return &container, nil +// } +// } +// return nil, errors.New("Container not found. ") +//} +// +//// ModifyContainerInformation Modifies information inside the container +//func (TC *TrackContainer) ModifyContainerInformation() error { +// // Gets all the information of tracker containers +// err, t := ViewTrackedContainers() +// if err != nil { +// return err +// } +// // Find the element where the containers match and +// // change them +// for i, container := range t.TrackContainerList { +// if TC.Id == container.Id { +// t.TrackContainerList[i] = *TC +// break +// } +// } +// // Write the modified information to the file +// // write modified information to the tracked json file +// err = t.WriteContainers() +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// WriteContainers Write information back to the config file +//func (TC *TrackContainers) WriteContainers() error { +// // Initialize config file +// config, err := config.ConfigInit(nil, nil) +// // write modified information to the tracked json file +// data, err := json.MarshalIndent(TC, "", "\t") +// if err != nil { +// return err +// } +// err = ioutil.WriteFile(config.TrackContainersPath, data, 0777) +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// CheckID Checks if the ID belongs to a group or a single container +//func CheckID(ID string) (string, error) { +// // For group checks if the 1st characters is "grp" +// if ID[0:3] == "grp" { +// return "group", nil +// } else { +// return "container", nil +// } +// return "", nil +//} diff --git a/client/container.go b/client/container.go index 295b39a..bde52ae 100644 --- a/client/container.go +++ b/client/container.go @@ -1,192 +1,180 @@ package client -import ( - b64 "encoding/base64" - "encoding/json" - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/Akilan1999/p2p-rendering-computation/p2p" - "github.com/Akilan1999/p2p-rendering-computation/server/docker" - "io/ioutil" - "net/http" - "strconv" -) - -var ( - serverPort = "8088" - client = http.Client{} -) - -// StartContainer Start container using REST api Implementation -// From the selected server IP address -// TODO: Test cases for this function -// Calls URL ex: http://0.0.0.0:8088/startcontainer?ports=0&GPU=false&ContainerName=docker-ubuntu-sshd -func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (*docker.DockerVM, error) { - // Passes URL with number of TCP ports to allocated and to give GPU access to the docker container - var URL string - //version := p2p.Ip4or6(IP) - // - ////Get port number of the server - //serverPort, err := GetServerPort(IP) - //if err != nil { - // return nil, err - //} - - //if version == "version 6" { - // URL = "http://[" + IP + "]:" + serverPort + "/startcontainer?ports=" + fmt.Sprint(NumPorts) + "&GPU=" + strconv.FormatBool(GPU) + "&ContainerName=" + ContainerName - //} else { - // Get config information - Config, err := config.ConfigInit(nil, nil) - if err != nil { - return nil, err - } - - // Get public key - PublicKey, err := Config.GetPublicKey() - if err != nil { - return nil, err - } - - // Used in URL to pass public key -> b64.StdEncoding.EncodeToString([]byte(PublicKey)) - URL = `http://` + IP + `/startcontainer?ports=` + fmt.Sprint(NumPorts) + `&GPU=` + strconv.FormatBool(GPU) + `&ContainerName=` + ContainerName + `&BaseImage=` + baseImage + `&PublicKey=` + b64.StdEncoding.EncodeToString([]byte(PublicKey)) - - // Encode URL due to public key passed. - resp, err := http.Get(URL) - if err != nil { - return nil, err - } - - // Convert response to byte value - byteValue, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - // Create variable for result response type - var dockerResult docker.DockerVM - - // Adds byte value to docker.DockerVM struct - json.Unmarshal(byteValue, &dockerResult) - if err != nil { - return nil, err - } - - // Adds the container to the tracked list - err = AddTrackContainer(&dockerResult, IP) - if err != nil { - return nil, err - } - - return &dockerResult, nil -} - -// RemoveContianer Stops and removes container from the server -func RemoveContianer(IP string, ID string) error { - var URL string - //version := p2p.Ip4or6(IP) - // - ////Get port number of the server - //serverPort, err := GetServerPort(IP) - //if err != nil { - // return err - //} - - //if version == "version 6" { - // URL = "http://[" + IP + "]:" + serverPort + "/RemoveContainer?id=" + ID - //} else { - URL = "http://" + IP + "/RemoveContainer?id=" + ID - //} - resp, err := http.Get(URL) - if err != nil { - return err - } - - // Convert response to byte value - byteValue, err := ioutil.ReadAll(resp.Body) - if err != nil { - return err - } - - // Checks if success is returned in the body - if string(byteValue[:]) == "success" { - fmt.Println("success") - } - - // Remove container from groups it exists in - err = RemoveContainerGroups(ID) - if err != nil { - return err - } - // Remove container created from the tracked list - err = RemoveTrackedContainer(ID) - if err != nil { - return err - } - - return nil -} - -// ViewContainers This function displays all containers available on server side -func ViewContainers(IP string) (*docker.DockerContainers, error) { - // Passes URL with route /ShowImages - var URL string - //version := p2p.Ip4or6(IP) - // - ////Get port number of the server - //serverPort, err := GetServerPort(IP) - //if err != nil { - // return nil, err - //} - - //if version == "version 6" { - // URL = "http://[" + IP + "]:" + serverPort + "/ShowImages" - //} else { - URL = "http://" + IP + "/ShowImages" - //} - resp, err := http.Get(URL) - if err != nil { - return nil, err - } - - // Convert response to byte value - byteValue, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - // Create variable for result response type - var Result docker.DockerContainers - - // Adds byte value to docker.DockerContainers struct - json.Unmarshal(byteValue, &Result) - if err != nil { - return nil, err - } - - return &Result, nil -} - -// GetServerPort Helper function to do find out server port information -func GetServerPort(IpAddress string) (string, error) { - // Getting information from the clients ip table - ipTable, err := p2p.ReadIpTable() - if err != nil { - return "", err - } - - // Iterate thorough ip table struct and find - // out which port is for the ip address provided - // in the parameter of the function - for _, address := range ipTable.IpAddress { - // If we found a match then return a port - if address.Ipv4 == IpAddress || address.Ipv6 == IpAddress { - return address.ServerPort, nil - } - } - - // We return default port - return "8088", nil -} +//var ( +// serverPort = "8088" +// client = http.Client{} +//) +// +//// StartContainer Start container using REST api Implementation +//// From the selected server IP address +//// TODO: Test cases for this function +//// Calls URL ex: http://0.0.0.0:8088/startcontainer?ports=0&GPU=false&ContainerName=docker-ubuntu-sshd +//func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (*docker.DockerVM, error) { +// // Passes URL with number of TCP ports to allocated and to give GPU access to the docker container +// var URL string +// //version := p2p.Ip4or6(IP) +// // +// ////Get port number of the server +// //serverPort, err := GetServerPort(IP) +// //if err != nil { +// // return nil, err +// //} +// +// //if version == "version 6" { +// // URL = "http://[" + IP + "]:" + serverPort + "/startcontainer?ports=" + fmt.Sprint(NumPorts) + "&GPU=" + strconv.FormatBool(GPU) + "&ContainerName=" + ContainerName +// //} else { +// // Get config information +// Config, err := config.ConfigInit(nil, nil) +// if err != nil { +// return nil, err +// } +// +// // Get public key +// PublicKey, err := Config.GetPublicKey() +// if err != nil { +// return nil, err +// } +// +// // Used in URL to pass public key -> b64.StdEncoding.EncodeToString([]byte(PublicKey)) +// URL = `http://` + IP + `/startcontainer?ports=` + fmt.Sprint(NumPorts) + `&GPU=` + strconv.FormatBool(GPU) + `&ContainerName=` + ContainerName + `&BaseImage=` + baseImage + `&PublicKey=` + b64.StdEncoding.EncodeToString([]byte(PublicKey)) +// +// // Encode URL due to public key passed. +// resp, err := http.Get(URL) +// if err != nil { +// return nil, err +// } +// +// // Convert response to byte value +// byteValue, err := ioutil.ReadAll(resp.Body) +// if err != nil { +// return nil, err +// } +// +// // Create variable for result response type +// var dockerResult docker.DockerVM +// +// // Adds byte value to docker.DockerVM struct +// json.Unmarshal(byteValue, &dockerResult) +// if err != nil { +// return nil, err +// } +// +// // Adds the container to the tracked list +// err = AddTrackContainer(&dockerResult, IP) +// if err != nil { +// return nil, err +// } +// +// return &dockerResult, nil +//} +// +//// RemoveContianer Stops and removes container from the server +//func RemoveContianer(IP string, ID string) error { +// var URL string +// //version := p2p.Ip4or6(IP) +// // +// ////Get port number of the server +// //serverPort, err := GetServerPort(IP) +// //if err != nil { +// // return err +// //} +// +// //if version == "version 6" { +// // URL = "http://[" + IP + "]:" + serverPort + "/RemoveContainer?id=" + ID +// //} else { +// URL = "http://" + IP + "/RemoveContainer?id=" + ID +// //} +// resp, err := http.Get(URL) +// if err != nil { +// return err +// } +// +// // Convert response to byte value +// byteValue, err := ioutil.ReadAll(resp.Body) +// if err != nil { +// return err +// } +// +// // Checks if success is returned in the body +// if string(byteValue[:]) == "success" { +// fmt.Println("success") +// } +// +// // Remove container from groups it exists in +// err = RemoveContainerGroups(ID) +// if err != nil { +// return err +// } +// // Remove container created from the tracked list +// err = RemoveTrackedContainer(ID) +// if err != nil { +// return err +// } +// +// return nil +//} +// +//// ViewContainers This function displays all containers available on server side +//func ViewContainers(IP string) (*docker.DockerContainers, error) { +// // Passes URL with route /ShowImages +// var URL string +// //version := p2p.Ip4or6(IP) +// // +// ////Get port number of the server +// //serverPort, err := GetServerPort(IP) +// //if err != nil { +// // return nil, err +// //} +// +// //if version == "version 6" { +// // URL = "http://[" + IP + "]:" + serverPort + "/ShowImages" +// //} else { +// URL = "http://" + IP + "/ShowImages" +// //} +// resp, err := http.Get(URL) +// if err != nil { +// return nil, err +// } +// +// // Convert response to byte value +// byteValue, err := ioutil.ReadAll(resp.Body) +// if err != nil { +// return nil, err +// } +// +// // Create variable for result response type +// var Result docker.DockerContainers +// +// // Adds byte value to docker.DockerContainers struct +// json.Unmarshal(byteValue, &Result) +// if err != nil { +// return nil, err +// } +// +// return &Result, nil +//} +// +//// GetServerPort Helper function to do find out server port information +//func GetServerPort(IpAddress string) (string, error) { +// // Getting information from the clients ip table +// ipTable, err := p2p.ReadIpTable() +// if err != nil { +// return "", err +// } +// +// // Iterate thorough ip table struct and find +// // out which port is for the ip address provided +// // in the parameter of the function +// for _, address := range ipTable.IpAddress { +// // If we found a match then return a port +// if address.Ipv4 == IpAddress || address.Ipv6 == IpAddress { +// return address.ServerPort, nil +// } +// } +// +// // We return default port +// return "8088", nil +//} // PrintStartContainer Prints results Generated container //func PrintStartContainer(d *docker.DockerVM){ diff --git a/cmd/action.go b/cmd/action.go index 11b059a..110abb1 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -7,7 +7,6 @@ import ( "github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable" "github.com/Akilan1999/p2p-rendering-computation/config/generate" "github.com/Akilan1999/p2p-rendering-computation/p2p" - "github.com/Akilan1999/p2p-rendering-computation/plugin" "github.com/Akilan1999/p2p-rendering-computation/server" "github.com/urfave/cli/v2" ) @@ -86,36 +85,36 @@ var CliAction = func(ctx *cli.Context) error { } // Displays all images available on the server side - if ViewImages != "" { - imageRes, err := client.ViewContainers(ViewImages) - standardOutput(err, imageRes) - } - - // Function called to stop and remove server from Docker - if RemoveVM != "" { - if ID == "" { - fmt.Println("provide container ID via --ID or --id") - } else { - err := client.RemoveContianer(RemoveVM, ID) - standardOutput(err, nil) - } - } + //if ViewImages != "" { + // imageRes, err := client.ViewContainers(ViewImages) + // standardOutput(err, imageRes) + //} + // + //// Function called to stop and remove server from Docker + //if RemoveVM != "" { + // if ID == "" { + // fmt.Println("provide container ID via --ID or --id") + // } else { + // err := client.RemoveContianer(RemoveVM, ID) + // standardOutput(err, nil) + // } + //} //Call function to create Docker container - if CreateVM != "" { - - var PortsInt int - - if Ports != "" { - // Convert Get Request value to int - fmt.Sscanf(Ports, "%d", &PortsInt) - } - - // Calls function to do Api call to start the container on the server side - imageRes, err := client.StartContainer(CreateVM, PortsInt, GPU, ContainerName, BaseImage) - - standardOutput(err, imageRes) - } + //if CreateVM != "" { + // + // var PortsInt int + // + // if Ports != "" { + // // Convert Get Request value to int + // fmt.Sscanf(Ports, "%d", &PortsInt) + // } + // + // // Calls function to do Api call to start the container on the server side + // imageRes, err := client.StartContainer(CreateVM, PortsInt, GPU, ContainerName, BaseImage) + // + // standardOutput(err, imageRes) + //} //Call if specs flag is called if Specs != "" { @@ -138,83 +137,83 @@ var CliAction = func(ctx *cli.Context) error { // If the view plugin flag is called then display all // plugins available - if ViewPlugin { - plugins, err := plugin.DetectPlugins() - standardOutput(err, plugins) - } + //if ViewPlugin { + // plugins, err := plugin.DetectPlugins() + // standardOutput(err, plugins) + //} // If the flag Tracked Container is called or the flag // --tc - if TrackedContainers { - err, trackedContainers := client.ViewTrackedContainers() - standardOutput(err, trackedContainers) - } + //if TrackedContainers { + // err, trackedContainers := client.ViewTrackedContainers() + // standardOutput(err, trackedContainers) + //} //Executing plugin when the plugin flag is called // --plugin - if ExecutePlugin != "" { - // To execute plugin requires the container ID or group ID provided when being executed - if ID != "" { - err := plugin.CheckRunPlugin(ExecutePlugin, ID) - standardOutput(err, nil) - } - //else { - // fmt.Println("provide container ID via --ID or --id") - //} - - } + //if ExecutePlugin != "" { + // // To execute plugin requires the container ID or group ID provided when being executed + // if ID != "" { + // err := plugin.CheckRunPlugin(ExecutePlugin, ID) + // standardOutput(err, nil) + // } + // //else { + // // fmt.Println("provide container ID via --ID or --id") + // //} + // + //} // Executing function to create new group // Creates new group and outputs JSON file - if CreateGroup { - group, err := client.CreateGroup() - standardOutput(err, group) - } + //if CreateGroup { + // group, err := client.CreateGroup() + // standardOutput(err, group) + //} // Actions to be performed when the // group flag is called // --group - if Group != "" { - // Remove container from group based on group ID provided - // --rmcgroup --id - if RemoveContainerGroup && ID != "" { - group, err := client.RemoveContainerGroup(ID, Group) - standardOutput(err, group) - } else if ID != "" { // Add container to group based on group ID provided - // --id - group, err := client.AddContainerToGroup(ID, Group) - standardOutput(err, group) - } else { // View all information about current group - group, err := client.GetGroup(Group) - standardOutput(err, group) - } - } + //if Group != "" { + // // Remove container from group based on group ID provided + // // --rmcgroup --id + // if RemoveContainerGroup && ID != "" { + // group, err := client.RemoveContainerGroup(ID, Group) + // standardOutput(err, group) + // } else if ID != "" { // Add container to group based on group ID provided + // // --id + // group, err := client.AddContainerToGroup(ID, Group) + // standardOutput(err, group) + // } else { // View all information about current group + // group, err := client.GetGroup(Group) + // standardOutput(err, group) + // } + //} // Execute function to remove entire group // when remove group flag is called // --rmgroup - if RemoveGroup != "" { - err := client.RemoveGroup(RemoveGroup) - standardOutput(err, nil) - } + //if RemoveGroup != "" { + // err := client.RemoveGroup(RemoveGroup) + // standardOutput(err, nil) + //} // Execute Function to view all groups - if Groups { - groups, err := client.ReadGroup() - standardOutput(err, groups) - } + //if Groups { + // groups, err := client.ReadGroup() + // standardOutput(err, groups) + //} //-------------------------------- - if PullPlugin != "" { - err := plugin.DownloadPlugin(PullPlugin) - standardOutput(err, nil) - } - - if RemovePlugin != "" { - err := plugin.DeletePlugin(RemovePlugin) - standardOutput(err, nil) - } + //if PullPlugin != "" { + // err := plugin.DownloadPlugin(PullPlugin) + // standardOutput(err, nil) + //} + // + //if RemovePlugin != "" { + // err := plugin.DeletePlugin(RemovePlugin) + // standardOutput(err, nil) + //} if AddMetaData != "" { err := clientIPTable.AddCustomInformationToIPTable(AddMetaData) diff --git a/cmd/flags.go b/cmd/flags.go index 34423b4..e56e022 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -74,48 +74,48 @@ var AppConfigFlags = []cli.Flag{ EnvVars: []string{"ADD_SERVER"}, Destination: &AddServer, }, - &cli.StringFlag{ - Name: "ViewImages", - Aliases: []string{"vi"}, - Usage: "View images available on the server IP address", - EnvVars: []string{"VIEW_IMAGES"}, - Destination: &ViewImages, - }, - &cli.StringFlag{ - Name: "CreateVM", - Aliases: []string{"touch"}, - Usage: "Creates Docker container on the selected server", - EnvVars: []string{"CREATE_VM"}, - Destination: &CreateVM, - }, - &cli.StringFlag{ - Name: "ContainerName", - Aliases: []string{"cn"}, - Usage: "Specifying the container run on the server side", - EnvVars: []string{"CONTAINER_NAME"}, - Destination: &ContainerName, - }, - &cli.StringFlag{ - Name: "BaseImage", - Aliases: []string{"bi"}, - Usage: "Specifying the docker base image to template the dockerfile", - EnvVars: []string{"CONTAINER_NAME"}, - Destination: &BaseImage, - }, - &cli.StringFlag{ - Name: "RemoveVM", - Aliases: []string{"rm"}, - Usage: "Stop and Remove Docker container (IP:port) accompanied by container ID via --ID or --id", - EnvVars: []string{"REMOVE_VM"}, - Destination: &RemoveVM, - }, - &cli.StringFlag{ - Name: "ID", - Aliases: []string{"id"}, - Usage: "Docker Container ID", - EnvVars: []string{"ID"}, - Destination: &ID, - }, + //&cli.StringFlag{ + // Name: "ViewImages", + // Aliases: []string{"vi"}, + // Usage: "View images available on the server IP address", + // EnvVars: []string{"VIEW_IMAGES"}, + // Destination: &ViewImages, + //}, + //&cli.StringFlag{ + // Name: "CreateVM", + // Aliases: []string{"touch"}, + // Usage: "Creates Docker container on the selected server", + // EnvVars: []string{"CREATE_VM"}, + // Destination: &CreateVM, + //}, + //&cli.StringFlag{ + // Name: "ContainerName", + // Aliases: []string{"cn"}, + // Usage: "Specifying the container run on the server side", + // EnvVars: []string{"CONTAINER_NAME"}, + // Destination: &ContainerName, + //}, + //&cli.StringFlag{ + // Name: "BaseImage", + // Aliases: []string{"bi"}, + // Usage: "Specifying the docker base image to template the dockerfile", + // EnvVars: []string{"CONTAINER_NAME"}, + // Destination: &BaseImage, + //}, + //&cli.StringFlag{ + // Name: "RemoveVM", + // Aliases: []string{"rm"}, + // Usage: "Stop and Remove Docker container (IP:port) accompanied by container ID via --ID or --id", + // EnvVars: []string{"REMOVE_VM"}, + // Destination: &RemoveVM, + //}, + //&cli.StringFlag{ + // Name: "ID", + // Aliases: []string{"id"}, + // Usage: "Docker Container ID", + // EnvVars: []string{"ID"}, + // Destination: &ID, + //}, &cli.StringFlag{ Name: "Ports", Aliases: []string{"p"}, @@ -123,13 +123,13 @@ var AppConfigFlags = []cli.Flag{ EnvVars: []string{"NUM_PORTS"}, Destination: &Ports, }, - &cli.BoolFlag{ - Name: "GPU", - Aliases: []string{"gpu"}, - Usage: "Create Docker Containers to access GPU", - EnvVars: []string{"USE_GPU"}, - Destination: &GPU, - }, + //&cli.BoolFlag{ + // Name: "GPU", + // Aliases: []string{"gpu"}, + // Usage: "Create Docker Containers to access GPU", + // EnvVars: []string{"USE_GPU"}, + // Destination: &GPU, + //}, &cli.StringFlag{ Name: "Specification", Aliases: []string{"specs"}, @@ -151,63 +151,63 @@ var AppConfigFlags = []cli.Flag{ EnvVars: []string{"NETWORK_INTERFACE"}, Destination: &NetworkInterface, }, - &cli.BoolFlag{ - Name: "ViewPlugins", - Aliases: []string{"vp"}, - Usage: "Shows plugins available to be executed", - EnvVars: []string{"VIEW_PLUGIN"}, - Destination: &ViewPlugin, - }, - &cli.BoolFlag{ - Name: "TrackedContainers", - Aliases: []string{"tc"}, - Usage: "View (currently running) containers which have " + - "been created from the client side ", - EnvVars: []string{"TRACKED_CONTAINERS"}, - Destination: &TrackedContainers, - }, - &cli.StringFlag{ - Name: "ExecutePlugin", - Aliases: []string{"plugin"}, - Usage: "Plugin which needs to be executed", - EnvVars: []string{"EXECUTE_PLUGIN"}, - Destination: &ExecutePlugin, - }, - &cli.BoolFlag{ - Name: "CreateGroup", - Aliases: []string{"cgroup"}, - Usage: "Creates a new group", - EnvVars: []string{"CREATE_GROUP"}, - Destination: &CreateGroup, - }, - &cli.StringFlag{ - Name: "Group", - Aliases: []string{"group"}, - Usage: "group flag with argument group ID", - EnvVars: []string{"GROUP"}, - Destination: &Group, - }, - &cli.BoolFlag{ - Name: "Groups", - Aliases: []string{"groups"}, - Usage: "View all groups", - EnvVars: []string{"GROUPS"}, - Destination: &Groups, - }, - &cli.BoolFlag{ - Name: "RemoveContainerGroup", - Aliases: []string{"rmcgroup"}, - Usage: "Remove specific container in the group", - EnvVars: []string{"REMOVE_CONTAINER_GROUP"}, - Destination: &RemoveContainerGroup, - }, - &cli.StringFlag{ - Name: "RemoveGroup", - Aliases: []string{"rmgroup"}, - Usage: "Removes the entire group", - EnvVars: []string{"REMOVE_GROUP"}, - Destination: &RemoveGroup, - }, + //&cli.BoolFlag{ + // Name: "ViewPlugins", + // Aliases: []string{"vp"}, + // Usage: "Shows plugins available to be executed", + // EnvVars: []string{"VIEW_PLUGIN"}, + // Destination: &ViewPlugin, + //}, + //&cli.BoolFlag{ + // Name: "TrackedContainers", + // Aliases: []string{"tc"}, + // Usage: "View (currently running) containers which have " + + // "been created from the client side ", + // EnvVars: []string{"TRACKED_CONTAINERS"}, + // Destination: &TrackedContainers, + //}, + //&cli.StringFlag{ + // Name: "ExecutePlugin", + // Aliases: []string{"plugin"}, + // Usage: "Plugin which needs to be executed", + // EnvVars: []string{"EXECUTE_PLUGIN"}, + // Destination: &ExecutePlugin, + //}, + //&cli.BoolFlag{ + // Name: "CreateGroup", + // Aliases: []string{"cgroup"}, + // Usage: "Creates a new group", + // EnvVars: []string{"CREATE_GROUP"}, + // Destination: &CreateGroup, + //}, + //&cli.StringFlag{ + // Name: "Group", + // Aliases: []string{"group"}, + // Usage: "group flag with argument group ID", + // EnvVars: []string{"GROUP"}, + // Destination: &Group, + //}, + //&cli.BoolFlag{ + // Name: "Groups", + // Aliases: []string{"groups"}, + // Usage: "View all groups", + // EnvVars: []string{"GROUPS"}, + // Destination: &Groups, + //}, + //&cli.BoolFlag{ + // Name: "RemoveContainerGroup", + // Aliases: []string{"rmcgroup"}, + // Usage: "Remove specific container in the group", + // EnvVars: []string{"REMOVE_CONTAINER_GROUP"}, + // Destination: &RemoveContainerGroup, + //}, + //&cli.StringFlag{ + // Name: "RemoveGroup", + // Aliases: []string{"rmgroup"}, + // Usage: "Removes the entire group", + // EnvVars: []string{"REMOVE_GROUP"}, + // Destination: &RemoveGroup, + //}, &cli.StringFlag{ Name: "MAPPort", Aliases: []string{"mp"}, @@ -231,20 +231,20 @@ var AppConfigFlags = []cli.Flag{ }, // Generate only allowed in dev release // -- REMOVE ON REGULAR RELEASE -- - &cli.StringFlag{ - Name: "Generate", - Aliases: []string{"gen"}, - Usage: "Generates a new copy of P2PRC which can be modified based on your needs", - EnvVars: []string{"GENERATE"}, - Destination: &Generate, - }, - &cli.StringFlag{ - Name: "ModuleName", - Aliases: []string{"mod"}, - Usage: "New go project module name", - EnvVars: []string{"MODULENAME"}, - Destination: &Modulename, - }, + //&cli.StringFlag{ + // Name: "Generate", + // Aliases: []string{"gen"}, + // Usage: "Generates a new copy of P2PRC which can be modified based on your needs", + // EnvVars: []string{"GENERATE"}, + // Destination: &Generate, + //}, + //&cli.StringFlag{ + // Name: "ModuleName", + // Aliases: []string{"mod"}, + // Usage: "New go project module name", + // EnvVars: []string{"MODULENAME"}, + // Destination: &Modulename, + //}, //&cli.BoolFlag{ // Name: "FRPServerProxy", // Aliases: []string{"proxy"}, @@ -253,20 +253,20 @@ var AppConfigFlags = []cli.Flag{ // Destination: &FRPProxy, //}, //-------------------------------- - &cli.StringFlag{ - Name: "PullPlugin", - Aliases: []string{"pp"}, - Usage: "Pulls plugin from git repos", - EnvVars: []string{"PULLPLUGIN"}, - Destination: &PullPlugin, - }, - &cli.StringFlag{ - Name: "RemovePlugin", - Aliases: []string{"rp"}, - Usage: "Removes plugin", - EnvVars: []string{"REMOVEPLUGIN"}, - Destination: &RemovePlugin, - }, + //&cli.StringFlag{ + // Name: "PullPlugin", + // Aliases: []string{"pp"}, + // Usage: "Pulls plugin from git repos", + // EnvVars: []string{"PULLPLUGIN"}, + // Destination: &PullPlugin, + //}, + //&cli.StringFlag{ + // Name: "RemovePlugin", + // Aliases: []string{"rp"}, + // Usage: "Removes plugin", + // EnvVars: []string{"REMOVEPLUGIN"}, + // Destination: &RemovePlugin, + //}, &cli.StringFlag{ Name: "AddMetaData", Aliases: []string{"amd"}, diff --git a/go.mod b/go.mod index b5794f4..ec6adbf 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/Akilan1999/p2p-rendering-computation go 1.18 require ( - github.com/apenella/go-ansible v1.1.0 github.com/docker/docker v20.10.0-beta1.0.20201113105859-b6bfff2a628f+incompatible github.com/fatedier/frp v0.45.0 github.com/gin-gonic/gin v1.6.3 @@ -16,7 +15,6 @@ require ( github.com/urfave/cli/v2 v2.3.0 gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3 golang.org/x/crypto v0.16.0 - gopkg.in/yaml.v2 v2.4.0 ) require ( @@ -24,8 +22,6 @@ require ( github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3 // indirect github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect github.com/acomagu/bufpipe v1.0.3 // indirect - github.com/apenella/go-common-utils v0.1.1 // indirect - github.com/apenella/go-common-utils/error v0.0.0-20200917063805-34b0ed3c4ce1 // indirect github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect @@ -100,5 +96,6 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/square/go-jose.v2 v2.4.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gotest.tools/v3 v3.0.3 // indirect ) diff --git a/go.sum b/go.sum index 3009871..5917bef 100644 --- a/go.sum +++ b/go.sum @@ -63,7 +63,6 @@ github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg3 github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg= github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -79,13 +78,6 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/apenella/go-ansible v1.1.0 h1:wWqaZBvoDxPjvtwXc2fXbDj546uBj/Kv2PL7PW82EfY= -github.com/apenella/go-ansible v1.1.0/go.mod h1:tHqFBSwWXF9k2hkLQWfq6oxMQZHslySQqttkA2siyqE= -github.com/apenella/go-common-utils v0.1.1 h1:dJA2tY22z6mYB5a+EogfiS7NxZsR/Ld3TWnZcS3JPa0= -github.com/apenella/go-common-utils v0.1.1/go.mod h1:E7RUbl9B1vdLkTIapoTE2W6pIgW7dTSJOxL3pf4gV6g= -github.com/apenella/go-common-utils/error v0.0.0-20200917063805-34b0ed3c4ce1 h1:lw/fwF65AaJVxyUTJShtBiZfaiafKde3QkR4im1glzQ= -github.com/apenella/go-common-utils/error v0.0.0-20200917063805-34b0ed3c4ce1/go.mod h1:Hj3S/BcSHKfv9VDMcrY7lsm9hGnb7cd70alSkl/Sv+4= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= @@ -106,7 +98,6 @@ github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8n github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -167,8 +158,6 @@ github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM= github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-oidc v2.2.1+incompatible h1:mh48q/BqXqgjVHpy2ZY7WnWAbenxRjsz9N1i1YxjHAk= @@ -200,7 +189,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= @@ -240,7 +228,6 @@ github.com/fatedier/golib v0.1.1-0.20220321042308-c306138b83ac/go.mod h1:fLV0TLw github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible h1:ssXat9YXFvigNge/IkkZvFMn8yeYKFX+uI6wn2mLJ74= github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible/go.mod h1:YpCOaxj7vvMThhIQ9AfTOPW2sfztQR5WDfs7AflSy4s= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -314,7 +301,6 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -385,13 +371,10 @@ github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -399,7 +382,6 @@ github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1: github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -462,7 +444,6 @@ github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5n github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= @@ -470,7 +451,6 @@ github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHef github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= @@ -506,7 +486,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -547,7 +526,6 @@ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6 github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E= github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= @@ -568,7 +546,6 @@ github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 h1:J9b7z+QKAm github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -583,8 +560,6 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= @@ -594,7 +569,6 @@ github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8 github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.0-20190522114515-bc1a522cf7b1/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= @@ -606,7 +580,6 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= @@ -635,20 +608,14 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -681,7 +648,6 @@ github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq// github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= @@ -703,7 +669,6 @@ github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2 github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 h1:EWU6Pktpas0n8lLQwDsRyZfmkPeRbdgPtW609es+/9E= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -718,7 +683,6 @@ gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 h1:dizWJqTWj gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40/go.mod h1:rOnSnoRyxMI3fe/7KIbVcsHRGxe30OONv8dEgo+vCfA= gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3 h1:qXqiXDgeQxspR3reot1pWme00CX1pXbxesdzND+EjbU= gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3/go.mod h1:sleOmkovWsDEQVYXmOJhx69qheoMTmCuPYyiCFCihlg= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= diff --git a/main.go b/main.go index c9cce69..cf7eca9 100644 --- a/main.go +++ b/main.go @@ -1,13 +1,10 @@ package main import ( - "log" - "os" - "os/signal" - "syscall" - "github.com/Akilan1999/p2p-rendering-computation/cmd" "github.com/urfave/cli/v2" + "log" + "os" ) // VERSION specifies the version of the platform @@ -19,20 +16,20 @@ var OS, Pull_location, Run_script string var List_servers, Ip_table bool // To be implemented later on -func getFireSignalsChannel() chan os.Signal { - - c := make(chan os.Signal, 1) - signal.Notify(c, - // https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html - syscall.SIGTERM, // "the normal way to politely ask a program to terminate" - syscall.SIGINT, // Ctrl+C - syscall.SIGQUIT, // Ctrl-\ - syscall.SIGKILL, // "always fatal", "SIGKILL and SIGSTOP may not be caught by a program" - syscall.SIGHUP, // "terminal is disconnected" - ) - return c - -} +//func getFireSignalsChannel() chan os.Signal { +// +// c := make(chan os.Signal, 1) +// signal.Notify(c, +// // https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html +// syscall.SIGTERM, // "the normal way to politely ask a program to terminate" +// syscall.SIGINT, // Ctrl+C +// syscall.SIGQUIT, // Ctrl-\ +// syscall.SIGKILL, // "always fatal", "SIGKILL and SIGSTOP may not be caught by a program" +// syscall.SIGHUP, // "terminal is disconnected" +// ) +// return c +// +//} func main() { app := cli.NewApp() diff --git a/p2p/frp/client.go b/p2p/frp/client.go index adabd37..09c9284 100644 --- a/p2p/frp/client.go +++ b/p2p/frp/client.go @@ -1,30 +1,28 @@ package frp import ( - "github.com/Akilan1999/p2p-rendering-computation/server/docker" - "github.com/fatedier/frp/client" - "github.com/fatedier/frp/pkg/config" - "github.com/phayes/freeport" - "math/rand" - "strconv" - "time" + "github.com/fatedier/frp/client" + "github.com/fatedier/frp/pkg/config" + "github.com/phayes/freeport" + "math/rand" + "strconv" ) // Client This struct stores // client information with server // proxy connected type Client struct { - Name string - Server *Server - ClientMappings []ClientMapping + Name string + Server *Server + ClientMappings []ClientMapping } // ClientMapping Stores client mapping ports // to proxy server type ClientMapping struct { - LocalIP string - LocalPort int - RemotePort int + LocalIP string + LocalPort int + RemotePort int } // StartFRPClientForServer Starts Server using FRP server @@ -33,154 +31,154 @@ type ClientMapping struct { // to open. This under the assumption the user knows the // exact port available in server doing the TURN connection. func StartFRPClientForServer(ipaddress string, port string, localport string, remoteport string) (string, error) { - // Setup server information - var s Server - s.address = ipaddress - // convert port to int - portInt, err := strconv.Atoi(port) - if err != nil { - return "", err - } - s.port = portInt + // Setup server information + var s Server + s.address = ipaddress + // convert port to int + portInt, err := strconv.Atoi(port) + if err != nil { + return "", err + } + s.port = portInt - // Setup client information - var c Client - c.Name = "ServerPort" - c.Server = &s + // Setup client information + var c Client + c.Name = "ServerPort" + c.Server = &s - // converts localport to int - portInt, err = strconv.Atoi(localport) - if err != nil { - return "", err - } + // converts localport to int + portInt, err = strconv.Atoi(localport) + if err != nil { + return "", err + } - var OpenPorts []int - // if the remote port is - // not empty then set the remote port to that. - if remoteport != "" { - // converts localport to int - portIntRemote, err := strconv.Atoi(remoteport) - if err != nil { - return "", err - } - OpenPorts = append(OpenPorts, portIntRemote) - } else { - //random port - //randPort := rangeIn(10000, 99999) - OpenPorts, err = freeport.GetFreePorts(1) - if err != nil { - return "", err - } - } - c.ClientMappings = []ClientMapping{ - { - LocalIP: "localhost", - LocalPort: portInt, - RemotePort: OpenPorts[0], - }, - } + var OpenPorts []int + // if the remote port is + // not empty then set the remote port to that. + if remoteport != "" { + // converts localport to int + portIntRemote, err := strconv.Atoi(remoteport) + if err != nil { + return "", err + } + OpenPorts = append(OpenPorts, portIntRemote) + } else { + //random port + //randPort := rangeIn(10000, 99999) + OpenPorts, err = freeport.GetFreePorts(1) + if err != nil { + return "", err + } + } + c.ClientMappings = []ClientMapping{ + { + LocalIP: "localhost", + LocalPort: portInt, + RemotePort: OpenPorts[0], + }, + } - // Start client server - go c.StartFRPClient() + // Start client server + go c.StartFRPClient() - return strconv.Itoa(OpenPorts[0]), nil + return strconv.Itoa(OpenPorts[0]), nil } -func StartFRPCDockerContainer(ipaddress string, port string, Docker *docker.DockerVM) (*docker.DockerVM, error) { - // setting new docker variable - - //var DockerFRP docker.DockerVM - - //DockerFRP = *Docker - //DockerFRP.Ports.PortSet = []docker.Port{} - // Setup server information - var s Server - s.address = ipaddress - // convert port to int - portInt, err := strconv.Atoi(port) - if err != nil { - return nil, err - } - s.port = portInt - - // Setup client information - var c Client - c.Name = "ServerPort" - c.Server = &s - - // set client mapping - //var clientMappings []ClientMapping - for i, _ := range Docker.Ports.PortSet { - portMap := Docker.Ports.PortSet[i].ExternalPort - - serverPort, err := GetFRPServerPort("http://" + ipaddress + ":" + port) - if err != nil { - return nil, err - } - - //delay to allow the FRP server to start - time.Sleep(1 * time.Second) - - proxyPort, err := StartFRPClientForServer(ipaddress, serverPort, strconv.Itoa(portMap), "") - if err != nil { - return nil, err - } - - portInt, err = strconv.Atoi(proxyPort) - if err != nil { - return nil, err - } - - Docker.Ports.PortSet[i].ExternalPort = portInt - } - - return Docker, nil - -} +//func StartFRPCDockerContainer(ipaddress string, port string, Docker *docker.DockerVM) (*docker.DockerVM, error) { +// // setting new docker variable +// +// //var DockerFRP docker.DockerVM +// +// //DockerFRP = *Docker +// //DockerFRP.Ports.PortSet = []docker.Port{} +// // Setup server information +// var s Server +// s.address = ipaddress +// // convert port to int +// portInt, err := strconv.Atoi(port) +// if err != nil { +// return nil, err +// } +// s.port = portInt +// +// // Setup client information +// var c Client +// c.Name = "ServerPort" +// c.Server = &s +// +// // set client mapping +// //var clientMappings []ClientMapping +// for i, _ := range Docker.Ports.PortSet { +// portMap := Docker.Ports.PortSet[i].ExternalPort +// +// serverPort, err := GetFRPServerPort("http://" + ipaddress + ":" + port) +// if err != nil { +// return nil, err +// } +// +// //delay to allow the FRP server to start +// time.Sleep(1 * time.Second) +// +// proxyPort, err := StartFRPClientForServer(ipaddress, serverPort, strconv.Itoa(portMap), "") +// if err != nil { +// return nil, err +// } +// +// portInt, err = strconv.Atoi(proxyPort) +// if err != nil { +// return nil, err +// } +// +// Docker.Ports.PortSet[i].ExternalPort = portInt +// } +// +// return Docker, nil +// +//} // StartFRPClient Starts FRP client func (c *Client) StartFRPClient() error { - cfg := config.GetDefaultClientConf() + cfg := config.GetDefaultClientConf() - //Config, err := defaultConfig.ConfigInit(nil, nil) - //if err != nil { - // return err - //} + //Config, err := defaultConfig.ConfigInit(nil, nil) + //if err != nil { + // return err + //} - var proxyConfs map[string]config.ProxyConf - var visitorCfgs map[string]config.VisitorConf + var proxyConfs map[string]config.ProxyConf + var visitorCfgs map[string]config.VisitorConf - proxyConfs = make(map[string]config.ProxyConf) + proxyConfs = make(map[string]config.ProxyConf) - cfg.ServerAddr = c.Server.address - cfg.ServerPort = c.Server.port - //cfg.TLSEnable = true - //cfg.TLSKeyFile = Config.KeyFile - //cfg.TLSCertFile = Config.PemFile + cfg.ServerAddr = c.Server.address + cfg.ServerPort = c.Server.port + //cfg.TLSEnable = true + //cfg.TLSKeyFile = Config.KeyFile + //cfg.TLSCertFile = Config.PemFile - for i, _ := range c.ClientMappings { - var tcpcnf config.TCPProxyConf - tcpcnf.LocalIP = c.ClientMappings[i].LocalIP - tcpcnf.LocalPort = c.ClientMappings[i].LocalPort - tcpcnf.RemotePort = c.ClientMappings[i].RemotePort + for i, _ := range c.ClientMappings { + var tcpcnf config.TCPProxyConf + tcpcnf.LocalIP = c.ClientMappings[i].LocalIP + tcpcnf.LocalPort = c.ClientMappings[i].LocalPort + tcpcnf.RemotePort = c.ClientMappings[i].RemotePort - proxyConfs[tcpcnf.ProxyName] = &tcpcnf - } + proxyConfs[tcpcnf.ProxyName] = &tcpcnf + } - cli, err := client.NewService(cfg, proxyConfs, visitorCfgs, "") - if err != nil { - return err - } + cli, err := client.NewService(cfg, proxyConfs, visitorCfgs, "") + if err != nil { + return err + } - cli.Run() + cli.Run() - return nil + return nil } // helper function to generate random // number in a certain range func rangeIn(low, hi int) int { - return low + rand.Intn(hi-low) + return low + rand.Intn(hi-low) } diff --git a/plugin/.dockerignore b/plugin/.dockerignore deleted file mode 100644 index 1fa069f..0000000 --- a/plugin/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -.idea -.DS_Store -Dockerfile diff --git a/plugin/.gitignore b/plugin/.gitignore deleted file mode 100644 index 090a1f0..0000000 --- a/plugin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea -.DS_Store diff --git a/plugin/README.md b/plugin/README.md deleted file mode 100644 index 8b13789..0000000 --- a/plugin/README.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugin/TestAnsible/description.txt b/plugin/TestAnsible/description.txt deleted file mode 100644 index b0a0a8f..0000000 --- a/plugin/TestAnsible/description.txt +++ /dev/null @@ -1 +0,0 @@ -Test if it's detected \ No newline at end of file diff --git a/plugin/TestAnsible/hosts b/plugin/TestAnsible/hosts deleted file mode 100644 index 07e4869..0000000 --- a/plugin/TestAnsible/hosts +++ /dev/null @@ -1,12 +0,0 @@ ---- -all: - vars: - ansible_python_interpreter: /usr/bin/python3 -main: - hosts: - host1: - ansible_host: 0.0.0.0 # Replace with your remote IP - ansible_port: 44003 # Replace with your remote SSH port - ansible_user: master # Replace wtih your username - ansible_ssh_pass: password - ansible_sudo_pass: password \ No newline at end of file diff --git a/plugin/TestAnsible/site.yml b/plugin/TestAnsible/site.yml deleted file mode 100644 index f263373..0000000 --- a/plugin/TestAnsible/site.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- hosts: all - - tasks: - - name: simple-ansibleplaybook - debug: - msg: Your are running 'simple-ansibleplaybook' example diff --git a/plugin/docs.md b/plugin/docs.md deleted file mode 100644 index e3914c1..0000000 --- a/plugin/docs.md +++ /dev/null @@ -1,224 +0,0 @@ - - -# plugin - -```go -import "github.com/Akilan1999/p2p-rendering-computation/plugin" -``` - -## Index - -- [func CheckRunPlugin\(PluginName string, ID string\) error](<#CheckRunPlugin>) -- [func DeletePlugin\(pluginname string\) error](<#DeletePlugin>) -- [func DownloadPlugin\(pluginurl string\) error](<#DownloadPlugin>) -- [func RunPluginContainer\(PluginName string, ContainerID string\) error](<#RunPluginContainer>) -- [type ExecuteIP](<#ExecuteIP>) - - [func \(e \*ExecuteIP\) ModifyHost\(p \*Plugin\) error](<#ExecuteIP.ModifyHost>) - - [func \(e \*ExecuteIP\) RunAnsible\(p \*Plugin\) error](<#ExecuteIP.RunAnsible>) -- [type Host](<#Host>) - - [func ReadHost\(filename string\) \(\*Host, error\)](<#ReadHost>) -- [type Plugin](<#Plugin>) - - [func RunPlugin\(pluginName string, IPAddresses \[\]\*ExecuteIP\) \(\*Plugin, error\)](<#RunPlugin>) - - [func SearchPlugin\(pluginname string\) \(\*Plugin, error\)](<#SearchPlugin>) - - [func \(p \*Plugin\) AutoSetPorts\(containerID string\) error](<#Plugin.AutoSetPorts>) - - [func \(p \*Plugin\) CopyToTmpPlugin\(\) error](<#Plugin.CopyToTmpPlugin>) - - [func \(p \*Plugin\) ExecutePlugin\(\) error](<#Plugin.ExecutePlugin>) - - [func \(p \*Plugin\) NumPorts\(\) error](<#Plugin.NumPorts>) -- [type Plugins](<#Plugins>) - - [func DetectPlugins\(\) \(\*Plugins, error\)](<#DetectPlugins>) - - - -## func [CheckRunPlugin]() - -```go -func CheckRunPlugin(PluginName string, ID string) error -``` - -CheckRunPlugin Checks if the ID belongs to the group or container calls the plugin function the appropriate amount of times - - -## func [DeletePlugin]() - -```go -func DeletePlugin(pluginname string) error -``` - -DeletePlugin The following function deletes a plugin based on the plugin name provided. - - -## func [DownloadPlugin]() - -```go -func DownloadPlugin(pluginurl string) error -``` - -DownloadPlugin This functions downloads package from a git repo. - - -## func [RunPluginContainer]() - -```go -func RunPluginContainer(PluginName string, ContainerID string) error -``` - -RunPluginContainer Runs ansible plugin based on plugin name and container name which is derived from the tracked containers file We pass in the group ID as a parameter because when we modify the ports taken - - -## type [ExecuteIP]() - -ExecuteIP IP Address to execute Ansible instruction - -```go -type ExecuteIP struct { - ContainerID string - IPAddress string - SSHPortNo string - Success bool -} -``` - - -### func \(\*ExecuteIP\) [ModifyHost]() - -```go -func (e *ExecuteIP) ModifyHost(p *Plugin) error -``` - -ModifyHost adds IP address , port no to the config file - - -### func \(\*ExecuteIP\) [RunAnsible]() - -```go -func (e *ExecuteIP) RunAnsible(p *Plugin) error -``` - -RunAnsible Executes based on credentials on the struct - - -## type [Host]() - -Host Struct for ansible host Generated from https://zhwt.github.io/yaml-to-go/ - -```go -type Host struct { - All struct { - Vars struct { - AnsiblePythonInterpreter string `yaml:"ansible_python_interpreter"` - } `yaml:"vars"` - } `yaml:"all"` - Main struct { - Hosts struct { - Host1 struct { - AnsibleHost string `yaml:"ansible_host"` - AnsiblePort int `yaml:"ansible_port"` - AnsibleUser string `yaml:"ansible_user"` - AnsibleSSHPass string `yaml:"ansible_ssh_pass"` - AnsibleSudoPass string `yaml:"ansible_sudo_pass"` - } `yaml:"host1"` - } `yaml:"hosts"` - } `yaml:"main"` -} -``` - - -### func [ReadHost]() - -```go -func ReadHost(filename string) (*Host, error) -``` - -ReadHost Reads host file and adds - - -## type [Plugin]() - -Plugin Information about the plugins available - -```go -type Plugin struct { - FolderName string - PluginDescription string - - Execute []*ExecuteIP - NumOfPorts int - // contains filtered or unexported fields -} -``` - - -### func [RunPlugin]() - -```go -func RunPlugin(pluginName string, IPAddresses []*ExecuteIP) (*Plugin, error) -``` - -RunPlugin Executes plugins based on the plugin name provided - - -### func [SearchPlugin]() - -```go -func SearchPlugin(pluginname string) (*Plugin, error) -``` - -SearchPlugin Detects plugin information based on the name provided on the parameter - - -### func \(\*Plugin\) [AutoSetPorts]() - -```go -func (p *Plugin) AutoSetPorts(containerID string) error -``` - -AutoSetPorts Automatically maps free ports to site.yml file - - -### func \(\*Plugin\) [CopyToTmpPlugin]() - -```go -func (p *Plugin) CopyToTmpPlugin() error -``` - -CopyToTmpPlugin This function would ensure that we create a copy of the plugin in the tmp directory, and it would be executed from there. This due to the reason of automating port allocation when running plugins - - -### func \(\*Plugin\) [ExecutePlugin]() - -```go -func (p *Plugin) ExecutePlugin() error -``` - -ExecutePlugin Function to execute plugins that are called - - -### func \(\*Plugin\) [NumPorts]() - -```go -func (p *Plugin) NumPorts() error -``` - -NumPorts Gets the Number the ports the plugin requires - - -## type [Plugins]() - -Plugins Array of all plugins detected - -```go -type Plugins struct { - PluginsDetected []*Plugin -} -``` - - -### func [DetectPlugins]() - -```go -func DetectPlugins() (*Plugins, error) -``` - -DetectPlugins Detects all the plugins available - -Generated by [gomarkdoc]() diff --git a/plugin/generate_test_case.sh b/plugin/generate_test_case.sh deleted file mode 100644 index cecca14..0000000 --- a/plugin/generate_test_case.sh +++ /dev/null @@ -1 +0,0 @@ -cp -r plugin/TestAnsible/ plugin/deploy/ diff --git a/plugin/packageManager.go b/plugin/packageManager.go deleted file mode 100644 index 2896acc..0000000 --- a/plugin/packageManager.go +++ /dev/null @@ -1,64 +0,0 @@ -package plugin - -import ( - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/go-git/go-git/v5" - "net/url" - "os" - "strings" -) - -// DownloadPlugin This functions downloads package from -// a git repo. -func DownloadPlugin(pluginurl string) error { - // paring plugin url - u, err := url.Parse(pluginurl) - if err != nil { - return err - } - path := u.Path - // Trim first character of the string - path = path[1:] - // trim last element of the string - path = path[:len(path)-1] - // Replaces / with _ - folder := strings.Replace(path, "/", "_", -1) - // Reads plugin path from the config path - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } - // clones a repo and stores it at the plugin directory - _, err = git.PlainClone(config.PluginPath+"/"+folder, false, &git.CloneOptions{ - URL: pluginurl, - Progress: os.Stdout, - }) - // returns error if raised - if err != nil { - return err - } - - return nil -} - -// DeletePlugin The following function deletes a plugin based on -// the plugin name provided. -func DeletePlugin(pluginname string) error { - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } - - plugin, err := SearchPlugin(pluginname) - if err != nil { - return err - } - - // Delete the directory holding the plugin - err = os.RemoveAll(config.PluginPath + "/" + plugin.FolderName) - if err != nil { - return err - } - - return nil -} diff --git a/plugin/plugin.go b/plugin/plugin.go deleted file mode 100644 index 31e0762..0000000 --- a/plugin/plugin.go +++ /dev/null @@ -1,464 +0,0 @@ -package plugin - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/client" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/google/uuid" - "gopkg.in/yaml.v2" - "io/ioutil" - "net" - "os" - "strconv" - "text/template" - - "github.com/apenella/go-ansible/pkg/execute" - "github.com/apenella/go-ansible/pkg/options" - "github.com/apenella/go-ansible/pkg/playbook" - "github.com/apenella/go-ansible/pkg/stdoutcallback/results" - "github.com/otiai10/copy" -) - -// Plugins Array of all plugins detected -type Plugins struct { - PluginsDetected []*Plugin -} - -// Plugin Information about the plugins available -type Plugin struct { - FolderName string - PluginDescription string - path string - Execute []*ExecuteIP - NumOfPorts int -} - -// ExecuteIP IP Address to execute Ansible instruction -type ExecuteIP struct { - ContainerID string - IPAddress string - SSHPortNo string - Success bool -} - -// Host Struct for ansible host -// Generated from https://zhwt.github.io/yaml-to-go/ -type Host struct { - All struct { - Vars struct { - AnsiblePythonInterpreter string `yaml:"ansible_python_interpreter"` - } `yaml:"vars"` - } `yaml:"all"` - Main struct { - Hosts struct { - Host1 struct { - AnsibleHost string `yaml:"ansible_host"` - AnsiblePort int `yaml:"ansible_port"` - AnsibleUser string `yaml:"ansible_user"` - AnsibleSSHPass string `yaml:"ansible_ssh_pass"` - AnsibleSudoPass string `yaml:"ansible_sudo_pass"` - } `yaml:"host1"` - } `yaml:"hosts"` - } `yaml:"main"` -} - -// DetectPlugins Detects all the plugins available -func DetectPlugins() (*Plugins, error) { - config, err := config.ConfigInit(nil, nil) - if err != nil { - return nil, err - } - folders, err := ioutil.ReadDir(config.PluginPath) - if err != nil { - return nil, err - } - - var plugins *Plugins = new(Plugins) - - for _, f := range folders { - if f.IsDir() { - //Declare variable plugin of type Plugin - var plugin Plugin - - // Setting name of folder to plugin - plugin.FolderName = f.Name() - // Getting Description from file description.txt - Description, err := ioutil.ReadFile(config.PluginPath + "/" + plugin.FolderName + "/description.txt") - // if we os.Open returns an error then handle it - if err != nil { - return nil, err - } - - // Get Description from description.txt - plugin.PluginDescription = string(Description) - // Set plugin path - plugin.path = config.PluginPath + "/" + plugin.FolderName - - plugins.PluginsDetected = append(plugins.PluginsDetected, &plugin) - // Get the number of ports the plugin needs - err = plugin.NumPorts() - if err != nil { - return nil, err - } - } - } - - return plugins, nil -} - -// SearchPlugin Detects plugin information based on the -// name provided on the parameter -func SearchPlugin(pluginname string) (*Plugin, error) { - plugins, err := DetectPlugins() - if err != nil { - return nil, err - } - - // loop ot find the plugin name that matches - for _, plugin := range plugins.PluginsDetected { - if pluginname == plugin.FolderName { - return plugin, nil - } - } - - return nil, errors.New("plugin not detected") -} - -// RunPlugin Executes plugins based on the plugin name provided -func RunPlugin(pluginName string, IPAddresses []*ExecuteIP) (*Plugin, error) { - plugins, err := DetectPlugins() - if err != nil { - return nil, err - } - - // Variable to store struct information about the plugin - var plugindetected *Plugin - for _, plugin := range plugins.PluginsDetected { - if plugin.FolderName == pluginName { - plugindetected = plugin - plugindetected.Execute = IPAddresses - // Get Execute plugin path from config file - config, err := config.ConfigInit(nil, nil) - if err != nil { - return nil, err - } - plugindetected.path = config.PluginPath - break - } - } - - if plugindetected == nil { - return nil, errors.New("Plugin not detected") - } - - // Create copy of the plugin the tmp directory - // To ensure we execute the plugin from there - err = plugindetected.CopyToTmpPlugin() - if err != nil { - return nil, err - } - - // Executing the plugin - err = plugindetected.ExecutePlugin() - if err != nil { - return nil, err - } - - return plugindetected, nil -} - -// ExecutePlugin Function to execute plugins that are called -func (p *Plugin) ExecutePlugin() error { - - // Run ip address to execute ansible inside - for _, execute := range p.Execute { - // Modify ansible hosts before executing - err := execute.ModifyHost(p) - if err != nil { - return err - } - // sets the ports to the plugin folder - err = p.AutoSetPorts(execute.ContainerID) - if err != nil { - return err - } - err = execute.RunAnsible(p) - if err != nil { - return err - } - // If ran successfully then change success flag to true - execute.Success = true - } - return nil -} - -// RunAnsible Executes based on credentials on the struct -func (e *ExecuteIP) RunAnsible(p *Plugin) error { - ansiblePlaybookConnectionOptions := &options.AnsibleConnectionOptions{ - User: "master", - } - - ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ - Inventory: p.path + "/" + p.FolderName + "/hosts", - ExtraVars: map[string]interface{}{"ansible_ssh_common_args": "-o StrictHostKeyChecking=no"}, - } - - ansiblePlaybookPrivilegeEscalationOptions := &options.AnsiblePrivilegeEscalationOptions{ - Become: true, - } - - playbook := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{p.path + "/" + p.FolderName + "/site.yml"}, - ConnectionOptions: ansiblePlaybookConnectionOptions, - PrivilegeEscalationOptions: ansiblePlaybookPrivilegeEscalationOptions, - Options: ansiblePlaybookOptions, - Exec: execute.NewDefaultExecute( - execute.WithTransformers( - results.Prepend("success"), - ), - ), - } - - err := playbook.Run(context.TODO()) - if err != nil { - return err - } - - return nil -} - -// ModifyHost adds IP address , port no to the config file -func (e *ExecuteIP) ModifyHost(p *Plugin) error { - host, err := ReadHost(p.path + "/" + p.FolderName + "/hosts") - if err != nil { - return err - } - // Setting ansible host - host.Main.Hosts.Host1.AnsibleHost = e.IPAddress - // Setting SSH port no - host.Main.Hosts.Host1.AnsiblePort, err = strconv.Atoi(e.SSHPortNo) - if err != nil { - return err - } - // Setting SSH user name - host.Main.Hosts.Host1.AnsibleUser = "master" - // Setting SSH password - host.Main.Hosts.Host1.AnsibleSSHPass = "password" - // Setting SSH sudo password - host.Main.Hosts.Host1.AnsibleSudoPass = "password" - - // write modified information to the hosts yaml file - data, err := yaml.Marshal(host) - if err != nil { - return err - } - err = ioutil.WriteFile(p.path+"/"+p.FolderName+"/hosts", data, 0777) - if err != nil { - return err - } - return nil -} - -// ReadHost Reads host file and adds -func ReadHost(filename string) (*Host, error) { - buf, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - - c := &Host{} - err = yaml.Unmarshal(buf, c) - if err != nil { - return nil, fmt.Errorf("in file %q: %v", filename, err) - } - - return c, nil -} - -// RunPluginContainer Runs ansible plugin based on plugin name and container name which -// is derived from the tracked containers file -// We pass in the group ID as a parameter because when we modify the ports taken -func RunPluginContainer(PluginName string, ContainerID string) error { - // Gets container information based on container ID - ContainerInformation, err := client.GetContainerInformation(ContainerID) - if err != nil { - return err - } - - // Setting Up IP's for which the plugins will be executed - var ExecuteIPs []*ExecuteIP - var ExecuteIP ExecuteIP - // Getting port no of SSH port - for _, port := range ContainerInformation.Container.Ports.PortSet { - if port.PortName == "SSH" { - ExecuteIP.SSHPortNo = fmt.Sprint(port.ExternalPort) - break - } - } - // Handle error if SSH port is not provided - if ExecuteIP.SSHPortNo == "" { - return errors.New("SSH port not found") - } - // Split the port no from ip address since current the IP address - // field is populated as - // : - - host, _, err := net.SplitHostPort(ContainerInformation.IpAddress) - if err != nil { - return err - } - // IP address of the container - ExecuteIP.IPAddress = host - // Set container ID to ExecutorIP - ExecuteIP.ContainerID = ContainerInformation.Id - // Append IP to list of executor IP - ExecuteIPs = append(ExecuteIPs, &ExecuteIP) - // Run plugin to execute plugin - _, err = RunPlugin(PluginName, ExecuteIPs) - if err != nil { - return err - } - - return nil -} - -// CheckRunPlugin Checks if the ID belongs to the group or container -// calls the plugin function the appropriate amount of times -func CheckRunPlugin(PluginName string, ID string) error { - // Check if the ID belongs to the group or container ID - id, err := client.CheckID(ID) - if err != nil { - return err - } - // When the ID belongs to a group - if id == "group" { - // gets the group information - group, err := client.GetGroup(ID) - if err != nil { - return err - } - // Iterate through each container information in the group - // and run the plugin in each of them - for _, container := range group.TrackContainerList { - // runs plugin for each container - err := RunPluginContainer(PluginName, container.Id) - if err != nil { - return err - } - } - } else { // This means the following ID is a container ID - err := RunPluginContainer(PluginName, ID) - if err != nil { - return err - } - } - - return nil -} - -// CopyToTmpPlugin This function would ensure that we create a copy of the -// plugin in the tmp directory, and it would be executed -// from there. This due to the reason of automating port allocation -// when running plugins -func (p *Plugin) CopyToTmpPlugin() error { - // generate rand to UUID this is debug the ansible file if needed - id := uuid.New() - // copies the plugin to the tmp directory - err := copy.Copy(p.path+"/"+p.FolderName, "/tmp/"+id.String()+"_"+p.FolderName) - if err != nil { - return err - } - - // Set the plugin execution to the tmp location - p.path = "/tmp" - p.FolderName = id.String() + "_" + p.FolderName - - return nil -} - -// AutoSetPorts Automatically maps free ports to site.yml file -func (p *Plugin) AutoSetPorts(containerID string) error { - container, err := client.GetContainerInformation(containerID) - if err != nil { - return err - } - // variable that would have a list of ports - // to be allocated to the plugin system - var ports []int - // Counted that increments when a port is taken - PortTaken := 0 - // setting all external ports available in an array - for i, port := range container.Container.Ports.PortSet { - if port.IsUsed == false { - // Ensuring we break outside the loop once the ports - // are set. - if PortTaken >= p.NumOfPorts { - break - } - // Setting the following port flag to true - container.Container.Ports.PortSet[i].IsUsed = true - // Incrementing the variable PortTaken - PortTaken++ - // Maps to internal since - // Inside the machine - // internal port -> (maps) same internal port - // TURN (i.e FRP) based approach (internal port -> maps to different external port) - ports = append(ports, port.InternalPort) - } - } - - // parses the site.yml file in the tmp directory - t, err := template.ParseFiles(p.path + "/" + p.FolderName + "/site.yml") - if err != nil { - return err - } - // opens the output file - f, err := os.Create(p.path + "/" + p.FolderName + "/site.yml") - if err != nil { - return err - } - // sends the ports to the site.yml file to populate them - err = t.Execute(f, ports) - if err != nil { - return err - } - // Once the following is done set port to taken - // n tracked container list - err = container.ModifyContainerInformation() - if err != nil { - return err - } - // Once the following is done set port to taken - // I(Groups) - err = container.ModifyContainerGroups() - if err != nil { - return err - } - - return nil -} - -// NumPorts Gets the Number the ports the -// plugin requires -func (p *Plugin) NumPorts() error { - jsonFile, err := os.Open(p.path + "/ports.json") - // if we os.Open returns an error then handle it - if err != nil { - return err - } - - // defer the closing of our jsonFile so that we can parse it later on - defer jsonFile.Close() - - // read our opened xmlFile as a byte array. - byteValue, _ := ioutil.ReadAll(jsonFile) - - // we unmarshal our byteArray which contains our - // jsonFile's content into 'users' which we defined above - json.Unmarshal(byteValue, &p) - - return nil -} diff --git a/plugin/plugin_test.go b/plugin/plugin_test.go deleted file mode 100644 index 8db66a1..0000000 --- a/plugin/plugin_test.go +++ /dev/null @@ -1,257 +0,0 @@ -package plugin - -// import ( -// "fmt" -// "github.com/Akilan1999/p2p-rendering-computation/client" -// "github.com/Akilan1999/p2p-rendering-computation/config" -// "github.com/Akilan1999/p2p-rendering-computation/server/docker" -// "net" -// "strconv" -// "testing" -// ) -// -// // Test if the dummy plugin added is detected -// func TestDetectPlugins(t *testing.T) { -// _, err := DetectPlugins() -// if err != nil { -// t.Fail() -// } -// } -// -// // Test ensures that the ansible are executed inside local containers -// func TestRunPlugin(t *testing.T) { -// var testips []*ExecuteIP -// var testip1, testip2 ExecuteIP -// -// // Create docker container and get SSH port -// container1, err := docker.BuildRunContainer(0, "false", "") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// //Test IP 1 configuration -// testip1.IPAddress = "0.0.0.0" -// testip1.SSHPortNo = strconv.Itoa(container1.Ports.PortSet[0].ExternalPort) -// -// // Create docker container and get SSH port -// container2, err := docker.BuildRunContainer(0, "false", "") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// //Test IP 2 configuration -// testip2.IPAddress = "0.0.0.0" -// testip2.SSHPortNo = strconv.Itoa(container2.Ports.PortSet[0].ExternalPort) -// -// testips = append(testips, &testip1) -// testips = append(testips, &testip2) -// -// _, err = RunPlugin("TestAnsible", testips) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removing container1 after Ansible is executed -// err = docker.StopAndRemoveContainer(container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// err = docker.StopAndRemoveContainer(container2.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// } -// -// // Test to ensure that the ansible host file is modified to -// // the appropriate IP -// func TestExecuteIP_ModifyHost(t *testing.T) { -// var plugin Plugin -// var testip ExecuteIP -// -// // Get plugin path from config file -// Config, err := config.ConfigInit(nil, nil) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// //Set plugin name -// plugin.FolderName = "TestAnsible" -// plugin.path = Config.PluginPath -// -// //Test IP 1 configuration -// testip.IPAddress = "0.0.0.0" -// testip.SSHPortNo = "41289" -// -// err = testip.ModifyHost(&plugin) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// } -// -// // Test to ensure the cli function runs as intended and executes -// // the test ansible script -// func TestRunPluginContainer(t *testing.T) { -// // Create docker container and get SSH port -// container1, err := docker.BuildRunContainer(0, "false", "") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Ensuring created container is the added to the tracked list -// err = client.AddTrackContainer(container1, "0.0.0.0") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Running test Ansible script -// err = RunPluginContainer("TestAnsible", container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removes container information from the tracker IP addresses -// err = client.RemoveTrackedContainer(container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removing container1 after Ansible is executed -// err = docker.StopAndRemoveContainer(container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// } -// -// // Testing the function can plugin can run with -// // group ID and container ID -// func TestCheckRunPlugin(t *testing.T) { -// // Create docker container and get SSH port -// container1, err := docker.BuildRunContainer(0, "false", "") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// // Create docker container and get SSH port -// container2, err := docker.BuildRunContainer(0, "false", "") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Ensuring created container1 is the added to the tracked list -// err = client.AddTrackContainer(container1, "0.0.0.0") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// // Ensuring created container2 is the added to the tracked list -// err = client.AddTrackContainer(container2, "0.0.0.0") -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Create group to add created containers -// group, err := client.CreateGroup() -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Add container 1 to the group -// _, err = client.AddContainerToGroup(container1.ID, group.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Add container 2 to the group -// _, err = client.AddContainerToGroup(container2.ID, group.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // -------------------------- Main test cases ------------------------------- -// -// // Checking function against container ID -// err = CheckRunPlugin("TestAnsible", container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Checking function against group ID -// err = CheckRunPlugin("TestAnsible", group.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // ---------------------------------------------------------------------------- -// -// // Remove created group -// err = client.RemoveGroup(group.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removes container1 information from the tracker IP addresses -// err = client.RemoveTrackedContainer(container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removing container1 after Ansible is executed -// err = docker.StopAndRemoveContainer(container1.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removes container2 information from the tracker IP addresses -// err = client.RemoveTrackedContainer(container2.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// // Removing container2 after Ansible is executed -// err = docker.StopAndRemoveContainer(container2.ID) -// if err != nil { -// fmt.Println(err) -// t.Fail() -// } -// -// } -// -// func TestDownloadPlugin(t *testing.T) { -// err := DownloadPlugin("https://github.com/Akilan1999/laplace/") -// if err != nil { -// -// } -// } -// -// // Simple test case implemented to the test if -// // the port no can be extracted from the IP address. -// func TestParseIP(t *testing.T) { -// host, port, err := net.SplitHostPort("12.34.23.13:5432") -// if err != nil { -// fmt.Printf("Error: %v\n", err) -// } else { -// fmt.Printf("Host: %s\nPort: %s\n", host, port) -// } -// } diff --git a/server/docker/.DS_Store b/server/docker/.DS_Store deleted file mode 100644 index 8f300a7..0000000 Binary files a/server/docker/.DS_Store and /dev/null differ diff --git a/server/docker/Makefile b/server/docker/Makefile deleted file mode 100644 index c522e6b..0000000 --- a/server/docker/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -SHELL := /bin/bash - -.PHONY: set_virtualenv,install_docker_requirements,dockerproc - -set_virtualenv: - virtualenv env - -install_docker_requirements: - source env/bin/activate && pip install -r requirements.txt - -dockerproc: - ADMIN_USER=admin ADMIN_PASSWORD=admin docker-compose -f dockprom/docker-compose.yml up -d \ No newline at end of file diff --git a/server/docker/README b/server/docker/README deleted file mode 100644 index af4eac9..0000000 --- a/server/docker/README +++ /dev/null @@ -1,6 +0,0 @@ -Docker Module P2P-rendering-computation -======================================== - -This module is incharge to spin up docker contaianers , create -SSH server and VNC server. This module is implemented using -python. \ No newline at end of file diff --git a/server/docker/docker.go b/server/docker/docker.go deleted file mode 100644 index 26dcd10..0000000 --- a/server/docker/docker.go +++ /dev/null @@ -1,508 +0,0 @@ -package docker - -import ( - "bufio" - "bytes" - "encoding/json" - "errors" - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/docker/docker/client" - "github.com/google/uuid" - "github.com/lithammer/shortuuid" - "github.com/otiai10/copy" - "github.com/phayes/freeport" - "io" - "io/ioutil" - "os" - "os/exec" - "text/template" -) - -type DockerVM struct { - SSHUsername string `json:"SSHUsername"` - SSHPublcKey string `json:"SSHPublicKey"` - ID string `json:"ID"` - TagName string `json:"TagName"` - ImagePath string `json:"ImagePath"` - Ports Ports `json:"Ports"` - GPU string `json:"GPU"` - TempPath string - BaseImage string - LogsPath string - SSHCommand string `json:"SSHCommand"` -} - -type DockerContainers struct { - DockerContainer []DockerContainer `json:"DockerContainer"` -} - -type DockerContainer struct { - ContainerName string `json:"DockerContainerName"` - ContainerDescription string `json:"ContainerDescription"` -} - -type Ports struct { - PortSet []Port `json:"Port"` -} -type Port struct { - PortName string `json:"PortName"` - InternalPort int `json:"InternalPort"` - Type string `json:"Type"` - ExternalPort int `json:"ExternalPort"` - IsUsed bool `json:"IsUsed"` - Description string `json:"Description"` -} - -type ErrorLine struct { - Error string `json:"error"` - ErrorDetail ErrorDetail `json:"errorDetail"` -} - -type ErrorDetail struct { - Message string `json:"message"` -} - -var dockerRegistryUserID = "" - -// BuildRunContainer Function is incharge to invoke building and running contianer and also allocating external -// ports -func BuildRunContainer(NumPorts int, GPU string, ContainerName string, baseImage string, publicKey string) (*DockerVM, error) { - //Docker Struct Variable - var RespDocker *DockerVM = new(DockerVM) - - // Sets if GPU is selected or not - RespDocker.GPU = GPU - - // Get config informatopn - - // Sets Free port to Struct - //RespDocker.SSHPort = Ports[0] - //RespDocker.VNCPort = Ports[1] - // Sets appropriate username and password to the - // variables in the struct - RespDocker.SSHUsername = "root" - //RespDocker.BaseImage = "ubuntu:20.04" - //RespDocker.VNCPassword = "vncpassword" - - //Default parameters - RespDocker.TagName = "p2p-ubuntu" - // Get Path from config - config, err := config.ConfigInit(nil, nil) - if err != nil { - return nil, err - } - RespDocker.ImagePath = config.DefaultDockerFile - RespDocker.LogsPath = config.DockerRunLogs - RespDocker.SSHPublcKey = publicKey - - // We are checking if the container name is not nil and not equal to the default one used - // which is docker-ubuntu-sshd - if ContainerName != "" && ContainerName != "docker-ubuntu-sshd" { - Containers, err := ViewAllContainers() - if err != nil { - return nil, err - } - - for _, dockerContainer := range Containers.DockerContainer { - if dockerContainer.ContainerName == ContainerName { - RespDocker.ImagePath = config.DockerContainers + ContainerName + "/" - RespDocker.TagName = ContainerName - break - } - } - if RespDocker.ImagePath == config.DefaultDockerFile { - return nil, errors.New("Container " + ContainerName + " does not exist in the server") - } - } - - // Checking if the base image is provided - if baseImage != "" { - RespDocker.BaseImage = baseImage - } else { - RespDocker.BaseImage = "ubuntu:20.04" - } - - // Template docker with the base image provided - err = RespDocker.TemplateDockerContainer() - if err != nil { - return nil, err - } - - // Template the DockerFile and point to the temp location - - PortsInformation, err := OpenPortsFile(RespDocker.ImagePath + "/" + RespDocker.TagName + "/ports.json") - if err != nil { - return nil, err - } - - // Number of perts we want to open + number of ports required inside the - // docker container - count := NumPorts + len(PortsInformation.PortSet) - // Creates number of ports - OpenPorts, err := freeport.GetFreePorts(count) - if err != nil { - return nil, err - } - // Allocate external ports to ports available in the ports.json file - for i := range PortsInformation.PortSet { - // Setting external ports - PortsInformation.PortSet[i].ExternalPort = OpenPorts[i] - PortsInformation.PortSet[i].IsUsed = true - } - //Length of Ports allocated from thr port file - portFileLength := len(PortsInformation.PortSet) - // Allocate New ports the user wants to generate - for i := 0; i < NumPorts; i++ { - var TempPort Port - TempPort.PortName = "AutoGen Port" - TempPort.Type = "tcp" - TempPort.InternalPort = OpenPorts[portFileLength+i] - TempPort.ExternalPort = OpenPorts[portFileLength+i] - TempPort.Description = "Auto generated TCP port" - TempPort.IsUsed = false - //Append temp port to port information - PortsInformation.PortSet = append(PortsInformation.PortSet, TempPort) - } - // Setting ports to the docker VM struct - RespDocker.Ports = *PortsInformation - - // Gets docker information from env variables - cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) - if err != nil { - return nil, err - } - - // Builds docker image - err = RespDocker.imageBuild(cli) - if err != nil { - return nil, err - } - - // Runs docker contianer - err = RespDocker.runContainer(cli) - - if err != nil { - return nil, err - } - - return RespDocker, nil - -} - -// Builds docker image (TODO: relative path for Dockerfile deploy) -func (d *DockerVM) imageBuild(dockerClient *client.Client) error { - //ctx, _ := context.WithTimeout(context.Background(), time.Second*2000) - //defer cancel() - - var cmd bytes.Buffer - cmd.WriteString("docker build -t " + d.TagName + " " + d.ImagePath + "/" + d.TagName + ` --build-arg SSH_KEY="` + d.SSHPublcKey + `"`) - //"-v=/opt/data:/data p2p-ubuntu /start > /dev/null" - cmdStr := cmd.String() - output, err := exec.Command("/bin/sh", "-c", cmdStr).Output() - fmt.Printf("%s", output) - if err != nil { - return err - } - - //tar, err := archive.TarWithOptions(d.ImagePath+"/"+d.TagName, &archive.TarOptions{}) - //if err != nil { - // return err - //} - // - //opts := types.ImageBuildOptions{ - // Dockerfile: "Dockerfile", - // Tags: []string{d.TagName}, - // Remove: true, - //} - //res, err := dockerClient.ImageBuild(ctx, tar, opts) - //if err != nil { - // return err - //} - // - //defer res.Body.Close() - // - //err = print(res.Body) - //if err != nil { - // return err - //} - - return nil -} - -// Starts container and assigns port numbers -// Sample Docker run Command -// docker run -d=true --name=Test123 --restart=always --gpus all -// -p 3443:6901 -p 3453:22 -p 3434:3434 -p 3245:3245 -v=/opt/data:/data -// p2p-ubuntu /start > /dev/null -func (d *DockerVM) runContainer(dockerClient *client.Client) error { - //ctx, _ := context.WithTimeout(context.Background(), time.Second*2000) - - // The first mode runs using the Docker Api. As the API supports using - // CPU and uses a shell script for GPU call because till this point of - // implementation docker api does not support the flag "--gpu all" - //if d.GPU != "true" { - // //Exposed ports for docker config file - // var ExposedPort nat.PortSet - // - // ExposedPort = nat.PortSet{ - // "22/tcp": struct{}{}, - // //"6901/tcp": struct{}{}, - // } - // - // // Port forwarding for VNC and SSH ports - // PortForwarding := nat.PortMap{ - // //"22/tcp": []nat.PortBinding{ - // // { - // // HostIP: "0.0.0.0", - // // HostPort: fmt.Sprint(d.SSHPort), - // // }, - // //}, - // //"6901/tcp": []nat.PortBinding{ - // // { - // // HostIP: "0.0.0.0", - // // HostPort: fmt.Sprint(d.VNCPort), - // // }, - // //}, - // } - // - // for i := range d.Ports.PortSet { - // // Parameters "tcp or udp", external port - // Port, err := nat.NewPort(d.Ports.PortSet[i].Type, fmt.Sprint(d.Ports.PortSet[i].InternalPort)) - // if err != nil { - // return err - // } - // - // // Exposed Ports - // ExposedPort[Port] = struct{}{} - // - // PortForwarding[Port] = []nat.PortBinding{ - // { - // HostIP: "0.0.0.0", - // HostPort: fmt.Sprint(d.Ports.PortSet[i].ExternalPort), - // }, - // } - // } - // - // config := &container.Config{ - // Image: d.TagName, - // Entrypoint: []string{"/start"}, - // Volumes: map[string]struct{}{"/opt/data:/data": {}}, - // ExposedPorts: ExposedPort, - // } - // hostConfig := &container.HostConfig{ - // PortBindings: PortForwarding, - // } - // - // res, err := dockerClient.ContainerCreate(ctx, config, hostConfig, - // nil, nil, "") - // - // // Set response ID - // d.ID = res.ID - // - // if err != nil { - // return err - // } - // - // err = dockerClient.ContainerStart(ctx, res.ID, types.ContainerStartOptions{}) - // - // if err != nil { - // return err - // } - //} else { - // Generate Random ID - id := shortuuid.New() - d.ID = id - - var cmd bytes.Buffer - cmd.WriteString("docker run -d=true --name=" + id + " --restart=always ") - if d.GPU == "true" { - cmd.WriteString("--gpus all ") - } - - for i := range d.Ports.PortSet { - cmd.WriteString("-p " + fmt.Sprint(d.Ports.PortSet[i].ExternalPort) + ":" + fmt.Sprint(d.Ports.PortSet[i].InternalPort) + " ") - } - cmd.WriteString("-v=/tmp:/data " + d.TagName + " > /dev/null") - //"-v=/opt/data:/data p2p-ubuntu /start > /dev/null" - cmdStr := cmd.String() - _, err := exec.Command("/bin/sh", "-c", cmdStr).Output() - if err != nil { - return err - } - //} - return nil -} - -// StopAndRemoveContainer -// Stop and remove a container -// Reference (https://gist.github.com/frikky/e2efcea6c733ea8d8d015b7fe8a91bf6) -func StopAndRemoveContainer(containername string) error { - //ctx := context.Background() - // - //// Gets docker information from env variables - //client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) - //if err != nil { - // return err - //} - // - //if err = client.ContainerStop(ctx, containername, nil); err != nil { - // return err - //} - // - //removeOptions := types.ContainerRemoveOptions{ - // RemoveVolumes: true, - // Force: true, - //} - // - //if err = client.ContainerRemove(ctx, containername, removeOptions); err != nil { - // return err - //} - - // stop docker container - var stop bytes.Buffer - stop.WriteString("docker stop " + containername) - - cmdStr := stop.String() - _, err := exec.Command("/bin/sh", "-c", cmdStr).Output() - if err != nil { - return err - } - - // remove docker container - var remove bytes.Buffer - remove.WriteString("docker remove " + containername) - - cmdStr = remove.String() - - _, err = exec.Command("/bin/sh", "-c", cmdStr).Output() - if err != nil { - return err - } - - return nil -} - -// ViewAllContainers returns all containers runnable and which can be built -func ViewAllContainers() (*DockerContainers, error) { - // Traverse the deploy path as per given in the config file - config, err := config.ConfigInit(nil, nil) - if err != nil { - return nil, err - } - - folders, err := ioutil.ReadDir(config.DockerContainers) - if err != nil { - return nil, err - } - - //Declare variable DockerContainers of type struct - var Containers *DockerContainers = new(DockerContainers) - - for _, f := range folders { - if f.IsDir() { - //Declare variable DockerContainer of type struct - var Container DockerContainer - - // Setting container name to deploy name - Container.ContainerName = f.Name() - // Getting Description from file description.txt - Description, err := ioutil.ReadFile(config.DockerContainers + "/" + Container.ContainerName + "/description.txt") - // if we os.Open returns an error then handle it - if err != nil { - return nil, err - } - - // Get Description from description.txt - Container.ContainerDescription = string(Description) - - Containers.DockerContainer = append(Containers.DockerContainer, Container) - } - } - - return Containers, nil -} - -func print(rd io.Reader) error { - var lastLine string - - scanner := bufio.NewScanner(rd) - for scanner.Scan() { - lastLine = scanner.Text() - } - - errLine := &ErrorLine{} - json.Unmarshal([]byte(lastLine), errLine) - if errLine.Error != "" { - return errors.New(errLine.Error) - } - - if err := scanner.Err(); err != nil { - return err - } - - return nil -} - -func OpenPortsFile(filename string) (*Ports, error) { - buf, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - - c := &Ports{} - err = json.Unmarshal(buf, c) - if err != nil { - return nil, fmt.Errorf("in file %q: %v", filename, err) - } - - return c, nil -} - -// TemplateDockerContainer This function templates the docker container -// with the base docker image to use -func (d *DockerVM) TemplateDockerContainer() error { - err := d.CopyToTmpContainer() - if err != nil { - return err - } - - // parses the site.yml file in the tmp directory - t, err := template.ParseFiles(d.ImagePath + "/" + d.TagName + "/Dockerfile") - if err != nil { - return err - } - // opens the output file - f, err := os.Create(d.ImagePath + "/" + d.TagName + "/Dockerfile") - if err != nil { - return err - } - - image := d.BaseImage - - // Pass in Docker Base Image - err = t.Execute(f, image) - if err != nil { - return err - } - - return nil -} - -// CopyToTmpContainer Creates a copy of the docker folder -func (d *DockerVM) CopyToTmpContainer() error { - // generate rand to UUID this is debug the ansible file if needed - id := uuid.New() - // copies the plugin to the tmp directory - err := copy.Copy(d.ImagePath+"/", d.LogsPath+id.String()+"_"+d.TagName) - if err != nil { - return err - } - - // Set the plugin execution to the tmp location - d.TagName = id.String() + "_" + d.TagName - // removing slash - d.ImagePath = d.LogsPath[:len(d.LogsPath)-1] - - return nil -} diff --git a/server/docker/docker_test.go b/server/docker/docker_test.go deleted file mode 100644 index 1e2bbd3..0000000 --- a/server/docker/docker_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package docker - -// import ( -// "testing" -// ) -// -// func TestDockerUbuntuSSHDProvided(t *testing.T) { -// // Testing by providing default container name -// _,err := BuildRunContainer(2,"false","docker-ubuntu-sshd") -// -// if err != nil { -// t.Error(err) -// } -// -// } -// -// func TestDockerDefaultContainer(t *testing.T) { -// // Testing by providing without providing default container name -// _,err := BuildRunContainer(2,"false","") -// -// if err != nil { -// t.Error(err) -// } -// } -// -// func TestContainerHorovod(t *testing.T) { -// // Testing by providing the horovod cpu image -// _,err := BuildRunContainer(2,"false","cpuhorovod") -// -// if err != nil { -// t.Error(err) -// } -// } -// -// func TestViewAllContainers(t *testing.T) { -// _,err := ViewAllContainers() -// -// if err != nil { -// t.Error(err) -// } -// -// } diff --git a/server/docker/dockprom/LICENSE b/server/docker/dockprom/LICENSE deleted file mode 100644 index cd9083b..0000000 --- a/server/docker/dockprom/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Stefan Prodan - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/server/docker/dockprom/README.md b/server/docker/dockprom/README.md deleted file mode 100644 index 9bb8602..0000000 --- a/server/docker/dockprom/README.md +++ /dev/null @@ -1,353 +0,0 @@ -dockprom -======== - -A monitoring solution for Docker hosts and containers with [Prometheus](https://prometheus.io/), [Grafana](http://grafana.org/), [cAdvisor](https://github.com/google/cadvisor), -[NodeExporter](https://github.com/prometheus/node_exporter) and alerting with [AlertManager](https://github.com/prometheus/alertmanager). - -***If you're looking for the Docker Swarm version please go to [stefanprodan/swarmprom](https://github.com/stefanprodan/swarmprom)*** - -## Install - -Clone this repository on your Docker host, cd into dockprom directory and run compose up: - -```bash -git clone https://github.com/stefanprodan/dockprom -cd dockprom - -ADMIN_USER=admin ADMIN_PASSWORD=admin docker-compose up -d -``` - -Prerequisites: - -* Docker Engine >= 1.13 -* Docker Compose >= 1.11 - -Containers: - -* Prometheus (metrics database) `http://:9090` -* Prometheus-Pushgateway (push acceptor for ephemeral and batch jobs) `http://:9091` -* AlertManager (alerts management) `http://:9093` -* Grafana (visualize metrics) `http://:3000` -* NodeExporter (host metrics collector) -* cAdvisor (containers metrics collector) -* Caddy (reverse proxy and basic auth provider for prometheus and alertmanager) - -## Setup Grafana - -Navigate to `http://:3000` and login with user ***admin*** password ***admin***. You can change the credentials in the compose file or by supplying the `ADMIN_USER` and `ADMIN_PASSWORD` environment variables on compose up. The config file can be added directly in grafana part like this -``` -grafana: - image: grafana/grafana:7.2.0 - env_file: - - config - -``` -and the config file format should have this content -``` -GF_SECURITY_ADMIN_USER=admin -GF_SECURITY_ADMIN_PASSWORD=changeme -GF_USERS_ALLOW_SIGN_UP=false -``` -If you want to change the password, you have to remove this entry, otherwise the change will not take effect -``` -- grafana_data:/var/lib/grafana -``` - -Grafana is preconfigured with dashboards and Prometheus as the default data source: - -* Name: Prometheus -* Type: Prometheus -* Url: http://prometheus:9090 -* Access: proxy - -***Docker Host Dashboard*** - -![Host](https://raw.githubusercontent.com/stefanprodan/dockprom/master/screens/Grafana_Docker_Host.png) - -The Docker Host Dashboard shows key metrics for monitoring the resource usage of your server: - -* Server uptime, CPU idle percent, number of CPU cores, available memory, swap and storage -* System load average graph, running and blocked by IO processes graph, interrupts graph -* CPU usage graph by mode (guest, idle, iowait, irq, nice, softirq, steal, system, user) -* Memory usage graph by distribution (used, free, buffers, cached) -* IO usage graph (read Bps, read Bps and IO time) -* Network usage graph by device (inbound Bps, Outbound Bps) -* Swap usage and activity graphs - -For storage and particularly Free Storage graph, you have to specify the fstype in grafana graph request. -You can find it in `grafana/dashboards/docker_host.json`, at line 480 : - - "expr": "sum(node_filesystem_free_bytes{fstype=\"btrfs\"})", - -I work on BTRFS, so i need to change `aufs` to `btrfs`. - -You can find right value for your system in Prometheus `http://:9090` launching this request : - - node_filesystem_free_bytes - -***Docker Containers Dashboard*** - -![Containers](https://raw.githubusercontent.com/stefanprodan/dockprom/master/screens/Grafana_Docker_Containers.png) - -The Docker Containers Dashboard shows key metrics for monitoring running containers: - -* Total containers CPU load, memory and storage usage -* Running containers graph, system load graph, IO usage graph -* Container CPU usage graph -* Container memory usage graph -* Container cached memory usage graph -* Container network inbound usage graph -* Container network outbound usage graph - -> [!NOTE] -> This dashboard doesn't show the containers that are part of the monitoring stack. - -***Monitor Services Dashboard*** - -![Monitor Services](https://raw.githubusercontent.com/stefanprodan/dockprom/master/screens/Grafana_Prometheus.png) - -The Monitor Services Dashboard shows key metrics for monitoring the containers that make up the monitoring stack: - -* Prometheus container uptime, monitoring stack total memory usage, Prometheus local storage memory chunks and series -* Container CPU usage graph -* Container memory usage graph -* Prometheus chunks to persist and persistence urgency graphs -* Prometheus chunks ops and checkpoint duration graphs -* Prometheus samples ingested rate, target scrapes and scrape duration graphs -* Prometheus HTTP requests graph -* Prometheus alerts graph - -## Define alerts - -Three alert groups have been setup within the [alert.rules](https://github.com/stefanprodan/dockprom/blob/master/prometheus/alert.rules) configuration file: - -* Monitoring services alerts [targets](https://github.com/stefanprodan/dockprom/blob/master/prometheus/alert.rules#L2-L11) -* Docker Host alerts [host](https://github.com/stefanprodan/dockprom/blob/master/prometheus/alert.rules#L13-L40) -* Docker Containers alerts [containers](https://github.com/stefanprodan/dockprom/blob/master/prometheus/alert.rules#L42-L69) - -You can modify the alert rules and reload them by making a HTTP POST call to Prometheus: - -``` -curl -X POST http://admin:admin@:9090/-/reload -``` - -***Monitoring services alerts*** - -Trigger an alert if any of the monitoring targets (node-exporter and cAdvisor) are down for more than 30 seconds: - -```yaml -- alert: monitor_service_down - expr: up == 0 - for: 30s - labels: - severity: critical - annotations: - summary: "Monitor service non-operational" - description: "Service {{ $labels.instance }} is down." -``` - -***Docker Host alerts*** - -Trigger an alert if the Docker host CPU is under high load for more than 30 seconds: - -```yaml -- alert: high_cpu_load - expr: node_load1 > 1.5 - for: 30s - labels: - severity: warning - annotations: - summary: "Server under high load" - description: "Docker host is under high load, the avg load 1m is at {{ $value}}. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." -``` - -Modify the load threshold based on your CPU cores. - -Trigger an alert if the Docker host memory is almost full: - -```yaml -- alert: high_memory_load - expr: (sum(node_memory_MemTotal_bytes) - sum(node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes) ) / sum(node_memory_MemTotal_bytes) * 100 > 85 - for: 30s - labels: - severity: warning - annotations: - summary: "Server memory is almost full" - description: "Docker host memory usage is {{ humanize $value}}%. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." -``` - -Trigger an alert if the Docker host storage is almost full: - -```yaml -- alert: high_storage_load - expr: (node_filesystem_size_bytes{fstype="aufs"} - node_filesystem_free_bytes{fstype="aufs"}) / node_filesystem_size_bytes{fstype="aufs"} * 100 > 85 - for: 30s - labels: - severity: warning - annotations: - summary: "Server storage is almost full" - description: "Docker host storage usage is {{ humanize $value}}%. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." -``` - -***Docker Containers alerts*** - -Trigger an alert if a container is down for more than 30 seconds: - -```yaml -- alert: jenkins_down - expr: absent(container_memory_usage_bytes{name="jenkins"}) - for: 30s - labels: - severity: critical - annotations: - summary: "Jenkins down" - description: "Jenkins container is down for more than 30 seconds." -``` - -Trigger an alert if a container is using more than 10% of total CPU cores for more than 30 seconds: - -```yaml -- alert: jenkins_high_cpu - expr: sum(rate(container_cpu_usage_seconds_total{name="jenkins"}[1m])) / count(node_cpu_seconds_total{mode="system"}) * 100 > 10 - for: 30s - labels: - severity: warning - annotations: - summary: "Jenkins high CPU usage" - description: "Jenkins CPU usage is {{ humanize $value}}%." -``` - -Trigger an alert if a container is using more than 1.2GB of RAM for more than 30 seconds: - -```yaml -- alert: jenkins_high_memory - expr: sum(container_memory_usage_bytes{name="jenkins"}) > 1200000000 - for: 30s - labels: - severity: warning - annotations: - summary: "Jenkins high memory usage" - description: "Jenkins memory consumption is at {{ humanize $value}}." -``` - -## Setup alerting - -The AlertManager service is responsible for handling alerts sent by Prometheus server. -AlertManager can send notifications via email, Pushover, Slack, HipChat or any other system that exposes a webhook interface. -A complete list of integrations can be found [here](https://prometheus.io/docs/alerting/configuration). - -You can view and silence notifications by accessing `http://:9093`. - -The notification receivers can be configured in [alertmanager/config.yml](https://github.com/stefanprodan/dockprom/blob/master/alertmanager/config.yml) file. - -To receive alerts via Slack you need to make a custom integration by choose ***incoming web hooks*** in your Slack team app page. -You can find more details on setting up Slack integration [here](http://www.robustperception.io/using-slack-with-the-alertmanager/). - -Copy the Slack Webhook URL into the ***api_url*** field and specify a Slack ***channel***. - -```yaml -route: - receiver: 'slack' - -receivers: - - name: 'slack' - slack_configs: - - send_resolved: true - text: "{{ .CommonAnnotations.description }}" - username: 'Prometheus' - channel: '#' - api_url: 'https://hooks.slack.com/services/' -``` - -![Slack Notifications](https://raw.githubusercontent.com/stefanprodan/dockprom/master/screens/Slack_Notifications.png) - -## Sending metrics to the Pushgateway - -The [pushgateway](https://github.com/prometheus/pushgateway) is used to collect data from batch jobs or from services. - -To push data, simply execute: - - echo "some_metric 3.14" | curl --data-binary @- http://user:password@localhost:9091/metrics/job/some_job - -Please replace the `user:password` part with your user and password set in the initial configuration (default: `admin:admin`). - -## Updating Grafana to v5.2.2 - -[In Grafana versions >= 5.1 the id of the grafana user has been changed](http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later). Unfortunately this means that files created prior to 5.1 won’t have the correct permissions for later versions. - -| Version | User | User ID | -|:-------:|:-------:|:-------:| -| < 5.1 | grafana | 104 | -| \>= 5.1 | grafana | 472 | - -There are two possible solutions to this problem. -- Change ownership from 104 to 472 -- Start the upgraded container as user 104 - -##### Specifying a user in docker-compose.yml - -To change ownership of the files run your grafana container as root and modify the permissions. - -First perform a `docker-compose down` then modify your docker-compose.yml to include the `user: root` option: - -``` - grafana: - image: grafana/grafana:5.2.2 - container_name: grafana - volumes: - - grafana_data:/var/lib/grafana - - ./grafana/datasources:/etc/grafana/datasources - - ./grafana/dashboards:/etc/grafana/dashboards - - ./grafana/setup.sh:/setup.sh - entrypoint: /setup.sh - user: root - environment: - - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin} - - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} - - GF_USERS_ALLOW_SIGN_UP=false - restart: unless-stopped - expose: - - 3000 - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" -``` - -Perform a `docker-compose up -d` and then issue the following commands: - -``` -docker exec -it --user root grafana bash - -# in the container you just started: -chown -R root:root /etc/grafana && \ -chmod -R a+r /etc/grafana && \ -chown -R grafana:grafana /var/lib/grafana && \ -chown -R grafana:grafana /usr/share/grafana -``` - -To run the grafana container as `user: 104` change your `docker-compose.yml` like such: - -``` - grafana: - image: grafana/grafana:5.2.2 - container_name: grafana - volumes: - - grafana_data:/var/lib/grafana - - ./grafana/datasources:/etc/grafana/datasources - - ./grafana/dashboards:/etc/grafana/dashboards - - ./grafana/setup.sh:/setup.sh - entrypoint: /setup.sh - user: "104" - environment: - - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin} - - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} - - GF_USERS_ALLOW_SIGN_UP=false - restart: unless-stopped - expose: - - 3000 - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" -``` diff --git a/server/docker/dockprom/alertmanager/config.yml b/server/docker/dockprom/alertmanager/config.yml deleted file mode 100644 index 9ecad73..0000000 --- a/server/docker/dockprom/alertmanager/config.yml +++ /dev/null @@ -1,11 +0,0 @@ -route: - receiver: 'slack' - -receivers: - - name: 'slack' - slack_configs: - - send_resolved: true - text: "{{ .CommonAnnotations.description }}" - username: 'Prometheus' - channel: '#' - api_url: 'https://hooks.slack.com/services/' diff --git a/server/docker/dockprom/caddy/Caddyfile b/server/docker/dockprom/caddy/Caddyfile deleted file mode 100644 index 4096680..0000000 --- a/server/docker/dockprom/caddy/Caddyfile +++ /dev/null @@ -1,36 +0,0 @@ -:9090 { - proxy / prometheus:9090 { - transparent - } - - errors stderr - tls off -} - -:9093 { - proxy / alertmanager:9093 { - transparent - } - - errors stderr - tls off -} - -:9091 { - proxy / pushgateway:9091 { - transparent - } - - errors stderr - tls off -} - -:3000 { - proxy / grafana:3000 { - transparent - websocket - } - - errors stderr - tls off -} diff --git a/server/docker/dockprom/config b/server/docker/dockprom/config deleted file mode 100644 index 72e84a6..0000000 --- a/server/docker/dockprom/config +++ /dev/null @@ -1,3 +0,0 @@ -GF_SECURITY_ADMIN_USER=admin -GF_SECURITY_ADMIN_PASSWORD=changeme -GF_USERS_ALLOW_SIGN_UP=false diff --git a/server/docker/dockprom/docker-compose.exporters.yml b/server/docker/dockprom/docker-compose.exporters.yml deleted file mode 100644 index 63b04f7..0000000 --- a/server/docker/dockprom/docker-compose.exporters.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: '2.1' - -services: - - nodeexporter: - image: prom/node-exporter:v1.0.1 - container_name: nodeexporter - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - '--path.procfs=/host/proc' - - '--path.rootfs=/rootfs' - - '--path.sysfs=/host/sys' - - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' - restart: unless-stopped - network_mode: host - labels: - org.label-schema.group: "monitoring" - - cadvisor: - image: gcr.io/cadvisor/cadvisor:v0.38.7 - container_name: cadvisor - volumes: - - /:/rootfs:ro - - /var/run:/var/run:rw - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - - /cgroup:/cgroup:ro - restart: unless-stopped - network_mode: host - labels: - org.label-schema.group: "monitoring" - - diff --git a/server/docker/dockprom/docker-compose.yml b/server/docker/dockprom/docker-compose.yml deleted file mode 100644 index 088455d..0000000 --- a/server/docker/dockprom/docker-compose.yml +++ /dev/null @@ -1,146 +0,0 @@ -version: '2.1' - -networks: - monitor-net: - driver: bridge - -volumes: - prometheus_data: {} - grafana_data: {} - -services: - - prometheus: - image: prom/prometheus:v2.24.1 - container_name: prometheus - volumes: - - ./prometheus:/etc/prometheus - - prometheus_data:/prometheus - command: - - '--config.file=/etc/prometheus/prometheus.yml' - - '--storage.tsdb.path=/prometheus' - - '--web.console.libraries=/etc/prometheus/console_libraries' - - '--web.console.templates=/etc/prometheus/consoles' - - '--storage.tsdb.retention.time=200h' - - '--web.enable-lifecycle' - restart: unless-stopped - expose: - - 9090 - ports: - - "9090:9090" - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" - - alertmanager: - image: prom/alertmanager:v0.21.0 - container_name: alertmanager - volumes: - - ./alertmanager:/etc/alertmanager - command: - - '--config.file=/etc/alertmanager/config.yml' - - '--storage.path=/alertmanager' - restart: unless-stopped - expose: - - 9093 - ports: - - "9093:9093" - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" - - nodeexporter: - image: prom/node-exporter:v1.0.1 - container_name: nodeexporter - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - '--path.procfs=/host/proc' - - '--path.rootfs=/rootfs' - - '--path.sysfs=/host/sys' - - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' - restart: unless-stopped - expose: - - 9100 - ports: - - "9100:9100" - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" - - cadvisor: - image: gcr.io/cadvisor/cadvisor:v0.38.7 - container_name: cadvisor - volumes: - - /:/rootfs:ro - - /var/run:/var/run:rw - - /sys:/sys:ro - - /var/lib/docker:/var/lib/docker:ro - #- /cgroup:/cgroup:ro #doesn't work on MacOS only for Linux - restart: unless-stopped - expose: - - 8080 - ports: - - "8080:8080" - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" - - grafana: - image: grafana/grafana:7.3.7 - container_name: grafana - volumes: - - grafana_data:/var/lib/grafana - - ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards - - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources - environment: - - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin} - - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} - - GF_USERS_ALLOW_SIGN_UP=false - restart: unless-stopped - expose: - - 3000 - ports: - - "3000:3000" - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" - - pushgateway: - image: prom/pushgateway:v1.4.0 - container_name: pushgateway - restart: unless-stopped - expose: - - 9091 - ports: - - "9091:9091" - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" - - caddy: - image: caddy:2.3.0-alpine - container_name: caddy - ports: - - "3000:3000" - - "9090:9090" - - "9093:9093" - - "9091:9091" - volumes: - - ./caddy:/etc/caddy - environment: - - ADMIN_USER=${ADMIN_USER:-admin} - - ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} - restart: unless-stopped - networks: - - monitor-net - labels: - org.label-schema.group: "monitoring" diff --git a/server/docker/dockprom/grafana/provisioning/dashboards/dashboard.yml b/server/docker/dockprom/grafana/provisioning/dashboards/dashboard.yml deleted file mode 100644 index d83b43c..0000000 --- a/server/docker/dockprom/grafana/provisioning/dashboards/dashboard.yml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: 1 - -providers: - - name: 'Prometheus' - orgId: 1 - folder: '' - type: file - disableDeletion: false - editable: true - allowUiUpdates: true - options: - path: /etc/grafana/provisioning/dashboards \ No newline at end of file diff --git a/server/docker/dockprom/grafana/provisioning/dashboards/docker_containers.json b/server/docker/dockprom/grafana/provisioning/dashboards/docker_containers.json deleted file mode 100644 index 5ac83a6..0000000 --- a/server/docker/dockprom/grafana/provisioning/dashboards/docker_containers.json +++ /dev/null @@ -1,1270 +0,0 @@ -{ - "id": null, - "title": "Docker Containers", - "description": "Containers metrics", - "tags": [ - "docker" - ], - "style": "dark", - "timezone": "browser", - "editable": true, - "hideControls": false, - "sharedCrosshair": true, - "rows": [ - { - "collapse": false, - "editable": true, - "height": "150px", - "panels": [ - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(50, 172, 45, 0.97)", - "rgba(237, 129, 40, 0.89)", - "rgba(245, 54, 54, 0.9)" - ], - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "format": "percent", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": true, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 4, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "sum(rate(container_cpu_user_seconds_total{image!=\"\"}[1m])) / count(node_cpu_seconds_total{mode=\"user\"}) * 100", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A", - "step": 10 - } - ], - "thresholds": "65, 90", - "title": "CPU Load", - "transparent": false, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 7, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "machine_cpu_cores", - "interval": "", - "intervalFactor": 2, - "legendFormat": "", - "metric": "machine_cpu_cores", - "refId": "A", - "step": 20 - } - ], - "thresholds": "", - "title": "CPU Cores", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(50, 172, 45, 0.97)", - "rgba(237, 129, 40, 0.89)", - "rgba(245, 54, 54, 0.9)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "percent", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": true, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 5, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "(sum(node_memory_MemTotal_bytes) - sum(node_memory_MemFree_bytes+node_memory_Buffers_bytes+node_memory_Cached_bytes) ) / sum(node_memory_MemTotal_bytes) * 100", - "interval": "10s", - "intervalFactor": 2, - "legendFormat": "", - "refId": "A", - "step": 20 - } - ], - "thresholds": "65, 90", - "title": "Memory Load", - "transparent": false, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "format": "bytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 2, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "sum(container_memory_usage_bytes{image!=\"\"})", - "interval": "10s", - "intervalFactor": 2, - "legendFormat": "", - "refId": "A", - "step": 20 - } - ], - "thresholds": "", - "timeFrom": "10s", - "title": "Used Memory", - "transparent": false, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(50, 172, 45, 0.97)", - "rgba(237, 129, 40, 0.89)", - "rgba(245, 54, 54, 0.9)" - ], - "datasource": "Prometheus", - "decimals": null, - "editable": true, - "error": false, - "format": "percent", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": true, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 6, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "(node_filesystem_size_bytes{fstype=\"aufs\"} - node_filesystem_free_bytes{fstype=\"aufs\"}) / node_filesystem_size_bytes{fstype=\"aufs\"} * 100", - "interval": "30s", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A", - "step": 30 - } - ], - "thresholds": "65, 90", - "title": "Storage Load", - "transparent": false, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "format": "bytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 3, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "sum(container_fs_usage_bytes)", - "interval": "30s", - "intervalFactor": 2, - "refId": "A", - "step": 60 - } - ], - "thresholds": "", - "title": "Used Storage", - "transparent": false, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - } - ], - "title": "Overview" - }, - { - "collapse": false, - "editable": true, - "height": "150px", - "panels": [ - { - "aliasColors": {}, - "bars": true, - "datasource": "Prometheus", - "decimals": 0, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)", - "thresholdLine": false - }, - "id": 9, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "scalar(count(container_memory_usage_bytes{image!=\"\"}) > 0)", - "interval": "", - "intervalFactor": 2, - "legendFormat": "containers", - "refId": "A", - "step": 2 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Running Containers", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "none", - "label": "", - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": true, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 10, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "load 1m", - "color": "#BF1B00" - } - ], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "node_load1", - "interval": "", - "intervalFactor": 2, - "legendFormat": "load 1m", - "metric": "node_load1", - "refId": "A", - "step": 2 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "System Load", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 15, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": false, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "read", - "yaxis": 1 - }, - { - "alias": "written", - "yaxis": 1 - }, - { - "alias": "io time", - "yaxis": 2 - } - ], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(irate(node_disk_read_bytes_total[5m]))", - "interval": "2s", - "intervalFactor": 4, - "legendFormat": "read", - "metric": "", - "refId": "A", - "step": 8 - }, - { - "expr": "sum(irate(node_disk_written_bytes_total[5m]))", - "interval": "2s", - "intervalFactor": 4, - "legendFormat": "written", - "metric": "", - "refId": "B", - "step": 8 - }, - { - "expr": "sum(irate(node_disk_io_time_seconds_total[5m]))", - "interval": "2s", - "intervalFactor": 4, - "legendFormat": "io time", - "metric": "", - "refId": "C", - "step": 8 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "I/O Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "ms", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "Host stats" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 8, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name) (rate(container_cpu_usage_seconds_total{image!=\"\",container_label_org_label_schema_group=\"\"}[1m])) / scalar(count(node_cpu_seconds_total{mode=\"user\"})) * 100", - "intervalFactor": 10, - "legendFormat": "{{ name }}", - "metric": "container_cpu_user_seconds_total", - "refId": "A", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Container CPU Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "percent", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - } - ], - "title": "CPU" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 11, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name)(container_memory_usage_bytes{image!=\"\",container_label_org_label_schema_group=\"\"})", - "intervalFactor": 1, - "legendFormat": "{{ name }}", - "metric": "container_memory_usage", - "refId": "A", - "step": 1 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Container Memory Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 12, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name) (container_memory_cache{image!=\"\",container_label_org_label_schema_group=\"\"})", - "intervalFactor": 2, - "legendFormat": "{{name}}", - "metric": "container_memory_cache", - "refId": "A", - "step": 2 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Container Cached Memory Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - } - ], - "title": "Memory" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 13, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name) (rate(container_network_receive_bytes_total{image!=\"\",container_label_org_label_schema_group=\"\"}[1m]))", - "intervalFactor": 10, - "legendFormat": "{{ name }}", - "metric": "container_network_receive_bytes_total", - "refId": "A", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Container Network Input", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 14, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name) (rate(container_network_transmit_bytes_total{image!=\"\",container_label_org_label_schema_group=\"\"}[1m]))", - "intervalFactor": 10, - "legendFormat": "{{ name }}", - "metric": "container_network_transmit_bytes_total", - "refId": "A", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Container Network Output", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - } - ], - "title": "Network" - } - ], - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "templating": { - "list": [] - }, - "annotations": { - "list": [] - }, - "refresh": "10s", - "schemaVersion": 12, - "version": 8, - "links": [], - "gnetId": null -} \ No newline at end of file diff --git a/server/docker/dockprom/grafana/provisioning/dashboards/docker_host.json b/server/docker/dockprom/grafana/provisioning/dashboards/docker_host.json deleted file mode 100644 index 91eb4ac..0000000 --- a/server/docker/dockprom/grafana/provisioning/dashboards/docker_host.json +++ /dev/null @@ -1,1441 +0,0 @@ -{ - "id": null, - "title": "Docker Host", - "description": "Docker host metrics", - "tags": [ - "system" - ], - "style": "dark", - "timezone": "browser", - "editable": true, - "hideControls": false, - "sharedCrosshair": true, - "rows": [ - { - "collapse": false, - "editable": true, - "height": "100px", - "panels": [ - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "decimals": 1, - "editable": true, - "error": false, - "format": "s", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 1, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "s", - "postfixFontSize": "80%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "node_time_seconds - node_boot_time_seconds", - "interval": "30s", - "intervalFactor": 1, - "refId": "A", - "step": 30 - } - ], - "thresholds": "", - "title": "Uptime", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "percent", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 13, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "sum(rate(node_cpu_seconds_total{mode=\"idle\"}[1m])) * 100 / scalar(count(node_cpu_seconds_total{mode=\"user\"}))", - "interval": "10s", - "intervalFactor": 2, - "legendFormat": "", - "refId": "A", - "step": 20 - } - ], - "thresholds": "", - "title": "CPU Idle", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 12, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "machine_cpu_cores", - "intervalFactor": 2, - "metric": "machine_cpu_cores", - "refId": "A", - "step": 2 - } - ], - "thresholds": "", - "title": "CPU Cores", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "bytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 2, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "node_memory_MemAvailable_bytes", - "interval": "30s", - "intervalFactor": 2, - "legendFormat": "", - "refId": "A", - "step": 60 - } - ], - "thresholds": "", - "title": "Available Memory", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "bytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 3, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "node_memory_SwapFree_bytes", - "interval": "30s", - "intervalFactor": 2, - "refId": "A", - "step": 60 - } - ], - "thresholds": "", - "title": "Free Swap", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "bytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 4, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 2, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [ - { - "expr": "sum(node_filesystem_free_bytes{fstype=\"aufs\"})", - "interval": "30s", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A", - "step": 30 - } - ], - "thresholds": "", - "title": "Free Storage", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg", - "timeFrom": "10s", - "hideTimeOverride": true - } - ], - "title": "Available resources" - }, - { - "collapse": false, - "editable": true, - "height": "150px", - "panels": [ - { - "aliasColors": {}, - "bars": true, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 9, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "load 1m", - "color": "#1F78C1" - } - ], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "node_load1", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "load 1m", - "refId": "A", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Load Average 1m", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": true, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 10, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "blocked by I/O", - "color": "#58140C" - } - ], - "span": 4, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "node_procs_running", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "running", - "metric": "node_procs_running", - "refId": "A", - "step": 10 - }, - { - "expr": "node_procs_blocked", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "blocked by I/O", - "metric": "node_procs_blocked", - "refId": "B", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Processes", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": true, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 11, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "interrupts", - "color": "#806EB7" - } - ], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": " irate(node_intr_total[5m])", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "interrupts", - "metric": "node_intr_total", - "refId": "A", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Interrupts", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - } - ], - "title": "Load" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 4, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 5, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "sum(rate(node_cpu_seconds_total[1m])) by (mode) * 100 / scalar(count(node_cpu_seconds_total{mode=\"user\"}))", - "intervalFactor": 10, - "legendFormat": "{{ mode }}", - "metric": "node_cpu_seconds_total", - "refId": "A", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "CPU Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "percent", - "label": null, - "logBase": 1, - "max": 100, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "title": "CPU" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 4, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 6, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "Used", - "color": "#BF1B00" - }, - { - "alias": "Free", - "color": "#7EB26D" - }, - { - "alias": "Buffers", - "color": "#6ED0E0" - }, - { - "alias": "Cached", - "color": "#EF843C" - } - ], - "span": 12, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "node_memory_MemTotal_bytes - (node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes)", - "intervalFactor": 1, - "legendFormat": "Used", - "refId": "A", - "step": 1 - }, - { - "expr": "node_memory_MemFree_bytes", - "intervalFactor": 1, - "legendFormat": "Free", - "refId": "B", - "step": 1 - }, - { - "expr": "node_memory_Buffers_bytes", - "intervalFactor": 1, - "legendFormat": "Buffers", - "refId": "C", - "step": 1 - }, - { - "expr": "node_memory_Cached_bytes", - "intervalFactor": 1, - "legendFormat": "Cached", - "refId": "D", - "step": 1 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Memory Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "Memory" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 7, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "read", - "yaxis": 1 - }, - { - "alias": "written", - "yaxis": 1 - }, - { - "alias": "io time", - "yaxis": 2 - } - ], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(irate(node_disk_read_bytes_total[1m]))", - "interval": "", - "intervalFactor": 1, - "legendFormat": "read", - "metric": "node_disk_read_bytes_total", - "refId": "A", - "step": 1 - }, - { - "expr": "sum(irate(node_disk_written_bytes_total[1m]))", - "intervalFactor": 1, - "legendFormat": "written", - "metric": "node_disk_written_bytes_total", - "refId": "B", - "step": 1 - }, - { - "expr": "sum(irate(node_disk_io_time_seconds_total[1m]))", - "intervalFactor": 1, - "legendFormat": "io time", - "metric": "node_disk_io_time_seconds_total", - "refId": "C", - "step": 1 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "I/O Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "ms", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "I/O" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 4, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 8, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "irate(node_network_receive_bytes_total{device!=\"lo\"}[1m])", - "intervalFactor": 1, - "legendFormat": "In: {{ device }}", - "metric": "node_network_receive_bytes_total", - "refId": "A", - "step": 1 - }, - { - "expr": "irate(node_network_transmit_bytes_total{device!=\"lo\"}[1m])", - "intervalFactor": 1, - "legendFormat": "Out: {{ device }}", - "metric": "node_network_transmit_bytes_total", - "refId": "B", - "step": 1 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Network Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - } - ], - "title": "Network" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 4, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 14, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "Used", - "color": "#890F02" - }, - { - "alias": "Free", - "color": "#7EB26D" - } - ], - "span": 6, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "Used", - "refId": "A", - "step": 10 - }, - { - "expr": "node_memory_SwapFree_bytes", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "Free", - "refId": "B", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Swap Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 15, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_vmstat_pswpin[1m]) * 4096 or irate(node_vmstat_pswpin[5m]) * 4096", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "In", - "refId": "A", - "step": 10 - }, - { - "expr": "rate(node_vmstat_pswpout[1m]) * 4096 or irate(node_vmstat_pswpout[5m]) * 4096", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "Out", - "refId": "B", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Swap I/O", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - } - ], - "title": "New row" - } - ], - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "templating": { - "list": [] - }, - "annotations": { - "list": [] - }, - "refresh": "10s", - "schemaVersion": 12, - "version": 2, - "links": [], - "gnetId": null -} \ No newline at end of file diff --git a/server/docker/dockprom/grafana/provisioning/dashboards/monitor_services.json b/server/docker/dockprom/grafana/provisioning/dashboards/monitor_services.json deleted file mode 100644 index 3d955a4..0000000 --- a/server/docker/dockprom/grafana/provisioning/dashboards/monitor_services.json +++ /dev/null @@ -1,3412 +0,0 @@ -{ - "id": null, - "title": "Monitor Services", - "tags": [ - "prometheus" - ], - "style": "dark", - "timezone": "browser", - "editable": true, - "hideControls": false, - "sharedCrosshair": true, - "panels": [ - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "decimals": 1, - "editable": true, - "error": false, - "format": "s", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 0, - "y": 0 - }, - "hideTimeOverride": true, - "id": 1, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "s", - "postfixFontSize": "80%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "tableColumn": "", - "targets": [ - { - "expr": "(time() - process_start_time_seconds{instance=\"localhost:9090\",job=\"prometheus\"})", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A", - "step": 10 - } - ], - "thresholds": "", - "timeFrom": "10s", - "timeShift": null, - "title": "Prometheus Uptime", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "format": "bytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 6, - "y": 0 - }, - "hideTimeOverride": true, - "id": 5, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "tableColumn": "", - "targets": [ - { - "expr": "sum(container_memory_usage_bytes{container_label_org_label_schema_group=\"monitoring\"})", - "format": "time_series", - "interval": "10s", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A", - "step": 10 - } - ], - "thresholds": "", - "timeFrom": "10s", - "timeShift": null, - "title": "Memory Usage", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 12, - "y": 0 - }, - "hideTimeOverride": true, - "id": 3, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "tableColumn": "", - "targets": [ - { - "expr": "prometheus_tsdb_head_chunks", - "interval": "10s", - "intervalFactor": 1, - "refId": "A", - "step": 10 - } - ], - "thresholds": "", - "timeFrom": "10s", - "timeShift": null, - "title": "In-Memory Chunks", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "Prometheus", - "editable": true, - "error": false, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 18, - "y": 0 - }, - "hideTimeOverride": true, - "id": 2, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "tableColumn": "", - "targets": [ - { - "expr": "prometheus_tsdb_head_series", - "interval": "10s", - "intervalFactor": 1, - "refId": "A", - "step": 10 - } - ], - "thresholds": "", - "timeFrom": "10s", - "timeShift": null, - "title": "In-Memory Series", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": {}, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 3 - }, - "id": 6, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name) (rate(container_cpu_user_seconds_total{container_label_org_label_schema_group=\"monitoring\"}[1m]) * 100 / scalar(count(node_cpu{mode=\"user\"})))", - "format": "time_series", - "hide": true, - "intervalFactor": 10, - "legendFormat": "{{ name }}", - "refId": "A", - "step": 10 - }, - { - "expr": "sum by (name) (rate(container_cpu_user_seconds_total{container_label_org_label_schema_group=\"monitoring\"}[1m]) * 100 / scalar(count(node_cpu_seconds_total{mode=\"user\"})))", - "format": "time_series", - "intervalFactor": 10, - "legendFormat": "{{ name }}", - "refId": "B" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Container CPU Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percent", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": {}, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 10 - }, - "id": 7, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum by (name) (container_memory_usage_bytes{container_label_org_label_schema_group=\"monitoring\"})", - "format": "time_series", - "interval": "", - "intervalFactor": 10, - "legendFormat": "{{ name }}", - "metric": "container_memory_usage_bytes", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Container Memory Usage", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 2, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": true, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "decimals": 0, - "editable": true, - "error": false, - "fill": 1, - "grid": {}, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 17 - }, - "id": 73, - "legend": { - "alignAsTable": true, - "avg": false, - "current": true, - "max": false, - "min": false, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": false, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": true, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(ALERTS{alertstate=\"firing\"}) by (alertname)", - "format": "time_series", - "interval": "30s", - "intervalFactor": 1, - "legendFormat": "{{ alertname }}", - "metric": "container_memory_usage_bytes", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Alerts", - "tooltip": { - "msResolution": true, - "shared": false, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 24 - }, - "id": 22, - "panels": [], - "repeat": null, - "title": "Prometheus Metrics", - "type": "row" - }, - { - "aliasColors": { - "Max": "#e24d42", - "Open": "#508642" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 25 - }, - "id": 18, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "process_max_fds{job=\"prometheus\"}", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "Max", - "refId": "A" - }, - { - "expr": "process_open_fds{job=\"prometheus\"}", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "Open", - "refId": "B" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "File Descriptors", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Allocated bytes": "#7EB26D", - "Allocated bytes - 1m max": "#BF1B00", - "Allocated bytes - 1m min": "#BF1B00", - "Allocated bytes - 5m max": "#BF1B00", - "Allocated bytes - 5m min": "#BF1B00", - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "RSS": "#447EBC" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "decimals": null, - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 25 - }, - "id": 58, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "/-/", - "fill": 0 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "process_resident_memory_bytes{job=\"prometheus\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "RSS", - "metric": "process_resident_memory_bytes", - "refId": "B", - "step": 10 - }, - { - "expr": "prometheus_local_storage_target_heap_size_bytes{job=\"prometheus\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Target heap size", - "metric": "go_memstats_alloc_bytes", - "refId": "D", - "step": 10 - }, - { - "expr": "go_memstats_next_gc_bytes{job=\"prometheus\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Next GC", - "metric": "go_memstats_next_gc_bytes", - "refId": "C", - "step": 10 - }, - { - "expr": "go_memstats_alloc_bytes{job=\"prometheus\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Allocated", - "metric": "go_memstats_alloc_bytes", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Memory", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Allocated bytes": "#F9BA8F", - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "RSS": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 25 - }, - "id": 60, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(go_memstats_alloc_bytes_total{job=\"prometheus\"}[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Allocated", - "metric": "go_memstats_alloc_bytes", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Allocations", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "Time series": "#70dbed" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 32 - }, - "id": 20, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "prometheus_tsdb_head_series", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Time series", - "metric": "prometheus_local_storage_memory_series", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head Time series", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 32 - }, - "id": 24, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "prometheus_tsdb_head_active_appenders", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Head Appenders", - "metric": "prometheus_local_storage_memory_series", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head Active Appenders", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "samples/s": "#e5a8e2" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 32 - }, - "id": 26, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_head_samples_appended_total[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Samples", - "metric": "prometheus_local_storage_ingested_samples_total", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Samples Appended", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "Bps", - "label": "", - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "To persist": "#9AC48A" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 39 - }, - "id": 28, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "/Max.*/", - "fill": 0 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "prometheus_tsdb_head_chunks", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Chunks", - "metric": "prometheus_local_storage_memory_chunks", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head Chunks", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 39 - }, - "id": 30, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_head_chunks_created_total[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Created", - "metric": "prometheus_local_storage_chunk_ops_total", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head Chunks Created", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ops", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "Removed": "#e5ac0e" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 39 - }, - "id": 32, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_head_chunks_removed_total[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Removed", - "metric": "prometheus_local_storage_chunk_ops_total", - "refId": "B", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head Chunks Removed", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ops", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max": "#447ebc", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "Min": "#447ebc", - "Now": "#7eb26d" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 46 - }, - "id": 34, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "Max", - "fillBelowTo": "Min", - "lines": false - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "prometheus_tsdb_head_min_time", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Min", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - }, - { - "expr": "time() * 1000", - "format": "time_series", - "hide": false, - "intervalFactor": 2, - "legendFormat": "Now", - "refId": "C" - }, - { - "expr": "prometheus_tsdb_head_max_time", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Max", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "B", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head Time Range", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "dateTimeAsIso", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 46 - }, - "id": 36, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_head_gc_duration_seconds_sum[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "GC Time", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Head GC Time/s", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 46 - }, - "id": 38, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "Queue length", - "yaxis": 2 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "prometheus_tsdb_blocks_loaded", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Blocks Loaded", - "metric": "prometheus_local_storage_indexing_batch_sizes_sum", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Blocks Loaded", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Failed Compactions": "#bf1b00", - "Failed Reloads": "#bf1b00", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 53 - }, - "id": 40, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_reloads_total[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Reloads", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "TSDB Reloads", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ops", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Failed Compactions": "#bf1b00", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "{instance=\"demo.robustperception.io:9090\",job=\"prometheus\"}": "#bf1b00" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 53 - }, - "id": 44, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_wal_corruptions_total[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "WAL Corruptions", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - }, - { - "expr": "rate(prometheus_tsdb_reloads_failures_total[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Reload Failures", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "B", - "step": 10 - }, - { - "expr": "rate(prometheus_tsdb_head_series_not_found[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Head Series Not Found", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "C", - "step": 10 - }, - { - "expr": "rate(prometheus_tsdb_compactions_failed_total[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Compaction Failures", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "D", - "step": 10 - }, - { - "expr": "rate(prometheus_tsdb_retention_cutoffs_failures_total[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Retention Cutoff Failures", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "E", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "TSDB Problems", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Failed Compactions": "#bf1b00", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 53 - }, - "id": 42, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_wal_fsync_duration_seconds_sum[1m]) / rate(prometheus_tsdb_wal_fsync_duration_seconds_count[1m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Fsync Latency", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - }, - { - "expr": "rate(prometheus_tsdb_wal_truncate_duration_seconds_sum[1m]) / rate(prometheus_tsdb_wal_truncate_duration_seconds_count[1m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Truncate Latency", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "B", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "WAL Latencies", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Failed Compactions": "#bf1b00", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 60 - }, - "id": 46, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_compactions_total[10m])", - "format": "time_series", - "interval": "", - "intervalFactor": 2, - "legendFormat": "Compactions", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Compactions", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 60 - }, - "id": 48, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_compaction_duration_seconds_sum[10m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Compaction Time", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Compaction Time", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Allocated bytes": "#F9BA8F", - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833", - "RSS": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 60 - }, - "id": 50, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_retention_cutoffs_total[10m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Retention Cutoffs", - "metric": "last", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Retention Cutoffs", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 67 - }, - "id": 56, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_tsdb_compaction_chunk_samples_sum[10m]) / rate(prometheus_tsdb_compaction_chunk_samples_count[10m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Chunk Samples", - "metric": "prometheus_local_storage_series_chunks_persisted_count", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "First Compaction, Avg Chunk Samples", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "grid": {}, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 67 - }, - "id": 10, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_target_interval_length_seconds_count[5m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{ interval }}", - "refId": "A", - "step": 2 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Target Scrapes", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "grid": {}, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 67 - }, - "id": 11, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "prometheus_target_interval_length_seconds{quantile!=\"0.01\", quantile!=\"0.05\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{quantile}} ({{interval}})", - "refId": "A", - "step": 2 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Scrape Duration", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "description": "", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 74 - }, - "id": 62, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_http_request_duration_seconds_count[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{handler}}", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "HTTP requests", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "reqps", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "description": "", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 74 - }, - "id": 64, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_http_request_duration_seconds_sum[1m]) / rate(prometheus_http_request_duration_seconds_count[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{handler}}", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "HTTP request latency", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "description": "", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 74 - }, - "id": 66, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_http_request_duration_seconds_sum[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{handler}}", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Time spent in HTTP requests", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "description": "Time spent in each mode, per second", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 0, - "y": 81 - }, - "id": 68, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_engine_query_duration_seconds_sum[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{slice}}", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Query engine timings", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 8, - "y": 81 - }, - "id": 70, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_rule_group_iterations_missed_total[1m]) ", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Rule group missed", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "B", - "step": 10 - }, - { - "expr": "rate(prometheus_rule_evaluation_failures_total[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Rule evals failed", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "C", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Rule group evaulation problems", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "Chunks": "#1F78C1", - "Chunks to persist": "#508642", - "Max chunks": "#052B51", - "Max to persist": "#3F6833" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "editable": true, - "error": false, - "fill": 1, - "gridPos": { - "h": 7, - "w": 8, - "x": 16, - "y": 81 - }, - "id": 72, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(prometheus_rule_group_duration_seconds_sum[1m])", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Rule evaluation duration", - "metric": "prometheus_local_storage_memory_chunkdescs", - "refId": "A", - "step": 10 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Evaluation time of rule groups", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "templating": { - "list": [] - }, - "annotations": { - "list": [] - }, - "refresh": "10s", - "schemaVersion": 12, - "version": 22, - "links": [], - "gnetId": null -} \ No newline at end of file diff --git a/server/docker/dockprom/grafana/provisioning/dashboards/nginx_container.json b/server/docker/dockprom/grafana/provisioning/dashboards/nginx_container.json deleted file mode 100644 index 0a35d2b..0000000 --- a/server/docker/dockprom/grafana/provisioning/dashboards/nginx_container.json +++ /dev/null @@ -1,398 +0,0 @@ -{ - "id": null, - "title": "Nginx", - "description": "Nginx exporter metrics", - "tags": [ - "nginx" - ], - "style": "dark", - "timezone": "browser", - "editable": true, - "hideControls": false, - "sharedCrosshair": true, - "rows": [ - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 3, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(irate(nginx_connections_processed_total{stage=\"any\"}[5m])) by (stage)", - "hide": false, - "interval": "", - "intervalFactor": 10, - "legendFormat": "requests", - "metric": "", - "refId": "B", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Requests/sec", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 2, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(nginx_connections_current) by (state)", - "interval": "", - "intervalFactor": 2, - "legendFormat": "{{state}}", - "metric": "", - "refId": "A", - "step": 2 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Connections", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "Prometheus", - "decimals": 2, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 1, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(irate(nginx_connections_processed_total{stage!=\"any\"}[5m])) by (stage)", - "hide": false, - "interval": "", - "intervalFactor": 10, - "legendFormat": "{{stage}}", - "metric": "", - "refId": "B", - "step": 10 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Connections rate", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "Nginx exporter metrics" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": null, - "editable": true, - "error": false, - "fill": 1, - "grid": { - "threshold1": null, - "threshold1Color": "rgba(216, 200, 27, 0.27)", - "threshold2": null, - "threshold2Color": "rgba(234, 112, 112, 0.22)" - }, - "id": 4, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(rate(container_cpu_usage_seconds_total{name=~\"nginx\"}[5m])) / count(node_cpu_seconds_total{mode=\"system\"}) * 100", - "intervalFactor": 2, - "legendFormat": "nginx", - "refId": "A", - "step": 2 - } - ], - "timeFrom": null, - "timeShift": null, - "title": "CPU usage", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "show": true - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "Nginx container metrics" - } - ], - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "templating": { - "list": [] - }, - "annotations": { - "list": [] - }, - "refresh": "10s", - "schemaVersion": 12, - "version": 9, - "links": [], - "gnetId": null -} \ No newline at end of file diff --git a/server/docker/dockprom/grafana/provisioning/datasources/datasource.yml b/server/docker/dockprom/grafana/provisioning/datasources/datasource.yml deleted file mode 100644 index bb37f13..0000000 --- a/server/docker/dockprom/grafana/provisioning/datasources/datasource.yml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: 1 - -datasources: - - name: Prometheus - type: prometheus - access: proxy - orgId: 1 - url: http://prometheus:9090 - basicAuth: false - isDefault: true - editable: true \ No newline at end of file diff --git a/server/docker/dockprom/helpers/aws/README.md b/server/docker/dockprom/helpers/aws/README.md deleted file mode 100644 index 22ffc15..0000000 --- a/server/docker/dockprom/helpers/aws/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Prometheus on EC2 & ECS: - -Some helpers for anyone configuring Prometheus on ECS and AWS EC2. - -To get started on AWS ECS and EC2: - -*For EC2/ECS nodes*: -- Import the ecs task definition and add cadvisor and node-exporter service/task definition and run them on each host you want to be monitored -- Any hosts which have "Monitoring: On" tag will be automatically added in the targets -- Expose ports 9100 and 9191 to your Prometheus host - -*For Prometheus host*: - -- Copy prometheus.yml configuration present here to base prometheus configuration to enable EC2 service discovery -- `docker compose up -d` - -> [!NOTE] -> Set query.staleness-delta to 1m make metrics more realtime - - -### TODO -- [ ] Add alerting rules based on ECS diff --git a/server/docker/dockprom/helpers/aws/cadvisor_ecs_task_definition.json b/server/docker/dockprom/helpers/aws/cadvisor_ecs_task_definition.json deleted file mode 100644 index f9a8527..0000000 --- a/server/docker/dockprom/helpers/aws/cadvisor_ecs_task_definition.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "family": "cadvisor", - "containerDefinitions": [ - { - "name": "cadvisor", - "image": "google/cadvisor", - "cpu": 10, - "memory": 300, - "portMappings": [ - { - "containerPort": 9191, - "hostPort": 9191 - } - ], - "essential": true, - "privileged": true, - "mountPoints": [ - { - "sourceVolume": "root", - "containerPath": "/rootfs", - "readOnly": true - }, - { - "sourceVolume": "var_run", - "containerPath": "/var/run", - "readOnly": false - }, - { - "sourceVolume": "sys", - "containerPath": "/sys", - "readOnly": true - }, - { - "sourceVolume": "var_lib_docker", - "containerPath": "/var/lib/docker", - "readOnly": true - }, - { - "sourceVolume": "cgroup", - "containerPath": "/cgroup", - "readOnly": true - } - ] - } - ], - "volumes": [ - { - "name": "root", - "host": { - "sourcePath": "/" - } - }, - { - "name": "var_run", - "host": { - "sourcePath": "/var/run" - } - }, - { - "name": "sys", - "host": { - "sourcePath": "/sys" - } - }, - { - "name": "var_lib_docker", - "host": { - "sourcePath": "/var/lib/docker/" - } - }, - { - "name": "cgroup", - "host": { - "sourcePath": "/cgroup" - } - } - ] -} \ No newline at end of file diff --git a/server/docker/dockprom/helpers/aws/node_exporter_task_definition.json b/server/docker/dockprom/helpers/aws/node_exporter_task_definition.json deleted file mode 100644 index 9a6e4dc..0000000 --- a/server/docker/dockprom/helpers/aws/node_exporter_task_definition.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "family": "prometheus", - "containerDefinitions": [ - { - "portMappings": [ - { - "hostPort": 9100, - "containerPort": 9100, - "protocol": "tcp" - } - ], - "essential": true, - "name": "node_exporter", - "image": "prom/node-exporter", - "cpu": 0, - "privileged": null, - "memoryReservation": 150 - } - ], - "volumes": [], - "networkMode": "host" -} diff --git a/server/docker/dockprom/helpers/aws/prometheus.yml b/server/docker/dockprom/helpers/aws/prometheus.yml deleted file mode 100644 index 7a94c75..0000000 --- a/server/docker/dockprom/helpers/aws/prometheus.yml +++ /dev/null @@ -1,53 +0,0 @@ -global: - scrape_interval: 15s - evaluation_interval: 15s - - # Attach these labels to any time series or alerts when communicating with - # external systems (federation, remote storage, Alertmanager). - external_labels: - monitor: 'docker-host-alpha' - -# Load and evaluate rules in this file every 'evaluation_interval' seconds. -rule_files: - - "targets.rules" - - "hosts.rules" - - "containers.rules" - -# A scrape configuration containing exactly one endpoint to scrape. -scrape_configs: - - job_name: 'nodeexporter' - scrape_interval: 5s - static_configs: - - targets: ['nodeexporter:9100'] - - - job_name: 'cadvisor' - scrape_interval: 5s - static_configs: - - targets: ['cadvisor:8080'] - - - job_name: 'prometheus' - scrape_interval: 10s - static_configs: - - targets: ['localhost:9090'] - - -# sample scrape configuration for AWS EC2 - - job_name: 'nodeexporter' - ec2_sd_configs: - - region: us-east-1 - port: 9100 - relabel_configs: - # Only monitor instances which have a tag called Monitoring "Monitoring" - - source_labels: [__meta_ec2_tag_Monitoring] - regex: On - action: keep - - - job_name: 'cadvisor' - ec2_sd_configs: - - region: us-east-1 - port: 9010 - relabel_configs: - # Only monitor instances which have a tag called Monitoring "Monitoring" - - source_labels: [__meta_ec2_tag_Monitoring] - regex: On - action: keep diff --git a/server/docker/dockprom/prometheus/alert.rules b/server/docker/dockprom/prometheus/alert.rules deleted file mode 100644 index 7b6eb07..0000000 --- a/server/docker/dockprom/prometheus/alert.rules +++ /dev/null @@ -1,70 +0,0 @@ -groups: -- name: targets - rules: - - alert: monitor_service_down - expr: up == 0 - for: 30s - labels: - severity: critical - annotations: - summary: "Monitor service non-operational" - description: "Service {{ $labels.instance }} is down." - -- name: host - rules: - - alert: high_cpu_load - expr: node_load1 > 1.5 - for: 30s - labels: - severity: warning - annotations: - summary: "Server under high load" - description: "Docker host is under high load, the avg load 1m is at {{ $value}}. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." - - - alert: high_memory_load - expr: (sum(node_memory_MemTotal_bytes) - sum(node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes) ) / sum(node_memory_MemTotal_bytes) * 100 > 85 - for: 30s - labels: - severity: warning - annotations: - summary: "Server memory is almost full" - description: "Docker host memory usage is {{ humanize $value}}%. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." - - - alert: high_storage_load - expr: (node_filesystem_size_bytes{fstype="aufs"} - node_filesystem_free_bytes{fstype="aufs"}) / node_filesystem_size_bytes{fstype="aufs"} * 100 > 85 - for: 30s - labels: - severity: warning - annotations: - summary: "Server storage is almost full" - description: "Docker host storage usage is {{ humanize $value}}%. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." - -- name: containers - rules: - - alert: jenkins_down - expr: absent(container_memory_usage_bytes{name="jenkins"}) - for: 30s - labels: - severity: critical - annotations: - summary: "Jenkins down" - description: "Jenkins container is down for more than 30 seconds." - - - alert: jenkins_high_cpu - expr: sum(rate(container_cpu_usage_seconds_total{name="jenkins"}[1m])) / count(node_cpu_seconds_total{mode="system"}) * 100 > 10 - for: 30s - labels: - severity: warning - annotations: - summary: "Jenkins high CPU usage" - description: "Jenkins CPU usage is {{ humanize $value}}%." - - - alert: jenkins_high_memory - expr: sum(container_memory_usage_bytes{name="jenkins"}) > 1200000000 - for: 30s - labels: - severity: warning - annotations: - summary: "Jenkins high memory usage" - description: "Jenkins memory consumption is at {{ humanize $value}}." - diff --git a/server/docker/dockprom/prometheus/prometheus.yml b/server/docker/dockprom/prometheus/prometheus.yml deleted file mode 100644 index 7906963..0000000 --- a/server/docker/dockprom/prometheus/prometheus.yml +++ /dev/null @@ -1,53 +0,0 @@ -global: - scrape_interval: 15s - evaluation_interval: 15s - - # Attach these labels to any time series or alerts when communicating with - # external systems (federation, remote storage, Alertmanager). - external_labels: - monitor: 'docker-host-alpha' - -# Load and evaluate rules in this file every 'evaluation_interval' seconds. -rule_files: - - "alert.rules" - -# A scrape configuration containing exactly one endpoint to scrape. -scrape_configs: - - job_name: 'nodeexporter' - scrape_interval: 5s - static_configs: - - targets: ['nodeexporter:9100'] - - - job_name: 'cadvisor' - scrape_interval: 5s - static_configs: - - targets: ['cadvisor:8080'] - - - job_name: 'prometheus' - scrape_interval: 10s - static_configs: - - targets: ['localhost:9090'] - - - job_name: 'pushgateway' - scrape_interval: 10s - honor_labels: true - static_configs: - - targets: ['pushgateway:9091'] - - -alerting: - alertmanagers: - - scheme: http - static_configs: - - targets: - - 'alertmanager:9093' - -# - job_name: 'nginx' -# scrape_interval: 10s -# static_configs: -# - targets: ['nginxexporter:9113'] - -# - job_name: 'aspnetcore' -# scrape_interval: 10s -# static_configs: -# - targets: ['eventlog-proxy:5000', 'eventlog:5000'] diff --git a/server/docker/dockprom/screens/Grafana_Docker_Containers.png b/server/docker/dockprom/screens/Grafana_Docker_Containers.png deleted file mode 100644 index 3f8b477..0000000 Binary files a/server/docker/dockprom/screens/Grafana_Docker_Containers.png and /dev/null differ diff --git a/server/docker/dockprom/screens/Grafana_Docker_Host.png b/server/docker/dockprom/screens/Grafana_Docker_Host.png deleted file mode 100644 index c0a37ac..0000000 Binary files a/server/docker/dockprom/screens/Grafana_Docker_Host.png and /dev/null differ diff --git a/server/docker/dockprom/screens/Grafana_Prometheus.png b/server/docker/dockprom/screens/Grafana_Prometheus.png deleted file mode 100644 index eee3294..0000000 Binary files a/server/docker/dockprom/screens/Grafana_Prometheus.png and /dev/null differ diff --git a/server/docker/dockprom/screens/Slack_Notifications.png b/server/docker/dockprom/screens/Slack_Notifications.png deleted file mode 100644 index 3eca7b5..0000000 Binary files a/server/docker/dockprom/screens/Slack_Notifications.png and /dev/null differ diff --git a/server/docker/docs.md b/server/docker/docs.md deleted file mode 100644 index 0185ff3..0000000 --- a/server/docker/docs.md +++ /dev/null @@ -1,174 +0,0 @@ - - -# docker - -```go -import "github.com/Akilan1999/p2p-rendering-computation/server/docker" -``` - -## Index - -- [func StopAndRemoveContainer\(containername string\) error](<#StopAndRemoveContainer>) -- [type DockerContainer](<#DockerContainer>) -- [type DockerContainers](<#DockerContainers>) - - [func ViewAllContainers\(\) \(\*DockerContainers, error\)](<#ViewAllContainers>) -- [type DockerVM](<#DockerVM>) - - [func BuildRunContainer\(NumPorts int, GPU string, ContainerName string, baseImage string, publicKey string\) \(\*DockerVM, error\)](<#BuildRunContainer>) - - [func \(d \*DockerVM\) CopyToTmpContainer\(\) error](<#DockerVM.CopyToTmpContainer>) - - [func \(d \*DockerVM\) TemplateDockerContainer\(\) error](<#DockerVM.TemplateDockerContainer>) -- [type ErrorDetail](<#ErrorDetail>) -- [type ErrorLine](<#ErrorLine>) -- [type Port](<#Port>) -- [type Ports](<#Ports>) - - [func OpenPortsFile\(filename string\) \(\*Ports, error\)](<#OpenPortsFile>) - - - -## func [StopAndRemoveContainer]() - -```go -func StopAndRemoveContainer(containername string) error -``` - -StopAndRemoveContainer Stop and remove a container Reference \(https://gist.github.com/frikky/e2efcea6c733ea8d8d015b7fe8a91bf6\) - - -## type [DockerContainer]() - - - -```go -type DockerContainer struct { - ContainerName string `json:"DockerContainerName"` - ContainerDescription string `json:"ContainerDescription"` -} -``` - - -## type [DockerContainers]() - - - -```go -type DockerContainers struct { - DockerContainer []DockerContainer `json:"DockerContainer"` -} -``` - - -### func [ViewAllContainers]() - -```go -func ViewAllContainers() (*DockerContainers, error) -``` - -ViewAllContainers returns all containers runnable and which can be built - - -## type [DockerVM]() - - - -```go -type DockerVM struct { - SSHUsername string `json:"SSHUsername"` - SSHPublcKey string `json:"SSHPublicKey"` - ID string `json:"ID"` - TagName string `json:"TagName"` - ImagePath string `json:"ImagePath"` - Ports Ports `json:"Ports"` - GPU string `json:"GPU"` - TempPath string - BaseImage string - LogsPath string - SSHCommand string `json:"SSHCommand"` -} -``` - - -### func [BuildRunContainer]() - -```go -func BuildRunContainer(NumPorts int, GPU string, ContainerName string, baseImage string, publicKey string) (*DockerVM, error) -``` - -BuildRunContainer Function is incharge to invoke building and running contianer and also allocating external ports - - -### func \(\*DockerVM\) [CopyToTmpContainer]() - -```go -func (d *DockerVM) CopyToTmpContainer() error -``` - -CopyToTmpContainer Creates a copy of the docker folder - - -### func \(\*DockerVM\) [TemplateDockerContainer]() - -```go -func (d *DockerVM) TemplateDockerContainer() error -``` - -TemplateDockerContainer This function templates the docker container with the base docker image to use - - -## type [ErrorDetail]() - - - -```go -type ErrorDetail struct { - Message string `json:"message"` -} -``` - - -## type [ErrorLine]() - - - -```go -type ErrorLine struct { - Error string `json:"error"` - ErrorDetail ErrorDetail `json:"errorDetail"` -} -``` - - -## type [Port]() - - - -```go -type Port struct { - PortName string `json:"PortName"` - InternalPort int `json:"InternalPort"` - Type string `json:"Type"` - ExternalPort int `json:"ExternalPort"` - IsUsed bool `json:"IsUsed"` - Description string `json:"Description"` -} -``` - - -## type [Ports]() - - - -```go -type Ports struct { - PortSet []Port `json:"Port"` -} -``` - - -### func [OpenPortsFile]() - -```go -func OpenPortsFile(filename string) (*Ports, error) -``` - - - -Generated by [gomarkdoc]() diff --git a/server/docker/kill-containers.sh b/server/docker/kill-containers.sh deleted file mode 100644 index 9dd68d6..0000000 --- a/server/docker/kill-containers.sh +++ /dev/null @@ -1,4 +0,0 @@ -docker kill $(docker ps -q)\ -docker rm $(docker ps -a -q) -docker rmi $(docker images -q) --force -docker system prune --all diff --git a/server/server.go b/server/server.go index 0e3ec1c..1c5ce44 100644 --- a/server/server.go +++ b/server/server.go @@ -1,7 +1,6 @@ package server import ( - b64 "encoding/base64" "encoding/json" "errors" "fmt" @@ -9,7 +8,6 @@ import ( "github.com/Akilan1999/p2p-rendering-computation/config" "github.com/Akilan1999/p2p-rendering-computation/p2p" "github.com/Akilan1999/p2p-rendering-computation/p2p/frp" - "github.com/Akilan1999/p2p-rendering-computation/server/docker" "github.com/gin-gonic/gin" "io/ioutil" "net/http" @@ -120,65 +118,65 @@ func Server() (*gin.Engine, error) { }) // Starts docker container in server - r.GET("/startcontainer", func(c *gin.Context) { - // Get Number of ports to open and whether to use GPU or not - Ports := c.DefaultQuery("ports", "0") - GPU := c.DefaultQuery("GPU", "false") - ContainerName := c.DefaultQuery("ContainerName", "") - BaseImage := c.DefaultQuery("BaseImage", "") - PublicKey := c.DefaultQuery("PublicKey", "") - var PortsInt int - - if PublicKey == "" { - c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", "Publickey not passed")) - } - - PublicKeyDecoded, err := b64.StdEncoding.DecodeString(PublicKey) - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) - } - - // Convert Get Request value to int - fmt.Sscanf(Ports, "%d", &PortsInt) - - fmt.Println(string(PublicKeyDecoded[:])) - - // Creates container and returns-back result to - // access container - resp, err := docker.BuildRunContainer(PortsInt, GPU, ContainerName, BaseImage, string(PublicKeyDecoded[:])) - - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) - } - - // Ensures that FRP is triggered only if a proxy address is provided - if ProxyIpAddr.Ipv4 != "" && c.Request.Host != "localhost:"+config.ServerPort && c.Request.Host != "0.0.0.0:"+config.ServerPort { - resp, err = frp.StartFRPCDockerContainer(ProxyIpAddr.Ipv4, lowestLatencyIpAddress.ServerPort, resp) - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) - } - } - - c.JSON(http.StatusOK, resp) - }) + //r.GET("/startcontainer", func(c *gin.Context) { + // // Get Number of ports to open and whether to use GPU or not + // Ports := c.DefaultQuery("ports", "0") + // GPU := c.DefaultQuery("GPU", "false") + // ContainerName := c.DefaultQuery("ContainerName", "") + // BaseImage := c.DefaultQuery("BaseImage", "") + // PublicKey := c.DefaultQuery("PublicKey", "") + // var PortsInt int + // + // if PublicKey == "" { + // c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", "Publickey not passed")) + // } + // + // PublicKeyDecoded, err := b64.StdEncoding.DecodeString(PublicKey) + // if err != nil { + // c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) + // } + // + // // Convert Get Request value to int + // fmt.Sscanf(Ports, "%d", &PortsInt) + // + // fmt.Println(string(PublicKeyDecoded[:])) + // + // // Creates container and returns-back result to + // // access container + // resp, err := docker.BuildRunContainer(PortsInt, GPU, ContainerName, BaseImage, string(PublicKeyDecoded[:])) + // + // if err != nil { + // c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) + // } + // + // // Ensures that FRP is triggered only if a proxy address is provided + // if ProxyIpAddr.Ipv4 != "" && c.Request.Host != "localhost:"+config.ServerPort && c.Request.Host != "0.0.0.0:"+config.ServerPort { + // resp, err = frp.StartFRPCDockerContainer(ProxyIpAddr.Ipv4, lowestLatencyIpAddress.ServerPort, resp) + // if err != nil { + // c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) + // } + // } + // + // c.JSON(http.StatusOK, resp) + //}) //Remove container - r.GET("/RemoveContainer", func(c *gin.Context) { - ID := c.DefaultQuery("id", "0") - if err := docker.StopAndRemoveContainer(ID); err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) - } - c.String(http.StatusOK, "success") - }) - - //Show images available - r.GET("/ShowImages", func(c *gin.Context) { - resp, err := docker.ViewAllContainers() - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) - } - c.JSON(http.StatusOK, resp) - }) + //r.GET("/RemoveContainer", func(c *gin.Context) { + // ID := c.DefaultQuery("id", "0") + // if err := docker.StopAndRemoveContainer(ID); err != nil { + // c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) + // } + // c.String(http.StatusOK, "success") + //}) + // + ////Show images available + //r.GET("/ShowImages", func(c *gin.Context) { + // resp, err := docker.ViewAllContainers() + // if err != nil { + // c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) + // } + // c.JSON(http.StatusOK, resp) + //}) // Request for port no from Server with address r.GET("/FRPPort", func(c *gin.Context) { diff --git a/wasm/wasm.go b/wasm/wasm.go new file mode 100644 index 0000000..948f5e2 --- /dev/null +++ b/wasm/wasm.go @@ -0,0 +1,156 @@ +package main + +import ( + "encoding/json" + "errors" + "time" + + "syscall/js" + + "github.com/Akilan1999/p2p-rendering-computation/abstractions" + "github.com/Akilan1999/p2p-rendering-computation/p2p/frp" +) + +func main() { + // Register functions + js.Global().Set("getSpecs", js.FuncOf(getSpecs)) + js.Global().Set("initConfig", js.FuncOf(initConfig)) + js.Global().Set("viewIPTable", js.FuncOf(viewIPTable)) + js.Global().Set("updateIPTable", js.FuncOf(updateIPTable)) + js.Global().Set("escapeFirewall", js.FuncOf(escapeFirewall)) + js.Global().Set("mapPort", js.FuncOf(mapPort)) + js.Global().Set("customInformation", js.FuncOf(customInformation)) + js.Global().Set("addRootNode", js.FuncOf(addRootNode)) + js.Global().Set("startServer", js.FuncOf(startServer)) + + // Prevent Go program from exiting + select {} +} + +// ------------------------------------- Helpers ---------------------------------------- + +func convertToJSValue(value interface{}) js.Value { + jsonBytes, err := json.Marshal(value) + if err != nil { + return js.ValueOf(map[string]interface{}{"error": err.Error()}) + } + return js.ValueOf(string(jsonBytes)) +} + +func returnError(err error) js.Value { + return js.ValueOf(map[string]interface{}{"error": err.Error()}) +} + +// ------------------------------------- WASM Functions ---------------------------------------- + +func getSpecs(this js.Value, args []js.Value) any { + if len(args) < 1 { + return returnError(jsError("Missing IP argument")) + } + specs, err := abstractions.GetSpecs(args[0].String()) + if err != nil { + return returnError(err) + } + return convertToJSValue(specs) +} + +func initConfig(this js.Value, args []js.Value) any { + if len(args) < 1 { + return returnError(jsError("Missing config argument")) + } + initData, err := abstractions.Init(args[0].String()) + if err != nil { + return returnError(err) + } + return convertToJSValue(initData) +} + +func viewIPTable(this js.Value, args []js.Value) any { + table, err := abstractions.ViewIPTable() + if err != nil { + return returnError(err) + } + return convertToJSValue(table) +} + +func updateIPTable(this js.Value, args []js.Value) any { + err := abstractions.UpdateIPTable() + if err != nil { + return returnError(err) + } + return js.ValueOf("Success") +} + +func escapeFirewall(this js.Value, args []js.Value) any { + if len(args) < 3 { + return returnError(jsError("Expected 3 arguments")) + } + host := args[0].String() + port := args[1].String() + internalPort := args[2].String() + + serverPort, err := frp.GetFRPServerPort("http://" + host + ":" + port) + if err != nil { + return returnError(err) + } + + time.Sleep(5 * time.Second) + + exposedPort, err := frp.StartFRPClientForServer(host+":"+port, serverPort, internalPort, "") + if err != nil { + return returnError(err) + } + + return js.ValueOf(exposedPort) +} + +func mapPort(this js.Value, args []js.Value) any { + if len(args) < 3 { + return returnError(jsError("Expected 3 arguments")) + } + port := args[0].String() + domain := args[1].String() + server := args[2].String() + + addr, err := abstractions.MapPort(port, domain, server) + if err != nil { + return returnError(err) + } + return js.ValueOf(addr.EntireAddress) +} + +func customInformation(this js.Value, args []js.Value) any { + if len(args) < 1 { + return returnError(jsError("Missing custom information")) + } + err := abstractions.AddCustomInformation(args[0].String()) + if err != nil { + return returnError(err) + } + return js.ValueOf("Success") +} + +func addRootNode(this js.Value, args []js.Value) any { + if len(args) < 2 { + return returnError(jsError("Expected 2 arguments")) + } + err := abstractions.AddRootNode(args[0].String(), args[1].String()) + if err != nil { + return returnError(err) + } + return js.ValueOf("Success") +} + +func startServer(this js.Value, args []js.Value) any { + _, err := abstractions.Start() + if err != nil { + return returnError(err) + } + return js.ValueOf("Server started") +} + +// ------------------------------------- Utility ---------------------------------------- + +func jsError(msg string) error { + return errors.New("WASM error: " + msg) +}