MCPcopy Index your code
hub / github.com/disqus/porkchop

github.com/disqus/porkchop @0.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.5 ↗ · + Follow
40 symbols 131 edges 14 files 1 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Porkchop

Porkchop is a simple HTTP-based system information server. You write plugins for it and it responds with the data based on your request.

Here is an example:

scott@beatbox:~% curl http://localhost:5000/cpuinfo
/cpuinfo/processor2/fpu yes 
/cpuinfo/processor2/f00f_bug no
/cpuinfo/processor2/cache_alignment 64
/cpuinfo/processor2/vendor_id AuthenticAMD
/cpuinfo/processor2/flags fpu 
/cpuinfo/processor2/bogomips 6384
/cpuinfo/processor2/hlt_bug no
/cpuinfo/processor2/apicid 2
/cpuinfo/processor2/fpu_exception yes 
/cpuinfo/processor2/stepping 3
/cpuinfo/processor2/wp yes 
/cpuinfo/processor2/siblings 4
/cpuinfo/processor2/model 4
/cpuinfo/processor2/coma_bug no
/cpuinfo/processor2/fdiv_bug no
/cpuinfo/processor3/fpu yes 
/cpuinfo/processor3/f00f_bug no
/cpuinfo/processor3/cache_alignment 64
/cpuinfo/processor3/vendor_id AuthenticAMD
/cpuinfo/processor3/flags fpu 
/cpuinfo/processor3/bogomips 6384
/cpuinfo/processor3/hlt_bug no
/cpuinfo/processor3/apicid 3
/cpuinfo/processor3/fpu_exception yes 
/cpuinfo/processor3/stepping 3
/cpuinfo/processor3/wp yes 
/cpuinfo/processor3/siblings 4
/cpuinfo/processor3/model 4
/cpuinfo/processor3/coma_bug no
/cpuinfo/processor3/fdiv_bug no
[snip]
/time 1311387215
scott@beatbox:~%

It can also respond with JSON via .json file extension or setting the Accept: application/json header.

scott@beatbox:~% curl http://localhost:5000/cpuinfo.json
{"cpuinfo": {"processor2": {"fpu": "yes", "f00f_bug": "no", "cache_alignment": "64", "vendor_id": "AuthenticAMD", "flags": "fpu", "bogomips": "6384", "hlt_bug": "no", "apicid": "2", "fpu_exception": "yes", "stepping": "3", "wp": "yes", "siblings": "4", "model": "4", "coma_bug": "no", "fdiv_bug": "no"}, "processor3": {"fpu": "yes", "f00f_bug": "no", "cache_alignment": "64", "vendor_id": "AuthenticAMD", "flags": "fpu", "bogomips": "6384", "hlt_bug": "no", "apicid": "3", "fpu_exception": "yes", "stepping": "3", "wp": "yes", "siblings": "4", "model": "4", "coma_bug": "no", "fdiv_bug": "no"}, "processor0": {"fpu": "yes", "f00f_bug": "no", "cache_alignment": "64", "vendor_id": "AuthenticAMD", "flags": "fpu", "bogomips": "6382", "hlt_bug": "no", "apicid": "0", "fpu_exception": "yes", "stepping": "3", "wp": "yes", "siblings": "4", "model": "4", "coma_bug": "no", "fdiv_bug": "no"}, "processor1": {"fpu": "yes", "f00f_bug": "no", "cache_alignment": "64", "vendor_id": "AuthenticAMD", "flags": "fpu", "bogomips": "6384", "hlt_bug": "no", "apicid": "1", "fpu_exception": "yes", "stepping": "3", "wp": "yes", "siblings": "4", "model": "4", "coma_bug": "no", "fdiv_bug": "no"}}, "time": "1311389934"}
scott@beatbox:~%

Installation

python setup.py install

Writing Plugins

It's pretty easy to write a new plugin. They're just Python modules with some common attributes:

  • A plugin must subclass porkchop.plugin.PorkchopPlugin.
  • The plugin's class must be suffixed with Plugin. Its actual file name in the plugin directory should also match the prefix. For example, FooPlugin would be in the file foo.py
  • The plugin's class must contain a method called get_data that returns a dictionary of the information to be displayed.

By default, a plugin's get_data method will only be called if the data is more then 60 seconds old. This can be changed on a per-plugin basis by setting self.refresh in the class's ___init___ method.

Core symbols most depended-on inside this repo

get_logger
called by 4
porkchop/commandline.py
format_body
called by 3
porkchop/server.py
load_plugins
called by 2
porkchop/plugin.py
json_path
called by 1
porkchop/server.py
should_refresh
called by 1
porkchop/plugin.py
str_to_obj
called by 1
porkchop/plugin.py
get_data
called by 1
porkchop/plugins/riak.py
get_vhosts
called by 1
porkchop/plugins/rabbitmq.py

Shape

Method 24
Class 13
Function 3

Languages

Python100%

Modules by API surface

porkchop/plugin.py8 symbols
porkchop/server.py6 symbols
porkchop/plugins/haproxy.py5 symbols
porkchop/plugins/rabbitmq.py4 symbols
porkchop/plugins/thing.py3 symbols
porkchop/plugins/runit.py3 symbols
porkchop/commandline.py3 symbols
porkchop/plugins/riak.py2 symbols
porkchop/plugins/iostat.py2 symbols
porkchop/plugins/facter.py2 symbols
porkchop/plugins/cpuinfo.py2 symbols

For agents

$ claude mcp add porkchop \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact