Skip to content

Commit

Permalink
Merge pull request #1135 from grogsaxle/develop
Browse files Browse the repository at this point in the history
add docker os family check
  • Loading branch information
daveed12 authored Apr 25, 2022
2 parents 4791540 + 6ef6596 commit f3ba938
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: check-merge-conflict
- id: check-ast
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
args: ['--line-length', '119']
Expand Down
11 changes: 11 additions & 0 deletions hubblestack/grains/docker_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __virtual__():


def get_docker_details(grains):
"""
Get docker details
"""
docker_grains = {}

docker_details = {}
Expand All @@ -41,9 +44,14 @@ def get_docker_details(grains):


def _is_docker_installed(grains):
"""
Check if docker is installed
"""
os_family = grains.get("os_family", "unknown").lower()
if "coreos" in os_family:
return True
elif "flatcar" in os_family:
return True
elif "debian" in os_family:
osquery_sql = 'select name from deb_packages where name like "%docker%"'
elif "redhat" in os_family:
Expand All @@ -63,6 +71,9 @@ def _is_docker_installed(grains):


def _is_docker_process_running():
"""
Check if docker is running
"""
osquery_sql = 'select name from processes where name LIKE "%dockerd%"'
query_result = osquery_util(query_sql=osquery_sql)
if len(query_result) != 0:
Expand Down

0 comments on commit f3ba938

Please sign in to comment.