Commit ad5f9532 authored by Eteri's avatar Eteri

fleutnbit: wendeling plugin initial commit

parent d9ae0eb1
......@@ -19,8 +19,9 @@ bin = ${:home}/bin
[fluentbit-service]
recipe = slapos.cookbook:wrapper
#command-line = {{ fluentbit_source_location }}/build/bin/fluent-bit -i cpu -o stdout
command-line = {{ fluentbit_source_location }}/build/bin/fluent-bit -e {{ fluentbit_go_repository_location}}/examples/out_gstdout/out_gstdout.so -i cpu -o gstdout
command-line =
{{ fluentbit_source_location }}/build/bin/fluent-bit -c {{ wendelin_conf_file }}/conf.cnf -e
{{ wendelin_test_path}}/{{ wendelin_plugin_filename }}.so
-i cpu -o wendelin_out -v
wrapper-path = ${directory:service}/fluentbit-service
output = $${:wrapper-path}
output = $${:wrapper-path}
\ No newline at end of file
......@@ -12,7 +12,10 @@ parts =
instance-profile
fluentbit-go-repository
fluentbit-build-go
# wendelin-profile
wendelin-plugin-file
wendelin-test
wendelin-conf-file
[instance-profile]
recipe = slapos.recipe.template:jinja2
......@@ -24,6 +27,9 @@ context =
section buildout buildout
key fluentbit_source_location fluentbit-source:location
key fluentbit_go_repository_location fluentbit-go-repository:location
key wendelin_test_path wendelin-test:path
key wendelin_plugin_filename wendelin-plugin-file:filename
key wendelin_conf_file wendelin-conf-file:location
[fluentbit-source]
recipe = slapos.recipe.build:gitclone
......@@ -50,4 +56,48 @@ path = ${fluentbit-go-repository:location}
configure-command = cd ${:path} && ${:go} get github.com/fluent/fluent-bit-go/output
make-binary =
make-targets = cd ${:path}/examples/out_gstdout &&
${:go} build -buildmode=c-shared -o out_gstdout.so out_gstdout.go
\ No newline at end of file
${:go} build -buildmode=c-shared -o out_gstdout.so out_gstdout.go
[wendelin-plugin-file]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/wendelin-plugin/out_wendelin.go
#md5sum = 88c4c33e374ea3f61cdd36b2816d24ba
filename = out_wendelin.go
location = ${buildout:parts-directory}/${:_buildout_section_name_}
mode = 0644
[wendelin-conf-file]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/wendelin-plugin/conf.cnf
#md5sum = 88c4c33e374ea3f61cdd36b2816d24ba
filename = conf.cnf
location = ${buildout:parts-directory}/${:_buildout_section_name_}
mode = 0644
[wendelin-test]
recipe = slapos.recipe.cmmi
go = ${golang19:location}/bin/go
path = ${wendelin-plugin-file:location}
configure-command = cd ${:path} && ${:go} get github.com/fluent/fluent-bit-go/output
make-binary =
make-targets = cd ${:path} &&
${:go} build -buildmode=c-shared -o ${wendelin-plugin-file:filename}.so ${wendelin-plugin-file:filename}
#[wendelin-profile]
#recipe = slapos.recipe.template:jinja2
#template = ${:_profile_base_location_}/wendelin-plugin/out_wendelin.go
#rendered = ${fluentbit-go-repository:location}/examples/out_gstdout/out_wendelin.go
#md5sum = a4cc579e1a4dd0eb58792a8dc6d47bc9
#mode = 0644
#[wendelin-test]
#recipe = slapos.recipe.cmmi
#go = ${golang19:location}/bin/go
#path = ${fluentbit-go-repository:location}
#configure-command = cd ${:path} && ${:go} get github.com/fluent/fluent-bit-go/output
#make-binary =
#make-targets = cd ${:path}/examples/out_gstdout &&
# ${:go} build -buildmode=c-shared -o out_wendelin.so out_wendelin.go
[INPUT]
Name cpu
Tag cpu
[OUTPUT]
Name http
Match *
Host softinst84835.host.vifib.net
URI /erp5
\ No newline at end of file
package main
import "github.com/fluent/fluent-bit-go/output"
import (
"fmt"
"unsafe"
"C"
)
//export FLBPluginRegister
func FLBPluginRegister(ctx unsafe.Pointer) int {
return output.FLBPluginRegister(ctx, "wendelin_out", "Wendelin Out GO!")
}
//export FLBPluginInit
// (fluentbit will call this)
// ctx (context) pointer to fluentbit context (state/ c code)
func FLBPluginInit(ctx unsafe.Pointer) int {
// Example to retrieve an optional configuration parameter
param := output.FLBPluginConfigKey(ctx, "param")
user := output.FLBPluginConfigKey(ctx, "user")
password := output.FLBPluginConfigKey(ctx, "password")
uri := output.FLBPluginConfigKey(ctx, "uri")
fmt.Printf("[flb-go] plugin parameter = '%s'\n", param)
fmt.Printf("[flb-go] plugin parameter = '%s'\n", user)
fmt.Printf("[flb-go] plugin parameter = '%s'\n", password)
fmt.Printf("[flb-go] plugin parameter = '%s'\n", uri)
return output.FLB_OK
}
//export FLBPluginFlush
func FLBPluginFlush(data unsafe.Pointer, length C.int, tag *C.char) int {
// change here for wendelin
// var count int
// var ret int
// var ts interface{}
// var record map[interface{}]interface{}
/*
// Create Fluent Bit decoder
dec := output.NewDecoder(data, int(length))
// Iterate Records
count = 0
for {
// Extract Record
ret, ts, record = output.GetRecord(dec)
if ret != 0 {
break
}
// Print record keys and values
timestamp := ts.(output.FLBTime)
fmt.Printf("[%d] %s: [%s, {", count, C.GoString(tag),
timestamp.String())
for k, v := range record {
fmt.Printf("\"%s\": %v, ", k, v)
}
fmt.Printf("}\n")
count++
}
*/
// Return options:
//
// output.FLB_OK = data have been processed.
// output.FLB_ERROR = unrecoverable error, do not try this again.
// output.FLB_RETRY = retry to flush later.
return output.FLB_OK
}
//export FLBPluginExit
func FLBPluginExit() int {
return output.FLB_OK
}
func main() {
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment