Skip to content

Commit

Permalink
initial commit: acc-m plugin wrapper for collector
Browse files Browse the repository at this point in the history
  • Loading branch information
smithclay committed Jul 31, 2024
1 parent 5650db0 commit 826e929
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sensu-plugin/allow_list/check-allow-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"args": [
""
],
"exec": "otel-metrics.rb",
"skip_arguments": true
}
]
1 change: 1 addition & 0 deletions sensu-plugin/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
otelcol-contrib
34 changes: 34 additions & 0 deletions sensu-plugin/bin/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
receivers:
hostmetrics:
collection_interval: 10s
scrapers:
cpu:
memory:
disk:
filesystem:
load:
network:
paging:
processes:

processors:
batch:
timeout: 5s
resourcedetection:
detectors: [env,system]

exporters:
carbon:
endpoint: "localhost:2003" # The address of the Carbon/Graphite server
timeout: 10s

service:
pipelines:
metrics:
receivers: [hostmetrics]
processors: [batch, resourcedetection]
exporters: [carbon]

extensions:
health_check:
pprof:
47 changes: 47 additions & 0 deletions sensu-plugin/bin/otel-metrics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env ruby

# This is just a simple TCP server that proxies metrics output from the
# carbonreceiver to stdout so it can be read by a sensu metrics plugin.

require 'socket'
require 'timeout'

PORT = 2003
HOST = '0.0.0.0'
TIMEOUT = 15

# TODO: run the collector binary / check if it's running.

def start_server
server = TCPServer.new(HOST, PORT)
#puts "Server started on #{HOST}:#{PORT}"

begin
Timeout.timeout(TIMEOUT) do
loop do
client = server.accept
Thread.new(client) do |client_connection|
handle_client(client_connection)
end
end
end
rescue Timeout::Error
#puts "Server timeout reached. Shutting down..."
ensure
server.close
end
end

def handle_client(client)
loop do
line = client.gets
break if line.nil? || line.chomp.empty?

puts line.chomp
client.puts line
end

client.close
end

start_server
3 changes: 3 additions & 0 deletions sensu-plugin/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Experimental OpenTelemetry ACC-M plugin

Work in progress.

0 comments on commit 826e929

Please sign in to comment.