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

Commit

Permalink
fix tail plugin troubleshooting logs and tsg (#1508)
Browse files Browse the repository at this point in the history
* fix tail plugin troubleshooting logs and tsg

* fix the typo
  • Loading branch information
NarineM authored Nov 14, 2022
1 parent 2e1afc3 commit 1d57a6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ sudo service crond start
* Onboarding to OMS Service failed
* The setting "Apply the following configuration to my Linux Servers" has not been check marked
* omsconfig has not picked up the latest Custom Log from the portal
* OMS Agent for Linux user `omsagent` is unable to access the Custom Log due to permissions or not being found
* `[DATETIME] [warn]: file not found. Continuing without tailing it.`
* `[DATETIME] [error]: file not accessible by omsagent.`
* Known Issue with Race Condition fixed in OMS Agent for Linux version 1.1.0-217
* OMS Agent for Linux user `omsagent` is unable to access the Custom Log due to permissions or path not being found. In that case osmagent.log will contain one of these messages:
* `[DATETIME] [info]: <path> not found. Continuing without tailing it.`
* `[DATETIME] [info]: <path> does not exist or not accessible. Cannot tail the file. Skipping.`
* `[DATETIME] [info]: <path> is excluded since it's unreadable or doesn't have proper permissions.`

#### Resolutions
* Check if onboarding the OMS Service was successful by checking if the following file exists: `/etc/opt/microsoft/omsagent/<workspace id>/conf/omsadmin.conf`
Expand All @@ -440,10 +440,10 @@ sudo service crond start
* If this command fails run the following command `sudo su omsagent -c 'python /opt/microsoft/omsconfig/Scripts/PerformRequiredConfigurationChecks.py'`. This command forces the omsconfig agent to talk to the OMS Portal Service and retrieve latest configuration.


**Background:** Instead of the OMS Agent for Linux user running as a privileged user, `root` - The OMS Agent for Linux runs as the `omsagent` user. In most cases explicit permission must be granted to this user in order for certain files to be read.
* To grant permission to `omsagent` user run the following commands
**Background:** Instead of the OMS Agent for Linux user running as a privileged user, `root` - The OMS Agent for Linux runs as the `omsagent` user. In most cases explicit permission must be granted to this user in order for certain files to be read. For custom log collection, read permission is required. To grant permission to `omsagent` user run the following commands:
* Add the `omsagent` user to specific group `sudo usermod -a -G <GROUPNAME> <USERNAME>`
* Grant universal read access to the required file `sudo chmod -R ugo+rx <FILE DIRECTORY>`
* Grant owner read access to the required file `sudo chmod -R ugo+rx <FILE DIRECTORY>`
* Restart the omsagent service: `sudo /opt/microsoft/omsagent/bin/service_control restart`

* There is a known issue with a Race Condition in OMS Agent for Linux version <1.1.0-217. After updating to the latest agent run the following command to get the latest version of the output plugin
* `sudo cp /etc/opt/microsoft/omsagent/sysconf/omsagent.conf /etc/opt/microsoft/omsagent/<workspace id>/conf/omsagent.conf`
Expand Down
18 changes: 9 additions & 9 deletions source/code/plugins/tailfilereader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def initialize(paths)
@log.formatter = proc do |severity, time, progname, msg|
"#{severity} #{msg}\n"
end
@log.info "Received paths from sudo tail plugin : #{paths}, log_level=#{level}"
@log.info "sudo tail plugin in agent configuration is provisioned to tail files from the following paths: #{paths}, log_level=#{level}"
end

attr_reader :paths

def file_exists(path)
if File.exist?(path)
@log.info "Following tail of #{path}"
@log.info "File path #{path} exists. Trying to tail."
return path
else
@log.warn "#{path} does not exist. Cannot tail the file."
@log.info "#{path} does not exist or not accessible. Cannot tail the file. Skipping."
return nil
end
end
Expand All @@ -51,12 +51,12 @@ def expand_paths()
@log.info "Following tail of #{p}"
expanded_paths << p
elsif !File.readable?(p)
@log.warn "#{p} is excluded since it's unreadable or doesn't have proper permissions."
@log.info "#{p} is excluded since it's unreadable or doesn't have proper permissions."
else
@log.warn "#{p} is a directory and thus cannot be tailed"
end
rescue Errno::ENOENT
@log.debug("#{p} is missing after refreshing file list")
@log.warn("#{p} is missing after refreshing file list")
end
}
else
Expand All @@ -65,7 +65,7 @@ def expand_paths()
if File.readable?(path) && !File.directory?(path)
expanded_paths << file
elsif !File.readable?(path)
@log.warn "#{path} is excluded since it's unreadable or doesn't have proper permissions."
@log.info "#{path} is excluded since it's unreadable or doesn't have proper permissions."
else
@log.warn "#{path} is a directory and thus cannot be tailed"
end
Expand Down Expand Up @@ -105,7 +105,7 @@ def start_watchers(paths)
begin
pe.update(File::Stat.new(path).ino, 0)
rescue Errno::ENOENT
@log.warn "#{path} not found. Continuing without tailing it."
@log.info "#{path} not found. Continuing without tailing it."
end
end
end
Expand Down Expand Up @@ -325,7 +325,7 @@ def self.parse(file, log)
file.each_line {|line|
m = /^([^\t]+)\t([0-9a-fA-F]+)\t([0-9a-fA-F]+)/.match(line)
unless m
@log.warn "Unparsable line in pos_file: #{line}"
@log.warn "Unparsable line in pos_file: #{line}. Skipping."
next
end
path = m[1]
Expand All @@ -343,7 +343,7 @@ def self.compact(file)
existent_entries = file.each_line.map { |line|
m = /^([^\t]+)\t([0-9a-fA-F]+)\t([0-9a-fA-F]+)/.match(line)
unless m
@log.warn "Unparsable line in pos_file: #{line}"
@log.warn "Unparsable line in pos_file: #{line}. Skipping."
next
end
path = m[1]
Expand Down

0 comments on commit 1d57a6a

Please sign in to comment.