Merge branch '9683e88' of wymiller/logman into master
This commit is contained in:
commit
854270f99c
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
config.yaml
|
||||
.vscode/
|
||||
vendor/
|
||||
vendor/
|
||||
*.log
|
||||
*.tar.gz
|
4
main.go
4
main.go
@ -1,6 +1,6 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "log"
|
||||
|
||||
func main() {
|
||||
config := initializeConfig("config.yaml")
|
||||
@ -8,5 +8,5 @@ func main() {
|
||||
clientConns := sshConn.dialConnection(sshConfig)
|
||||
_ = sshConn.openSession(clientConns)
|
||||
success := sshConn.executeSFTP(clientConns)
|
||||
fmt.Println(success)
|
||||
log.Println(success)
|
||||
}
|
||||
|
13
sftp.go
13
sftp.go
@ -3,20 +3,18 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/sftp"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
var (
|
||||
dstPath string = "/root/"
|
||||
dstPath string = "/home/wyatt/"
|
||||
srcPath string = "/var/log/"
|
||||
filename string = "dmesg"
|
||||
filename string = "dpkg.log"
|
||||
)
|
||||
|
||||
func getFile(client *ssh.Client) {
|
||||
t := time.Now()
|
||||
sftp, err := sftp.NewClient(client)
|
||||
|
||||
if err != nil {
|
||||
@ -33,8 +31,7 @@ func getFile(client *ssh.Client) {
|
||||
|
||||
defer srcFile.Close()
|
||||
|
||||
timeResult := timeToString(t)
|
||||
dstFile, err := os.Create(dstPath + filename + timeResult)
|
||||
dstFile, err := os.Create(dstPath + filename)
|
||||
|
||||
if err != nil {
|
||||
fmt.Errorf("FUCK")
|
||||
@ -44,7 +41,3 @@ func getFile(client *ssh.Client) {
|
||||
|
||||
srcFile.WriteTo(dstFile)
|
||||
}
|
||||
|
||||
func timeToString(currentTime time.Time) string {
|
||||
return currentTime.String()
|
||||
}
|
||||
|
2
ssh.go
2
ssh.go
@ -96,7 +96,7 @@ func (s SSHConnection) executeSFTP(execute SSHClients) SSHSFTP {
|
||||
// TODO: this is just a placeholder, change to the actual tarring executable
|
||||
getFile(j)
|
||||
|
||||
err := gzipit("/root/"+filename, ".")
|
||||
err := gzipit("/home/wyatt/"+filename, ".")
|
||||
|
||||
if err != nil {
|
||||
fmt.Errorf("Cannot gzip file(s)", err)
|
||||
|
7
string.go
Normal file
7
string.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
func timeToString(currentTime time.Time) string {
|
||||
return currentTime.String()
|
||||
}
|
Loading…
Reference in New Issue
Block a user