mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
Add pkg/kmsg
This very simple program reads from `/dev/kmsg` and logs the output. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
parent
565f787bb3
commit
793dd1b257
@ -88,8 +88,6 @@ conds
|
|||||||
socket could be created to keep syslog compatibility, e.g. by using
|
socket could be created to keep syslog compatibility, e.g. by using
|
||||||
https://github.com/mcuadros/go-syslog. Processes that require syslog should
|
https://github.com/mcuadros/go-syslog. Processes that require syslog should
|
||||||
then be able to log directly to memlogd.
|
then be able to log directly to memlogd.
|
||||||
- Kernel messages not read on startup yet (but can be captured with
|
|
||||||
`logwrite dmesg`)
|
|
||||||
- Currently no direct external hooks exposed - but options available that
|
- Currently no direct external hooks exposed - but options available that
|
||||||
could be added. Should also be possible to pipe output to e.g. `oklog`
|
could be added. Should also be possible to pipe output to e.g. `oklog`
|
||||||
from `logread` (https://github.com/oklog/oklog)
|
from `logread` (https://github.com/oklog/oklog)
|
||||||
|
14
pkg/kmsg/Dockerfile
Normal file
14
pkg/kmsg/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM linuxkit/alpine:6264e5b39af8eb1da7ffa4c05a7ccc597da01197 AS mirror
|
||||||
|
|
||||||
|
RUN apk add --no-cache go musl-dev linux-headers
|
||||||
|
ENV GOPATH=/go PATH=$PATH:/go/bin
|
||||||
|
|
||||||
|
COPY . /go/src/kmsg/
|
||||||
|
RUN go-compile.sh /go/src/kmsg
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
ENTRYPOINT []
|
||||||
|
CMD []
|
||||||
|
WORKDIR /
|
||||||
|
COPY --from=mirror /go/bin/kmsg /usr/bin/kmsg
|
||||||
|
CMD ["/usr/bin/kmsg"]
|
6
pkg/kmsg/build.yml
Normal file
6
pkg/kmsg/build.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
image: kmsg
|
||||||
|
config:
|
||||||
|
binds:
|
||||||
|
- /dev/kmsg:/dev/kmsg
|
||||||
|
capabilities:
|
||||||
|
- CAP_SYSLOG
|
25
pkg/kmsg/main.go
Normal file
25
pkg/kmsg/main.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
// Log the kernel log buffer (from /dev/kmsg)
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/euank/go-kmsg-parser/kmsgparser"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
parser, err := kmsgparser.NewParser()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("unable to create parser: %v", err)
|
||||||
|
}
|
||||||
|
defer parser.Close()
|
||||||
|
|
||||||
|
kmsg := parser.Parse()
|
||||||
|
|
||||||
|
for msg := range kmsg {
|
||||||
|
fmt.Printf("(%d) - %s: %s", msg.SequenceNumber, msg.Timestamp.Format(time.RFC3339Nano), msg.Message)
|
||||||
|
}
|
||||||
|
}
|
1
pkg/kmsg/vendor.conf
Normal file
1
pkg/kmsg/vendor.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
github.com/euank/go-kmsg-parser 5ba4d492e455a77d25dcf0d2c4acc9f2afebef4e
|
Loading…
Reference in New Issue
Block a user