Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

create heartbeat status file in out_oms #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions Providers/Modules/Plugins/Common/plugin/out_oms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def initialize
require_relative 'omslog'
require_relative 'oms_configuration'
require_relative 'oms_common'
require 'fileutils'
end

config_param :omsadmin_conf_path, :string, :default => '/etc/opt/microsoft/omsagent/conf/omsadmin.conf'
Expand All @@ -39,6 +40,16 @@ def shutdown
super
end

def write_heartbeat_status()
fn = '/var/opt/microsoft/omsagent/log/heartbeat'
begin
FileUtils.touch(fn)
@log.info "Written heartbeat status"
rescue => e
@log.warn "Error:'#{e}'"
end
end

def write_status_file(success, message)
fn = '/var/opt/microsoft/omsagent/log/ODSIngestion.status'
status = '{ "operation": "ODSIngestion", "success": "%s", "message": "%s" }' % [success, message]
Expand Down Expand Up @@ -103,8 +114,13 @@ def write(chunk)
# Group records based on their datatype because OMS does not support a single request with multiple datatypes.
datatypes = {}
unmergable_records = []
heartbeat_found = false
chunk.msgpack_each {|(tag, record)|
if record.has_key?('DataType') and record.has_key?('IPName')
if !heartbeat_found && tag.include?('oms.heartbeat')
heartbeat_found = true
end

key = "#{record['DataType']}.#{record['IPName']}".upcase

if datatypes.has_key?(key)
Expand All @@ -126,6 +142,11 @@ def write(chunk)
handle_record(key, record)
end

if heartbeat_found
write_heartbeat_status()
heartbeat_found = false
end

@log.trace "Handling #{unmergable_records.size} unmergeable records"
unmergable_records.each { |key, record|
handle_record(key, record)
Expand Down