Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add journalctl launcher logs to flare #1592

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works pretty well except for powershell adding a new line between each log, we could remove with some post processing of the output but ... 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to monkey here, you could also add Get-EventLog -Newest 10 -LogName System -Source "Service Control Manager" -Message "*launcherkolidek2svc*" | select -ExpandProperty message

cmd, err := allowedcmd.Powershell(ctx, cmdStr)
if err != nil {
return fmt.Errorf("creating powershell command: %w", err)
Expand Down
Loading