Comments (11)
The pcp module on branch bmr-pcp-plugin has something along these lines:
from sos.plugins import Plugin, RedHatPlugin
class sar(Plugin, RedHatPlugin):
"""Collect PCP information
"""
files = ('/var/log/pcp', '/var/lib/pcp/config')
packages = ('pcp',)
def setup(self):
self.addCopySpecs(list(self.files))
from sos.
My only concern is the possible overloading of the meaning of files. Is it common to specify paths in files that you don't actually want copies of?
from sos.
There are a few - emc checks for /opt/Navisphere/bin
, vmware /usr/bin/vmware
, pxe /usr/sbin/pxeos
, corosync /usr/bin/corosync
, systemtap /usr/bin/stap
, ds /opt/redhat-ds
, systemd /usr/lib/systemd/systemd
, cloudforms /usr/share/katello/script/katello-debug
.
I'd almost say that most of these are candidates for a new 'binaries'|'executables' list - apart from /opt/redhat-ds
and /opt/Navisphere/bin
they are all binaries run by the modules. Those two could be easily changed to check for a specific binary in that path.
from sos.
We could also make addCopySpec skip binary files (on a switch perhaps) so that we never copy binaries unless we really mean to.
EDIT: this might be hard to do...
from sos.
Question is how to check for them reliably? Execute perms won't work as there are legitimate cases where we do collect files with this mode - initscripts for e.g. as well as other things that hook into the system by placing an executable file somewhere (cluster resource agents etc.).
I don't really want to get into sniffing files to type them so I'd rather separate these things out into a new list if we're going to pursue this.
from sos.
Yes, it involves guessing. A common way of doing it is to look for a null byte in the first K of the file. This provides false positives for UTF-16 files. It's messy and we should probably avoid it.
Growing a new binaries/executables member simplifies things wrt automagical copying but I think it could make plugin authorship a bit more confusing. I think this can be worked around with a review of a new plugin though.
from sos.
It'd probably be better to do it the way file does - check for the magic numbers of applicable binary formats (for us probably just ELF32/64 but if it needs to work cross platform more).
Still, I think it'd be OK with documentation for authors and review - programmers already need to differentiate between the two when calling addCopySpec*() or collectExtOutput().
from sos.
python-magic
could provide a way to do this, but I don't think adding a dependency is something I'd like to argue for. I'm ok with separate lists.
We might want to come up with more descriptive names for each list to give a hint as to what's going on. Of course, all bets are off if you implement your own setup()
without invoking super()
.
Perhaps we could have a copy_files
member, that setup()
consumes and a required_files
(check_files
?) that is used specifically for checkenabled. copy_files
would be consumed in checkenabled as well. Just thinking out loud here...
from sos.
I like copy_files, or files_list, or something - I've been bitten at least once by redefining a superclass member in subclasses - things get Weird® very fast when you overwrite files, for e.g. :-)
In some ways I like _list suffixes - "executable" is already getting a bit wordy (whichever synonym you use.. command, binary, executable, program, ...) - I don't like "run_programs" and "check_programs" e.g.
Anyway, this isn't urgent so we can kick it around some more to get it right.
from sos.
Another idea:
check_for = ['/path/to/thing', '/path/to/other/bin/myexe']
and
copy_list = ['/path/to/config', '/path/to/log/foo']
I'm still not 100% if it's reasonable to assume that items in copy_list
should be required for the plugin to run. It might be a toss up. In the best case it fits the most common need, in the worst it makes a situation where you have to override setup()
and checkenabled()
to get your plugin to run in an environment where some of your files you wish to copy don't exist, but you still want to continue.
from sos.
All the plugins that include binaries in their files lists currently define a setup() method so they'd be unaffected by this. I've pushed commit f1c643d which adds a default Plugin.setup() and converts the plugins that were previously just collecting their own file lists to use it.
It means a simple plugin can now be just:
class Anacron(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
plugin_name = 'anacron'
files = ('/etc/anacrontab',)
from sos.
Related Issues (20)
- [logs] Logs plugin will always load CoSLogs variant
- [collector] Add a wrapper to import yaml HOT 2
- [tests] networking plugin test can fail if /sys/class/net/bonding_masters file exists HOT 1
- [virsh] may collect SPICE passwords in virt-manager logs HOT 1
- [ubuntu] `--upload-url` implicitly suppress report upload for ubuntu policy HOT 1
- Typos in sos-collect manpage
- [tests] restrict foreman tests to x86_64 architecture only
- URL for commercial support seems wrong HOT 2
- [report] Rename sos_commands to sos_plugins? HOT 2
- support for pebble service manager HOT 3
- [juju] cluster collection doesn't work in 2 scenarios HOT 2
- [collect] sos collect does not detect snap HOT 3
- [networking] route call returns only IPv4 routing table
- [services] Is the services plugin still useful? HOT 3
- sos report --all-logs does not gather all rotated logs in ubuntu HOT 1
- [networking] Collect `sysctl -a` from namespaces
- [juju] add_copy_spec does not collect dot files HOT 2
- Should --plugopts overwrite or add plugin options from config file or preset? HOT 2
- [tests] all cleaner tests to have --no-update option HOT 2
- Issue with do_file_private_sub on the juju plugin HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sos.