Skip to content

Commit

Permalink
add journalctl launcher logs to flare (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett authored Feb 9, 2024
1 parent d67f7c1 commit 0915b7d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ee/allowedcmd/cmd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func Ip(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, "/usr/sbin/ip", arg...)
}

func Journalctl(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, "/usr/bin/journalctl", arg...)
}

func Loginctl(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, "/usr/bin/loginctl", arg...)
}
Expand Down
20 changes: 18 additions & 2 deletions ee/debug/checkups/init_logs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ package checkups
import (
"archive/zip"
"context"
"fmt"

"github.com/kolide/launcher/ee/allowedcmd"
)

func writeInitLogs(_ context.Context, _ *zip.Writer) error {
return nil
func writeInitLogs(ctx context.Context, logZip *zip.Writer) error {
cmd, err := allowedcmd.Journalctl(ctx, "-u", "launcher.kolide-k2.service")
if err != nil {
return fmt.Errorf("creating journalctl command: %w", err)
}

outFile, err := logZip.Create("linux_journalctl_launcher_logs.json")
if err != nil {
return fmt.Errorf("creating linux_journalctl_launcher_logs.json: %w", err)
}

cmd.Stderr = outFile
cmd.Stdout = outFile

return cmd.Run()
}
2 changes: 1 addition & 1 deletion ee/debug/checkups/init_logs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func writeInitLogs(ctx context.Context, logZip *zip.Writer) error {
cmdStr := `Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='launcher'} | ConvertTo-Json`
cmdStr := `Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='launcher'} | ForEach-Object { $_.Message }`
cmd, err := allowedcmd.Powershell(ctx, cmdStr)
if err != nil {
return fmt.Errorf("creating powershell command: %w", err)
Expand Down

0 comments on commit 0915b7d

Please sign in to comment.