Created
February 21, 2023 23:53
-
-
Save korylprince/4952a2949170b10c8fd0ffcbdd289889 to your computer and use it in GitHub Desktop.
Inspect MicroMDM Device Command Queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/boltdb/bolt" | |
"github.com/micromdm/micromdm/platform/queue" | |
) | |
func run() error { | |
if len(os.Args) != 3 { | |
fmt.Printf("usage: %s /path/to/micromdm.db udid", os.Args[0]) | |
os.Exit(1) | |
} | |
db, err := bolt.Open(os.Args[1], 0600, nil) | |
if err != nil { | |
return fmt.Errorf("could not open %s: %w", os.Args[1], err) | |
} | |
dev := new(queue.DeviceCommand) | |
if err := db.View(func(tx *bolt.Tx) error { | |
b := tx.Bucket([]byte(queue.DeviceCommandBucket)) | |
v := b.Get([]byte(os.Args[2])) | |
if v == nil { | |
return fmt.Errorf("udid %s not found", os.Args[2]) | |
} | |
return queue.UnmarshalDeviceCommand(v, dev) | |
}); err != nil { | |
return err | |
} | |
fmt.Printf("Queued: %d, Completed: %d, Failed: %d, NotNow: %d\n", | |
len(dev.Commands), | |
len(dev.Completed), | |
len(dev.Failed), | |
len(dev.NotNow), | |
) | |
for idx, cmd := range dev.Commands { | |
fmt.Printf("Commmand %d (UUID: %s)\n", idx, cmd.UUID) | |
fmt.Println(string(cmd.Payload) + "\n\n") | |
} | |
return nil | |
} | |
func main() { | |
if err := run(); err != nil { | |
fmt.Println(err) | |
} | |
} |
I do indeed have one 😅 mine is probably over engineered with fancy output 😂 https://gist.github.com/discentem/3ebac6731b7cc577669a9c60fe1b292f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar to https://gist.github.com/jessepeterson/8222174c65042afba5c22fb4934d30a4 and I think @discentem also has one of these, too ;P