mandatory commit
This commit is contained in:
parent
5afa2c0f9a
commit
3871351ace
36
sftp.go
36
sftp.go
@ -14,30 +14,34 @@ var (
|
|||||||
filename string = "dpkg.log"
|
filename string = "dpkg.log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getFile(client *ssh.Client) {
|
func (s SSHConnection) getFile(client *ssh.Client) {
|
||||||
sftp, err := sftp.NewClient(client)
|
sftp, err := sftp.NewClient(client)
|
||||||
|
//var srcFile []*os.File
|
||||||
|
//var dstFile []*os.File
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("FUCK")
|
fmt.Errorf("Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
defer sftp.Close()
|
defer sftp.Close()
|
||||||
|
|
||||||
srcFile, err := sftp.Open(srcPath + filename)
|
for _, j := range s.Logs {
|
||||||
|
srcFile, err := sftp.Open(srcPath + j)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("FUCK")
|
fmt.Errorf("Error")
|
||||||
|
}
|
||||||
|
|
||||||
|
defer srcFile.Close()
|
||||||
|
|
||||||
|
dstFile, err := os.Create(dstPath + j)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Errorf("Error")
|
||||||
|
}
|
||||||
|
|
||||||
|
defer dstFile.Close()
|
||||||
|
srcFile.WriteTo(dstFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer srcFile.Close()
|
|
||||||
|
|
||||||
dstFile, err := os.Create(dstPath + filename)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Errorf("FUCK")
|
|
||||||
}
|
|
||||||
|
|
||||||
defer dstFile.Close()
|
|
||||||
|
|
||||||
srcFile.WriteTo(dstFile)
|
|
||||||
}
|
}
|
||||||
|
4
ssh.go
4
ssh.go
@ -18,6 +18,7 @@ type SSHConnection struct {
|
|||||||
Password string
|
Password string
|
||||||
Port int
|
Port int
|
||||||
Hosts []string
|
Hosts []string
|
||||||
|
Logs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SSHClients []*ssh.Client
|
type SSHClients []*ssh.Client
|
||||||
@ -39,6 +40,7 @@ func initializeConnection(config Configuration) (*SSHConnection, *ssh.ClientConf
|
|||||||
Password: config.Password,
|
Password: config.Password,
|
||||||
Port: config.Port,
|
Port: config.Port,
|
||||||
Hosts: config.Hosts,
|
Hosts: config.Hosts,
|
||||||
|
Logs: config.Logs,
|
||||||
}
|
}
|
||||||
|
|
||||||
sshConfig := &ssh.ClientConfig{
|
sshConfig := &ssh.ClientConfig{
|
||||||
@ -96,7 +98,7 @@ func (s SSHConnection) executeSFTP(execute SSHClients) SSHSFTP {
|
|||||||
|
|
||||||
for _, j := range execute {
|
for _, j := range execute {
|
||||||
// TODO: this is just a placeholder, change to the actual tarring executable
|
// TODO: this is just a placeholder, change to the actual tarring executable
|
||||||
getFile(j)
|
s.getFile(j)
|
||||||
|
|
||||||
err := gzipit(homedir+filename, ".")
|
err := gzipit(homedir+filename, ".")
|
||||||
|
|
||||||
|
4
todo.md
4
todo.md
@ -4,4 +4,6 @@
|
|||||||
- Allow fetching of multiple log files (fields under the defined host? Seperate key/field? Dynamic?)
|
- Allow fetching of multiple log files (fields under the defined host? Seperate key/field? Dynamic?)
|
||||||
- Allow different machines to collect different log files
|
- Allow different machines to collect different log files
|
||||||
- Allow to gather directories of log files
|
- Allow to gather directories of log files
|
||||||
- Develop a log getting logs for sanity
|
- Develop a log getting logs for sanity
|
||||||
|
|
||||||
|
Developing a way to include a log space in the config which this program does not have.
|
Loading…
Reference in New Issue
Block a user