in source/code/plugins/in_npmd_server.rb [278:343]
def npmd_reader
begin
begin
_line = @npmdClientSock.gets
if _line.nil? and !is_npmd_seen_in_ps()
@npmdClientSock = nil
Logger::logInfo "Exiting reader thread as npmdAgent found stopped"
break
end
@watch_dog_sync.synchronize do
@watch_dog_last_pet = Time.now
end
next if _line.nil? or _line.strip== ""
_json = check_and_get_json(_line.chomp)
unless !_json.nil?
Logger::logWarn "Sent string to plugin is not a json string", Logger::loop
log_error "String received not json: #{_line[0..100]}" if _line.bytesize > 50
else
unless _json.key?("DataItems") and !_json["DataItems"].nil? and _json["DataItems"] != ""
Logger::logWarn "No valid data items found in sent json #{_json}", Logger::loop
else
_uploadData = _json["DataItems"].reject {|x| x["SubType"] == NPM_DIAG}
_diagLogs = _json["DataItems"].select {|x| x["SubType"] == NPM_DIAG}
_validUploadDataItems = Array.new
_batchTime = Time.now.utc.strftime("%Y-%m-%d %H:%M:%SZ")
_subtypeList = ["EndpointHealth", "EndpointPath", "ExpressRoutePath", "EndpointDiagnostics", "ConnectionMonitorTestResult", "ConnectionMonitorPath", "NetworkAgentDiagnostics"]
_uploadData.each do |item|
item["TimeGenerated"] = _batchTime
if item.key?("SubType")
if !@fqdn.nil? and item["SubType"] == "NetworkPath"
@num_path_data += 1 unless @num_path_data.nil?
_validUploadDataItems << item if is_valid_dataitem(item)
elsif !@agentId.nil? and item["SubType"] == "NetworkAgent"
@num_agent_data += 1 unless @num_agent_data.nil?
if shouldUploadNetworkAgentInfo(item)
_validUploadDataItems << item if is_valid_dataitem(item)
else
Logger::logInfo "Network Agent data upload is skipped because it hasnt changed from the last time"
end
elsif _subtypeList.include?item["SubType"]
Logger::logInfo "#{item["SubType"]} is uploaded"
_validUploadDataItems << item if is_valid_dataitem(item)
else
log_error "Invalid Subtype data received"
end
end
end
emit_upload_data_dataitems(_validUploadDataItems) if !_validUploadDataItems.nil? and !_validUploadDataItems.empty?
emit_diag_log_dataitems_of_agent(_diagLogs) if !_diagLogs.nil? and !_diagLogs.empty?
end
end
rescue StandardError => e
unless is_npmd_seen_in_ps()
@npmdClientSock = nil
Logger::logInfo "Exiting reader thread. NPMD found stopped", Logger::loop + Logger::resc
break;
else
log_error "Got error while reading data from NPMD: #{e}", Logger::loop + Logger::resc
end
end
end while !@npmdClientSock.nil?
end