• Stars
    star
    455
  • Rank 92,790 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command line tool to view namespaces and cgroups, useful for low-level container prodding

cinf

Go Report Card

This is cinf, short for container info, a command line tool to view namespaces and cgroups, the stuff that makes up Linux containers such as Docker, rkt/appc, or OCI/runc. It might be useful for low-level container prodding, when you need to understand what's going on under the hood. Read more here: Containers are a lie …

Contents:

Install

Simply download the Linux binary:

curl -s -L https://github.com/mhausenblas/cinf/releases/latest/download/cinf_linux_amd64.tar.gz \
     -o cinf.tar.gz && \
     tar xvzf cinf.tar.gz cinf && \
     mv cinf /usr/local/bin && \
     rm cinf*

Or build from source (note that you'll get the latest, experimental version via this method):

go get github.com/mhausenblas/cinf

GOOS=linux go build

The cinf package docs are available online.

Use

The following sections show basic usage. For a complete end-to-end usage, see the walkthrough.

Note that if you want to see detailed debug messages, you can do that via a DEBUG environment variable, like so: sudo DEBUG=true cinf.

To see all namespaces

To list all available namespaces and a summary of how many processes are in them along with the user IDs and the top-level command line executed, simply do the following:

$ sudo cinf

NAMESPACE   TYPE  NPROCS  USERS                     CMD

4026532396  pid   1       1000                      sleep10000
4026532398  net   1       1000                      sleep10000
4026531837  user  109     0,1,101,102,104,106,1000  /sbin/init
4026532196  pid   2       0,104                     nginx: master proces
4026532293  mnt   1       0                         md5sum/dev/urandom
4026532298  net   1       0                         md5sum/dev/urandom
4026532393  mnt   1       1000                      sleep10000
4026532296  pid   1       0                         md5sum/dev/urandom
4026531840  mnt   104     0,1,101,102,106,1000      /sbin/init
4026531839  ipc   105     0,1,101,102,106,1000      /sbin/init
4026531836  pid   105     0,1,101,102,106,1000      /sbin/init
4026532193  mnt   2       0,104                     nginx: master proces
4026532198  net   2       0,104                     nginx: master proces
4026531838  uts   105     0,1,101,102,106,1000      /sbin/init
4026532194  uts   2       0,104                     nginx: master proces
4026532294  uts   1       0                         md5sum/dev/urandom
4026532394  uts   1       1000                      sleep10000
4026532395  ipc   1       1000                      sleep10000
4026531956  net   105     0,1,101,102,106,1000      /sbin/init
4026531856  mnt   1       0
4026532195  ipc   2       0,104                     nginx: master proces
4026532295  ipc   1       0                         md5sum/dev/urandom

To dig into a namespace

Assuming we're interested in more information on namespace 4026532398, we would do the following:

$ sudo cinf --namespace 4026532193

To dig into a cgroup

Let's dig into a specific cgroup (with hierarchy ID 3) of a process (with PID 27681):

$ sudo cinf --cgroup 27681:3

To dig into a process

It is also possible to list the namespaces a specific process is in:

$ sudo cinf --pid 27681

To monitor a process

The interactive, top like mode of cinf is as follows. Let's say we want to monitor the control files memory.usage_in_bytes, cpuacct.usage, and blkio.throttle.io_service_bytes for process with PID 27681:

$ sudo cinf --mon 27681:memory.usage_in_bytes,cpuacct.usage,blkio.throttle.io_service_bytes

Note that a more detailed usage description is available via the walkthrough.

CLI reference

There are three arguments you can provide to cinf, to dig into specific aspects of a namespace, cgroup, or process:

  • --namespace $NAMESPACE_ID … List details about namespace with provided ID.
  • --cgroup $PID:$CGROUP_HIERARCHY_ID … List details of a cgroup a process belongs to.
  • --pid $PID … List namespaces the process with provided process ID is in.
  • --mon $PID:$CF1,$CF2,… … Monitor process with provided process ID and the control files specified.

The meaning of the output columns is as follows:

  • Overview (without arguments):
    • NAMESPACE … the namespace ID
    • TYPE … the type of namespace, see also explanation of the namespaces below
    • NPROCS … number of processes in the namespace
    • USERS … user IDs in the namespace
    • CMD … command line of the root process
  • Detailed namespace view (--namespace):
    • PID … process ID
    • PPID … process ID of parent
    • NAME … process name
    • CMD … process command line
    • NTHREADS… number of threads
    • CGROUPS … summary of the attached cgroups
    • STATE … process state
  • Detailed cgroups view (--cgroup):
    • CONTROLFILE … the name of the control file, see also cgroup man pages below
    • VALUE … the content of the control file
  • Detailed process view (--pid):
    • NAMESPACE … the namespace ID
    • TYPE … the type of namespace
  • Monitor process view (--mon):
    • PID … process ID
    • PPID … process ID of parent
    • UIDS … real, effective, saved set, filesystem user ID
    • STATE … process state
    • NAMESPACE … the IDs of the namespaces the process is in
    • CONTROLFILE … the name of the control file, see also cgroup man pages below
    • VALUE … the content of the control file

Background

I developed cinf because existing tools like systemd-cgtop or lsns didn't do what I wanted. Also, I needed it for educational purposes (like training sessions, etc.). Note that the output format cinf uses is modelled after lsns, so kudos to Karel for the inspiration.

If you want to learn more about container building blocks such as namespaces and cgroups, check out containerz.info.

More Repositories

1

dnpipes

Distributed Named Pipes
Go
452
star
2

lambda-architecture.net

A repository of information, examples and good practices around the Lambda Architecture
CSS
369
star
3

kboom

The Kubernetes scale & soak load tester
Go
301
star
4

reshifter

Kubernetes cluster state management
CSS
295
star
5

burry.sh

Cloud Native Infrastructure BackUp & RecoveRY
Go
260
star
6

mkdocs-deploy-gh-pages

GitHub Action to deploy an MkDocs site to GitHub Pages
Shell
233
star
7

rbac.dev

A collection of good practices and tools for Kubernetes RBAC
223
star
8

schema-org-rdf

Schema.org in RDF
HTML
185
star
9

k8s-sec

Kubernetes Security: from Image Hygiene to Network Policies
145
star
10

cidrchk

CLI tool for CIDR range operations (check, generate)
Go
133
star
11

kubed-sh

A cloud native Kubernetes cluster shell for the casual user
Go
97
star
12

krs

A command line tool for capturing and serializing Kubernetes resource statistics in OpenMetrics format
Go
95
star
13

kube-rpi

Kubernetes on Raspberry Pi 4 with 64-bit OS
82
star
14

the-container-security-book

The Container Security Book—a free book for practitioners
82
star
15

modern-linux.info

Learning Modern Linux book website
Shell
80
star
16

cn-ref

A collection of tools and references around container networking
78
star
17

rbIAM

A unified IAM+Kubernetes RBAC access control exploration tool
Go
75
star
18

5stardata.info

Information around TimBL's 5 star Open Data plan
HTML
70
star
19

eksphemeral

A simple Amazon EKS manager for ephemeral clusters
Go
66
star
20

stateful-kubernetes

All Thingz Stateful Apps & Tooling in Kubernetes
HTML
66
star
21

kn

A collection of shell functions for Kubernetes native dabbling
Shell
50
star
22

right-size-guide

A CLI tool providing memory & CPU recommendations for containerized apps
Go
48
star
23

l2i

The Lambda Layer Inspector (L2I)
Go
43
star
24

rbacadabra

A collection of RBAC recipes and tips & tricks
42
star
25

zdd-lab

DC/OS Zero Downtime Deployments Lab
Shell
39
star
26

simpleservice

A simple service for testing container orchestration setups
Python
35
star
27

yages

Yet another gRPC echo server (YAGES)
Go
34
star
28

troubleshooting-k8s-apps

Troubleshooting Kubernetes Applications
HTML
33
star
29

kubectl-in-action

Tips and Tricks around using kubectl to manage your Kubernetes cluster
29
star
30

usn-app

UberSocialNet—applying the Lambda Architecture
Python
29
star
31

o11y-in-action.cloud

Cloud Observability in Action
Go
26
star
32

web.instata

Turn your POTD into Web data
Python
26
star
33

canihaznonprivilegedcontainers.info

Advocacy site for the uptake of using non-privileged containers
24
star
34

omnidator

Translates Schema.org annotated data formats (microdata, CSV, etc.) into other data formats (JSON, RDF, etc.)
Python
24
star
35

mehdb

Educational Kubernetes-native NoSQL datastore using StatefulSet and persistent volumes
Go
23
star
36

k8s-autoscale

Kubernetes Autoscaling Experiments
JavaScript
23
star
37

turtled

A simple online RDF Turtle editor
JavaScript
22
star
38

nase

A PoC for native Kubernetes secrets support via AWS Secrets Manager
Go
21
star
39

hadoop-data-ingestion

Renders options for ingesting data into Hadoop
21
star
40

operator-101

A step-by-step walkthrough of bootstrapping a Kubernetes operator
19
star
41

mkdocs-template

A template for MkDocs publishing via GitHub Action
19
star
42

mrlin

mrlin is 'MapReduce processing of Linked Data' … because it's magic
Python
17
star
43

gitops101

GitOps 101
16
star
44

m-shop

Marathon/Docker deployment of a Web application incl. analytics using the ELK stack
JavaScript
15
star
45

ld-in-couch

Enables you to store, process and query Linked Data in Apache CouchDB.
Python
15
star
46

s3-echoer

Reads input from stdin and uploads it to an existing S3 bucket
Go
14
star
47

kruiser

A proxy that transparently exposes gRPC Kubernetes services cluster-externally
Go
14
star
48

imgn

From monolith to containerized microservices to serverless
Go
14
star
49

otel-adoption-survey-2022

OpenTelemetry Adoption Survey 2022
14
star
50

arn.services

Utility service for Amazon Resource Names (ARNs)
Go
13
star
51

tride

turning tabular data into entities
Python
13
star
52

apache-drill-frontend

A front-end for Apache Drill
JavaScript
13
star
53

aws-tmux

AWS status for tmux
Shell
13
star
54

apache-drill-sandbox

A collection of experiments and recipes around Apache Drill
12
star
55

fosdem2018-godevroom-networkingdeepdive

FOSDEM 2018 Go devroom, Networking deepdive—From net.Dial to gRPC
Go
12
star
56

http-range-14-burner

A collection of http-range-14 facts to produce an infographic about resources spent over the past 10y
11
star
57

go4systasks

Using the Go programming language for system tasks
Go
11
star
58

aws-container-security-survey-2020

AWS container security survey 2020
11
star
59

awsometag

A tool to tag AWS resources in a unified manner
Go
11
star
60

aws-container-security-survey-2019

Questions and results of the AWS container security survey 2019
11
star
61

boring-is-cool

Advocacy site for boring technology
HTML
10
star
62

mc

A Simple Mesos-DNS Client
Python
10
star
63

temporal-opa

Temporal reasoning with OPA
Open Policy Agent
10
star
64

using-client-go

A versioned collection of snippets showing how to use client-go
Go
10
star
65

Racoon

Rapid-appraisal crawler for original open data nuggets
Python
9
star
66

apache-big-data-cheat-sheet

A cheat sheet for Big Data technologies at and from The Apache Software Foundation
9
star
67

kubecuddler

A simple Go package wrapping kubectl invocations
Go
8
star
68

madr

Linked Open Data Mobile AugmenteD Reality
Python
8
star
69

go4ops

Go for ops
Go
8
star
70

marvin

A demonstrator for a nanoservices-based application on DC/OS
JavaScript
8
star
71

addrable

Addressable tabular data on the Web
JavaScript
7
star
72

dromedar

Apache Drill On Apache Mesos
Python
7
star
73

ref.otel.help

Collection of OpenTelemetry good practices, tutorials, docs
Python
7
star
74

odc2011

Local Planning Explorer Ireland
PHP
7
star
75

school-explorer

Presents information about schools to help parents to decide where to send their kids to
PHP
7
star
76

RDF2x

A collection of converters from RDF to data formats
6
star
77

openshift-cheat-sheet

Cheat sheet for OpenShift
6
star
78

dependentjobs

DependentJobs for Kubernetes
Go
6
star
79

influxdb-dweet.io

Experiment to ingest data from dweet.io into InfluxDB
Python
6
star
80

fallacies-of-distributed-gomputing

The Fallacies Of Distributed Gomputing—talk at GopherCon 2017
Go
6
star
81

container-networking

Container Networking
5
star
82

ld-profiler

Dirt-simple Linked Data access profiler
Python
5
star
83

sparqlbin.com

A generic SPARQL processor and sharing tool.
Python
5
star
84

letsgo

Let's Go! is a hands-on introduction into the Go programming language
Go
5
star
85

clump

A cluster dump tool
Go
5
star
86

bigdatainthecloud.info

The Q&A site for devops, developers and analysts that deal with Big Data processing in cloud computing environments.
5
star
87

shodan

An event-sourcing-based RDF datastore and processor
Python
4
star
88

aws-cli-fu

Collection of my favorite AWS CLI calls
4
star
89

2018-state-of-faas-on-kube

KubeCon Europe 2018—Lightning Talk: The State Of FaaS on Kubernetes
4
star
90

qrcan

Query Resolver & Comprehensive Archive Network
JavaScript
4
star
91

kaput

Kubernetes Attack and Policy Underminer Tool
Go
4
star
92

hdt-online

A simple HDT converter online service
JavaScript
4
star
93

cloudnaive.online

All things infosec concerning *nix, containers, Kubernetes, and serverless computing
4
star
94

funcnstein

a multi-platform tool for managing functions
3
star
95

sdx

Seamless Developer Experience
Go
3
star
96

util-containers

A collection of utility container images
3
star
97

github-api-fetcher

Fetches data from the public GitHub API and ingests it into various sinks
Go
3
star
98

containerz.info

Advocacy website around Linux containers
HTML
3
star
99

noteless

A e2e demo of serverless technologies
Go
3
star
100

rdfxml.info

An advocacy site to inform people about the drawbacks of RDF/XML
3
star