mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-03 17:44:07 +02:00
Compare commits
117 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffb3a0ee5f | ||
|
|
94b12b57aa | ||
|
|
6d149e8457 | ||
|
|
1ad89c90d8 | ||
|
|
fb71c7b020 | ||
|
|
28ed17ad3b | ||
|
|
0c2a4e2bf7 | ||
|
|
62bec30de2 | ||
|
|
3fced77e4e | ||
|
|
a09d1d8b76 | ||
|
|
8f4243fbd8 | ||
|
|
47aaf20549 | ||
|
|
0c5289ea50 | ||
|
|
3e53323514 | ||
|
|
a5ee9861b9 | ||
|
|
feb8ca7654 | ||
|
|
a7abe4473b | ||
|
|
780b9b61de | ||
|
|
19ace36ffa | ||
|
|
5fff8afc9f | ||
|
|
4ad230c927 | ||
|
|
dd98eb1ec8 | ||
|
|
c6baf42e72 | ||
|
|
e2bac97d56 | ||
|
|
d112ee94d0 | ||
|
|
27b21b2faf | ||
|
|
8c96d5cd20 | ||
|
|
c29ed3fd69 | ||
|
|
cedf603f12 | ||
|
|
279161c36f | ||
|
|
ce0b43d919 | ||
|
|
ddafa5bf06 | ||
|
|
bc7116c31b | ||
|
|
53b7092721 | ||
|
|
beb9174b1b | ||
|
|
aea41ed341 | ||
|
|
d789494cb1 | ||
|
|
608e7b4cff | ||
|
|
4ee199c02a | ||
|
|
fbf47d4085 | ||
|
|
5a238e4b42 | ||
|
|
f852b8246a | ||
|
|
88140d929a | ||
|
|
45f7268240 | ||
|
|
3a3c8e4d4a | ||
|
|
c1ac183a04 | ||
|
|
18bb779ee5 | ||
|
|
8b6612fe79 | ||
|
|
fde0bc8534 | ||
|
|
e661a78939 | ||
|
|
847e346602 | ||
|
|
b969751688 | ||
|
|
ad6f2ba03a | ||
|
|
63c6a5edc0 | ||
|
|
9f4cf9dd5e | ||
|
|
51331b6dc0 | ||
|
|
efb6761033 | ||
|
|
6a4f737a0f | ||
|
|
be6864b778 | ||
|
|
de3b91a36c | ||
|
|
ef5482c3b5 | ||
|
|
d20b795137 | ||
|
|
8a134065df | ||
|
|
22aee1bfa4 | ||
|
|
b282820fd6 | ||
|
|
3ee098306d | ||
|
|
09e8f379a6 | ||
|
|
69018cdb3a | ||
|
|
d0d7254c6a | ||
|
|
cc0f0971d7 | ||
|
|
2af61730f0 | ||
|
|
83f41b83dc | ||
|
|
1fb84fce88 | ||
|
|
a8837e1244 | ||
|
|
04d2eec558 | ||
|
|
1b57ec92f0 | ||
|
|
4d88595404 | ||
|
|
52b1272a3a | ||
|
|
d2ccad6a83 | ||
|
|
cad6dde4ac | ||
|
|
06811c3539 | ||
|
|
0cb23c2b21 | ||
|
|
ac4688dca2 | ||
|
|
326c3b4670 | ||
|
|
9b29d0c268 | ||
|
|
e0013c3871 | ||
|
|
a75744075b | ||
|
|
525aec1a02 | ||
|
|
0bf9a7a072 | ||
|
|
d8f2f4c95b | ||
|
|
35d733b44f | ||
|
|
9179b4175c | ||
|
|
bb07d78c78 | ||
|
|
07b179cd7f | ||
|
|
054422d837 | ||
|
|
3e052d1810 | ||
|
|
c8e72805cf | ||
|
|
12a80e7db0 | ||
|
|
ee7ff9a09d | ||
|
|
f6478fb636 | ||
|
|
811a0b0495 | ||
|
|
aeb48edf72 | ||
|
|
b1e94f0df7 | ||
|
|
60050e3c0f | ||
|
|
39ef09aa5b | ||
|
|
8377d43116 | ||
|
|
54e4c447ab | ||
|
|
937a9fa9cf | ||
|
|
808ff6cf0e | ||
|
|
7f5c649a95 | ||
|
|
b72727dec9 | ||
|
|
3fc88bfb33 | ||
|
|
9f2279d586 | ||
|
|
346a14cb9b | ||
|
|
dac00d17ff | ||
|
|
9ca7cd4060 | ||
|
|
aa31628970 |
@@ -1,5 +1,52 @@
|
||||
jc changelog
|
||||
|
||||
20200710 v1.12.0
|
||||
- Add sysctl command parser tested on linux, macOS, and freebsd12
|
||||
- Update the cli code to allow older versions of the pygments library (2.3.0) for debian packaging
|
||||
- Code cleanup on the cli
|
||||
- Add tests for the cli
|
||||
- Vendorize cgitb as tracebackplus for verbose debug messages
|
||||
|
||||
20200625 v1.11.8
|
||||
- Add verbose debug option using -dd argument
|
||||
|
||||
20200622 v1.11.7
|
||||
- Fix iptables parser issue which would not output the last chain
|
||||
|
||||
20200614 v1.11.6
|
||||
- Improve and standardize empty data check for all parsers
|
||||
|
||||
20200612 v1.11.5
|
||||
- Update airport_s parser to fix error on parsing empty data
|
||||
- Update arp parser to fix error on parsing empty data
|
||||
- Update blkid parser to fix error on parsing empty data
|
||||
- Update crontab parser to fix error on parsing empty data
|
||||
- Update crontab_u parser to fix error on parsing empty data
|
||||
- Update df parser to fix error on parsing empty data
|
||||
- Update free parser to fix error on parsing empty data
|
||||
- Update lsblk parser to fix error on parsing empty data
|
||||
- Update lsmod parser to fix error on parsing empty data
|
||||
- Update mount parser to fix error on parsing empty data
|
||||
- Update netstat parser to fix error on parsing empty data
|
||||
- Update ntpq parser to fix error on parsing empty data
|
||||
- Update ps parser to fix error on parsing empty data
|
||||
- Update route parser to fix error on parsing empty data
|
||||
- Update systemctl parser to fix error on parsing empty data
|
||||
- Update systemctl_lj parser to fix error on parsing empty data
|
||||
- Update systemctl_ls parser to fix error on parsing empty data
|
||||
- Update systemctl_luf parser to fix error on parsing empty data
|
||||
- Update uptime parser to fix error on parsing empty data
|
||||
- Update w parser to fix error on parsing empty data
|
||||
- Update xml parser to fix error on parsing empty data
|
||||
- Add tests to all parsers for no data condition
|
||||
- Update ss parser to fix integer fields
|
||||
|
||||
20200610 v1.11.4
|
||||
- Update ls parser to fix error on parsing an empty directory
|
||||
|
||||
20200609 v1.11.3
|
||||
- Add local parser plugin feature (contributed by Dean Serenevy)
|
||||
|
||||
20200530 v1.11.2
|
||||
- Update netstat parser to add freebsd support
|
||||
- Update netstat parser to add route_flags_pretty field
|
||||
@@ -12,7 +59,7 @@ jc changelog
|
||||
- Update w parser to strip whitespace from what field
|
||||
- Update last parser to fix FreeBSD issues
|
||||
- Update stat parser to change osx_flags field name to unix_flags
|
||||
- Update stat parser to add osx_device field for freebsd and osx
|
||||
- Update stat parser to add unix_device field for freebsd and osx
|
||||
- Fix freebsd compatibility message for df, fstab, mount, ntpq, stat, and uname parsers
|
||||
- Fix compatibility message for platforms that include the version number at the end (e.g. freebsd12)
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
|
||||
pydocmd simple jc.parsers.shadow+ > ../docs/parsers/shadow.md
|
||||
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
|
||||
pydocmd simple jc.parsers.stat+ > ../docs/parsers/stat.md
|
||||
pydocmd simple jc.parsers.sysctl+ > ../docs/parsers/sysctl.md
|
||||
pydocmd simple jc.parsers.systemctl+ > ../docs/parsers/systemctl.md
|
||||
pydocmd simple jc.parsers.systemctl_lj+ > ../docs/parsers/systemctl_lj.md
|
||||
pydocmd simple jc.parsers.systemctl_ls+ > ../docs/parsers/systemctl_ls.md
|
||||
|
||||
@@ -177,7 +177,11 @@ Examples:
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "ens33",
|
||||
"kind": "route"
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP",
|
||||
"GATEWAY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
@@ -188,7 +192,10 @@ Examples:
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "docker0",
|
||||
"kind": "route"
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
@@ -199,7 +206,10 @@ Examples:
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "ens33",
|
||||
"kind": "route"
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -15,53 +15,48 @@ Examples:
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
"gateway": "_gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"flags": "UG",
|
||||
"metric": 100,
|
||||
"metric": 202,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "ens33",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.0.0",
|
||||
"flags": "U",
|
||||
"metric": 0,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "docker",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
"irtt": 0,
|
||||
"flags_pretty": [
|
||||
"UP",
|
||||
"GATEWAY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"flags": "U",
|
||||
"metric": 100,
|
||||
"metric": 202,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "ens33",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
"irtt": 0,
|
||||
"flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
$ route -ee | jc --route -p -r
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
"gateway": "_gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"flags": "UG",
|
||||
"metric": "100",
|
||||
"metric": "202",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "ens33",
|
||||
@@ -69,25 +64,12 @@ Examples:
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.0.0",
|
||||
"flags": "U",
|
||||
"metric": "0",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "docker",
|
||||
"mss": "0",
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"flags": "U",
|
||||
"metric": "100",
|
||||
"metric": "202",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "ens33",
|
||||
@@ -97,6 +79,7 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
|
||||
@@ -142,10 +142,10 @@ Returns:
|
||||
"modify_time": string, # - = null
|
||||
"change_time": string, # - = null
|
||||
"birth_time": string, # - = null
|
||||
"osx_device": integer,
|
||||
"unix_device": integer,
|
||||
"rdev": integer,
|
||||
"block_size": integer,
|
||||
"osx_flags": string
|
||||
"unix_flags": string
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
84
docs/parsers/sysctl.md
Normal file
84
docs/parsers/sysctl.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# jc.parsers.sysctl
|
||||
jc - JSON CLI output utility sysctl -a Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --sysctl as the first argument if the piped input is coming from sysctl -a
|
||||
|
||||
Note: since sysctl output is not easily parsable only a very simple key/value object
|
||||
will be output. An attempt is made to convert obvious integers and floats. If no
|
||||
conversion is desired, use the -r (raw) option.
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sysctl | jc --sysctl -p
|
||||
{
|
||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"user.bc_base_max": 99,
|
||||
"user.bc_dim_max": 2048,
|
||||
"user.bc_scale_max": 99,
|
||||
"user.bc_string_max": 1000,
|
||||
"user.coll_weights_max": 2,
|
||||
"user.expr_nest_max": 32
|
||||
...
|
||||
}
|
||||
|
||||
$ sysctl | jc --sysctl -p -r
|
||||
{
|
||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"user.bc_base_max": "99",
|
||||
"user.bc_dim_max": "2048",
|
||||
"user.bc_scale_max": "99",
|
||||
"user.bc_string_max": "1000",
|
||||
"user.coll_weights_max": "2",
|
||||
"user.expr_nest_max": "32",
|
||||
...
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
@@ -48,3 +48,18 @@ Returns:
|
||||
|
||||
no return, just prints output to STDERR
|
||||
|
||||
## has_data
|
||||
```python
|
||||
has_data(data)
|
||||
```
|
||||
|
||||
Checks if the input contains data. If there are any non-whitespace characters then return True, else return False
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) input to check whether it contains data
|
||||
|
||||
Returns:
|
||||
|
||||
Boolean True if input string (data) contains non-whitespace characters, otherwise False
|
||||
|
||||
|
||||
611
jc/appdirs.py
Normal file
611
jc/appdirs.py
Normal file
@@ -0,0 +1,611 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2005-2010 ActiveState Software Inc.
|
||||
# Copyright (c) 2013 Eddy Petrișor
|
||||
|
||||
'''
|
||||
# This is the MIT license
|
||||
|
||||
Copyright (c) 2010 ActiveState Software Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
'''
|
||||
|
||||
"""Utilities for determining application-specific dirs.
|
||||
|
||||
See <https://github.com/ActiveState/appdirs> for details and usage.
|
||||
"""
|
||||
# Dev Notes:
|
||||
# - MSDN on where to store app data files:
|
||||
# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
|
||||
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
|
||||
# - XDG spec for Un*x: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
|
||||
__version__ = "1.4.4"
|
||||
__version_info__ = tuple(int(segment) for segment in __version__.split("."))
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
unicode = str
|
||||
|
||||
if sys.platform.startswith('java'):
|
||||
import platform
|
||||
os_name = platform.java_ver()[3][0]
|
||||
if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc.
|
||||
system = 'win32'
|
||||
elif os_name.startswith('Mac'): # "Mac OS X", etc.
|
||||
system = 'darwin'
|
||||
else: # "Linux", "SunOS", "FreeBSD", etc.
|
||||
# Setting this to "linux2" is not ideal, but only Windows or Mac
|
||||
# are actually checked for and the rest of the module expects
|
||||
# *sys.platform* style strings.
|
||||
system = 'linux2'
|
||||
else:
|
||||
system = sys.platform
|
||||
|
||||
|
||||
|
||||
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
|
||||
r"""Return full path to the user-specific data dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"roaming" (boolean, default False) can be set True to use the Windows
|
||||
roaming appdata directory. That means that for users on a Windows
|
||||
network setup for roaming profiles, this user data will be
|
||||
sync'd on login. See
|
||||
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
|
||||
for a discussion of issues.
|
||||
|
||||
Typical user data directories are:
|
||||
Mac OS X: ~/Library/Application Support/<AppName>
|
||||
Unix: ~/.local/share/<AppName> # or in $XDG_DATA_HOME, if defined
|
||||
Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
|
||||
Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
|
||||
Win 7 (not roaming): C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
|
||||
Win 7 (roaming): C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
|
||||
|
||||
For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
|
||||
That means, by default "~/.local/share/<AppName>".
|
||||
"""
|
||||
if system == "win32":
|
||||
if appauthor is None:
|
||||
appauthor = appname
|
||||
const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
|
||||
path = os.path.normpath(_get_win_folder(const))
|
||||
if appname:
|
||||
if appauthor is not False:
|
||||
path = os.path.join(path, appauthor, appname)
|
||||
else:
|
||||
path = os.path.join(path, appname)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('~/Library/Application Support/')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share"))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
|
||||
r"""Return full path to the user-shared data dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"multipath" is an optional parameter only applicable to *nix
|
||||
which indicates that the entire list of data dirs should be
|
||||
returned. By default, the first item from XDG_DATA_DIRS is
|
||||
returned, or '/usr/local/share/<AppName>',
|
||||
if XDG_DATA_DIRS is not set
|
||||
|
||||
Typical site data directories are:
|
||||
Mac OS X: /Library/Application Support/<AppName>
|
||||
Unix: /usr/local/share/<AppName> or /usr/share/<AppName>
|
||||
Win XP: C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
|
||||
Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
|
||||
Win 7: C:\ProgramData\<AppAuthor>\<AppName> # Hidden, but writeable on Win 7.
|
||||
|
||||
For Unix, this is using the $XDG_DATA_DIRS[0] default.
|
||||
|
||||
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
|
||||
"""
|
||||
if system == "win32":
|
||||
if appauthor is None:
|
||||
appauthor = appname
|
||||
path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA"))
|
||||
if appname:
|
||||
if appauthor is not False:
|
||||
path = os.path.join(path, appauthor, appname)
|
||||
else:
|
||||
path = os.path.join(path, appname)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('/Library/Application Support')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
# XDG default for $XDG_DATA_DIRS
|
||||
# only first, if multipath is False
|
||||
path = os.getenv('XDG_DATA_DIRS',
|
||||
os.pathsep.join(['/usr/local/share', '/usr/share']))
|
||||
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
|
||||
if appname:
|
||||
if version:
|
||||
appname = os.path.join(appname, version)
|
||||
pathlist = [os.sep.join([x, appname]) for x in pathlist]
|
||||
|
||||
if multipath:
|
||||
path = os.pathsep.join(pathlist)
|
||||
else:
|
||||
path = pathlist[0]
|
||||
return path
|
||||
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
|
||||
r"""Return full path to the user-specific config dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"roaming" (boolean, default False) can be set True to use the Windows
|
||||
roaming appdata directory. That means that for users on a Windows
|
||||
network setup for roaming profiles, this user data will be
|
||||
sync'd on login. See
|
||||
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
|
||||
for a discussion of issues.
|
||||
|
||||
Typical user config directories are:
|
||||
Mac OS X: ~/Library/Preferences/<AppName>
|
||||
Unix: ~/.config/<AppName> # or in $XDG_CONFIG_HOME, if defined
|
||||
Win *: same as user_data_dir
|
||||
|
||||
For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
|
||||
That means, by default "~/.config/<AppName>".
|
||||
"""
|
||||
if system == "win32":
|
||||
path = user_data_dir(appname, appauthor, None, roaming)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('~/Library/Preferences/')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config"))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
|
||||
r"""Return full path to the user-shared data dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"multipath" is an optional parameter only applicable to *nix
|
||||
which indicates that the entire list of config dirs should be
|
||||
returned. By default, the first item from XDG_CONFIG_DIRS is
|
||||
returned, or '/etc/xdg/<AppName>', if XDG_CONFIG_DIRS is not set
|
||||
|
||||
Typical site config directories are:
|
||||
Mac OS X: same as site_data_dir
|
||||
Unix: /etc/xdg/<AppName> or $XDG_CONFIG_DIRS[i]/<AppName> for each value in
|
||||
$XDG_CONFIG_DIRS
|
||||
Win *: same as site_data_dir
|
||||
Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
|
||||
|
||||
For Unix, this is using the $XDG_CONFIG_DIRS[0] default, if multipath=False
|
||||
|
||||
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
|
||||
"""
|
||||
if system == 'win32':
|
||||
path = site_data_dir(appname, appauthor)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('/Library/Preferences')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
# XDG default for $XDG_CONFIG_DIRS
|
||||
# only first, if multipath is False
|
||||
path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
|
||||
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
|
||||
if appname:
|
||||
if version:
|
||||
appname = os.path.join(appname, version)
|
||||
pathlist = [os.sep.join([x, appname]) for x in pathlist]
|
||||
|
||||
if multipath:
|
||||
path = os.pathsep.join(pathlist)
|
||||
else:
|
||||
path = pathlist[0]
|
||||
return path
|
||||
|
||||
|
||||
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
|
||||
r"""Return full path to the user-specific cache dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"opinion" (boolean) can be False to disable the appending of
|
||||
"Cache" to the base app data dir for Windows. See
|
||||
discussion below.
|
||||
|
||||
Typical user cache directories are:
|
||||
Mac OS X: ~/Library/Caches/<AppName>
|
||||
Unix: ~/.cache/<AppName> (XDG default)
|
||||
Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache
|
||||
Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Cache
|
||||
|
||||
On Windows the only suggestion in the MSDN docs is that local settings go in
|
||||
the `CSIDL_LOCAL_APPDATA` directory. This is identical to the non-roaming
|
||||
app data dir (the default returned by `user_data_dir` above). Apps typically
|
||||
put cache data somewhere *under* the given dir here. Some examples:
|
||||
...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
|
||||
...\Acme\SuperApp\Cache\1.0
|
||||
OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
|
||||
This can be disabled with the `opinion=False` option.
|
||||
"""
|
||||
if system == "win32":
|
||||
if appauthor is None:
|
||||
appauthor = appname
|
||||
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
|
||||
if appname:
|
||||
if appauthor is not False:
|
||||
path = os.path.join(path, appauthor, appname)
|
||||
else:
|
||||
path = os.path.join(path, appname)
|
||||
if opinion:
|
||||
path = os.path.join(path, "Cache")
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('~/Library/Caches')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
path = os.getenv('XDG_CACHE_HOME', os.path.expanduser('~/.cache'))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def user_state_dir(appname=None, appauthor=None, version=None, roaming=False):
|
||||
r"""Return full path to the user-specific state dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"roaming" (boolean, default False) can be set True to use the Windows
|
||||
roaming appdata directory. That means that for users on a Windows
|
||||
network setup for roaming profiles, this user data will be
|
||||
sync'd on login. See
|
||||
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
|
||||
for a discussion of issues.
|
||||
|
||||
Typical user state directories are:
|
||||
Mac OS X: same as user_data_dir
|
||||
Unix: ~/.local/state/<AppName> # or in $XDG_STATE_HOME, if defined
|
||||
Win *: same as user_data_dir
|
||||
|
||||
For Unix, we follow this Debian proposal <https://wiki.debian.org/XDGBaseDirectorySpecification#state>
|
||||
to extend the XDG spec and support $XDG_STATE_HOME.
|
||||
|
||||
That means, by default "~/.local/state/<AppName>".
|
||||
"""
|
||||
if system in ["win32", "darwin"]:
|
||||
path = user_data_dir(appname, appauthor, None, roaming)
|
||||
else:
|
||||
path = os.getenv('XDG_STATE_HOME', os.path.expanduser("~/.local/state"))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
|
||||
r"""Return full path to the user-specific log dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"opinion" (boolean) can be False to disable the appending of
|
||||
"Logs" to the base app data dir for Windows, and "log" to the
|
||||
base cache dir for Unix. See discussion below.
|
||||
|
||||
Typical user log directories are:
|
||||
Mac OS X: ~/Library/Logs/<AppName>
|
||||
Unix: ~/.cache/<AppName>/log # or under $XDG_CACHE_HOME if defined
|
||||
Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Logs
|
||||
Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Logs
|
||||
|
||||
On Windows the only suggestion in the MSDN docs is that local settings
|
||||
go in the `CSIDL_LOCAL_APPDATA` directory. (Note: I'm interested in
|
||||
examples of what some windows apps use for a logs dir.)
|
||||
|
||||
OPINION: This function appends "Logs" to the `CSIDL_LOCAL_APPDATA`
|
||||
value for Windows and appends "log" to the user cache dir for Unix.
|
||||
This can be disabled with the `opinion=False` option.
|
||||
"""
|
||||
if system == "darwin":
|
||||
path = os.path.join(
|
||||
os.path.expanduser('~/Library/Logs'),
|
||||
appname)
|
||||
elif system == "win32":
|
||||
path = user_data_dir(appname, appauthor, version)
|
||||
version = False
|
||||
if opinion:
|
||||
path = os.path.join(path, "Logs")
|
||||
else:
|
||||
path = user_cache_dir(appname, appauthor, version)
|
||||
version = False
|
||||
if opinion:
|
||||
path = os.path.join(path, "log")
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
class AppDirs(object):
|
||||
"""Convenience wrapper for getting application dirs."""
|
||||
def __init__(self, appname=None, appauthor=None, version=None,
|
||||
roaming=False, multipath=False):
|
||||
self.appname = appname
|
||||
self.appauthor = appauthor
|
||||
self.version = version
|
||||
self.roaming = roaming
|
||||
self.multipath = multipath
|
||||
|
||||
@property
|
||||
def user_data_dir(self):
|
||||
return user_data_dir(self.appname, self.appauthor,
|
||||
version=self.version, roaming=self.roaming)
|
||||
|
||||
@property
|
||||
def site_data_dir(self):
|
||||
return site_data_dir(self.appname, self.appauthor,
|
||||
version=self.version, multipath=self.multipath)
|
||||
|
||||
@property
|
||||
def user_config_dir(self):
|
||||
return user_config_dir(self.appname, self.appauthor,
|
||||
version=self.version, roaming=self.roaming)
|
||||
|
||||
@property
|
||||
def site_config_dir(self):
|
||||
return site_config_dir(self.appname, self.appauthor,
|
||||
version=self.version, multipath=self.multipath)
|
||||
|
||||
@property
|
||||
def user_cache_dir(self):
|
||||
return user_cache_dir(self.appname, self.appauthor,
|
||||
version=self.version)
|
||||
|
||||
@property
|
||||
def user_state_dir(self):
|
||||
return user_state_dir(self.appname, self.appauthor,
|
||||
version=self.version)
|
||||
|
||||
@property
|
||||
def user_log_dir(self):
|
||||
return user_log_dir(self.appname, self.appauthor,
|
||||
version=self.version)
|
||||
|
||||
|
||||
#---- internal support stuff
|
||||
|
||||
def _get_win_folder_from_registry(csidl_name):
|
||||
"""This is a fallback technique at best. I'm not sure if using the
|
||||
registry for this guarantees us the correct answer for all CSIDL_*
|
||||
names.
|
||||
"""
|
||||
if PY3:
|
||||
import winreg as _winreg
|
||||
else:
|
||||
import _winreg
|
||||
|
||||
shell_folder_name = {
|
||||
"CSIDL_APPDATA": "AppData",
|
||||
"CSIDL_COMMON_APPDATA": "Common AppData",
|
||||
"CSIDL_LOCAL_APPDATA": "Local AppData",
|
||||
}[csidl_name]
|
||||
|
||||
key = _winreg.OpenKey(
|
||||
_winreg.HKEY_CURRENT_USER,
|
||||
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
|
||||
)
|
||||
dir, type = _winreg.QueryValueEx(key, shell_folder_name)
|
||||
return dir
|
||||
|
||||
|
||||
def _get_win_folder_with_ctypes(csidl_name):
|
||||
import ctypes
|
||||
|
||||
csidl_const = {
|
||||
"CSIDL_APPDATA": 26,
|
||||
"CSIDL_COMMON_APPDATA": 35,
|
||||
"CSIDL_LOCAL_APPDATA": 28,
|
||||
}[csidl_name]
|
||||
|
||||
buf = ctypes.create_unicode_buffer(1024)
|
||||
ctypes.windll.shell32.SHGetFolderPathW(None, csidl_const, None, 0, buf)
|
||||
|
||||
# Downgrade to short path name if have highbit chars. See
|
||||
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
|
||||
has_high_char = False
|
||||
for c in buf:
|
||||
if ord(c) > 255:
|
||||
has_high_char = True
|
||||
break
|
||||
if has_high_char:
|
||||
buf2 = ctypes.create_unicode_buffer(1024)
|
||||
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
|
||||
buf = buf2
|
||||
|
||||
return buf.value
|
||||
|
||||
def _get_win_folder_with_jna(csidl_name):
|
||||
import array
|
||||
from com.sun import jna
|
||||
from com.sun.jna.platform import win32
|
||||
|
||||
buf_size = win32.WinDef.MAX_PATH * 2
|
||||
buf = array.zeros('c', buf_size)
|
||||
shell = win32.Shell32.INSTANCE
|
||||
shell.SHGetFolderPath(None, getattr(win32.ShlObj, csidl_name), None, win32.ShlObj.SHGFP_TYPE_CURRENT, buf)
|
||||
dir = jna.Native.toString(buf.tostring()).rstrip("\0")
|
||||
|
||||
# Downgrade to short path name if have highbit chars. See
|
||||
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
|
||||
has_high_char = False
|
||||
for c in dir:
|
||||
if ord(c) > 255:
|
||||
has_high_char = True
|
||||
break
|
||||
if has_high_char:
|
||||
buf = array.zeros('c', buf_size)
|
||||
kernel = win32.Kernel32.INSTANCE
|
||||
if kernel.GetShortPathName(dir, buf, buf_size):
|
||||
dir = jna.Native.toString(buf.tostring()).rstrip("\0")
|
||||
|
||||
return dir
|
||||
|
||||
if system == "win32":
|
||||
try:
|
||||
from ctypes import windll
|
||||
except ImportError:
|
||||
try:
|
||||
import com.sun.jna
|
||||
except ImportError:
|
||||
_get_win_folder = _get_win_folder_from_registry
|
||||
else:
|
||||
_get_win_folder = _get_win_folder_with_jna
|
||||
else:
|
||||
_get_win_folder = _get_win_folder_with_ctypes
|
||||
|
||||
|
||||
#---- self test code
|
||||
|
||||
if __name__ == "__main__":
|
||||
appname = "MyApp"
|
||||
appauthor = "MyCompany"
|
||||
|
||||
props = ("user_data_dir",
|
||||
"user_config_dir",
|
||||
"user_cache_dir",
|
||||
"user_state_dir",
|
||||
"user_log_dir",
|
||||
"site_data_dir",
|
||||
"site_config_dir")
|
||||
|
||||
print("-- app dirs %s --" % __version__)
|
||||
|
||||
print("-- app dirs (with optional 'version')")
|
||||
dirs = AppDirs(appname, appauthor, version="1.0")
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
|
||||
print("\n-- app dirs (without optional 'version')")
|
||||
dirs = AppDirs(appname, appauthor)
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
|
||||
print("\n-- app dirs (without optional 'appauthor')")
|
||||
dirs = AppDirs(appname)
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
|
||||
print("\n-- app dirs (with disabled 'appauthor')")
|
||||
dirs = AppDirs(appname, appauthor=False)
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
199
jc/cli.py
199
jc/cli.py
@@ -1,24 +1,28 @@
|
||||
"""jc - JSON CLI output utility
|
||||
JC cli module
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import shlex
|
||||
import importlib
|
||||
import textwrap
|
||||
import signal
|
||||
import json
|
||||
import pygments
|
||||
from pygments import highlight
|
||||
from pygments.style import Style
|
||||
from pygments.token import (Name, Number, String, Keyword)
|
||||
from pygments.lexers import JsonLexer
|
||||
from pygments.formatters import Terminal256Formatter
|
||||
import jc.utils
|
||||
import jc.appdirs as appdirs
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.11.2'
|
||||
description = 'jc cli output JSON conversion tool'
|
||||
version = '1.12.0'
|
||||
description = 'JSON conversion tool for CLI output'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
@@ -66,6 +70,7 @@ parsers = [
|
||||
'shadow',
|
||||
'ss',
|
||||
'stat',
|
||||
'sysctl',
|
||||
'systemctl',
|
||||
'systemctl-lj',
|
||||
'systemctl-ls',
|
||||
@@ -79,9 +84,67 @@ parsers = [
|
||||
'yaml'
|
||||
]
|
||||
|
||||
# List of custom or override parsers.
|
||||
# Allow any <user_data_dir>/jc/jcparsers/*.py
|
||||
local_parsers = []
|
||||
data_dir = appdirs.user_data_dir('jc', 'jc')
|
||||
local_parsers_dir = os.path.join(data_dir, 'jcparsers')
|
||||
if os.path.isdir(local_parsers_dir):
|
||||
sys.path.append(data_dir)
|
||||
for name in os.listdir(local_parsers_dir):
|
||||
if re.match(r'\w+\.py', name) and os.path.isfile(os.path.join(local_parsers_dir, name)):
|
||||
plugin_name = name[0:-3]
|
||||
local_parsers.append(plugin_name)
|
||||
if plugin_name not in parsers:
|
||||
parsers.append(plugin_name)
|
||||
|
||||
def set_env_colors():
|
||||
|
||||
# We only support 2.3.0+, pygments changed color names in 2.4.0.
|
||||
# startswith is sufficient and avoids potential exceptions from split and int.
|
||||
if pygments.__version__.startswith('2.3.'):
|
||||
PYGMENT_COLOR = {
|
||||
'black': '#ansiblack',
|
||||
'red': '#ansidarkred',
|
||||
'green': '#ansidarkgreen',
|
||||
'yellow': '#ansibrown',
|
||||
'blue': '#ansidarkblue',
|
||||
'magenta': '#ansipurple',
|
||||
'cyan': '#ansiteal',
|
||||
'gray': '#ansilightgray',
|
||||
'brightblack': '#ansidarkgray',
|
||||
'brightred': '#ansired',
|
||||
'brightgreen': '#ansigreen',
|
||||
'brightyellow': '#ansiyellow',
|
||||
'brightblue': '#ansiblue',
|
||||
'brightmagenta': '#ansifuchsia',
|
||||
'brightcyan': '#ansiturquoise',
|
||||
'white': '#ansiwhite',
|
||||
}
|
||||
else:
|
||||
PYGMENT_COLOR = {
|
||||
'black': 'ansiblack',
|
||||
'red': 'ansired',
|
||||
'green': 'ansigreen',
|
||||
'yellow': 'ansiyellow',
|
||||
'blue': 'ansiblue',
|
||||
'magenta': 'ansimagenta',
|
||||
'cyan': 'ansicyan',
|
||||
'gray': 'ansigray',
|
||||
'brightblack': 'ansibrightblack',
|
||||
'brightred': 'ansibrightred',
|
||||
'brightgreen': 'ansibrightgreen',
|
||||
'brightyellow': 'ansibrightyellow',
|
||||
'brightblue': 'ansibrightblue',
|
||||
'brightmagenta': 'ansibrightmagenta',
|
||||
'brightcyan': 'ansibrightcyan',
|
||||
'white': 'ansiwhite',
|
||||
}
|
||||
|
||||
|
||||
def set_env_colors(env_colors=None):
|
||||
"""
|
||||
Return a dictionary to be used in Pygments custom style class.
|
||||
|
||||
Grab custom colors from JC_COLORS environment variable. JC_COLORS env variable takes 4 comma
|
||||
separated string values and should be in the format of:
|
||||
|
||||
@@ -97,40 +160,36 @@ def set_env_colors():
|
||||
JC_COLORS=default,default,default,default
|
||||
|
||||
"""
|
||||
env_colors = os.getenv('JC_COLORS')
|
||||
input_error = False
|
||||
|
||||
if env_colors:
|
||||
color_list = env_colors.split(',')
|
||||
else:
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
|
||||
if len(color_list) != 4:
|
||||
input_error = True
|
||||
|
||||
if env_colors and len(color_list) != 4:
|
||||
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
|
||||
input_error = True
|
||||
|
||||
if env_colors:
|
||||
for color in color_list:
|
||||
if color not in ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray', 'brightblack', 'brightred',
|
||||
'brightgreen', 'brightyellow', 'brightblue', 'brightmagenta', 'brightcyan', 'white', 'default']:
|
||||
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
|
||||
input_error = True
|
||||
for color in color_list:
|
||||
if color != 'default' and color not in PYGMENT_COLOR:
|
||||
input_error = True
|
||||
|
||||
# if there is an issue with the env variable, just set all colors to default and move on
|
||||
if input_error:
|
||||
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
|
||||
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
|
||||
return {
|
||||
Name.Tag: f'bold ansi{color_list[0]}' if not color_list[0] == 'default' else f'bold ansiblue', # key names
|
||||
Keyword: f'ansi{color_list[1]}' if not color_list[1] == 'default' else f'ansibrightblack', # true, false, null
|
||||
Number: f'ansi{color_list[2]}' if not color_list[2] == 'default' else f'ansimagenta', # numbers
|
||||
String: f'ansi{color_list[3]}' if not color_list[3] == 'default' else f'ansigreen' # strings
|
||||
Name.Tag: f'bold {PYGMENT_COLOR[color_list[0]]}' if not color_list[0] == 'default' else f"bold {PYGMENT_COLOR['blue']}", # key names
|
||||
Keyword: PYGMENT_COLOR[color_list[1]] if not color_list[1] == 'default' else PYGMENT_COLOR['brightblack'], # true, false, null
|
||||
Number: PYGMENT_COLOR[color_list[2]] if not color_list[2] == 'default' else PYGMENT_COLOR['magenta'], # numbers
|
||||
String: PYGMENT_COLOR[color_list[3]] if not color_list[3] == 'default' else PYGMENT_COLOR['green'] # strings
|
||||
}
|
||||
|
||||
|
||||
def piped_output():
|
||||
"""returns False if stdout is a TTY. True if output is being piped to another program"""
|
||||
"""Return False if stdout is a TTY. True if output is being piped to another program"""
|
||||
if sys.stdout.isatty():
|
||||
return False
|
||||
else:
|
||||
@@ -138,33 +197,34 @@ def piped_output():
|
||||
|
||||
|
||||
def ctrlc(signum, frame):
|
||||
"""exit with error on SIGINT"""
|
||||
"""Exit with error on SIGINT"""
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parser_shortname(parser_argument):
|
||||
"""short name of the parser with dashes and no -- prefix"""
|
||||
"""Return short name of the parser with dashes and no -- prefix"""
|
||||
return parser_argument[2:]
|
||||
|
||||
|
||||
def parser_argument(parser):
|
||||
"""short name of the parser with dashes and with -- prefix"""
|
||||
"""Return short name of the parser with dashes and with -- prefix"""
|
||||
return f'--{parser}'
|
||||
|
||||
|
||||
def parser_mod_shortname(parser):
|
||||
"""short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
|
||||
"""Return short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
|
||||
return parser.replace('--', '').replace('-', '_')
|
||||
|
||||
|
||||
def parser_module(parser):
|
||||
"""import the module just in time and return the module object"""
|
||||
importlib.import_module('jc.parsers.' + parser_mod_shortname(parser))
|
||||
return getattr(jc.parsers, parser_mod_shortname(parser))
|
||||
"""Import the module just in time and return the module object"""
|
||||
shortname = parser_mod_shortname(parser)
|
||||
path = ('jcparsers.' if shortname in local_parsers else 'jc.parsers.')
|
||||
return importlib.import_module(path + shortname)
|
||||
|
||||
|
||||
def parsers_text(indent=0, pad=0):
|
||||
"""return the argument and description information from each parser"""
|
||||
"""Return the argument and description information from each parser"""
|
||||
ptext = ''
|
||||
for parser in parsers:
|
||||
parser_arg = parser_argument(parser)
|
||||
@@ -182,7 +242,7 @@ def parsers_text(indent=0, pad=0):
|
||||
|
||||
|
||||
def about_jc():
|
||||
"""return jc info and the contents of each parser.info as a dictionary"""
|
||||
"""Return jc info and the contents of each parser.info as a dictionary"""
|
||||
parser_list = []
|
||||
|
||||
for parser in parsers:
|
||||
@@ -212,7 +272,7 @@ def about_jc():
|
||||
|
||||
|
||||
def helptext(message):
|
||||
"""return the help text with the list of parsers"""
|
||||
"""Return the help text with the list of parsers"""
|
||||
parsers_string = parsers_text(indent=12, pad=17)
|
||||
|
||||
helptext_string = f'''
|
||||
@@ -228,7 +288,7 @@ def helptext(message):
|
||||
{parsers_string}
|
||||
Options:
|
||||
-a about jc
|
||||
-d debug - show trace messages
|
||||
-d debug - show traceback (-dd for verbose traceback)
|
||||
-m monochrome output
|
||||
-p pretty print output
|
||||
-q quiet - suppress warnings
|
||||
@@ -241,30 +301,30 @@ def helptext(message):
|
||||
|
||||
jc -p ls -al
|
||||
'''
|
||||
print(textwrap.dedent(helptext_string), file=sys.stderr)
|
||||
|
||||
|
||||
def json_out(data, pretty=False, mono=False, piped_out=False):
|
||||
# set colors
|
||||
class JcStyle(Style):
|
||||
styles = set_env_colors()
|
||||
return textwrap.dedent(helptext_string)
|
||||
|
||||
|
||||
def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False):
|
||||
"""Return a JSON formatted string. String may include color codes or be pretty printed."""
|
||||
if not mono and not piped_out:
|
||||
# set colors
|
||||
class JcStyle(Style):
|
||||
styles = set_env_colors(env_colors)
|
||||
|
||||
if pretty:
|
||||
print(highlight(json.dumps(data, indent=2), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
return str(highlight(json.dumps(data, indent=2), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
else:
|
||||
print(highlight(json.dumps(data), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
return str(highlight(json.dumps(data), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
else:
|
||||
if pretty:
|
||||
print(json.dumps(data, indent=2))
|
||||
return json.dumps(data, indent=2)
|
||||
else:
|
||||
print(json.dumps(data))
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
def generate_magic_command(args):
|
||||
"""
|
||||
Returns a tuple with a boolean and a command, where the boolean signifies that
|
||||
Return a tuple with a boolean and a command, where the boolean signifies that
|
||||
the command is valid, and the command is either a command string or None.
|
||||
"""
|
||||
|
||||
@@ -297,7 +357,7 @@ def generate_magic_command(args):
|
||||
magic_dict = {}
|
||||
parser_info = about_jc()['parsers']
|
||||
|
||||
# Create a dictionary of magic_commands to their respective parsers.
|
||||
# create a dictionary of magic_commands to their respective parsers.
|
||||
for entry in parser_info:
|
||||
# Update the dict with all of the magic commands for this parser, if they exist.
|
||||
magic_dict.update({mc: entry['argument'] for mc in entry.get('magic_commands', [])})
|
||||
@@ -306,7 +366,7 @@ def generate_magic_command(args):
|
||||
one_word_command = args_given[0]
|
||||
two_word_command = ' '.join(args_given[0:2])
|
||||
|
||||
# Try to get a parser for two_word_command, otherwise get one for one_word_command
|
||||
# try to get a parser for two_word_command, otherwise get one for one_word_command
|
||||
found_parser = magic_dict.get(two_word_command, magic_dict.get(one_word_command))
|
||||
|
||||
# construct a new command line using the standard syntax: COMMAND | jc --PARSER -OPTIONS
|
||||
@@ -319,6 +379,7 @@ def generate_magic_command(args):
|
||||
|
||||
|
||||
def magic():
|
||||
"""Runs the command generated by generate_magic_command() to support magic syntax"""
|
||||
valid_command, run_command = generate_magic_command(sys.argv)
|
||||
if valid_command:
|
||||
os.system(run_command)
|
||||
@@ -326,7 +387,7 @@ def magic():
|
||||
elif run_command is None:
|
||||
return
|
||||
else:
|
||||
helptext(f'parser not found for "{run_command}"')
|
||||
print(helptext(f'parser not found for "{run_command}"'), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -340,6 +401,8 @@ def main():
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
jc_colors = os.getenv('JC_COLORS')
|
||||
|
||||
# try magic syntax first: e.g. jc -p ls -al
|
||||
magic()
|
||||
|
||||
@@ -351,54 +414,54 @@ def main():
|
||||
options.extend(opt[1:])
|
||||
|
||||
debug = 'd' in options
|
||||
verbose_debug = True if options.count('d') > 1 else False
|
||||
mono = 'm' in options
|
||||
pretty = 'p' in options
|
||||
quiet = 'q' in options
|
||||
raw = 'r' in options
|
||||
|
||||
if verbose_debug:
|
||||
import jc.tracebackplus
|
||||
jc.tracebackplus.enable(context=11)
|
||||
|
||||
if 'a' in options:
|
||||
json_out(about_jc(), pretty=pretty, mono=mono, piped_out=piped_output())
|
||||
print(json_out(about_jc(), pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
|
||||
sys.exit(0)
|
||||
|
||||
if sys.stdin.isatty():
|
||||
helptext('missing piped data')
|
||||
print(helptext('missing piped data'), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
data = sys.stdin.read()
|
||||
|
||||
found = False
|
||||
|
||||
if debug:
|
||||
for arg in sys.argv:
|
||||
parser_name = parser_shortname(arg)
|
||||
for arg in sys.argv:
|
||||
parser_name = parser_shortname(arg)
|
||||
|
||||
if parser_name in parsers:
|
||||
# load parser module just in time so we don't need to load all modules
|
||||
parser = parser_module(arg)
|
||||
if parser_name in parsers:
|
||||
# load parser module just in time so we don't need to load all modules
|
||||
parser = parser_module(arg)
|
||||
try:
|
||||
result = parser.parse(data, raw=raw, quiet=quiet)
|
||||
found = True
|
||||
break
|
||||
else:
|
||||
for arg in sys.argv:
|
||||
parser_name = parser_shortname(arg)
|
||||
|
||||
if parser_name in parsers:
|
||||
# load parser module just in time so we don't need to load all modules
|
||||
parser = parser_module(arg)
|
||||
try:
|
||||
result = parser.parse(data, raw=raw, quiet=quiet)
|
||||
found = True
|
||||
break
|
||||
except Exception:
|
||||
except Exception:
|
||||
if debug:
|
||||
raise
|
||||
else:
|
||||
import jc.utils
|
||||
jc.utils.error_message(
|
||||
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
|
||||
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n'
|
||||
' For details use the -d or -dd option.')
|
||||
sys.exit(1)
|
||||
|
||||
if not found:
|
||||
helptext('missing or incorrect arguments')
|
||||
print(helptext('missing or incorrect arguments'), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
json_out(result, pretty=pretty, mono=mono, piped_out=piped_output())
|
||||
print(json_out(result, pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -55,7 +55,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'airport -I command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -131,9 +131,11 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = {}
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
raw_output[linedata[0].strip().lower().replace(' ', '_').replace('.', '_')] = linedata[1].strip()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
raw_output[linedata[0].strip().lower().replace(' ', '_').replace('.', '_')] = linedata[1].strip()
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -88,7 +88,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = 'airport -s command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -170,15 +170,17 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
# fix headers
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
cleandata[0] = cleandata[0].replace('security (auth/unicast/group)', 'security')
|
||||
if jc.utils.has_data(data):
|
||||
# fix headers
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
cleandata[0] = cleandata[0].replace('security (auth/unicast/group)', 'security')
|
||||
|
||||
# parse the data
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
# parse the data
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -99,7 +99,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.4'
|
||||
version = '1.6'
|
||||
description = 'arp command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -171,69 +171,65 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
# remove final Entries row if -v was used
|
||||
if cleandata[-1].startswith('Entries:'):
|
||||
cleandata.pop(-1)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# detect if freebsd/osx style was used
|
||||
if cleandata[0][-1] == ']':
|
||||
raw_output = []
|
||||
for line in cleandata:
|
||||
splitline = line.split()
|
||||
output_line = {
|
||||
'name': splitline[0],
|
||||
'address': splitline[1].lstrip('(').rstrip(')'),
|
||||
'hwtype': splitline[-1].lstrip('[').rstrip(']'),
|
||||
'hwaddress': splitline[3],
|
||||
'iface': splitline[5]
|
||||
}
|
||||
# remove final Entries row if -v was used
|
||||
if cleandata[-1].startswith('Entries:'):
|
||||
cleandata.pop(-1)
|
||||
|
||||
if 'permanent' in splitline:
|
||||
output_line['permanent'] = True
|
||||
# detect if freebsd/osx style was used
|
||||
if cleandata[0][-1] == ']':
|
||||
for line in cleandata:
|
||||
splitline = line.split()
|
||||
output_line = {
|
||||
'name': splitline[0],
|
||||
'address': splitline[1].lstrip('(').rstrip(')'),
|
||||
'hwtype': splitline[-1].lstrip('[').rstrip(']'),
|
||||
'hwaddress': splitline[3],
|
||||
'iface': splitline[5]
|
||||
}
|
||||
|
||||
if 'permanent' in splitline:
|
||||
output_line['permanent'] = True
|
||||
else:
|
||||
output_line['permanent'] = False
|
||||
|
||||
if 'expires' in splitline:
|
||||
output_line['expires'] = splitline[-3]
|
||||
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
output_line['permanent'] = False
|
||||
return process(raw_output)
|
||||
|
||||
if 'expires' in splitline:
|
||||
output_line['expires'] = splitline[-3]
|
||||
# detect if linux style was used
|
||||
elif cleandata[0].startswith('Address'):
|
||||
|
||||
raw_output.append(output_line)
|
||||
# fix header row to change Flags Mask to flags_mask
|
||||
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
# otherwise, try bsd style
|
||||
else:
|
||||
return process(raw_output)
|
||||
for line in cleandata:
|
||||
line = line.split()
|
||||
output_line = {
|
||||
'name': line[0],
|
||||
'address': line[1].lstrip('(').rstrip(')'),
|
||||
'hwtype': line[4].lstrip('[').rstrip(']'),
|
||||
'hwaddress': line[3],
|
||||
'iface': line[6],
|
||||
}
|
||||
raw_output.append(output_line)
|
||||
|
||||
# detect if linux style was used
|
||||
elif cleandata[0].startswith('Address'):
|
||||
|
||||
# fix header row to change Flags Mask to flags_mask
|
||||
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
|
||||
# otherwise, try bsd style
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
raw_output = []
|
||||
for line in cleandata:
|
||||
line = line.split()
|
||||
output_line = {
|
||||
'name': line[0],
|
||||
'address': line[1].lstrip('(').rstrip(')'),
|
||||
'hwtype': line[4].lstrip('[').rstrip(']'),
|
||||
'hwaddress': line[3],
|
||||
'iface': line[6],
|
||||
}
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return process(raw_output)
|
||||
|
||||
@@ -79,7 +79,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = 'blkid command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -176,7 +176,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
if data:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# if the first field is a device, use normal parsing:
|
||||
if data.split(maxsplit=1)[0][-1] == ':':
|
||||
linedata = data.splitlines()
|
||||
|
||||
@@ -132,7 +132,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.4'
|
||||
description = 'crontab command and file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -225,44 +225,46 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('#'):
|
||||
cleandata.pop(i)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# Pop any variable assignment lines
|
||||
cron_var = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if '=' in line:
|
||||
var_line = cleandata.pop(i)
|
||||
var_name = var_line.split('=', maxsplit=1)[0].strip()
|
||||
var_value = var_line.split('=', maxsplit=1)[1].strip()
|
||||
cron_var.append({'name': var_name,
|
||||
'value': var_value})
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('#'):
|
||||
cleandata.pop(i)
|
||||
|
||||
raw_output['variables'] = cron_var
|
||||
# Pop any variable assignment lines
|
||||
cron_var = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if '=' in line:
|
||||
var_line = cleandata.pop(i)
|
||||
var_name = var_line.split('=', maxsplit=1)[0].strip()
|
||||
var_value = var_line.split('=', maxsplit=1)[1].strip()
|
||||
cron_var.append({'name': var_name,
|
||||
'value': var_value})
|
||||
|
||||
# Pop any shortcut lines
|
||||
shortcut_list = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('@'):
|
||||
shortcut_line = cleandata.pop(i)
|
||||
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
|
||||
cmd = shortcut_line.split(maxsplit=1)[1].strip()
|
||||
shortcut_list.append({'occurrence': occurrence,
|
||||
'command': cmd})
|
||||
raw_output['variables'] = cron_var
|
||||
|
||||
# Add header row for parsing
|
||||
cleandata[:0] = ['minute hour day_of_month month day_of_week command']
|
||||
# Pop any shortcut lines
|
||||
shortcut_list = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('@'):
|
||||
shortcut_line = cleandata.pop(i)
|
||||
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
|
||||
cmd = shortcut_line.split(maxsplit=1)[1].strip()
|
||||
shortcut_list.append({'occurrence': occurrence,
|
||||
'command': cmd})
|
||||
|
||||
if len(cleandata) > 1:
|
||||
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
# Add header row for parsing
|
||||
cleandata[:0] = ['minute hour day_of_month month day_of_week command']
|
||||
|
||||
raw_output['schedule'] = cron_list
|
||||
if len(cleandata) > 1:
|
||||
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
# Add shortcut entries back in
|
||||
for item in shortcut_list:
|
||||
raw_output['schedule'].append(item)
|
||||
raw_output['schedule'] = cron_list
|
||||
|
||||
# Add shortcut entries back in
|
||||
for item in shortcut_list:
|
||||
raw_output['schedule'].append(item)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -133,7 +133,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'crontab file parser with user support'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -226,46 +226,48 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('#'):
|
||||
cleandata.pop(i)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# Pop any variable assignment lines
|
||||
cron_var = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if '=' in line:
|
||||
var_line = cleandata.pop(i)
|
||||
var_name = var_line.split('=', maxsplit=1)[0].strip()
|
||||
var_value = var_line.split('=', maxsplit=1)[1].strip()
|
||||
cron_var.append({'name': var_name,
|
||||
'value': var_value})
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('#'):
|
||||
cleandata.pop(i)
|
||||
|
||||
raw_output['variables'] = cron_var
|
||||
# Pop any variable assignment lines
|
||||
cron_var = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if '=' in line:
|
||||
var_line = cleandata.pop(i)
|
||||
var_name = var_line.split('=', maxsplit=1)[0].strip()
|
||||
var_value = var_line.split('=', maxsplit=1)[1].strip()
|
||||
cron_var.append({'name': var_name,
|
||||
'value': var_value})
|
||||
|
||||
# Pop any shortcut lines
|
||||
shortcut_list = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('@'):
|
||||
shortcut_line = cleandata.pop(i)
|
||||
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
|
||||
usr = shortcut_line.split(maxsplit=2)[1].strip()
|
||||
cmd = shortcut_line.split(maxsplit=2)[2].strip()
|
||||
shortcut_list.append({'occurrence': occurrence,
|
||||
'user': usr,
|
||||
'command': cmd})
|
||||
raw_output['variables'] = cron_var
|
||||
|
||||
# Add header row for parsing
|
||||
cleandata[:0] = ['minute hour day_of_month month day_of_week user command']
|
||||
# Pop any shortcut lines
|
||||
shortcut_list = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('@'):
|
||||
shortcut_line = cleandata.pop(i)
|
||||
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
|
||||
usr = shortcut_line.split(maxsplit=2)[1].strip()
|
||||
cmd = shortcut_line.split(maxsplit=2)[2].strip()
|
||||
shortcut_list.append({'occurrence': occurrence,
|
||||
'user': usr,
|
||||
'command': cmd})
|
||||
|
||||
if len(cleandata) > 1:
|
||||
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
# Add header row for parsing
|
||||
cleandata[:0] = ['minute hour day_of_month month day_of_week user command']
|
||||
|
||||
raw_output['schedule'] = cron_list
|
||||
if len(cleandata) > 1:
|
||||
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
# Add shortcut entries back in
|
||||
for item in shortcut_list:
|
||||
raw_output['schedule'].append(item)
|
||||
raw_output['schedule'] = cron_list
|
||||
|
||||
# Add shortcut entries back in
|
||||
for item in shortcut_list:
|
||||
raw_output['schedule'].append(item)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -63,7 +63,7 @@ import csv
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'CSV file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -123,7 +123,8 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
dialect = None
|
||||
try:
|
||||
dialect = csv.Sniffer().sniff(data[:1024])
|
||||
|
||||
@@ -73,7 +73,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
version = '1.5'
|
||||
description = 'df command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -184,14 +184,17 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
||||
# fix headers
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
cleandata[0] = cleandata[0].replace('mounted on', 'mounted_on')
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# parse the data
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
# fix headers
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
cleandata[0] = cleandata[0].replace('mounted on', 'mounted_on')
|
||||
|
||||
# parse the data
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -324,7 +324,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
description = 'dig command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -574,100 +574,103 @@ def parse(data, raw=False, quiet=False):
|
||||
axfr = False
|
||||
|
||||
output_entry = {}
|
||||
for line in cleandata:
|
||||
|
||||
if line.startswith('; <<>> ') and ' axfr ' in line.lower():
|
||||
question = False
|
||||
authority = False
|
||||
answer = False
|
||||
axfr = True
|
||||
axfr_list = []
|
||||
continue
|
||||
if jc.utils.has_data(data):
|
||||
for line in cleandata:
|
||||
|
||||
if ';' not in line and axfr:
|
||||
axfr_list.append(parse_axfr(line))
|
||||
output_entry.update({'axfr': axfr_list})
|
||||
continue
|
||||
if line.startswith('; <<>> ') and ' axfr ' in line.lower():
|
||||
question = False
|
||||
authority = False
|
||||
answer = False
|
||||
axfr = True
|
||||
axfr_list = []
|
||||
continue
|
||||
|
||||
if line.startswith(';; ->>HEADER<<-'):
|
||||
output_entry = {}
|
||||
output_entry.update(parse_header(line))
|
||||
continue
|
||||
if ';' not in line and axfr:
|
||||
axfr_list.append(parse_axfr(line))
|
||||
output_entry.update({'axfr': axfr_list})
|
||||
continue
|
||||
|
||||
if line.startswith(';; flags:'):
|
||||
output_entry.update(parse_flags_line(line))
|
||||
continue
|
||||
if line.startswith(';; ->>HEADER<<-'):
|
||||
output_entry = {}
|
||||
output_entry.update(parse_header(line))
|
||||
continue
|
||||
|
||||
if line.startswith(';; QUESTION SECTION:'):
|
||||
question = True
|
||||
authority = False
|
||||
answer = False
|
||||
axfr = False
|
||||
continue
|
||||
if line.startswith(';; flags:'):
|
||||
output_entry.update(parse_flags_line(line))
|
||||
continue
|
||||
|
||||
if question:
|
||||
output_entry['question'] = parse_question(line)
|
||||
question = False
|
||||
authority = False
|
||||
answer = False
|
||||
axfr = False
|
||||
continue
|
||||
if line.startswith(';; QUESTION SECTION:'):
|
||||
question = True
|
||||
authority = False
|
||||
answer = False
|
||||
axfr = False
|
||||
continue
|
||||
|
||||
if line.startswith(';; AUTHORITY SECTION:'):
|
||||
question = False
|
||||
authority = True
|
||||
answer = False
|
||||
axfr = False
|
||||
authority_list = []
|
||||
continue
|
||||
if question:
|
||||
output_entry['question'] = parse_question(line)
|
||||
question = False
|
||||
authority = False
|
||||
answer = False
|
||||
axfr = False
|
||||
continue
|
||||
|
||||
if ';' not in line and authority:
|
||||
authority_list.append(parse_authority(line))
|
||||
output_entry.update({'authority': authority_list})
|
||||
continue
|
||||
if line.startswith(';; AUTHORITY SECTION:'):
|
||||
question = False
|
||||
authority = True
|
||||
answer = False
|
||||
axfr = False
|
||||
authority_list = []
|
||||
continue
|
||||
|
||||
if line.startswith(';; ANSWER SECTION:'):
|
||||
question = False
|
||||
authority = False
|
||||
answer = True
|
||||
axfr = False
|
||||
answer_list = []
|
||||
continue
|
||||
if ';' not in line and authority:
|
||||
authority_list.append(parse_authority(line))
|
||||
output_entry.update({'authority': authority_list})
|
||||
continue
|
||||
|
||||
if ';' not in line and answer:
|
||||
answer_list.append(parse_answer(line))
|
||||
output_entry.update({'answer': answer_list})
|
||||
continue
|
||||
if line.startswith(';; ANSWER SECTION:'):
|
||||
question = False
|
||||
authority = False
|
||||
answer = True
|
||||
axfr = False
|
||||
answer_list = []
|
||||
continue
|
||||
|
||||
# footer consists of 4 lines
|
||||
# footer line 1
|
||||
if line.startswith(';; Query time:'):
|
||||
output_entry.update({'query_time': line.split(':')[1].lstrip()})
|
||||
continue
|
||||
if ';' not in line and answer:
|
||||
answer_list.append(parse_answer(line))
|
||||
output_entry.update({'answer': answer_list})
|
||||
continue
|
||||
|
||||
# footer line 2
|
||||
if line.startswith(';; SERVER:'):
|
||||
output_entry.update({'server': line.split(':')[1].lstrip()})
|
||||
continue
|
||||
# footer consists of 4 lines
|
||||
# footer line 1
|
||||
if line.startswith(';; Query time:'):
|
||||
output_entry.update({'query_time': line.split(':')[1].lstrip()})
|
||||
continue
|
||||
|
||||
# footer line 3
|
||||
if line.startswith(';; WHEN:'):
|
||||
output_entry.update({'when': line.split(':', maxsplit=1)[1].lstrip()})
|
||||
continue
|
||||
# footer line 2
|
||||
if line.startswith(';; SERVER:'):
|
||||
output_entry.update({'server': line.split(':')[1].lstrip()})
|
||||
continue
|
||||
|
||||
# footer line 4 (last line)
|
||||
if line.startswith(';; MSG SIZE rcvd:'):
|
||||
output_entry.update({'rcvd': line.split(':')[1].lstrip()})
|
||||
# footer line 3
|
||||
if line.startswith(';; WHEN:'):
|
||||
output_entry.update({'when': line.split(':', maxsplit=1)[1].lstrip()})
|
||||
continue
|
||||
|
||||
if output_entry:
|
||||
raw_output.append(output_entry)
|
||||
elif line.startswith(';; XFR size:'):
|
||||
output_entry.update({'size': line.split(':')[1].lstrip()})
|
||||
# footer line 4 (last line)
|
||||
if line.startswith(';; MSG SIZE rcvd:'):
|
||||
output_entry.update({'rcvd': line.split(':')[1].lstrip()})
|
||||
|
||||
if output_entry:
|
||||
raw_output.append(output_entry)
|
||||
if output_entry:
|
||||
raw_output.append(output_entry)
|
||||
elif line.startswith(';; XFR size:'):
|
||||
output_entry.update({'size': line.split(':')[1].lstrip()})
|
||||
|
||||
if output_entry:
|
||||
raw_output.append(output_entry)
|
||||
|
||||
raw_output = list(filter(None, raw_output))
|
||||
|
||||
raw_output = list(filter(None, raw_output))
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
|
||||
@@ -102,7 +102,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'dmidecode command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -190,148 +190,150 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
data = data.splitlines()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# remove header rows
|
||||
for row in data.copy():
|
||||
if row:
|
||||
data.pop(0)
|
||||
else:
|
||||
break
|
||||
data = data.splitlines()
|
||||
|
||||
# main parsing loop
|
||||
for line in data:
|
||||
# new item
|
||||
if not line:
|
||||
item_header = True
|
||||
item_values = False
|
||||
value_list = False
|
||||
# remove header rows
|
||||
for row in data.copy():
|
||||
if row:
|
||||
data.pop(0)
|
||||
else:
|
||||
break
|
||||
|
||||
# main parsing loop
|
||||
for line in data:
|
||||
# new item
|
||||
if not line:
|
||||
item_header = True
|
||||
item_values = False
|
||||
value_list = False
|
||||
|
||||
if item:
|
||||
if values:
|
||||
item['values'][attribute] = values
|
||||
if key_data:
|
||||
item['values'][f'{key}_data'] = key_data
|
||||
raw_output.append(item)
|
||||
|
||||
item = {}
|
||||
header = None
|
||||
key = None
|
||||
val = None
|
||||
attribute = None
|
||||
values = []
|
||||
key_data = []
|
||||
continue
|
||||
|
||||
# header
|
||||
if line.startswith('Handle ') and line.endswith('bytes'):
|
||||
|
||||
# Handle 0x0000, DMI type 0, 24 bytes
|
||||
header = line.replace(',', ' ').split()
|
||||
item = {
|
||||
'handle': header[1],
|
||||
'type': header[4],
|
||||
'bytes': header[5]
|
||||
}
|
||||
continue
|
||||
|
||||
# description
|
||||
if item_header:
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = False
|
||||
|
||||
item['description'] = line
|
||||
item['values'] = {}
|
||||
continue
|
||||
|
||||
# new item if multiple descriptions in handle
|
||||
if not item_header and not line.startswith('\t'):
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = False
|
||||
|
||||
if item:
|
||||
if values:
|
||||
item['values'][attribute] = values
|
||||
if key_data:
|
||||
item['values'][f'{key}_data'] = key_data
|
||||
raw_output.append(item)
|
||||
|
||||
item = {
|
||||
'handle': header[1],
|
||||
'type': header[4],
|
||||
'bytes': header[5],
|
||||
'description': line,
|
||||
'values': {}
|
||||
}
|
||||
|
||||
key = None
|
||||
val = None
|
||||
attribute = None
|
||||
values = []
|
||||
key_data = []
|
||||
continue
|
||||
|
||||
# keys and values
|
||||
if item_values \
|
||||
and len(line.split(':', maxsplit=1)) == 2 \
|
||||
and line.startswith('\t') \
|
||||
and not line.startswith('\t\t') \
|
||||
and not line.strip().endswith(':'):
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = False
|
||||
|
||||
if item:
|
||||
if values:
|
||||
item['values'][attribute] = values
|
||||
values = []
|
||||
if key_data:
|
||||
item['values'][f'{key}_data'] = key_data
|
||||
raw_output.append(item)
|
||||
key_data = []
|
||||
|
||||
item = {}
|
||||
header = None
|
||||
key = None
|
||||
val = None
|
||||
attribute = None
|
||||
values = []
|
||||
key_data = []
|
||||
continue
|
||||
key = line.split(':', maxsplit=1)[0].strip().lower().replace(' ', '_')
|
||||
val = line.split(':', maxsplit=1)[1].strip()
|
||||
item['values'].update({key: val})
|
||||
continue
|
||||
|
||||
# header
|
||||
if line.startswith('Handle ') and line.endswith('bytes'):
|
||||
# multi-line key
|
||||
if item_values \
|
||||
and line.startswith('\t') \
|
||||
and not line.startswith('\t\t') \
|
||||
and line.strip().endswith(':'):
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = True
|
||||
|
||||
# Handle 0x0000, DMI type 0, 24 bytes
|
||||
header = line.replace(',', ' ').split()
|
||||
item = {
|
||||
'handle': header[1],
|
||||
'type': header[4],
|
||||
'bytes': header[5]
|
||||
}
|
||||
continue
|
||||
|
||||
# description
|
||||
if item_header:
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = False
|
||||
|
||||
item['description'] = line
|
||||
item['values'] = {}
|
||||
continue
|
||||
|
||||
# new item if multiple descriptions in handle
|
||||
if not item_header and not line.startswith('\t'):
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = False
|
||||
|
||||
if item:
|
||||
if values:
|
||||
item['values'][attribute] = values
|
||||
values = []
|
||||
if key_data:
|
||||
item['values'][f'{key}_data'] = key_data
|
||||
raw_output.append(item)
|
||||
key_data = []
|
||||
|
||||
item = {
|
||||
'handle': header[1],
|
||||
'type': header[4],
|
||||
'bytes': header[5],
|
||||
'description': line,
|
||||
'values': {}
|
||||
}
|
||||
|
||||
key = None
|
||||
val = None
|
||||
attribute = None
|
||||
values = []
|
||||
key_data = []
|
||||
continue
|
||||
|
||||
# keys and values
|
||||
if item_values \
|
||||
and len(line.split(':', maxsplit=1)) == 2 \
|
||||
and line.startswith('\t') \
|
||||
and not line.startswith('\t\t') \
|
||||
and not line.strip().endswith(':'):
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = False
|
||||
|
||||
if values:
|
||||
item['values'][attribute] = values
|
||||
attribute = line[:-1].strip().lower().replace(' ', '_')
|
||||
values = []
|
||||
if key_data:
|
||||
item['values'][f'{key}_data'] = key_data
|
||||
key_data = []
|
||||
continue
|
||||
|
||||
key = line.split(':', maxsplit=1)[0].strip().lower().replace(' ', '_')
|
||||
val = line.split(':', maxsplit=1)[1].strip()
|
||||
item['values'].update({key: val})
|
||||
continue
|
||||
# multi-line values
|
||||
if value_list \
|
||||
and line.startswith('\t\t'):
|
||||
values.append(line.strip())
|
||||
continue
|
||||
|
||||
# multi-line key
|
||||
if item_values \
|
||||
and line.startswith('\t') \
|
||||
and not line.startswith('\t\t') \
|
||||
and line.strip().endswith(':'):
|
||||
item_header = False
|
||||
item_values = True
|
||||
value_list = True
|
||||
# data for hybrid multi-line objects
|
||||
if item_values \
|
||||
and not value_list \
|
||||
and line.startswith('\t\t'):
|
||||
if f'{key}_data' not in item['values']:
|
||||
item['values'][f'{key}_data'] = []
|
||||
key_data.append(line.strip())
|
||||
continue
|
||||
|
||||
if values:
|
||||
item['values'][attribute] = values
|
||||
values = []
|
||||
if key_data:
|
||||
item['values'][f'{key}_data'] = key_data
|
||||
key_data = []
|
||||
|
||||
attribute = line[:-1].strip().lower().replace(' ', '_')
|
||||
values = []
|
||||
continue
|
||||
|
||||
# multi-line values
|
||||
if value_list \
|
||||
and line.startswith('\t\t'):
|
||||
values.append(line.strip())
|
||||
continue
|
||||
|
||||
# data for hybrid multi-line objects
|
||||
if item_values \
|
||||
and not value_list \
|
||||
and line.startswith('\t\t'):
|
||||
if f'{key}_data' not in item['values']:
|
||||
item['values'][f'{key}_data'] = []
|
||||
key_data.append(line.strip())
|
||||
continue
|
||||
|
||||
if item:
|
||||
raw_output.append(item)
|
||||
if item:
|
||||
raw_output.append(item)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -73,7 +73,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'du command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -137,12 +137,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
cleandata.insert(0, 'size name')
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'env command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -116,12 +116,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = {}
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for entry in cleandata:
|
||||
parsed_line = entry.split('=', maxsplit=1)
|
||||
|
||||
@@ -48,7 +48,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'file command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -104,23 +104,26 @@ def parse(data, raw=False, quiet=False):
|
||||
raw_output = []
|
||||
|
||||
warned = False
|
||||
for line in filter(None, data.splitlines()):
|
||||
linedata = line.rsplit(': ', maxsplit=1)
|
||||
|
||||
try:
|
||||
filename = linedata[0].strip()
|
||||
filetype = linedata[1].strip()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
raw_output.append(
|
||||
{
|
||||
'filename': filename,
|
||||
'type': filetype
|
||||
}
|
||||
)
|
||||
except IndexError:
|
||||
if not warned:
|
||||
jc.utils.warning_message('Filenames with newline characters detected. Some filenames may be truncated.')
|
||||
warned = True
|
||||
for line in filter(None, data.splitlines()):
|
||||
linedata = line.rsplit(': ', maxsplit=1)
|
||||
|
||||
try:
|
||||
filename = linedata[0].strip()
|
||||
filetype = linedata[1].strip()
|
||||
|
||||
raw_output.append(
|
||||
{
|
||||
'filename': filename,
|
||||
'type': filetype
|
||||
}
|
||||
)
|
||||
except IndexError:
|
||||
if not warned:
|
||||
jc.utils.warning_message('Filenames with newline characters detected. Some filenames may be truncated.')
|
||||
warned = True
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -78,9 +78,11 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
# parse the content
|
||||
pass
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
# parse the content
|
||||
pass
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -53,7 +53,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = 'free command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -122,14 +122,18 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('buff/cache', 'buff_cache')
|
||||
cleandata[0] = 'type ' + cleandata[0]
|
||||
raw_output = []
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for entry in raw_output:
|
||||
entry['type'] = entry['type'].rstrip(':')
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('buff/cache', 'buff_cache')
|
||||
cleandata[0] = 'type ' + cleandata[0]
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
for entry in raw_output:
|
||||
entry['type'] = entry['type'].rstrip(':')
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -70,7 +70,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
description = 'fstab file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -141,7 +141,8 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for line in cleandata:
|
||||
output_line = {}
|
||||
# ignore commented lines
|
||||
|
||||
@@ -94,7 +94,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = '/etc/group file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -169,7 +169,8 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for entry in cleandata:
|
||||
if entry.startswith('#'):
|
||||
continue
|
||||
|
||||
@@ -60,7 +60,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = '/etc/gshadow file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -131,7 +131,8 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for entry in cleandata:
|
||||
if entry.startswith('#'):
|
||||
continue
|
||||
|
||||
@@ -44,7 +44,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
description = 'history command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -108,17 +108,19 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = {}
|
||||
|
||||
# split lines and clear out any non-ascii chars
|
||||
linedata = data.encode('ascii', errors='ignore').decode().splitlines()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# Skip any blank lines
|
||||
for entry in filter(None, linedata):
|
||||
try:
|
||||
parsed_line = entry.split(maxsplit=1)
|
||||
raw_output[parsed_line[0]] = parsed_line[1]
|
||||
except IndexError:
|
||||
# need to catch indexerror in case there is weird input from prior commands
|
||||
pass
|
||||
# split lines and clear out any non-ascii chars
|
||||
linedata = data.encode('ascii', errors='ignore').decode().splitlines()
|
||||
|
||||
# Skip any blank lines
|
||||
for entry in filter(None, linedata):
|
||||
try:
|
||||
parsed_line = entry.split(maxsplit=1)
|
||||
raw_output[parsed_line[0]] = parsed_line[1]
|
||||
except IndexError:
|
||||
# need to catch indexerror in case there is weird input from prior commands
|
||||
pass
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -61,7 +61,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = '/etc/hosts file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -117,12 +117,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for line in cleandata:
|
||||
output_line = {}
|
||||
# ignore commented lines
|
||||
|
||||
@@ -70,7 +70,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'id command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -166,12 +166,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
cleandata = data.split()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.split()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for section in cleandata:
|
||||
if section.startswith('uid'):
|
||||
uid_parsed = section.replace('(', '=').replace(')', '=')
|
||||
|
||||
@@ -147,7 +147,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.7'
|
||||
version = '1.8'
|
||||
description = 'ifconfig command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -475,14 +475,16 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
parsed = IfconfigParser(console_output=data)
|
||||
interfaces = parsed.get_interfaces()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# convert ifconfigparser output to a dictionary
|
||||
for iface in interfaces:
|
||||
d = interfaces[iface]._asdict()
|
||||
dct = dict(d)
|
||||
raw_output.append(dct)
|
||||
parsed = IfconfigParser(console_output=data)
|
||||
interfaces = parsed.get_interfaces()
|
||||
|
||||
# convert ifconfigparser output to a dictionary
|
||||
for iface in interfaces:
|
||||
d = interfaces[iface]._asdict()
|
||||
dct = dict(d)
|
||||
raw_output.append(dct)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -47,7 +47,7 @@ import configparser
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'INI file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -101,7 +101,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = {}
|
||||
|
||||
if data:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
ini = configparser.ConfigParser()
|
||||
ini.read_string(data)
|
||||
raw_output = {s: dict(ini.items(s)) for s in ini.sections()}
|
||||
|
||||
@@ -134,7 +134,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.4'
|
||||
description = 'iptables command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -194,19 +194,19 @@ def process(proc_data):
|
||||
if 'bytes' in rule:
|
||||
multiplier = 1
|
||||
if rule['bytes'][-1] == 'K':
|
||||
multiplier = 1000
|
||||
multiplier = 10 ** 3
|
||||
rule['bytes'] = rule['bytes'].rstrip('K')
|
||||
elif rule['bytes'][-1] == 'M':
|
||||
multiplier = 1000000
|
||||
multiplier = 10 ** 6
|
||||
rule['bytes'] = rule['bytes'].rstrip('M')
|
||||
elif rule['bytes'][-1] == 'G':
|
||||
multiplier = 1000000000
|
||||
multiplier = 10 ** 9
|
||||
rule['bytes'] = rule['bytes'].rstrip('G')
|
||||
elif rule['bytes'][-1] == 'T':
|
||||
multiplier = 1000000000000
|
||||
multiplier = 10 ** 12
|
||||
rule['bytes'] = rule['bytes'].rstrip('T')
|
||||
elif rule['bytes'][-1] == 'P':
|
||||
multiplier = 1000000000000000
|
||||
multiplier = 10 ** 15
|
||||
rule['bytes'] = rule['bytes'].rstrip('P')
|
||||
|
||||
try:
|
||||
@@ -243,36 +243,39 @@ def parse(data, raw=False, quiet=False):
|
||||
chain = {}
|
||||
headers = []
|
||||
|
||||
cleandata = data.splitlines()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for line in cleandata:
|
||||
for line in list(filter(None, data.splitlines())):
|
||||
|
||||
if line.startswith('Chain'):
|
||||
if line.startswith('Chain'):
|
||||
if chain:
|
||||
raw_output.append(chain)
|
||||
|
||||
chain = {}
|
||||
headers = []
|
||||
|
||||
parsed_line = line.split()
|
||||
|
||||
chain['chain'] = parsed_line[1]
|
||||
chain['rules'] = []
|
||||
|
||||
continue
|
||||
|
||||
elif line.startswith('target') or line.find('pkts') == 1 or line.startswith('num'):
|
||||
headers = []
|
||||
headers = [h for h in ' '.join(line.lower().strip().split()).split() if h]
|
||||
headers.append("options")
|
||||
|
||||
continue
|
||||
|
||||
else:
|
||||
rule = line.split(maxsplit=len(headers) - 1)
|
||||
temp_rule = dict(zip(headers, rule))
|
||||
if temp_rule:
|
||||
chain['rules'].append(temp_rule)
|
||||
|
||||
if chain:
|
||||
raw_output.append(chain)
|
||||
chain = {}
|
||||
headers = []
|
||||
|
||||
parsed_line = line.split()
|
||||
|
||||
chain['chain'] = parsed_line[1]
|
||||
chain['rules'] = []
|
||||
|
||||
continue
|
||||
|
||||
elif line.startswith('target') or line.find('pkts') == 1 or line.startswith('num'):
|
||||
headers = []
|
||||
headers = [h for h in ' '.join(line.lower().strip().split()).split() if h]
|
||||
headers.append("options")
|
||||
|
||||
continue
|
||||
|
||||
else:
|
||||
rule = line.split(maxsplit=len(headers) - 1)
|
||||
temp_rule = dict(zip(headers, rule))
|
||||
if temp_rule:
|
||||
chain['rules'].append(temp_rule)
|
||||
|
||||
raw_output = list(filter(None, raw_output))
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -77,7 +77,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'jobs command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -144,12 +144,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for entry in cleandata:
|
||||
output_line = {}
|
||||
|
||||
@@ -72,7 +72,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
description = 'last and lastb command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -149,12 +149,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for entry in cleandata:
|
||||
output_line = {}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.4'
|
||||
version = '1.6'
|
||||
description = 'ls command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -226,20 +226,20 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Delete first line if it starts with 'total 1234'
|
||||
if linedata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# Delete first line if it starts with 'total 1234'
|
||||
if re.match(r'total [0-9]+', linedata[0]):
|
||||
linedata.pop(0)
|
||||
|
||||
# Look for parent line if glob or -R is used
|
||||
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]) \
|
||||
and linedata[0].endswith(':'):
|
||||
parent = linedata.pop(0)[:-1]
|
||||
# Pop following total line if it exists
|
||||
if re.match(r'total [0-9]+', linedata[0]):
|
||||
linedata.pop(0)
|
||||
# Look for parent line if glob or -R is used
|
||||
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]) \
|
||||
and linedata[0].endswith(':'):
|
||||
parent = linedata.pop(0)[:-1]
|
||||
# Pop following total line if it exists
|
||||
if re.match(r'total [0-9]+', linedata[0]):
|
||||
linedata.pop(0)
|
||||
|
||||
if linedata:
|
||||
# Check if -l was used to parse extra data
|
||||
if re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]):
|
||||
for entry in linedata:
|
||||
|
||||
@@ -216,7 +216,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
version = '1.5'
|
||||
description = 'lsblk command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -327,20 +327,23 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = data.splitlines()
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace(':', '_')
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in raw_output:
|
||||
entry['name'] = entry['name'].encode('ascii', errors='ignore').decode()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace(':', '_')
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in raw_output:
|
||||
entry['name'] = entry['name'].encode('ascii', errors='ignore').decode()
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -107,7 +107,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'lsmod command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -175,13 +175,17 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
raw_output = []
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for mod in raw_output:
|
||||
if 'by' in mod:
|
||||
mod['by'] = mod['by'].split(',')
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
for mod in raw_output:
|
||||
if 'by' in mod:
|
||||
mod['by'] = mod['by'].split(',')
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -97,7 +97,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'lsof command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -169,12 +169,11 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('/', '_')
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
version = '1.5'
|
||||
description = 'mount command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -158,12 +158,12 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
# check for OSX output
|
||||
if ' type ' not in cleandata[0]:
|
||||
raw_output = osx_parse(cleandata)
|
||||
|
||||
@@ -176,7 +176,11 @@ Examples:
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "ens33",
|
||||
"kind": "route"
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP",
|
||||
"GATEWAY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
@@ -187,7 +191,10 @@ Examples:
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "docker0",
|
||||
"kind": "route"
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
@@ -198,7 +205,10 @@ Examples:
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "ens33",
|
||||
"kind": "route"
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -237,7 +247,7 @@ Examples:
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.6'
|
||||
version = '1.8'
|
||||
description = 'netstat command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -421,29 +431,30 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
# check for FreeBSD/OSX vs Linux
|
||||
# is this from FreeBSD/OSX?
|
||||
if cleandata[0] == 'Active Internet connections' \
|
||||
or cleandata[0] == 'Active Internet connections (including servers)' \
|
||||
or cleandata[0] == 'Active Multipath Internet connections' \
|
||||
or cleandata[0] == 'Active LOCAL (UNIX) domain sockets' \
|
||||
or cleandata[0] == 'Registered kernel control modules' \
|
||||
or cleandata[0] == 'Active kernel event sockets' \
|
||||
or cleandata[0] == 'Active kernel control sockets' \
|
||||
or cleandata[0] == 'Routing tables' \
|
||||
or cleandata[0].startswith('Name '):
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
import jc.parsers.netstat_freebsd_osx
|
||||
raw_output = jc.parsers.netstat_freebsd_osx.parse(cleandata)
|
||||
# check for FreeBSD/OSX vs Linux
|
||||
# is this from FreeBSD/OSX?
|
||||
if cleandata[0] == 'Active Internet connections' \
|
||||
or cleandata[0] == 'Active Internet connections (including servers)' \
|
||||
or cleandata[0] == 'Active Multipath Internet connections' \
|
||||
or cleandata[0] == 'Active LOCAL (UNIX) domain sockets' \
|
||||
or cleandata[0] == 'Registered kernel control modules' \
|
||||
or cleandata[0] == 'Active kernel event sockets' \
|
||||
or cleandata[0] == 'Active kernel control sockets' \
|
||||
or cleandata[0] == 'Routing tables' \
|
||||
or cleandata[0].startswith('Name '):
|
||||
|
||||
# use linux parser
|
||||
else:
|
||||
import jc.parsers.netstat_linux
|
||||
raw_output = jc.parsers.netstat_linux.parse(cleandata)
|
||||
import jc.parsers.netstat_freebsd_osx
|
||||
raw_output = jc.parsers.netstat_freebsd_osx.parse(cleandata)
|
||||
|
||||
# use linux parser
|
||||
else:
|
||||
import jc.parsers.netstat_linux
|
||||
raw_output = jc.parsers.netstat_linux.parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -183,7 +183,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'ntpq -p command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -268,28 +268,30 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = 's ' + cleandata[0]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# delete header delimiter
|
||||
del cleandata[1]
|
||||
cleandata[0] = 's ' + cleandata[0]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
# separate first character with a space for easier parsing
|
||||
for i, line in list(enumerate(cleandata[1:])):
|
||||
if line[0] == ' ':
|
||||
# fixup for no-state
|
||||
cleandata[i + 1] = '~ ' + line[1:]
|
||||
else:
|
||||
# fixup - realign columns since we added the 's' column
|
||||
cleandata[i + 1] = line[:1] + ' ' + line[1:]
|
||||
# delete header delimiter
|
||||
del cleandata[1]
|
||||
|
||||
# fixup for occaisional ip/hostname fields with a space
|
||||
cleandata[i + 1] = cleandata[i + 1].replace(' (', '_(')
|
||||
# separate first character with a space for easier parsing
|
||||
for i, line in list(enumerate(cleandata[1:])):
|
||||
if line[0] == ' ':
|
||||
# fixup for no-state
|
||||
cleandata[i + 1] = '~ ' + line[1:]
|
||||
else:
|
||||
# fixup - realign columns since we added the 's' column
|
||||
cleandata[i + 1] = line[:1] + ' ' + line[1:]
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
# fixup for occaisional ip/hostname fields with a space
|
||||
cleandata[i + 1] = cleandata[i + 1].replace(' (', '_(')
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -78,7 +78,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = '/etc/passwd file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -146,12 +146,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for entry in cleandata:
|
||||
if entry.startswith('#'):
|
||||
continue
|
||||
|
||||
@@ -32,7 +32,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'pip list command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -88,28 +88,28 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = []
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
# detect legacy output type
|
||||
if ' (' in cleandata[0]:
|
||||
for row in cleandata:
|
||||
raw_output.append({'package': row.split(' (')[0],
|
||||
'version': row.split(' (')[1].rstrip(')')})
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# otherwise normal table output
|
||||
else:
|
||||
# clear separator line
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if '---' in line:
|
||||
cleandata.pop(i)
|
||||
# detect legacy output type
|
||||
if ' (' in cleandata[0]:
|
||||
for row in cleandata:
|
||||
raw_output.append({'package': row.split(' (')[0],
|
||||
'version': row.split(' (')[1].rstrip(')')})
|
||||
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
# otherwise normal table output
|
||||
else:
|
||||
# clear separator line
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if '---' in line:
|
||||
cleandata.pop(i)
|
||||
|
||||
if cleandata:
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
if cleandata:
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -42,7 +42,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'pip show command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -107,12 +107,11 @@ def parse(data, raw=False, quiet=False):
|
||||
raw_output = []
|
||||
package = {}
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for row in cleandata:
|
||||
if row.startswith('---'):
|
||||
raw_output.append(package)
|
||||
|
||||
@@ -177,7 +177,7 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'ps command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -282,9 +282,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
raw_output = []
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -14,53 +14,48 @@ Examples:
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
"gateway": "_gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"flags": "UG",
|
||||
"metric": 100,
|
||||
"metric": 202,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "ens33",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.0.0",
|
||||
"flags": "U",
|
||||
"metric": 0,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "docker",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
"irtt": 0,
|
||||
"flags_pretty": [
|
||||
"UP",
|
||||
"GATEWAY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"flags": "U",
|
||||
"metric": 100,
|
||||
"metric": 202,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "ens33",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
"irtt": 0,
|
||||
"flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
$ route -ee | jc --route -p -r
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
"gateway": "_gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"flags": "UG",
|
||||
"metric": "100",
|
||||
"metric": "202",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "ens33",
|
||||
@@ -68,25 +63,12 @@ Examples:
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.0.0",
|
||||
"flags": "U",
|
||||
"metric": "0",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "docker",
|
||||
"mss": "0",
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"flags": "U",
|
||||
"metric": "100",
|
||||
"metric": "202",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "ens33",
|
||||
@@ -95,13 +77,14 @@ Examples:
|
||||
"irtt": "0"
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'route command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -199,9 +182,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
raw_output = []
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -84,7 +84,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = '/etc/shadow file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -153,12 +153,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for entry in cleandata:
|
||||
if entry.startswith('#'):
|
||||
continue
|
||||
|
||||
@@ -251,7 +251,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = 'ss command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -308,17 +308,17 @@ def process(proc_data):
|
||||
except (ValueError):
|
||||
entry[key] = None
|
||||
|
||||
if 'local_port' in entry:
|
||||
if 'local_port' in entry:
|
||||
try:
|
||||
entry['local_port_num'] = int(entry['local_port'])
|
||||
except (ValueError):
|
||||
pass
|
||||
|
||||
if 'peer_port' in entry:
|
||||
try:
|
||||
entry['peer_port_num'] = int(entry['peer_port'])
|
||||
except (ValueError):
|
||||
pass
|
||||
if 'peer_port' in entry:
|
||||
try:
|
||||
entry['peer_port_num'] = int(entry['peer_port'])
|
||||
except (ValueError):
|
||||
pass
|
||||
|
||||
return proc_data
|
||||
|
||||
@@ -342,12 +342,12 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6']
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
header_text = cleandata[0].lower()
|
||||
header_text = header_text.replace('netidstate', 'netid state')
|
||||
header_text = header_text.replace('local address:port', 'local_address local_port')
|
||||
|
||||
@@ -105,7 +105,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.4'
|
||||
version = '1.5'
|
||||
description = 'stat command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -197,12 +197,11 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# linux output
|
||||
if cleandata[0].startswith(' File: '):
|
||||
|
||||
154
jc/parsers/sysctl.py
Normal file
154
jc/parsers/sysctl.py
Normal file
@@ -0,0 +1,154 @@
|
||||
"""jc - JSON CLI output utility sysctl -a Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --sysctl as the first argument if the piped input is coming from sysctl -a
|
||||
|
||||
Note: since sysctl output is not easily parsable only a very simple key/value object
|
||||
will be output. An attempt is made to convert obvious integers and floats. If no
|
||||
conversion is desired, use the -r (raw) option.
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sysctl | jc --sysctl -p
|
||||
{
|
||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"user.bc_base_max": 99,
|
||||
"user.bc_dim_max": 2048,
|
||||
"user.bc_scale_max": 99,
|
||||
"user.bc_string_max": 1000,
|
||||
"user.coll_weights_max": 2,
|
||||
"user.expr_nest_max": 32
|
||||
...
|
||||
}
|
||||
|
||||
$ sysctl | jc --sysctl -p -r
|
||||
{
|
||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"user.bc_base_max": "99",
|
||||
"user.bc_dim_max": "2048",
|
||||
"user.bc_scale_max": "99",
|
||||
"user.bc_string_max": "1000",
|
||||
"user.coll_weights_max": "2",
|
||||
"user.expr_nest_max": "32",
|
||||
...
|
||||
}
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'sysctl command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
# details = 'enter any other details here'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'freebsd']
|
||||
magic_commands = ['sysctl']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
"""
|
||||
for key in proc_data:
|
||||
try:
|
||||
proc_data[key] = int(proc_data[key])
|
||||
except (ValueError):
|
||||
try:
|
||||
proc_data[key] = float(proc_data[key])
|
||||
except (ValueError):
|
||||
pass
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
data = data.splitlines()
|
||||
|
||||
# linux uses = and bsd uses :
|
||||
if ' = ' in data[0]:
|
||||
delim = ' = '
|
||||
else:
|
||||
delim = ': '
|
||||
|
||||
for line in data:
|
||||
linedata = line.split(delim, maxsplit=1)
|
||||
|
||||
# bsd adds values to newlines, which need to be fixed up with this try/except block
|
||||
try:
|
||||
key = linedata[0]
|
||||
value = linedata[1]
|
||||
|
||||
# syctl -a repeats some keys on linux. Append values from repeating keys
|
||||
# to the previous key value
|
||||
if key in raw_output:
|
||||
existing_value = raw_output[key]
|
||||
raw_output[key] = existing_value + '\n' + value
|
||||
continue
|
||||
|
||||
# fix for weird multiline output in bsd
|
||||
# if the key looks strange (has spaces or no dots) then it's probably a value field
|
||||
# on a separate line. in this case, just append it to the previous key in the dictionary.
|
||||
if '.' not in key or ' ' in key:
|
||||
previous_key = [*raw_output.keys()][-1]
|
||||
raw_output[previous_key] = raw_output[previous_key] + '\n' + line
|
||||
continue
|
||||
|
||||
# if the key looks normal then just add to the dictionary as normal
|
||||
else:
|
||||
raw_output[key] = value
|
||||
continue
|
||||
|
||||
# if there is an IndexError exception, then there was no delimiter in the line.
|
||||
# In this case just append the data line as a value to the previous key.
|
||||
except IndexError:
|
||||
prior_key = [*raw_output.keys()][-1]
|
||||
raw_output[prior_key] = raw_output[prior_key] + '\n' + line
|
||||
continue
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
@@ -40,7 +40,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'systemctl command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -96,27 +96,30 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
linedata = list(filter(None, linedata))
|
||||
# clean up non-ascii characters, if any
|
||||
cleandata = []
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0]
|
||||
header_list = header_text.lower().split()
|
||||
|
||||
linedata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'LOAD = ' in entry:
|
||||
break
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
else:
|
||||
entry_list = entry.rstrip().split(maxsplit=4)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
# clean up non-ascii characters, if any
|
||||
cleandata = []
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0]
|
||||
header_list = header_text.lower().split()
|
||||
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'LOAD = ' in entry:
|
||||
break
|
||||
|
||||
else:
|
||||
entry_list = entry.rstrip().split(maxsplit=4)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -59,7 +59,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'systemctl list-jobs command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -122,28 +122,32 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
linedata = list(filter(None, linedata))
|
||||
# clean up non-ascii characters, if any
|
||||
cleandata = []
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0]
|
||||
header_text = header_text.lower()
|
||||
header_list = header_text.split()
|
||||
|
||||
linedata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'No jobs running.' in entry or 'jobs listed.' in entry:
|
||||
break
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
else:
|
||||
entry_list = entry.split(maxsplit=4)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
cleandata = []
|
||||
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0]
|
||||
header_text = header_text.lower()
|
||||
header_list = header_text.split()
|
||||
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'No jobs running.' in entry or 'jobs listed.' in entry:
|
||||
break
|
||||
|
||||
else:
|
||||
entry_list = entry.split(maxsplit=4)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -34,7 +34,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'systemctl list-sockets command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -88,27 +88,30 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
linedata = list(filter(None, linedata))
|
||||
# clean up non-ascii characters, if any
|
||||
cleandata = []
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0].lower()
|
||||
header_list = header_text.split()
|
||||
|
||||
linedata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'sockets listed.' in entry:
|
||||
break
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
else:
|
||||
entry_list = entry.rsplit(maxsplit=2)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
cleandata = []
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0].lower()
|
||||
header_list = header_text.split()
|
||||
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'sockets listed.' in entry:
|
||||
break
|
||||
|
||||
else:
|
||||
entry_list = entry.rsplit(maxsplit=2)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -31,7 +31,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'systemctl list-unit-files command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -84,28 +84,31 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
linedata = list(filter(None, linedata))
|
||||
# clean up non-ascii characters, if any
|
||||
cleandata = []
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0]
|
||||
header_text = header_text.lower().replace('unit file', 'unit_file')
|
||||
header_list = header_text.split()
|
||||
|
||||
linedata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'unit files listed.' in entry:
|
||||
break
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
else:
|
||||
entry_list = entry.split(maxsplit=4)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
cleandata = []
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in linedata:
|
||||
cleandata.append(entry.encode('ascii', errors='ignore').decode())
|
||||
|
||||
header_text = cleandata[0]
|
||||
header_text = header_text.lower().replace('unit file', 'unit_file')
|
||||
header_list = header_text.split()
|
||||
|
||||
raw_output = []
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
if 'unit files listed.' in entry:
|
||||
break
|
||||
|
||||
else:
|
||||
entry_list = entry.split(maxsplit=4)
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -38,7 +38,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'timedatectl status command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -109,12 +109,14 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = {}
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
raw_output[linedata[0].strip().lower().replace(' ', '_')] = linedata[1].strip()
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if linedata[0].strip() == 'DST active':
|
||||
break
|
||||
for line in filter(None, data.splitlines()):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
raw_output[linedata[0].strip().lower().replace(' ', '_')] = linedata[1].strip()
|
||||
|
||||
if linedata[0].strip() == 'DST active':
|
||||
break
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -30,7 +30,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
description = 'uname -a command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -88,9 +88,9 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
split_line = data.split()
|
||||
|
||||
if len(split_line) > 1:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# check for OSX output
|
||||
if data.startswith('Darwin'):
|
||||
parsed_line = data.split()
|
||||
|
||||
@@ -34,7 +34,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = 'uptime command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -107,10 +107,10 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
cleandata = data.splitlines()
|
||||
|
||||
if cleandata:
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
parsed_line = cleandata[0].split()
|
||||
|
||||
# allow space for odd times
|
||||
|
||||
@@ -83,7 +83,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'w command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -149,36 +149,40 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
header_text = cleandata[0].lower()
|
||||
# fixup for 'from' column that can be blank
|
||||
from_col = header_text.find('from')
|
||||
# clean up 'login@' header
|
||||
# even though @ in a key is valid json, it can make things difficult
|
||||
header_text = header_text.replace('login@', 'login_at')
|
||||
headers = [h for h in ' '.join(header_text.strip().split()).split() if h]
|
||||
|
||||
# parse lines
|
||||
raw_output = []
|
||||
if cleandata:
|
||||
for entry in cleandata[1:]:
|
||||
output_line = {}
|
||||
|
||||
# normalize data by inserting Null for missing data
|
||||
temp_line = entry.split(maxsplit=len(headers) - 1)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# fix from column, always at column 2
|
||||
if 'from' in headers:
|
||||
if entry[from_col] in string.whitespace:
|
||||
temp_line.insert(2, '-')
|
||||
header_text = cleandata[0].lower()
|
||||
# fixup for 'from' column that can be blank
|
||||
from_col = header_text.find('from')
|
||||
# clean up 'login@' header
|
||||
# even though @ in a key is valid json, it can make things difficult
|
||||
header_text = header_text.replace('login@', 'login_at')
|
||||
headers = [h for h in ' '.join(header_text.strip().split()).split() if h]
|
||||
|
||||
output_line = dict(zip(headers, temp_line))
|
||||
raw_output.append(output_line)
|
||||
# parse lines
|
||||
raw_output = []
|
||||
if cleandata:
|
||||
for entry in cleandata[1:]:
|
||||
output_line = {}
|
||||
|
||||
# strip whitespace from beginning and end of all string values
|
||||
for row in raw_output:
|
||||
for item in row:
|
||||
if isinstance(row[item], str):
|
||||
row[item] = row[item].strip()
|
||||
# normalize data by inserting Null for missing data
|
||||
temp_line = entry.split(maxsplit=len(headers) - 1)
|
||||
|
||||
# fix from column, always at column 2
|
||||
if 'from' in headers:
|
||||
if entry[from_col] in string.whitespace:
|
||||
temp_line.insert(2, '-')
|
||||
|
||||
output_line = dict(zip(headers, temp_line))
|
||||
raw_output.append(output_line)
|
||||
|
||||
# strip whitespace from beginning and end of all string values
|
||||
for row in raw_output:
|
||||
for item in row:
|
||||
if isinstance(row[item], str):
|
||||
row[item] = row[item].strip()
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
@@ -103,7 +103,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'who command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -174,12 +174,12 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if cleandata:
|
||||
for line in cleandata:
|
||||
output_line = {}
|
||||
linedata = line.split()
|
||||
|
||||
@@ -59,7 +59,7 @@ import xmltodict
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = 'XML file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -111,7 +111,10 @@ def parse(data, raw=False, quiet=False):
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
if data:
|
||||
raw_output = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
raw_output = xmltodict.parse(data)
|
||||
|
||||
if raw:
|
||||
|
||||
@@ -71,7 +71,7 @@ from ruamel.yaml import YAML
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'YAML file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -126,10 +126,13 @@ def parse(data, raw=False, quiet=False):
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
yaml = YAML(typ='safe')
|
||||
|
||||
for document in yaml.load_all(data):
|
||||
raw_output.append(document)
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
yaml = YAML(typ='safe')
|
||||
|
||||
for document in yaml.load_all(data):
|
||||
raw_output.append(document)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
247
jc/tracebackplus.py
Normal file
247
jc/tracebackplus.py
Normal file
@@ -0,0 +1,247 @@
|
||||
"""More comprehensive traceback formatting for Python scripts.
|
||||
To enable this module, do:
|
||||
import tracebackplus; tracebackplus.enable()
|
||||
at the top of your script. The optional arguments to enable() are:
|
||||
logdir - if set, tracebacks are written to files in this directory
|
||||
context - number of lines of source code to show for each stack frame
|
||||
By default, tracebacks are displayed but not saved and the context is 5 lines.
|
||||
Alternatively, if you have caught an exception and want tracebackplus to display it
|
||||
for you, call tracebackplus.handler(). The optional argument to handler() is a
|
||||
3-item tuple (etype, evalue, etb) just like the value of sys.exc_info().
|
||||
"""
|
||||
|
||||
'''
|
||||
tracebackplus was derived from the cgitb standard library module. As cgitb is being
|
||||
deprecated, this simplified version of cgitb was created.
|
||||
|
||||
https://github.com/python/cpython/blob/3.8/Lib/cgitb.py
|
||||
|
||||
"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
|
||||
All Rights Reserved"
|
||||
|
||||
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
--------------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Python") in source or binary form and
|
||||
its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python alone or in any derivative version,
|
||||
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
|
||||
All Rights Reserved" are retained in Python alone or in any derivative version
|
||||
prepared by Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python.
|
||||
|
||||
4. PSF is making Python available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
'''
|
||||
|
||||
import inspect
|
||||
import keyword
|
||||
import linecache
|
||||
import os
|
||||
import pydoc
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import tokenize
|
||||
import traceback
|
||||
|
||||
|
||||
__UNDEF__ = [] # a special sentinel object
|
||||
|
||||
|
||||
def lookup(name, frame, locals):
|
||||
"""Find the value for a given name in the given environment."""
|
||||
if name in locals:
|
||||
return 'local', locals[name]
|
||||
if name in frame.f_globals:
|
||||
return 'global', frame.f_globals[name]
|
||||
if '__builtins__' in frame.f_globals:
|
||||
builtins = frame.f_globals['__builtins__']
|
||||
if isinstance(builtins, dict):
|
||||
if name in builtins:
|
||||
return 'builtin', builtins[name]
|
||||
else:
|
||||
if hasattr(builtins, name):
|
||||
return 'builtin', getattr(builtins, name)
|
||||
return None, __UNDEF__
|
||||
|
||||
|
||||
def scanvars(reader, frame, locals):
|
||||
"""Scan one logical line of Python and look up values of variables used."""
|
||||
vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
|
||||
for ttype, token, start, end, line in tokenize.generate_tokens(reader):
|
||||
if ttype == tokenize.NEWLINE:
|
||||
break
|
||||
if ttype == tokenize.NAME and token not in keyword.kwlist:
|
||||
if lasttoken == '.':
|
||||
if parent is not __UNDEF__:
|
||||
value = getattr(parent, token, __UNDEF__)
|
||||
vars.append((prefix + token, prefix, value))
|
||||
else:
|
||||
where, value = lookup(token, frame, locals)
|
||||
vars.append((token, where, value))
|
||||
elif token == '.':
|
||||
prefix += lasttoken + '.'
|
||||
parent = value
|
||||
else:
|
||||
parent, prefix = None, ''
|
||||
lasttoken = token
|
||||
return vars
|
||||
|
||||
|
||||
def text(einfo, context=5):
|
||||
"""Return a plain text document describing a given traceback."""
|
||||
etype, evalue, etb = einfo
|
||||
if isinstance(etype, type):
|
||||
etype = etype.__name__
|
||||
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
|
||||
date = time.ctime(time.time())
|
||||
head = '%s\n%s\n%s\n' % (str(etype), pyver, date) + '''
|
||||
A problem occurred in a Python script. Here is the sequence of
|
||||
function calls leading up to the error, in the order they occurred.
|
||||
'''
|
||||
|
||||
frames = []
|
||||
records = inspect.getinnerframes(etb, context)
|
||||
for frame, file, lnum, func, lines, index in records:
|
||||
file = file and os.path.abspath(file) or '?'
|
||||
args, varargs, varkw, locals = inspect.getargvalues(frame)
|
||||
call = ''
|
||||
if func != '?':
|
||||
call = 'in ' + func + \
|
||||
inspect.formatargvalues(args, varargs, varkw, locals,
|
||||
formatvalue=lambda value: '=' + pydoc.text.repr(value))
|
||||
|
||||
highlight = {}
|
||||
|
||||
def reader(lnum=[lnum]):
|
||||
highlight[lnum[0]] = 1
|
||||
try:
|
||||
return linecache.getline(file, lnum[0])
|
||||
finally:
|
||||
lnum[0] += 1
|
||||
vars = scanvars(reader, frame, locals)
|
||||
|
||||
rows = [' %s %s' % (file, call)]
|
||||
if index is not None:
|
||||
i = lnum - index
|
||||
for line in lines:
|
||||
num = '%5d ' % i
|
||||
rows.append(num + line.rstrip())
|
||||
i += 1
|
||||
|
||||
done, dump = {}, []
|
||||
for name, where, value in vars:
|
||||
if name in done:
|
||||
continue
|
||||
done[name] = 1
|
||||
if value is not __UNDEF__:
|
||||
if where == 'global':
|
||||
name = 'global ' + name
|
||||
elif where != 'local':
|
||||
name = where + name.split('.')[-1]
|
||||
dump.append('%s = %s' % (name, pydoc.text.repr(value)))
|
||||
else:
|
||||
dump.append(name + ' undefined')
|
||||
|
||||
rows.append('\n'.join(dump))
|
||||
frames.append('\n%s\n' % '\n'.join(rows))
|
||||
|
||||
exception = ['%s: %s' % (str(etype), str(evalue))]
|
||||
for name in dir(evalue):
|
||||
value = pydoc.text.repr(getattr(evalue, name))
|
||||
exception.append('\n%s%s = %s' % (' ' * 4, name, value))
|
||||
|
||||
return head + ''.join(frames) + ''.join(exception) + '''
|
||||
|
||||
The above is a description of an error in a Python program. Here is
|
||||
the original traceback:
|
||||
|
||||
%s
|
||||
''' % ''.join(traceback.format_exception(etype, evalue, etb))
|
||||
|
||||
|
||||
class Hook:
|
||||
"""A hook to replace sys.excepthook"""
|
||||
|
||||
def __init__(self, logdir=None, context=5, file=None):
|
||||
self.logdir = logdir # log tracebacks to files if not None
|
||||
self.context = context # number of source code lines per frame
|
||||
self.file = file or sys.stdout # place to send the output
|
||||
|
||||
def __call__(self, etype, evalue, etb):
|
||||
self.handle((etype, evalue, etb))
|
||||
|
||||
def handle(self, info=None):
|
||||
info = info or sys.exc_info()
|
||||
|
||||
formatter = text
|
||||
|
||||
try:
|
||||
doc = formatter(info, self.context)
|
||||
except: # just in case something goes wrong
|
||||
doc = ''.join(traceback.format_exception(*info))
|
||||
|
||||
self.file.write(doc + '\n')
|
||||
|
||||
if self.logdir is not None:
|
||||
suffix = '.txt'
|
||||
(fd, path) = tempfile.mkstemp(suffix=suffix, dir=self.logdir)
|
||||
|
||||
try:
|
||||
with os.fdopen(fd, 'w') as file:
|
||||
file.write(doc)
|
||||
msg = '%s contains the description of this error.' % path
|
||||
except:
|
||||
msg = 'Tried to save traceback to %s, but failed.' % path
|
||||
|
||||
self.file.write(msg + '\n')
|
||||
|
||||
try:
|
||||
self.file.flush()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
handler = Hook().handle
|
||||
|
||||
|
||||
def enable(logdir=None, context=5):
|
||||
"""Install an exception handler that sends verbose tracebacks to STDOUT."""
|
||||
sys.excepthook = Hook(logdir=logdir, context=context)
|
||||
18
jc/utils.py
18
jc/utils.py
@@ -66,4 +66,20 @@ def compatibility(mod_name, compatible):
|
||||
if not platform_found:
|
||||
mod = mod_name.split('.')[-1]
|
||||
compat_list = ', '.join(compatible)
|
||||
warning_message(f'{mod} parser not compatible with your OS ({sys.platform}).\n Compatible platforms: {compat_list}')
|
||||
warning_message(f'{mod} parser not compatible with your OS ({sys.platform}).\n'
|
||||
f' Compatible platforms: {compat_list}')
|
||||
|
||||
|
||||
def has_data(data):
|
||||
"""
|
||||
Checks if the input contains data. If there are any non-whitespace characters then return True, else return False
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) input to check whether it contains data
|
||||
|
||||
Returns:
|
||||
|
||||
Boolean True if input string (data) contains non-whitespace characters, otherwise False
|
||||
"""
|
||||
return True if data and not data.isspace() else False
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
ruamel.yaml>=0.15.0
|
||||
xmltodict>=0.12.0
|
||||
Pygments>=2.4.2
|
||||
Pygments>=2.3.0
|
||||
|
||||
4
setup.py
4
setup.py
@@ -5,14 +5,14 @@ with open('README.md', 'r') as f:
|
||||
|
||||
setuptools.setup(
|
||||
name='jc',
|
||||
version='1.11.2',
|
||||
version='1.12.0',
|
||||
author='Kelly Brazil',
|
||||
author_email='kellyjonbrazil@gmail.com',
|
||||
description='Converts the output of popular command-line tools and file-types to JSON.',
|
||||
install_requires=[
|
||||
'ruamel.yaml>=0.15.0',
|
||||
'xmltodict>=0.12.0',
|
||||
'Pygments>=2.4.2'
|
||||
'Pygments>=2.3.0'
|
||||
],
|
||||
license='MIT',
|
||||
long_description=long_description,
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "INPUT", "rules": [{"target": "INPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD", "rules": [{"target": "FORWARD_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POSTROUTING", "rules": [{"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD_direct", "rules": []}, {"chain": "INPUT_direct", "rules": []}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}]
|
||||
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "INPUT", "rules": [{"target": "INPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD", "rules": [{"target": "FORWARD_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POSTROUTING", "rules": [{"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD_direct", "rules": []}, {"chain": "INPUT_direct", "rules": []}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}, {"chain": "PRE_public_log", "rules": []}]
|
||||
|
||||
2
tests/fixtures/centos-7.7/iptables-nat.json
vendored
2
tests/fixtures/centos-7.7/iptables-nat.json
vendored
@@ -1 +1 @@
|
||||
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "INPUT", "rules": []}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "!loopback/8", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "POSTROUTING", "rules": [{"target": "MASQUERADE", "prot": "all", "opt": null, "source": "172.17.0.0/16", "destination": "anywhere"}, {"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "DOCKER", "rules": [{"target": "RETURN", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_ZONES", "rules": [{"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "POSTROUTING_ZONES_SOURCE", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "POST_public", "rules": [{"target": "POST_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POST_public_allow", "rules": []}, {"chain": "POST_public_deny", "rules": []}, {"chain": "POST_public_log", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}]
|
||||
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "INPUT", "rules": []}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "!loopback/8", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "POSTROUTING", "rules": [{"target": "MASQUERADE", "prot": "all", "opt": null, "source": "172.17.0.0/16", "destination": "anywhere"}, {"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "DOCKER", "rules": [{"target": "RETURN", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_ZONES", "rules": [{"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "POSTROUTING_ZONES_SOURCE", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "POST_public", "rules": [{"target": "POST_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POST_public_allow", "rules": []}, {"chain": "POST_public_deny", "rules": []}, {"chain": "POST_public_log", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}, {"chain": "PRE_public_log", "rules": []}]
|
||||
|
||||
2
tests/fixtures/centos-7.7/iptables-raw.json
vendored
2
tests/fixtures/centos-7.7/iptables-raw.json
vendored
@@ -1 +1 @@
|
||||
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}]
|
||||
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}, {"chain": "PRE_public_log", "rules": []}]
|
||||
|
||||
2
tests/fixtures/centos-7.7/ss-sudo-a.json
vendored
2
tests/fixtures/centos-7.7/ss-sudo-a.json
vendored
File diff suppressed because one or more lines are too long
1
tests/fixtures/centos-7.7/sysctl-a.json
vendored
Normal file
1
tests/fixtures/centos-7.7/sysctl-a.json
vendored
Normal file
File diff suppressed because one or more lines are too long
918
tests/fixtures/centos-7.7/sysctl-a.out
vendored
Normal file
918
tests/fixtures/centos-7.7/sysctl-a.out
vendored
Normal file
@@ -0,0 +1,918 @@
|
||||
abi.vsyscall32 = 1
|
||||
crypto.fips_enabled = 0
|
||||
debug.exception-trace = 1
|
||||
debug.kprobes-optimization = 1
|
||||
debug.panic_on_rcu_stall = 0
|
||||
dev.cdrom.autoclose = 1
|
||||
dev.cdrom.autoeject = 0
|
||||
dev.cdrom.check_media = 0
|
||||
dev.cdrom.debug = 0
|
||||
dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.20 2003/12/17
|
||||
dev.cdrom.info =
|
||||
dev.cdrom.info = drive name: sr0
|
||||
dev.cdrom.info = drive speed: 1
|
||||
dev.cdrom.info = drive # of slots: 1
|
||||
dev.cdrom.info = Can close tray: 1
|
||||
dev.cdrom.info = Can open tray: 1
|
||||
dev.cdrom.info = Can lock tray: 1
|
||||
dev.cdrom.info = Can change speed: 1
|
||||
dev.cdrom.info = Can select disk: 0
|
||||
dev.cdrom.info = Can read multisession: 1
|
||||
dev.cdrom.info = Can read MCN: 1
|
||||
dev.cdrom.info = Reports media changed: 1
|
||||
dev.cdrom.info = Can play audio: 1
|
||||
dev.cdrom.info = Can write CD-R: 1
|
||||
dev.cdrom.info = Can write CD-RW: 1
|
||||
dev.cdrom.info = Can read DVD: 1
|
||||
dev.cdrom.info = Can write DVD-R: 1
|
||||
dev.cdrom.info = Can write DVD-RAM: 1
|
||||
dev.cdrom.info = Can read MRW: 1
|
||||
dev.cdrom.info = Can write MRW: 1
|
||||
dev.cdrom.info = Can write RAM: 1
|
||||
dev.cdrom.info =
|
||||
dev.cdrom.info =
|
||||
dev.cdrom.lock = 1
|
||||
dev.hpet.max-user-freq = 64
|
||||
dev.mac_hid.mouse_button2_keycode = 97
|
||||
dev.mac_hid.mouse_button3_keycode = 100
|
||||
dev.mac_hid.mouse_button_emulation = 0
|
||||
dev.parport.default.spintime = 500
|
||||
dev.parport.default.timeslice = 200
|
||||
dev.raid.speed_limit_max = 200000
|
||||
dev.raid.speed_limit_min = 1000
|
||||
dev.scsi.logging_level = 0
|
||||
fs.aio-max-nr = 65536
|
||||
fs.aio-nr = 0
|
||||
fs.binfmt_misc.status = enabled
|
||||
fs.dentry-state = 182164 165608 45 0 149757 0
|
||||
fs.dir-notify-enable = 1
|
||||
fs.epoll.max_user_watches = 785940
|
||||
fs.file-max = 379085
|
||||
fs.file-nr = 1152 0 379085
|
||||
fs.inode-nr = 34807 2263
|
||||
fs.inode-state = 34807 2263 0 0 0 0 0
|
||||
fs.inotify.max_queued_events = 16384
|
||||
fs.inotify.max_user_instances = 128
|
||||
fs.inotify.max_user_watches = 8192
|
||||
fs.lease-break-time = 45
|
||||
fs.leases-enable = 1
|
||||
fs.may_detach_mounts = 1
|
||||
fs.mount-max = 100000
|
||||
fs.mqueue.msg_default = 10
|
||||
fs.mqueue.msg_max = 10
|
||||
fs.mqueue.msgsize_default = 8192
|
||||
fs.mqueue.msgsize_max = 8192
|
||||
fs.mqueue.queues_max = 256
|
||||
fs.nr_open = 1048576
|
||||
fs.overflowgid = 65534
|
||||
fs.overflowuid = 65534
|
||||
fs.pipe-max-size = 1048576
|
||||
fs.pipe-user-pages-hard = 0
|
||||
fs.pipe-user-pages-soft = 16384
|
||||
fs.quota.allocated_dquots = 0
|
||||
fs.quota.cache_hits = 0
|
||||
fs.quota.drops = 0
|
||||
fs.quota.free_dquots = 0
|
||||
fs.quota.lookups = 0
|
||||
fs.quota.reads = 0
|
||||
fs.quota.syncs = 0
|
||||
fs.quota.warnings = 1
|
||||
fs.quota.writes = 0
|
||||
fs.suid_dumpable = 0
|
||||
fs.xfs.age_buffer_centisecs = 1500
|
||||
fs.xfs.error_level = 3
|
||||
fs.xfs.filestream_centisecs = 3000
|
||||
fs.xfs.inherit_noatime = 1
|
||||
fs.xfs.inherit_nodefrag = 1
|
||||
fs.xfs.inherit_nodump = 1
|
||||
fs.xfs.inherit_nosymlinks = 0
|
||||
fs.xfs.inherit_sync = 1
|
||||
fs.xfs.irix_sgid_inherit = 0
|
||||
fs.xfs.irix_symlink_mode = 0
|
||||
fs.xfs.panic_mask = 0
|
||||
fs.xfs.rotorstep = 1
|
||||
fs.xfs.speculative_prealloc_lifetime = 300
|
||||
fs.xfs.stats_clear = 0
|
||||
fs.xfs.xfsbufd_centisecs = 100
|
||||
fs.xfs.xfssyncd_centisecs = 3000
|
||||
kernel.acct = 4 2 30
|
||||
kernel.acpi_video_flags = 0
|
||||
kernel.auto_msgmni = 1
|
||||
kernel.bootloader_type = 114
|
||||
kernel.bootloader_version = 2
|
||||
kernel.cap_last_cap = 36
|
||||
kernel.compat-log = 1
|
||||
kernel.core_pattern = core
|
||||
kernel.core_pipe_limit = 0
|
||||
kernel.core_uses_pid = 1
|
||||
kernel.ctrl-alt-del = 0
|
||||
kernel.dmesg_restrict = 0
|
||||
kernel.domainname = (none)
|
||||
kernel.ftrace_dump_on_oops = 0
|
||||
kernel.ftrace_enabled = 1
|
||||
kernel.hardlockup_all_cpu_backtrace = 0
|
||||
kernel.hardlockup_panic = 1
|
||||
kernel.hostname = localhost.localdomain
|
||||
kernel.hotplug =
|
||||
kernel.hung_task_check_count = 4194304
|
||||
kernel.hung_task_panic = 0
|
||||
kernel.hung_task_timeout_secs = 120
|
||||
kernel.hung_task_warnings = 10
|
||||
kernel.io_delay_type = 0
|
||||
kernel.kexec_load_disabled = 0
|
||||
kernel.keys.gc_delay = 300
|
||||
kernel.keys.maxbytes = 20000
|
||||
kernel.keys.maxkeys = 200
|
||||
kernel.keys.persistent_keyring_expiry = 259200
|
||||
kernel.keys.root_maxbytes = 25000000
|
||||
kernel.keys.root_maxkeys = 1000000
|
||||
kernel.kptr_restrict = 0
|
||||
kernel.max_lock_depth = 1024
|
||||
kernel.modprobe = /sbin/modprobe
|
||||
kernel.modules_disabled = 0
|
||||
kernel.msg_next_id = -1
|
||||
kernel.msgmax = 8192
|
||||
kernel.msgmnb = 16384
|
||||
kernel.msgmni = 7535
|
||||
kernel.ngroups_max = 65536
|
||||
kernel.nmi_watchdog = 1
|
||||
kernel.ns_last_pid = 49181
|
||||
kernel.numa_balancing = 0
|
||||
kernel.numa_balancing_scan_delay_ms = 1000
|
||||
kernel.numa_balancing_scan_period_max_ms = 60000
|
||||
kernel.numa_balancing_scan_period_min_ms = 1000
|
||||
kernel.numa_balancing_scan_size_mb = 256
|
||||
kernel.numa_balancing_settle_count = 4
|
||||
kernel.osrelease = 3.10.0-1062.1.2.el7.x86_64
|
||||
kernel.ostype = Linux
|
||||
kernel.overflowgid = 65534
|
||||
kernel.overflowuid = 65534
|
||||
kernel.panic = 0
|
||||
kernel.panic_on_io_nmi = 0
|
||||
kernel.panic_on_oops = 1
|
||||
kernel.panic_on_stackoverflow = 0
|
||||
kernel.panic_on_unrecovered_nmi = 0
|
||||
kernel.panic_on_warn = 0
|
||||
kernel.perf_cpu_time_max_percent = 25
|
||||
kernel.perf_event_max_sample_rate = 100000
|
||||
kernel.perf_event_mlock_kb = 516
|
||||
kernel.perf_event_paranoid = 2
|
||||
kernel.pid_max = 131072
|
||||
kernel.poweroff_cmd = /sbin/poweroff
|
||||
kernel.print-fatal-signals = 0
|
||||
kernel.printk = 4 4 1 7
|
||||
kernel.printk_delay = 0
|
||||
kernel.printk_ratelimit = 5
|
||||
kernel.printk_ratelimit_burst = 10
|
||||
kernel.pty.max = 4096
|
||||
kernel.pty.nr = 0
|
||||
kernel.pty.reserve = 1024
|
||||
kernel.random.boot_id = 9e51ba01-3e54-4fbd-b007-a9563d0156d5
|
||||
kernel.random.entropy_avail = 744
|
||||
kernel.random.poolsize = 4096
|
||||
kernel.random.read_wakeup_threshold = 64
|
||||
kernel.random.urandom_min_reseed_secs = 60
|
||||
kernel.random.uuid = 91912f7c-e25e-48ef-8e53-c1ee7f8b38c8
|
||||
kernel.random.write_wakeup_threshold = 896
|
||||
kernel.randomize_va_space = 2
|
||||
kernel.real-root-dev = 0
|
||||
kernel.sched_autogroup_enabled = 0
|
||||
kernel.sched_cfs_bandwidth_slice_us = 5000
|
||||
kernel.sched_child_runs_first = 0
|
||||
kernel.sched_latency_ns = 6000000
|
||||
kernel.sched_migration_cost_ns = 500000
|
||||
kernel.sched_min_granularity_ns = 10000000
|
||||
kernel.sched_nr_migrate = 32
|
||||
kernel.sched_rr_timeslice_ms = 100
|
||||
kernel.sched_rt_period_us = 1000000
|
||||
kernel.sched_rt_runtime_us = 950000
|
||||
kernel.sched_schedstats = 0
|
||||
kernel.sched_shares_window_ns = 10000000
|
||||
kernel.sched_time_avg_ms = 1000
|
||||
kernel.sched_tunable_scaling = 1
|
||||
kernel.sched_wakeup_granularity_ns = 15000000
|
||||
kernel.seccomp.actions_avail = kill trap errno trace allow
|
||||
kernel.seccomp.actions_logged = kill trap errno trace
|
||||
kernel.sem = 250 32000 32 128
|
||||
kernel.sem_next_id = -1
|
||||
kernel.shm_next_id = -1
|
||||
kernel.shm_rmid_forced = 0
|
||||
kernel.shmall = 18446744073692774399
|
||||
kernel.shmmax = 18446744073692774399
|
||||
kernel.shmmni = 4096
|
||||
kernel.softlockup_all_cpu_backtrace = 0
|
||||
kernel.softlockup_panic = 0
|
||||
kernel.stack_tracer_enabled = 0
|
||||
kernel.sysctl_writes_strict = 1
|
||||
kernel.sysrq = 16
|
||||
kernel.tainted = 536870912
|
||||
kernel.threads-max = 29981
|
||||
kernel.timer_migration = 1
|
||||
kernel.traceoff_on_warning = 0
|
||||
kernel.unknown_nmi_panic = 0
|
||||
kernel.version = #1 SMP Mon Sep 30 14:19:46 UTC 2019
|
||||
kernel.watchdog = 1
|
||||
kernel.watchdog_cpumask = 0-127
|
||||
kernel.watchdog_thresh = 10
|
||||
kernel.yama.ptrace_scope = 0
|
||||
net.bridge.bridge-nf-call-arptables = 0
|
||||
net.bridge.bridge-nf-call-ip6tables = 0
|
||||
net.bridge.bridge-nf-call-iptables = 0
|
||||
net.bridge.bridge-nf-filter-pppoe-tagged = 0
|
||||
net.bridge.bridge-nf-filter-vlan-tagged = 0
|
||||
net.bridge.bridge-nf-pass-vlan-input-dev = 0
|
||||
net.core.bpf_jit_enable = 1
|
||||
net.core.busy_poll = 0
|
||||
net.core.busy_read = 0
|
||||
net.core.default_qdisc = pfifo_fast
|
||||
net.core.dev_weight = 64
|
||||
net.core.dev_weight_rx_bias = 1
|
||||
net.core.dev_weight_tx_bias = 1
|
||||
net.core.message_burst = 10
|
||||
net.core.message_cost = 5
|
||||
net.core.netdev_budget = 300
|
||||
net.core.netdev_max_backlog = 1000
|
||||
net.core.netdev_rss_key = 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
|
||||
net.core.netdev_tstamp_prequeue = 1
|
||||
net.core.optmem_max = 20480
|
||||
net.core.rmem_default = 212992
|
||||
net.core.rmem_max = 212992
|
||||
net.core.rps_sock_flow_entries = 0
|
||||
net.core.somaxconn = 128
|
||||
net.core.warnings = 1
|
||||
net.core.wmem_default = 212992
|
||||
net.core.wmem_max = 212992
|
||||
net.core.xfrm_acq_expires = 30
|
||||
net.core.xfrm_aevent_etime = 10
|
||||
net.core.xfrm_aevent_rseqth = 2
|
||||
net.core.xfrm_larval_drop = 1
|
||||
net.ipv4.cipso_cache_bucket_size = 10
|
||||
net.ipv4.cipso_cache_enable = 1
|
||||
net.ipv4.cipso_rbm_optfmt = 0
|
||||
net.ipv4.cipso_rbm_strictvalid = 1
|
||||
net.ipv4.conf.all.accept_local = 0
|
||||
net.ipv4.conf.all.accept_redirects = 0
|
||||
net.ipv4.conf.all.accept_source_route = 0
|
||||
net.ipv4.conf.all.arp_accept = 0
|
||||
net.ipv4.conf.all.arp_announce = 0
|
||||
net.ipv4.conf.all.arp_filter = 0
|
||||
net.ipv4.conf.all.arp_ignore = 0
|
||||
net.ipv4.conf.all.arp_notify = 0
|
||||
net.ipv4.conf.all.bootp_relay = 0
|
||||
net.ipv4.conf.all.disable_policy = 0
|
||||
net.ipv4.conf.all.disable_xfrm = 0
|
||||
net.ipv4.conf.all.force_igmp_version = 0
|
||||
net.ipv4.conf.all.forwarding = 1
|
||||
net.ipv4.conf.all.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.all.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.all.log_martians = 0
|
||||
net.ipv4.conf.all.mc_forwarding = 0
|
||||
net.ipv4.conf.all.medium_id = 0
|
||||
net.ipv4.conf.all.promote_secondaries = 1
|
||||
net.ipv4.conf.all.proxy_arp = 0
|
||||
net.ipv4.conf.all.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.all.route_localnet = 0
|
||||
net.ipv4.conf.all.rp_filter = 1
|
||||
net.ipv4.conf.all.secure_redirects = 1
|
||||
net.ipv4.conf.all.send_redirects = 1
|
||||
net.ipv4.conf.all.shared_media = 1
|
||||
net.ipv4.conf.all.src_valid_mark = 0
|
||||
net.ipv4.conf.all.tag = 0
|
||||
net.ipv4.conf.default.accept_local = 0
|
||||
net.ipv4.conf.default.accept_redirects = 1
|
||||
net.ipv4.conf.default.accept_source_route = 0
|
||||
net.ipv4.conf.default.arp_accept = 0
|
||||
net.ipv4.conf.default.arp_announce = 0
|
||||
net.ipv4.conf.default.arp_filter = 0
|
||||
net.ipv4.conf.default.arp_ignore = 0
|
||||
net.ipv4.conf.default.arp_notify = 0
|
||||
net.ipv4.conf.default.bootp_relay = 0
|
||||
net.ipv4.conf.default.disable_policy = 0
|
||||
net.ipv4.conf.default.disable_xfrm = 0
|
||||
net.ipv4.conf.default.force_igmp_version = 0
|
||||
net.ipv4.conf.default.forwarding = 1
|
||||
net.ipv4.conf.default.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.default.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.default.log_martians = 0
|
||||
net.ipv4.conf.default.mc_forwarding = 0
|
||||
net.ipv4.conf.default.medium_id = 0
|
||||
net.ipv4.conf.default.promote_secondaries = 1
|
||||
net.ipv4.conf.default.proxy_arp = 0
|
||||
net.ipv4.conf.default.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.default.route_localnet = 0
|
||||
net.ipv4.conf.default.rp_filter = 1
|
||||
net.ipv4.conf.default.secure_redirects = 1
|
||||
net.ipv4.conf.default.send_redirects = 1
|
||||
net.ipv4.conf.default.shared_media = 1
|
||||
net.ipv4.conf.default.src_valid_mark = 0
|
||||
net.ipv4.conf.default.tag = 0
|
||||
net.ipv4.conf.docker0.accept_local = 0
|
||||
net.ipv4.conf.docker0.accept_redirects = 1
|
||||
net.ipv4.conf.docker0.accept_source_route = 0
|
||||
net.ipv4.conf.docker0.arp_accept = 0
|
||||
net.ipv4.conf.docker0.arp_announce = 0
|
||||
net.ipv4.conf.docker0.arp_filter = 0
|
||||
net.ipv4.conf.docker0.arp_ignore = 0
|
||||
net.ipv4.conf.docker0.arp_notify = 0
|
||||
net.ipv4.conf.docker0.bootp_relay = 0
|
||||
net.ipv4.conf.docker0.disable_policy = 0
|
||||
net.ipv4.conf.docker0.disable_xfrm = 0
|
||||
net.ipv4.conf.docker0.force_igmp_version = 0
|
||||
net.ipv4.conf.docker0.forwarding = 1
|
||||
net.ipv4.conf.docker0.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.docker0.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.docker0.log_martians = 0
|
||||
net.ipv4.conf.docker0.mc_forwarding = 0
|
||||
net.ipv4.conf.docker0.medium_id = 0
|
||||
net.ipv4.conf.docker0.promote_secondaries = 1
|
||||
net.ipv4.conf.docker0.proxy_arp = 0
|
||||
net.ipv4.conf.docker0.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.docker0.route_localnet = 0
|
||||
net.ipv4.conf.docker0.rp_filter = 1
|
||||
net.ipv4.conf.docker0.secure_redirects = 1
|
||||
net.ipv4.conf.docker0.send_redirects = 1
|
||||
net.ipv4.conf.docker0.shared_media = 1
|
||||
net.ipv4.conf.docker0.src_valid_mark = 0
|
||||
net.ipv4.conf.docker0.tag = 0
|
||||
net.ipv4.conf.ens33.accept_local = 0
|
||||
net.ipv4.conf.ens33.accept_redirects = 1
|
||||
net.ipv4.conf.ens33.accept_source_route = 0
|
||||
net.ipv4.conf.ens33.arp_accept = 0
|
||||
net.ipv4.conf.ens33.arp_announce = 0
|
||||
net.ipv4.conf.ens33.arp_filter = 0
|
||||
net.ipv4.conf.ens33.arp_ignore = 0
|
||||
net.ipv4.conf.ens33.arp_notify = 0
|
||||
net.ipv4.conf.ens33.bootp_relay = 0
|
||||
net.ipv4.conf.ens33.disable_policy = 0
|
||||
net.ipv4.conf.ens33.disable_xfrm = 0
|
||||
net.ipv4.conf.ens33.force_igmp_version = 0
|
||||
net.ipv4.conf.ens33.forwarding = 1
|
||||
net.ipv4.conf.ens33.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.ens33.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.ens33.log_martians = 0
|
||||
net.ipv4.conf.ens33.mc_forwarding = 0
|
||||
net.ipv4.conf.ens33.medium_id = 0
|
||||
net.ipv4.conf.ens33.promote_secondaries = 1
|
||||
net.ipv4.conf.ens33.proxy_arp = 0
|
||||
net.ipv4.conf.ens33.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.ens33.route_localnet = 0
|
||||
net.ipv4.conf.ens33.rp_filter = 1
|
||||
net.ipv4.conf.ens33.secure_redirects = 1
|
||||
net.ipv4.conf.ens33.send_redirects = 1
|
||||
net.ipv4.conf.ens33.shared_media = 1
|
||||
net.ipv4.conf.ens33.src_valid_mark = 0
|
||||
net.ipv4.conf.ens33.tag = 0
|
||||
net.ipv4.conf.lo.accept_local = 0
|
||||
net.ipv4.conf.lo.accept_redirects = 1
|
||||
net.ipv4.conf.lo.accept_source_route = 1
|
||||
net.ipv4.conf.lo.arp_accept = 0
|
||||
net.ipv4.conf.lo.arp_announce = 0
|
||||
net.ipv4.conf.lo.arp_filter = 0
|
||||
net.ipv4.conf.lo.arp_ignore = 0
|
||||
net.ipv4.conf.lo.arp_notify = 0
|
||||
net.ipv4.conf.lo.bootp_relay = 0
|
||||
net.ipv4.conf.lo.disable_policy = 1
|
||||
net.ipv4.conf.lo.disable_xfrm = 1
|
||||
net.ipv4.conf.lo.force_igmp_version = 0
|
||||
net.ipv4.conf.lo.forwarding = 1
|
||||
net.ipv4.conf.lo.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.lo.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.lo.log_martians = 0
|
||||
net.ipv4.conf.lo.mc_forwarding = 0
|
||||
net.ipv4.conf.lo.medium_id = 0
|
||||
net.ipv4.conf.lo.promote_secondaries = 0
|
||||
net.ipv4.conf.lo.proxy_arp = 0
|
||||
net.ipv4.conf.lo.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.lo.route_localnet = 0
|
||||
net.ipv4.conf.lo.rp_filter = 0
|
||||
net.ipv4.conf.lo.secure_redirects = 1
|
||||
net.ipv4.conf.lo.send_redirects = 1
|
||||
net.ipv4.conf.lo.shared_media = 1
|
||||
net.ipv4.conf.lo.src_valid_mark = 0
|
||||
net.ipv4.conf.lo.tag = 0
|
||||
net.ipv4.fib_multipath_hash_policy = 0
|
||||
net.ipv4.fwmark_reflect = 0
|
||||
net.ipv4.icmp_echo_ignore_all = 0
|
||||
net.ipv4.icmp_echo_ignore_broadcasts = 1
|
||||
net.ipv4.icmp_errors_use_inbound_ifaddr = 0
|
||||
net.ipv4.icmp_ignore_bogus_error_responses = 1
|
||||
net.ipv4.icmp_msgs_burst = 50
|
||||
net.ipv4.icmp_msgs_per_sec = 1000
|
||||
net.ipv4.icmp_ratelimit = 1000
|
||||
net.ipv4.icmp_ratemask = 6168
|
||||
net.ipv4.igmp_max_memberships = 20
|
||||
net.ipv4.igmp_max_msf = 10
|
||||
net.ipv4.igmp_qrv = 2
|
||||
net.ipv4.inet_peer_maxttl = 600
|
||||
net.ipv4.inet_peer_minttl = 120
|
||||
net.ipv4.inet_peer_threshold = 65664
|
||||
net.ipv4.ip_default_ttl = 64
|
||||
net.ipv4.ip_dynaddr = 0
|
||||
net.ipv4.ip_early_demux = 1
|
||||
net.ipv4.ip_forward = 1
|
||||
net.ipv4.ip_forward_use_pmtu = 0
|
||||
net.ipv4.ip_local_port_range = 32768 60999
|
||||
net.ipv4.ip_local_reserved_ports =
|
||||
net.ipv4.ip_no_pmtu_disc = 0
|
||||
net.ipv4.ip_nonlocal_bind = 0
|
||||
net.ipv4.ipfrag_high_thresh = 4194304
|
||||
net.ipv4.ipfrag_low_thresh = 3145728
|
||||
net.ipv4.ipfrag_max_dist = 64
|
||||
net.ipv4.ipfrag_secret_interval = 600
|
||||
net.ipv4.ipfrag_time = 30
|
||||
net.ipv4.neigh.default.anycast_delay = 100
|
||||
net.ipv4.neigh.default.app_solicit = 0
|
||||
net.ipv4.neigh.default.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.default.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.default.gc_interval = 30
|
||||
net.ipv4.neigh.default.gc_stale_time = 60
|
||||
net.ipv4.neigh.default.gc_thresh1 = 128
|
||||
net.ipv4.neigh.default.gc_thresh2 = 512
|
||||
net.ipv4.neigh.default.gc_thresh3 = 1024
|
||||
net.ipv4.neigh.default.locktime = 100
|
||||
net.ipv4.neigh.default.mcast_solicit = 3
|
||||
net.ipv4.neigh.default.proxy_delay = 80
|
||||
net.ipv4.neigh.default.proxy_qlen = 64
|
||||
net.ipv4.neigh.default.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.default.ucast_solicit = 3
|
||||
net.ipv4.neigh.default.unres_qlen = 31
|
||||
net.ipv4.neigh.default.unres_qlen_bytes = 65536
|
||||
net.ipv4.neigh.docker0.anycast_delay = 100
|
||||
net.ipv4.neigh.docker0.app_solicit = 0
|
||||
net.ipv4.neigh.docker0.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.docker0.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.docker0.gc_stale_time = 60
|
||||
net.ipv4.neigh.docker0.locktime = 100
|
||||
net.ipv4.neigh.docker0.mcast_solicit = 3
|
||||
net.ipv4.neigh.docker0.proxy_delay = 80
|
||||
net.ipv4.neigh.docker0.proxy_qlen = 64
|
||||
net.ipv4.neigh.docker0.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.docker0.ucast_solicit = 3
|
||||
net.ipv4.neigh.docker0.unres_qlen = 31
|
||||
net.ipv4.neigh.docker0.unres_qlen_bytes = 65536
|
||||
net.ipv4.neigh.ens33.anycast_delay = 100
|
||||
net.ipv4.neigh.ens33.app_solicit = 0
|
||||
net.ipv4.neigh.ens33.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.ens33.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.ens33.gc_stale_time = 60
|
||||
net.ipv4.neigh.ens33.locktime = 100
|
||||
net.ipv4.neigh.ens33.mcast_solicit = 3
|
||||
net.ipv4.neigh.ens33.proxy_delay = 80
|
||||
net.ipv4.neigh.ens33.proxy_qlen = 64
|
||||
net.ipv4.neigh.ens33.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.ens33.ucast_solicit = 3
|
||||
net.ipv4.neigh.ens33.unres_qlen = 31
|
||||
net.ipv4.neigh.ens33.unres_qlen_bytes = 65536
|
||||
net.ipv4.neigh.lo.anycast_delay = 100
|
||||
net.ipv4.neigh.lo.app_solicit = 0
|
||||
net.ipv4.neigh.lo.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.lo.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.lo.gc_stale_time = 60
|
||||
net.ipv4.neigh.lo.locktime = 100
|
||||
net.ipv4.neigh.lo.mcast_solicit = 3
|
||||
net.ipv4.neigh.lo.proxy_delay = 80
|
||||
net.ipv4.neigh.lo.proxy_qlen = 64
|
||||
net.ipv4.neigh.lo.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.lo.ucast_solicit = 3
|
||||
net.ipv4.neigh.lo.unres_qlen = 31
|
||||
net.ipv4.neigh.lo.unres_qlen_bytes = 65536
|
||||
net.ipv4.ping_group_range = 1 0
|
||||
net.ipv4.route.error_burst = 5000
|
||||
net.ipv4.route.error_cost = 1000
|
||||
net.ipv4.route.gc_elasticity = 8
|
||||
net.ipv4.route.gc_interval = 60
|
||||
net.ipv4.route.gc_min_interval = 0
|
||||
net.ipv4.route.gc_min_interval_ms = 500
|
||||
net.ipv4.route.gc_thresh = -1
|
||||
net.ipv4.route.gc_timeout = 300
|
||||
net.ipv4.route.max_size = 2147483647
|
||||
net.ipv4.route.min_adv_mss = 256
|
||||
net.ipv4.route.min_pmtu = 552
|
||||
net.ipv4.route.mtu_expires = 600
|
||||
net.ipv4.route.redirect_load = 20
|
||||
net.ipv4.route.redirect_number = 9
|
||||
net.ipv4.route.redirect_silence = 20480
|
||||
net.ipv4.tcp_abort_on_overflow = 0
|
||||
net.ipv4.tcp_adv_win_scale = 1
|
||||
net.ipv4.tcp_allowed_congestion_control = cubic reno
|
||||
net.ipv4.tcp_app_win = 31
|
||||
net.ipv4.tcp_autocorking = 1
|
||||
net.ipv4.tcp_available_congestion_control = cubic reno
|
||||
net.ipv4.tcp_base_mss = 512
|
||||
net.ipv4.tcp_challenge_ack_limit = 1000
|
||||
net.ipv4.tcp_congestion_control = cubic
|
||||
net.ipv4.tcp_dsack = 1
|
||||
net.ipv4.tcp_early_retrans = 3
|
||||
net.ipv4.tcp_ecn = 2
|
||||
net.ipv4.tcp_fack = 1
|
||||
net.ipv4.tcp_fastopen = 0
|
||||
net.ipv4.tcp_fin_timeout = 60
|
||||
net.ipv4.tcp_frto = 2
|
||||
net.ipv4.tcp_invalid_ratelimit = 500
|
||||
net.ipv4.tcp_keepalive_intvl = 75
|
||||
net.ipv4.tcp_keepalive_probes = 9
|
||||
net.ipv4.tcp_keepalive_time = 7200
|
||||
net.ipv4.tcp_limit_output_bytes = 262144
|
||||
net.ipv4.tcp_low_latency = 0
|
||||
net.ipv4.tcp_max_orphans = 16384
|
||||
net.ipv4.tcp_max_ssthresh = 0
|
||||
net.ipv4.tcp_max_syn_backlog = 128
|
||||
net.ipv4.tcp_max_tw_buckets = 16384
|
||||
net.ipv4.tcp_mem = 88053 117406 176106
|
||||
net.ipv4.tcp_min_snd_mss = 48
|
||||
net.ipv4.tcp_min_tso_segs = 2
|
||||
net.ipv4.tcp_moderate_rcvbuf = 1
|
||||
net.ipv4.tcp_mtu_probing = 0
|
||||
net.ipv4.tcp_no_metrics_save = 0
|
||||
net.ipv4.tcp_notsent_lowat = -1
|
||||
net.ipv4.tcp_orphan_retries = 0
|
||||
net.ipv4.tcp_reordering = 3
|
||||
net.ipv4.tcp_retrans_collapse = 1
|
||||
net.ipv4.tcp_retries1 = 3
|
||||
net.ipv4.tcp_retries2 = 15
|
||||
net.ipv4.tcp_rfc1337 = 0
|
||||
net.ipv4.tcp_rmem = 4096 87380 6291456
|
||||
net.ipv4.tcp_sack = 1
|
||||
net.ipv4.tcp_slow_start_after_idle = 1
|
||||
net.ipv4.tcp_stdurg = 0
|
||||
net.ipv4.tcp_syn_retries = 6
|
||||
net.ipv4.tcp_synack_retries = 5
|
||||
net.ipv4.tcp_syncookies = 1
|
||||
net.ipv4.tcp_thin_dupack = 0
|
||||
net.ipv4.tcp_thin_linear_timeouts = 0
|
||||
net.ipv4.tcp_timestamps = 1
|
||||
net.ipv4.tcp_tso_win_divisor = 3
|
||||
net.ipv4.tcp_tw_recycle = 0
|
||||
net.ipv4.tcp_tw_reuse = 0
|
||||
net.ipv4.tcp_window_scaling = 1
|
||||
net.ipv4.tcp_wmem = 4096 16384 4194304
|
||||
net.ipv4.tcp_workaround_signed_windows = 0
|
||||
net.ipv4.udp_mem = 89943 119926 179886
|
||||
net.ipv4.udp_rmem_min = 4096
|
||||
net.ipv4.udp_wmem_min = 4096
|
||||
net.ipv4.xfrm4_gc_thresh = 32768
|
||||
net.ipv6.anycast_src_echo_reply = 0
|
||||
net.ipv6.bindv6only = 0
|
||||
net.ipv6.conf.all.accept_dad = 0
|
||||
net.ipv6.conf.all.accept_ra = 1
|
||||
net.ipv6.conf.all.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.all.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.all.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.all.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.all.accept_redirects = 1
|
||||
net.ipv6.conf.all.accept_source_route = 0
|
||||
net.ipv6.conf.all.autoconf = 1
|
||||
net.ipv6.conf.all.dad_transmits = 1
|
||||
net.ipv6.conf.all.disable_ipv6 = 0
|
||||
net.ipv6.conf.all.enhanced_dad = 1
|
||||
net.ipv6.conf.all.force_mld_version = 0
|
||||
net.ipv6.conf.all.force_tllao = 0
|
||||
net.ipv6.conf.all.forwarding = 0
|
||||
net.ipv6.conf.all.hop_limit = 64
|
||||
net.ipv6.conf.all.keep_addr_on_down = 0
|
||||
net.ipv6.conf.all.max_addresses = 16
|
||||
net.ipv6.conf.all.max_desync_factor = 600
|
||||
net.ipv6.conf.all.mc_forwarding = 0
|
||||
net.ipv6.conf.all.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.all.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.all.mtu = 1280
|
||||
net.ipv6.conf.all.ndisc_notify = 0
|
||||
net.ipv6.conf.all.optimistic_dad = 0
|
||||
net.ipv6.conf.all.proxy_ndp = 0
|
||||
net.ipv6.conf.all.regen_max_retry = 3
|
||||
net.ipv6.conf.all.router_probe_interval = 60
|
||||
net.ipv6.conf.all.router_solicitation_delay = 1
|
||||
net.ipv6.conf.all.router_solicitation_interval = 4
|
||||
net.ipv6.conf.all.router_solicitations = 3
|
||||
net.ipv6.conf.all.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.all.temp_valid_lft = 604800
|
||||
net.ipv6.conf.all.use_optimistic = 0
|
||||
net.ipv6.conf.all.use_tempaddr = 0
|
||||
net.ipv6.conf.default.accept_dad = 1
|
||||
net.ipv6.conf.default.accept_ra = 1
|
||||
net.ipv6.conf.default.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.default.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.default.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.default.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.default.accept_redirects = 1
|
||||
net.ipv6.conf.default.accept_source_route = 0
|
||||
net.ipv6.conf.default.autoconf = 1
|
||||
net.ipv6.conf.default.dad_transmits = 1
|
||||
net.ipv6.conf.default.disable_ipv6 = 0
|
||||
net.ipv6.conf.default.enhanced_dad = 1
|
||||
net.ipv6.conf.default.force_mld_version = 0
|
||||
net.ipv6.conf.default.force_tllao = 0
|
||||
net.ipv6.conf.default.forwarding = 0
|
||||
net.ipv6.conf.default.hop_limit = 64
|
||||
net.ipv6.conf.default.keep_addr_on_down = 0
|
||||
net.ipv6.conf.default.max_addresses = 16
|
||||
net.ipv6.conf.default.max_desync_factor = 600
|
||||
net.ipv6.conf.default.mc_forwarding = 0
|
||||
net.ipv6.conf.default.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.default.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.default.mtu = 1280
|
||||
net.ipv6.conf.default.ndisc_notify = 0
|
||||
net.ipv6.conf.default.optimistic_dad = 0
|
||||
net.ipv6.conf.default.proxy_ndp = 0
|
||||
net.ipv6.conf.default.regen_max_retry = 3
|
||||
net.ipv6.conf.default.router_probe_interval = 60
|
||||
net.ipv6.conf.default.router_solicitation_delay = 1
|
||||
net.ipv6.conf.default.router_solicitation_interval = 4
|
||||
net.ipv6.conf.default.router_solicitations = 3
|
||||
net.ipv6.conf.default.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.default.temp_valid_lft = 604800
|
||||
net.ipv6.conf.default.use_optimistic = 0
|
||||
net.ipv6.conf.default.use_tempaddr = 0
|
||||
net.ipv6.conf.docker0.accept_dad = 1
|
||||
net.ipv6.conf.docker0.accept_ra = 1
|
||||
net.ipv6.conf.docker0.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.docker0.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.docker0.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.docker0.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.docker0.accept_redirects = 1
|
||||
net.ipv6.conf.docker0.accept_source_route = 0
|
||||
net.ipv6.conf.docker0.autoconf = 1
|
||||
net.ipv6.conf.docker0.dad_transmits = 1
|
||||
net.ipv6.conf.docker0.disable_ipv6 = 0
|
||||
net.ipv6.conf.docker0.enhanced_dad = 1
|
||||
net.ipv6.conf.docker0.force_mld_version = 0
|
||||
net.ipv6.conf.docker0.force_tllao = 0
|
||||
net.ipv6.conf.docker0.forwarding = 0
|
||||
net.ipv6.conf.docker0.hop_limit = 64
|
||||
net.ipv6.conf.docker0.keep_addr_on_down = 0
|
||||
net.ipv6.conf.docker0.max_addresses = 16
|
||||
net.ipv6.conf.docker0.max_desync_factor = 600
|
||||
net.ipv6.conf.docker0.mc_forwarding = 0
|
||||
net.ipv6.conf.docker0.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.docker0.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.docker0.mtu = 1500
|
||||
net.ipv6.conf.docker0.ndisc_notify = 0
|
||||
net.ipv6.conf.docker0.optimistic_dad = 0
|
||||
net.ipv6.conf.docker0.proxy_ndp = 0
|
||||
net.ipv6.conf.docker0.regen_max_retry = 3
|
||||
net.ipv6.conf.docker0.router_probe_interval = 60
|
||||
net.ipv6.conf.docker0.router_solicitation_delay = 1
|
||||
net.ipv6.conf.docker0.router_solicitation_interval = 4
|
||||
net.ipv6.conf.docker0.router_solicitations = 3
|
||||
net.ipv6.conf.docker0.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.docker0.temp_valid_lft = 604800
|
||||
net.ipv6.conf.docker0.use_optimistic = 0
|
||||
net.ipv6.conf.docker0.use_tempaddr = 0
|
||||
net.ipv6.conf.ens33.accept_dad = 1
|
||||
net.ipv6.conf.ens33.accept_ra = 1
|
||||
net.ipv6.conf.ens33.accept_ra_defrtr = 0
|
||||
net.ipv6.conf.ens33.accept_ra_pinfo = 0
|
||||
net.ipv6.conf.ens33.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.ens33.accept_ra_rtr_pref = 0
|
||||
net.ipv6.conf.ens33.accept_redirects = 1
|
||||
net.ipv6.conf.ens33.accept_source_route = 0
|
||||
net.ipv6.conf.ens33.autoconf = 1
|
||||
net.ipv6.conf.ens33.dad_transmits = 1
|
||||
net.ipv6.conf.ens33.disable_ipv6 = 0
|
||||
net.ipv6.conf.ens33.enhanced_dad = 1
|
||||
net.ipv6.conf.ens33.force_mld_version = 0
|
||||
net.ipv6.conf.ens33.force_tllao = 0
|
||||
net.ipv6.conf.ens33.forwarding = 0
|
||||
net.ipv6.conf.ens33.hop_limit = 64
|
||||
net.ipv6.conf.ens33.keep_addr_on_down = 0
|
||||
net.ipv6.conf.ens33.max_addresses = 16
|
||||
net.ipv6.conf.ens33.max_desync_factor = 600
|
||||
net.ipv6.conf.ens33.mc_forwarding = 0
|
||||
net.ipv6.conf.ens33.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.ens33.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.ens33.mtu = 1500
|
||||
net.ipv6.conf.ens33.ndisc_notify = 0
|
||||
net.ipv6.conf.ens33.optimistic_dad = 0
|
||||
net.ipv6.conf.ens33.proxy_ndp = 0
|
||||
net.ipv6.conf.ens33.regen_max_retry = 3
|
||||
net.ipv6.conf.ens33.router_probe_interval = 60
|
||||
net.ipv6.conf.ens33.router_solicitation_delay = 1
|
||||
net.ipv6.conf.ens33.router_solicitation_interval = 4
|
||||
net.ipv6.conf.ens33.router_solicitations = 3
|
||||
net.ipv6.conf.ens33.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.ens33.temp_valid_lft = 604800
|
||||
net.ipv6.conf.ens33.use_optimistic = 0
|
||||
net.ipv6.conf.ens33.use_tempaddr = 0
|
||||
net.ipv6.conf.lo.accept_dad = -1
|
||||
net.ipv6.conf.lo.accept_ra = 1
|
||||
net.ipv6.conf.lo.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.lo.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.lo.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.lo.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.lo.accept_redirects = 1
|
||||
net.ipv6.conf.lo.accept_source_route = 0
|
||||
net.ipv6.conf.lo.autoconf = 1
|
||||
net.ipv6.conf.lo.dad_transmits = 1
|
||||
net.ipv6.conf.lo.disable_ipv6 = 0
|
||||
net.ipv6.conf.lo.enhanced_dad = 1
|
||||
net.ipv6.conf.lo.force_mld_version = 0
|
||||
net.ipv6.conf.lo.force_tllao = 0
|
||||
net.ipv6.conf.lo.forwarding = 0
|
||||
net.ipv6.conf.lo.hop_limit = 64
|
||||
net.ipv6.conf.lo.keep_addr_on_down = 0
|
||||
net.ipv6.conf.lo.max_addresses = 16
|
||||
net.ipv6.conf.lo.max_desync_factor = 600
|
||||
net.ipv6.conf.lo.mc_forwarding = 0
|
||||
net.ipv6.conf.lo.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.lo.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.lo.mtu = 65536
|
||||
net.ipv6.conf.lo.ndisc_notify = 0
|
||||
net.ipv6.conf.lo.optimistic_dad = 0
|
||||
net.ipv6.conf.lo.proxy_ndp = 0
|
||||
net.ipv6.conf.lo.regen_max_retry = 3
|
||||
net.ipv6.conf.lo.router_probe_interval = 60
|
||||
net.ipv6.conf.lo.router_solicitation_delay = 1
|
||||
net.ipv6.conf.lo.router_solicitation_interval = 4
|
||||
net.ipv6.conf.lo.router_solicitations = 3
|
||||
net.ipv6.conf.lo.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.lo.temp_valid_lft = 604800
|
||||
net.ipv6.conf.lo.use_optimistic = 0
|
||||
net.ipv6.conf.lo.use_tempaddr = -1
|
||||
net.ipv6.fwmark_reflect = 0
|
||||
net.ipv6.icmp.ratelimit = 1000
|
||||
net.ipv6.idgen_delay = 1
|
||||
net.ipv6.idgen_retries = 3
|
||||
net.ipv6.ip6frag_high_thresh = 4194304
|
||||
net.ipv6.ip6frag_low_thresh = 3145728
|
||||
net.ipv6.ip6frag_secret_interval = 600
|
||||
net.ipv6.ip6frag_time = 60
|
||||
net.ipv6.ip_nonlocal_bind = 0
|
||||
net.ipv6.mld_max_msf = 64
|
||||
net.ipv6.mld_qrv = 2
|
||||
net.ipv6.neigh.default.anycast_delay = 100
|
||||
net.ipv6.neigh.default.app_solicit = 0
|
||||
net.ipv6.neigh.default.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.default.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.default.gc_interval = 30
|
||||
net.ipv6.neigh.default.gc_stale_time = 60
|
||||
net.ipv6.neigh.default.gc_thresh1 = 128
|
||||
net.ipv6.neigh.default.gc_thresh2 = 512
|
||||
net.ipv6.neigh.default.gc_thresh3 = 1024
|
||||
net.ipv6.neigh.default.locktime = 0
|
||||
net.ipv6.neigh.default.mcast_solicit = 3
|
||||
net.ipv6.neigh.default.proxy_delay = 80
|
||||
net.ipv6.neigh.default.proxy_qlen = 64
|
||||
net.ipv6.neigh.default.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.default.ucast_solicit = 3
|
||||
net.ipv6.neigh.default.unres_qlen = 31
|
||||
net.ipv6.neigh.default.unres_qlen_bytes = 65536
|
||||
net.ipv6.neigh.docker0.anycast_delay = 100
|
||||
net.ipv6.neigh.docker0.app_solicit = 0
|
||||
net.ipv6.neigh.docker0.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.docker0.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.docker0.gc_stale_time = 60
|
||||
net.ipv6.neigh.docker0.locktime = 0
|
||||
net.ipv6.neigh.docker0.mcast_solicit = 3
|
||||
net.ipv6.neigh.docker0.proxy_delay = 80
|
||||
net.ipv6.neigh.docker0.proxy_qlen = 64
|
||||
net.ipv6.neigh.docker0.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.docker0.ucast_solicit = 3
|
||||
net.ipv6.neigh.docker0.unres_qlen = 31
|
||||
net.ipv6.neigh.docker0.unres_qlen_bytes = 65536
|
||||
net.ipv6.neigh.ens33.anycast_delay = 100
|
||||
net.ipv6.neigh.ens33.app_solicit = 0
|
||||
net.ipv6.neigh.ens33.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.ens33.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.ens33.gc_stale_time = 60
|
||||
net.ipv6.neigh.ens33.locktime = 0
|
||||
net.ipv6.neigh.ens33.mcast_solicit = 3
|
||||
net.ipv6.neigh.ens33.proxy_delay = 80
|
||||
net.ipv6.neigh.ens33.proxy_qlen = 64
|
||||
net.ipv6.neigh.ens33.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.ens33.ucast_solicit = 3
|
||||
net.ipv6.neigh.ens33.unres_qlen = 31
|
||||
net.ipv6.neigh.ens33.unres_qlen_bytes = 65536
|
||||
net.ipv6.neigh.lo.anycast_delay = 100
|
||||
net.ipv6.neigh.lo.app_solicit = 0
|
||||
net.ipv6.neigh.lo.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.lo.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.lo.gc_stale_time = 60
|
||||
net.ipv6.neigh.lo.locktime = 0
|
||||
net.ipv6.neigh.lo.mcast_solicit = 3
|
||||
net.ipv6.neigh.lo.proxy_delay = 80
|
||||
net.ipv6.neigh.lo.proxy_qlen = 64
|
||||
net.ipv6.neigh.lo.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.lo.ucast_solicit = 3
|
||||
net.ipv6.neigh.lo.unres_qlen = 31
|
||||
net.ipv6.neigh.lo.unres_qlen_bytes = 65536
|
||||
net.ipv6.route.gc_elasticity = 9
|
||||
net.ipv6.route.gc_interval = 30
|
||||
net.ipv6.route.gc_min_interval = 0
|
||||
net.ipv6.route.gc_min_interval_ms = 500
|
||||
net.ipv6.route.gc_thresh = 1024
|
||||
net.ipv6.route.gc_timeout = 60
|
||||
net.ipv6.route.max_size = 16384
|
||||
net.ipv6.route.min_adv_mss = 1220
|
||||
net.ipv6.route.mtu_expires = 600
|
||||
net.ipv6.xfrm6_gc_thresh = 32768
|
||||
net.netfilter.nf_conntrack_acct = 0
|
||||
net.netfilter.nf_conntrack_buckets = 16384
|
||||
net.netfilter.nf_conntrack_checksum = 1
|
||||
net.netfilter.nf_conntrack_count = 2
|
||||
net.netfilter.nf_conntrack_dccp_loose = 1
|
||||
net.netfilter.nf_conntrack_dccp_timeout_closereq = 64
|
||||
net.netfilter.nf_conntrack_dccp_timeout_closing = 64
|
||||
net.netfilter.nf_conntrack_dccp_timeout_open = 43200
|
||||
net.netfilter.nf_conntrack_dccp_timeout_partopen = 480
|
||||
net.netfilter.nf_conntrack_dccp_timeout_request = 240
|
||||
net.netfilter.nf_conntrack_dccp_timeout_respond = 480
|
||||
net.netfilter.nf_conntrack_dccp_timeout_timewait = 240
|
||||
net.netfilter.nf_conntrack_events = 1
|
||||
net.netfilter.nf_conntrack_events_retry_timeout = 15
|
||||
net.netfilter.nf_conntrack_expect_max = 256
|
||||
net.netfilter.nf_conntrack_frag6_high_thresh = 4194304
|
||||
net.netfilter.nf_conntrack_frag6_low_thresh = 3145728
|
||||
net.netfilter.nf_conntrack_frag6_timeout = 60
|
||||
net.netfilter.nf_conntrack_generic_timeout = 600
|
||||
net.netfilter.nf_conntrack_helper = 1
|
||||
net.netfilter.nf_conntrack_icmp_timeout = 30
|
||||
net.netfilter.nf_conntrack_icmpv6_timeout = 30
|
||||
net.netfilter.nf_conntrack_log_invalid = 0
|
||||
net.netfilter.nf_conntrack_max = 65536
|
||||
net.netfilter.nf_conntrack_sctp_timeout_closed = 10
|
||||
net.netfilter.nf_conntrack_sctp_timeout_cookie_echoed = 3
|
||||
net.netfilter.nf_conntrack_sctp_timeout_cookie_wait = 3
|
||||
net.netfilter.nf_conntrack_sctp_timeout_established = 432000
|
||||
net.netfilter.nf_conntrack_sctp_timeout_heartbeat_acked = 210
|
||||
net.netfilter.nf_conntrack_sctp_timeout_heartbeat_sent = 30
|
||||
net.netfilter.nf_conntrack_sctp_timeout_shutdown_ack_sent = 3
|
||||
net.netfilter.nf_conntrack_sctp_timeout_shutdown_recd = 0
|
||||
net.netfilter.nf_conntrack_sctp_timeout_shutdown_sent = 0
|
||||
net.netfilter.nf_conntrack_tcp_be_liberal = 0
|
||||
net.netfilter.nf_conntrack_tcp_loose = 1
|
||||
net.netfilter.nf_conntrack_tcp_max_retrans = 3
|
||||
net.netfilter.nf_conntrack_tcp_timeout_close = 10
|
||||
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
|
||||
net.netfilter.nf_conntrack_tcp_timeout_established = 432000
|
||||
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
|
||||
net.netfilter.nf_conntrack_tcp_timeout_last_ack = 30
|
||||
net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300
|
||||
net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 60
|
||||
net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 120
|
||||
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
|
||||
net.netfilter.nf_conntrack_tcp_timeout_unacknowledged = 300
|
||||
net.netfilter.nf_conntrack_timestamp = 0
|
||||
net.netfilter.nf_conntrack_udp_timeout = 30
|
||||
net.netfilter.nf_conntrack_udp_timeout_stream = 180
|
||||
net.netfilter.nf_log.0 = NONE
|
||||
net.netfilter.nf_log.1 = NONE
|
||||
net.netfilter.nf_log.10 = NONE
|
||||
net.netfilter.nf_log.11 = NONE
|
||||
net.netfilter.nf_log.12 = NONE
|
||||
net.netfilter.nf_log.2 = NONE
|
||||
net.netfilter.nf_log.3 = NONE
|
||||
net.netfilter.nf_log.4 = NONE
|
||||
net.netfilter.nf_log.5 = NONE
|
||||
net.netfilter.nf_log.6 = NONE
|
||||
net.netfilter.nf_log.7 = NONE
|
||||
net.netfilter.nf_log.8 = NONE
|
||||
net.netfilter.nf_log.9 = NONE
|
||||
net.netfilter.nf_log_all_netns = 0
|
||||
net.nf_conntrack_max = 65536
|
||||
net.unix.max_dgram_qlen = 512
|
||||
user.max_ipc_namespaces = 14990
|
||||
user.max_mnt_namespaces = 14990
|
||||
user.max_net_namespaces = 14990
|
||||
user.max_pid_namespaces = 14990
|
||||
user.max_user_namespaces = 0
|
||||
user.max_uts_namespaces = 14990
|
||||
vm.admin_reserve_kbytes = 8192
|
||||
vm.block_dump = 0
|
||||
vm.dirty_background_bytes = 0
|
||||
vm.dirty_background_ratio = 10
|
||||
vm.dirty_bytes = 0
|
||||
vm.dirty_expire_centisecs = 3000
|
||||
vm.dirty_ratio = 30
|
||||
vm.dirty_writeback_centisecs = 500
|
||||
vm.drop_caches = 0
|
||||
vm.extfrag_threshold = 500
|
||||
vm.hugepages_treat_as_movable = 0
|
||||
vm.hugetlb_shm_group = 0
|
||||
vm.laptop_mode = 0
|
||||
vm.legacy_va_layout = 0
|
||||
vm.lowmem_reserve_ratio = 256 256 32
|
||||
vm.max_map_count = 65530
|
||||
vm.memory_failure_early_kill = 0
|
||||
vm.memory_failure_recovery = 1
|
||||
vm.min_free_kbytes = 67584
|
||||
vm.min_slab_ratio = 5
|
||||
vm.min_unmapped_ratio = 1
|
||||
vm.mmap_min_addr = 4096
|
||||
vm.nr_hugepages = 0
|
||||
vm.nr_hugepages_mempolicy = 0
|
||||
vm.nr_overcommit_hugepages = 0
|
||||
vm.nr_pdflush_threads = 0
|
||||
vm.numa_zonelist_order = default
|
||||
vm.oom_dump_tasks = 1
|
||||
vm.oom_kill_allocating_task = 0
|
||||
vm.overcommit_kbytes = 0
|
||||
vm.overcommit_memory = 0
|
||||
vm.overcommit_ratio = 50
|
||||
vm.page-cluster = 3
|
||||
vm.panic_on_oom = 0
|
||||
vm.percpu_pagelist_fraction = 0
|
||||
vm.stat_interval = 1
|
||||
vm.swappiness = 30
|
||||
vm.user_reserve_kbytes = 117506
|
||||
vm.vfs_cache_pressure = 100
|
||||
vm.zone_reclaim_mode = 0
|
||||
1
tests/fixtures/freebsd12/sysctl-a.json
vendored
Normal file
1
tests/fixtures/freebsd12/sysctl-a.json
vendored
Normal file
File diff suppressed because one or more lines are too long
3783
tests/fixtures/freebsd12/sysctl-a.out
vendored
Normal file
3783
tests/fixtures/freebsd12/sysctl-a.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/nixos/route-ee.json
vendored
Normal file
1
tests/fixtures/nixos/route-ee.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"destination": "default", "gateway": "_gateway", "genmask": "0.0.0.0", "flags": "UG", "metric": 202, "ref": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "flags": "U", "metric": 202, "ref": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "flags_pretty": ["UP"]}]
|
||||
4
tests/fixtures/nixos/route-ee.out
vendored
Normal file
4
tests/fixtures/nixos/route-ee.out
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Kernel IP routing table
|
||||
Destination Gateway Genmask Flags Metric Ref Use Iface MSS Window irtt
|
||||
default _gateway 0.0.0.0 UG 202 0 0 ens33 0 0 0
|
||||
192.168.71.0 0.0.0.0 255.255.255.0 U 202 0 0 ens33 0 0 0
|
||||
1
tests/fixtures/osx-10.14.6/sysctl-a.json
vendored
Normal file
1
tests/fixtures/osx-10.14.6/sysctl-a.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1287
tests/fixtures/osx-10.14.6/sysctl-a.out
vendored
Normal file
1287
tests/fixtures/osx-10.14.6/sysctl-a.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
[{"chain": "INPUT", "rules": [{"num": 1, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 2, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 3, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"num": 4, "target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"num": 5, "target": "DROP", "prot": "all", "opt": null, "source": "15.15.15.51", "destination": "anywhere"}, {"num": 6, "target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}]
|
||||
[{"chain": "INPUT", "rules": [{"num": 1, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 2, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 3, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"num": 4, "target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"num": 5, "target": "DROP", "prot": "all", "opt": null, "source": "15.15.15.51", "destination": "anywhere"}, {"num": 6, "target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}, {"chain": "OUTPUT", "rules": [{"num": 1, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 2, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate ESTABLISHED"}, {"num": 3, "target": "ACCEPT", "prot": "tcp", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "tcp spt:ssh ctstate ESTABLISHED"}]}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"chain": "INPUT", "rules": [{"pkts": 66, "bytes": 6034, "target": "ACCEPT", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 1137, "bytes": 318000, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate RELATED,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate INVALID"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "15.15.15.0/24", "destination": "0.0.0.0/0", "options": "tcp dpt:22 ctstate NEW,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate RELATED,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate INVALID"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "15.15.15.0/24", "destination": "0.0.0.0/0", "options": "tcp dpt:22 ctstate NEW,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate RELATED,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate INVALID"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "15.15.15.51", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "15.15.15.0/24", "destination": "0.0.0.0/0", "options": "tcp dpt:22 ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}]
|
||||
[{"chain": "INPUT", "rules": [{"pkts": 66, "bytes": 6034, "target": "ACCEPT", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 1137, "bytes": 318000, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate RELATED,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate INVALID"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "15.15.15.0/24", "destination": "0.0.0.0/0", "options": "tcp dpt:22 ctstate NEW,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate RELATED,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate INVALID"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "15.15.15.0/24", "destination": "0.0.0.0/0", "options": "tcp dpt:22 ctstate NEW,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate RELATED,ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate INVALID"}, {"pkts": 0, "bytes": 0, "target": "DROP", "prot": "all", "opt": null, "in": "lo", "out": "*", "source": "15.15.15.51", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "15.15.15.0/24", "destination": "0.0.0.0/0", "options": "tcp dpt:22 ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}, {"chain": "OUTPUT", "rules": [{"pkts": 66, "bytes": 6034, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "lo", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 889, "bytes": 158000, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "tcp spt:22 ctstate ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "lo", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "tcp spt:22 ctstate ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "lo", "source": "0.0.0.0/0", "destination": "0.0.0.0/0"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "all", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "ctstate ESTABLISHED"}, {"pkts": 0, "bytes": 0, "target": "ACCEPT", "prot": "tcp", "opt": null, "in": "*", "out": "*", "source": "0.0.0.0/0", "destination": "0.0.0.0/0", "options": "tcp spt:22 ctstate ESTABLISHED"}]}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"chain": "INPUT", "rules": [{"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"target": "DROP", "prot": "all", "opt": null, "source": "15.15.15.51", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}]
|
||||
[{"chain": "INPUT", "rules": [{"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"target": "DROP", "prot": "all", "opt": null, "source": "15.15.15.51", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}, {"chain": "OUTPUT", "rules": [{"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate ESTABLISHED"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "tcp spt:ssh ctstate ESTABLISHED"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate ESTABLISHED"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "tcp spt:ssh ctstate ESTABLISHED"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate ESTABLISHED"}, {"target": "ACCEPT", "prot": "tcp", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "tcp spt:ssh ctstate ESTABLISHED"}]}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"chain": "PREROUTING", "rules": []}, {"chain": "INPUT", "rules": []}, {"chain": "FORWARD", "rules": []}, {"chain": "OUTPUT", "rules": []}]
|
||||
[{"chain": "PREROUTING", "rules": []}, {"chain": "INPUT", "rules": []}, {"chain": "FORWARD", "rules": []}, {"chain": "OUTPUT", "rules": []}, {"chain": "POSTROUTING", "rules": []}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"chain": "PREROUTING", "rules": []}, {"chain": "INPUT", "rules": []}, {"chain": "OUTPUT", "rules": []}]
|
||||
[{"chain": "PREROUTING", "rules": []}, {"chain": "INPUT", "rules": []}, {"chain": "OUTPUT", "rules": []}, {"chain": "POSTROUTING", "rules": []}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"chain": "PREROUTING", "rules": []}]
|
||||
[{"chain": "PREROUTING", "rules": []}, {"chain": "OUTPUT", "rules": []}]
|
||||
|
||||
2
tests/fixtures/ubuntu-18.04/ss-sudo-a.json
vendored
2
tests/fixtures/ubuntu-18.04/ss-sudo-a.json
vendored
File diff suppressed because one or more lines are too long
1
tests/fixtures/ubuntu-18.04/sysctl-a.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/sysctl-a.json
vendored
Normal file
File diff suppressed because one or more lines are too long
878
tests/fixtures/ubuntu-18.04/sysctl-a.out
vendored
Normal file
878
tests/fixtures/ubuntu-18.04/sysctl-a.out
vendored
Normal file
@@ -0,0 +1,878 @@
|
||||
abi.vsyscall32 = 1
|
||||
debug.exception-trace = 1
|
||||
debug.kprobes-optimization = 1
|
||||
dev.cdrom.autoclose = 1
|
||||
dev.cdrom.autoeject = 0
|
||||
dev.cdrom.check_media = 0
|
||||
dev.cdrom.debug = 0
|
||||
dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.20 2003/12/17
|
||||
dev.cdrom.info =
|
||||
dev.cdrom.info = drive name: sr1 sr0
|
||||
dev.cdrom.info = drive speed: 1 1
|
||||
dev.cdrom.info = drive # of slots: 1 1
|
||||
dev.cdrom.info = Can close tray: 1 1
|
||||
dev.cdrom.info = Can open tray: 1 1
|
||||
dev.cdrom.info = Can lock tray: 1 1
|
||||
dev.cdrom.info = Can change speed: 1 1
|
||||
dev.cdrom.info = Can select disk: 0 0
|
||||
dev.cdrom.info = Can read multisession: 1 1
|
||||
dev.cdrom.info = Can read MCN: 1 1
|
||||
dev.cdrom.info = Reports media changed: 1 1
|
||||
dev.cdrom.info = Can play audio: 1 1
|
||||
dev.cdrom.info = Can write CD-R: 1 1
|
||||
dev.cdrom.info = Can write CD-RW: 1 1
|
||||
dev.cdrom.info = Can read DVD: 1 1
|
||||
dev.cdrom.info = Can write DVD-R: 1 1
|
||||
dev.cdrom.info = Can write DVD-RAM: 1 1
|
||||
dev.cdrom.info = Can read MRW: 1 1
|
||||
dev.cdrom.info = Can write MRW: 1 1
|
||||
dev.cdrom.info = Can write RAM: 1 1
|
||||
dev.cdrom.info =
|
||||
dev.cdrom.info =
|
||||
dev.cdrom.lock = 0
|
||||
dev.hpet.max-user-freq = 64
|
||||
dev.mac_hid.mouse_button2_keycode = 97
|
||||
dev.mac_hid.mouse_button3_keycode = 100
|
||||
dev.mac_hid.mouse_button_emulation = 0
|
||||
dev.raid.speed_limit_max = 200000
|
||||
dev.raid.speed_limit_min = 1000
|
||||
dev.scsi.logging_level = 0
|
||||
dev.tty.ldisc_autoload = 1
|
||||
fs.aio-max-nr = 65536
|
||||
fs.aio-nr = 0
|
||||
fs.binfmt_misc.status = enabled
|
||||
fs.dentry-state = 46910 16600 45 0 0 0
|
||||
fs.dir-notify-enable = 1
|
||||
fs.epoll.max_user_watches = 400302
|
||||
fs.file-max = 194386
|
||||
fs.file-nr = 1024 0 194386
|
||||
fs.inode-nr = 51130 7369
|
||||
fs.inode-state = 51130 7369 0 0 0 0 0
|
||||
fs.inotify.max_queued_events = 16384
|
||||
fs.inotify.max_user_instances = 1024
|
||||
fs.inotify.max_user_watches = 8192
|
||||
fs.lease-break-time = 45
|
||||
fs.leases-enable = 1
|
||||
fs.mount-max = 100000
|
||||
fs.mqueue.msg_default = 10
|
||||
fs.mqueue.msg_max = 10
|
||||
fs.mqueue.msgsize_default = 8192
|
||||
fs.mqueue.msgsize_max = 8192
|
||||
fs.mqueue.queues_max = 256
|
||||
fs.nr_open = 1048576
|
||||
fs.overflowgid = 65534
|
||||
fs.overflowuid = 65534
|
||||
fs.pipe-max-size = 1048576
|
||||
fs.pipe-user-pages-hard = 0
|
||||
fs.pipe-user-pages-soft = 16384
|
||||
fs.quota.allocated_dquots = 0
|
||||
fs.quota.cache_hits = 0
|
||||
fs.quota.drops = 0
|
||||
fs.quota.free_dquots = 0
|
||||
fs.quota.lookups = 0
|
||||
fs.quota.reads = 0
|
||||
fs.quota.syncs = 78
|
||||
fs.quota.writes = 0
|
||||
fs.suid_dumpable = 2
|
||||
fs.xfs.error_level = 3
|
||||
fs.xfs.filestream_centisecs = 3000
|
||||
fs.xfs.inherit_noatime = 1
|
||||
fs.xfs.inherit_nodefrag = 1
|
||||
fs.xfs.inherit_nodump = 1
|
||||
fs.xfs.inherit_nosymlinks = 0
|
||||
fs.xfs.inherit_sync = 1
|
||||
fs.xfs.irix_sgid_inherit = 0
|
||||
fs.xfs.irix_symlink_mode = 0
|
||||
fs.xfs.panic_mask = 0
|
||||
fs.xfs.rotorstep = 1
|
||||
fs.xfs.speculative_cow_prealloc_lifetime = 1800
|
||||
fs.xfs.speculative_prealloc_lifetime = 300
|
||||
fs.xfs.stats_clear = 0
|
||||
fs.xfs.xfssyncd_centisecs = 3000
|
||||
kernel.acct = 4 2 30
|
||||
kernel.acpi_video_flags = 0
|
||||
kernel.auto_msgmni = 0
|
||||
kernel.bootloader_type = 114
|
||||
kernel.bootloader_version = 2
|
||||
kernel.cap_last_cap = 37
|
||||
kernel.core_pattern = |/usr/share/apport/apport %p %s %c %d %P %E
|
||||
kernel.core_pipe_limit = 0
|
||||
kernel.core_uses_pid = 0
|
||||
kernel.ctrl-alt-del = 0
|
||||
kernel.dmesg_restrict = 0
|
||||
kernel.domainname = (none)
|
||||
kernel.ftrace_dump_on_oops = 0
|
||||
kernel.ftrace_enabled = 1
|
||||
kernel.hardlockup_all_cpu_backtrace = 0
|
||||
kernel.hardlockup_panic = 0
|
||||
kernel.hostname = kbrazil-ubuntu
|
||||
kernel.hotplug =
|
||||
kernel.hung_task_check_count = 4194304
|
||||
kernel.hung_task_panic = 0
|
||||
kernel.hung_task_timeout_secs = 120
|
||||
kernel.hung_task_warnings = 10
|
||||
kernel.io_delay_type = 1
|
||||
kernel.kexec_load_disabled = 0
|
||||
kernel.keys.gc_delay = 300
|
||||
kernel.keys.maxbytes = 20000
|
||||
kernel.keys.maxkeys = 200
|
||||
kernel.keys.persistent_keyring_expiry = 259200
|
||||
kernel.keys.root_maxbytes = 25000000
|
||||
kernel.keys.root_maxkeys = 1000000
|
||||
kernel.kptr_restrict = 1
|
||||
kernel.max_lock_depth = 1024
|
||||
kernel.modprobe = /sbin/modprobe
|
||||
kernel.modules_disabled = 0
|
||||
kernel.msg_next_id = -1
|
||||
kernel.msgmax = 8192
|
||||
kernel.msgmnb = 16384
|
||||
kernel.msgmni = 32000
|
||||
kernel.ngroups_max = 65536
|
||||
kernel.nmi_watchdog = 0
|
||||
kernel.ns_last_pid = 23649
|
||||
kernel.numa_balancing = 0
|
||||
kernel.numa_balancing_scan_delay_ms = 1000
|
||||
kernel.numa_balancing_scan_period_max_ms = 60000
|
||||
kernel.numa_balancing_scan_period_min_ms = 1000
|
||||
kernel.numa_balancing_scan_size_mb = 256
|
||||
kernel.osrelease = 4.15.0-101-generic
|
||||
kernel.ostype = Linux
|
||||
kernel.overflowgid = 65534
|
||||
kernel.overflowuid = 65534
|
||||
kernel.panic = 0
|
||||
kernel.panic_on_io_nmi = 0
|
||||
kernel.panic_on_oops = 0
|
||||
kernel.panic_on_rcu_stall = 0
|
||||
kernel.panic_on_unrecovered_nmi = 0
|
||||
kernel.panic_on_warn = 0
|
||||
kernel.perf_cpu_time_max_percent = 25
|
||||
kernel.perf_event_max_contexts_per_stack = 8
|
||||
kernel.perf_event_max_sample_rate = 100000
|
||||
kernel.perf_event_max_stack = 127
|
||||
kernel.perf_event_mlock_kb = 516
|
||||
kernel.perf_event_paranoid = 3
|
||||
kernel.pid_max = 131072
|
||||
kernel.poweroff_cmd = /sbin/poweroff
|
||||
kernel.print-fatal-signals = 0
|
||||
kernel.printk = 4 4 1 7
|
||||
kernel.printk_delay = 0
|
||||
kernel.printk_devkmsg = ratelimit
|
||||
kernel.printk_ratelimit = 5
|
||||
kernel.printk_ratelimit_burst = 10
|
||||
kernel.pty.max = 4096
|
||||
kernel.pty.nr = 0
|
||||
kernel.pty.reserve = 1024
|
||||
kernel.random.boot_id = cf190d28-d4c9-4d52-8f8a-ce556669abf5
|
||||
kernel.random.entropy_avail = 565
|
||||
kernel.random.poolsize = 4096
|
||||
kernel.random.read_wakeup_threshold = 64
|
||||
kernel.random.urandom_min_reseed_secs = 60
|
||||
kernel.random.uuid = 7100e887-f0ae-450e-b9c3-972bb4f7f30f
|
||||
kernel.random.write_wakeup_threshold = 896
|
||||
kernel.randomize_va_space = 2
|
||||
kernel.real-root-dev = 0
|
||||
kernel.sched_autogroup_enabled = 1
|
||||
kernel.sched_cfs_bandwidth_slice_us = 5000
|
||||
kernel.sched_child_runs_first = 0
|
||||
kernel.sched_latency_ns = 6000000
|
||||
kernel.sched_migration_cost_ns = 500000
|
||||
kernel.sched_min_granularity_ns = 750000
|
||||
kernel.sched_nr_migrate = 32
|
||||
kernel.sched_rr_timeslice_ms = 100
|
||||
kernel.sched_rt_period_us = 1000000
|
||||
kernel.sched_rt_runtime_us = 950000
|
||||
kernel.sched_schedstats = 0
|
||||
kernel.sched_time_avg_ms = 1000
|
||||
kernel.sched_tunable_scaling = 1
|
||||
kernel.sched_wakeup_granularity_ns = 1000000
|
||||
kernel.seccomp.actions_avail = kill_process kill_thread trap errno trace log allow
|
||||
kernel.seccomp.actions_logged = kill_process kill_thread trap errno trace log
|
||||
kernel.sem = 32000 1024000000 500 32000
|
||||
kernel.sem_next_id = -1
|
||||
kernel.sg-big-buff = 32768
|
||||
kernel.shm_next_id = -1
|
||||
kernel.shm_rmid_forced = 0
|
||||
kernel.shmall = 18446744073692774399
|
||||
kernel.shmmax = 18446744073692774399
|
||||
kernel.shmmni = 4096
|
||||
kernel.soft_watchdog = 1
|
||||
kernel.softlockup_all_cpu_backtrace = 0
|
||||
kernel.softlockup_panic = 0
|
||||
kernel.stack_tracer_enabled = 0
|
||||
kernel.sysctl_writes_strict = 1
|
||||
kernel.sysrq = 176
|
||||
kernel.tainted = 0
|
||||
kernel.threads-max = 15270
|
||||
kernel.timer_migration = 1
|
||||
kernel.traceoff_on_warning = 0
|
||||
kernel.tracepoint_printk = 0
|
||||
kernel.unknown_nmi_panic = 0
|
||||
kernel.unprivileged_bpf_disabled = 0
|
||||
kernel.unprivileged_userns_clone = 1
|
||||
kernel.version = #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020
|
||||
kernel.watchdog = 1
|
||||
kernel.watchdog_cpumask = 0-127
|
||||
kernel.watchdog_thresh = 10
|
||||
kernel.yama.ptrace_scope = 1
|
||||
net.core.bpf_jit_enable = 1
|
||||
net.core.busy_poll = 0
|
||||
net.core.busy_read = 0
|
||||
net.core.default_qdisc = fq_codel
|
||||
net.core.dev_weight = 64
|
||||
net.core.dev_weight_rx_bias = 1
|
||||
net.core.dev_weight_tx_bias = 1
|
||||
net.core.flow_limit_cpu_bitmap = 00000000,00000000,00000000,00000000
|
||||
net.core.flow_limit_table_len = 4096
|
||||
net.core.max_skb_frags = 17
|
||||
net.core.message_burst = 10
|
||||
net.core.message_cost = 5
|
||||
net.core.netdev_budget = 300
|
||||
net.core.netdev_budget_usecs = 2000
|
||||
net.core.netdev_max_backlog = 1000
|
||||
net.core.netdev_rss_key = 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
|
||||
net.core.netdev_tstamp_prequeue = 1
|
||||
net.core.optmem_max = 20480
|
||||
net.core.rmem_default = 212992
|
||||
net.core.rmem_max = 212992
|
||||
net.core.rps_sock_flow_entries = 0
|
||||
net.core.somaxconn = 128
|
||||
net.core.tstamp_allow_data = 1
|
||||
net.core.warnings = 0
|
||||
net.core.wmem_default = 212992
|
||||
net.core.wmem_max = 212992
|
||||
net.core.xfrm_acq_expires = 30
|
||||
net.core.xfrm_aevent_etime = 10
|
||||
net.core.xfrm_aevent_rseqth = 2
|
||||
net.core.xfrm_larval_drop = 1
|
||||
net.ipv4.cipso_cache_bucket_size = 10
|
||||
net.ipv4.cipso_cache_enable = 1
|
||||
net.ipv4.cipso_rbm_optfmt = 0
|
||||
net.ipv4.cipso_rbm_strictvalid = 1
|
||||
net.ipv4.conf.all.accept_local = 0
|
||||
net.ipv4.conf.all.accept_redirects = 1
|
||||
net.ipv4.conf.all.accept_source_route = 0
|
||||
net.ipv4.conf.all.arp_accept = 0
|
||||
net.ipv4.conf.all.arp_announce = 0
|
||||
net.ipv4.conf.all.arp_filter = 0
|
||||
net.ipv4.conf.all.arp_ignore = 0
|
||||
net.ipv4.conf.all.arp_notify = 0
|
||||
net.ipv4.conf.all.bootp_relay = 0
|
||||
net.ipv4.conf.all.disable_policy = 0
|
||||
net.ipv4.conf.all.disable_xfrm = 0
|
||||
net.ipv4.conf.all.drop_gratuitous_arp = 0
|
||||
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv4.conf.all.force_igmp_version = 0
|
||||
net.ipv4.conf.all.forwarding = 0
|
||||
net.ipv4.conf.all.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.all.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.all.ignore_routes_with_linkdown = 0
|
||||
net.ipv4.conf.all.log_martians = 0
|
||||
net.ipv4.conf.all.mc_forwarding = 0
|
||||
net.ipv4.conf.all.medium_id = 0
|
||||
net.ipv4.conf.all.promote_secondaries = 1
|
||||
net.ipv4.conf.all.proxy_arp = 0
|
||||
net.ipv4.conf.all.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.all.route_localnet = 0
|
||||
net.ipv4.conf.all.rp_filter = 1
|
||||
net.ipv4.conf.all.secure_redirects = 1
|
||||
net.ipv4.conf.all.send_redirects = 1
|
||||
net.ipv4.conf.all.shared_media = 1
|
||||
net.ipv4.conf.all.src_valid_mark = 0
|
||||
net.ipv4.conf.all.tag = 0
|
||||
net.ipv4.conf.default.accept_local = 0
|
||||
net.ipv4.conf.default.accept_redirects = 1
|
||||
net.ipv4.conf.default.accept_source_route = 1
|
||||
net.ipv4.conf.default.arp_accept = 0
|
||||
net.ipv4.conf.default.arp_announce = 0
|
||||
net.ipv4.conf.default.arp_filter = 0
|
||||
net.ipv4.conf.default.arp_ignore = 0
|
||||
net.ipv4.conf.default.arp_notify = 0
|
||||
net.ipv4.conf.default.bootp_relay = 0
|
||||
net.ipv4.conf.default.disable_policy = 0
|
||||
net.ipv4.conf.default.disable_xfrm = 0
|
||||
net.ipv4.conf.default.drop_gratuitous_arp = 0
|
||||
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv4.conf.default.force_igmp_version = 0
|
||||
net.ipv4.conf.default.forwarding = 0
|
||||
net.ipv4.conf.default.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.default.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.default.ignore_routes_with_linkdown = 0
|
||||
net.ipv4.conf.default.log_martians = 0
|
||||
net.ipv4.conf.default.mc_forwarding = 0
|
||||
net.ipv4.conf.default.medium_id = 0
|
||||
net.ipv4.conf.default.promote_secondaries = 0
|
||||
net.ipv4.conf.default.proxy_arp = 0
|
||||
net.ipv4.conf.default.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.default.route_localnet = 0
|
||||
net.ipv4.conf.default.rp_filter = 1
|
||||
net.ipv4.conf.default.secure_redirects = 1
|
||||
net.ipv4.conf.default.send_redirects = 1
|
||||
net.ipv4.conf.default.shared_media = 1
|
||||
net.ipv4.conf.default.src_valid_mark = 0
|
||||
net.ipv4.conf.default.tag = 0
|
||||
net.ipv4.conf.ens33.accept_local = 0
|
||||
net.ipv4.conf.ens33.accept_redirects = 1
|
||||
net.ipv4.conf.ens33.accept_source_route = 1
|
||||
net.ipv4.conf.ens33.arp_accept = 0
|
||||
net.ipv4.conf.ens33.arp_announce = 0
|
||||
net.ipv4.conf.ens33.arp_filter = 0
|
||||
net.ipv4.conf.ens33.arp_ignore = 0
|
||||
net.ipv4.conf.ens33.arp_notify = 0
|
||||
net.ipv4.conf.ens33.bootp_relay = 0
|
||||
net.ipv4.conf.ens33.disable_policy = 0
|
||||
net.ipv4.conf.ens33.disable_xfrm = 0
|
||||
net.ipv4.conf.ens33.drop_gratuitous_arp = 0
|
||||
net.ipv4.conf.ens33.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv4.conf.ens33.force_igmp_version = 0
|
||||
net.ipv4.conf.ens33.forwarding = 0
|
||||
net.ipv4.conf.ens33.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.ens33.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.ens33.ignore_routes_with_linkdown = 0
|
||||
net.ipv4.conf.ens33.log_martians = 0
|
||||
net.ipv4.conf.ens33.mc_forwarding = 0
|
||||
net.ipv4.conf.ens33.medium_id = 0
|
||||
net.ipv4.conf.ens33.promote_secondaries = 0
|
||||
net.ipv4.conf.ens33.proxy_arp = 0
|
||||
net.ipv4.conf.ens33.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.ens33.route_localnet = 0
|
||||
net.ipv4.conf.ens33.rp_filter = 1
|
||||
net.ipv4.conf.ens33.secure_redirects = 1
|
||||
net.ipv4.conf.ens33.send_redirects = 1
|
||||
net.ipv4.conf.ens33.shared_media = 1
|
||||
net.ipv4.conf.ens33.src_valid_mark = 0
|
||||
net.ipv4.conf.ens33.tag = 0
|
||||
net.ipv4.conf.lo.accept_local = 0
|
||||
net.ipv4.conf.lo.accept_redirects = 1
|
||||
net.ipv4.conf.lo.accept_source_route = 1
|
||||
net.ipv4.conf.lo.arp_accept = 0
|
||||
net.ipv4.conf.lo.arp_announce = 0
|
||||
net.ipv4.conf.lo.arp_filter = 0
|
||||
net.ipv4.conf.lo.arp_ignore = 0
|
||||
net.ipv4.conf.lo.arp_notify = 0
|
||||
net.ipv4.conf.lo.bootp_relay = 0
|
||||
net.ipv4.conf.lo.disable_policy = 1
|
||||
net.ipv4.conf.lo.disable_xfrm = 1
|
||||
net.ipv4.conf.lo.drop_gratuitous_arp = 0
|
||||
net.ipv4.conf.lo.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv4.conf.lo.force_igmp_version = 0
|
||||
net.ipv4.conf.lo.forwarding = 0
|
||||
net.ipv4.conf.lo.igmpv2_unsolicited_report_interval = 10000
|
||||
net.ipv4.conf.lo.igmpv3_unsolicited_report_interval = 1000
|
||||
net.ipv4.conf.lo.ignore_routes_with_linkdown = 0
|
||||
net.ipv4.conf.lo.log_martians = 0
|
||||
net.ipv4.conf.lo.mc_forwarding = 0
|
||||
net.ipv4.conf.lo.medium_id = 0
|
||||
net.ipv4.conf.lo.promote_secondaries = 0
|
||||
net.ipv4.conf.lo.proxy_arp = 0
|
||||
net.ipv4.conf.lo.proxy_arp_pvlan = 0
|
||||
net.ipv4.conf.lo.route_localnet = 0
|
||||
net.ipv4.conf.lo.rp_filter = 0
|
||||
net.ipv4.conf.lo.secure_redirects = 1
|
||||
net.ipv4.conf.lo.send_redirects = 1
|
||||
net.ipv4.conf.lo.shared_media = 1
|
||||
net.ipv4.conf.lo.src_valid_mark = 0
|
||||
net.ipv4.conf.lo.tag = 0
|
||||
net.ipv4.fib_multipath_hash_policy = 0
|
||||
net.ipv4.fib_multipath_use_neigh = 0
|
||||
net.ipv4.fwmark_reflect = 0
|
||||
net.ipv4.icmp_echo_ignore_all = 0
|
||||
net.ipv4.icmp_echo_ignore_broadcasts = 1
|
||||
net.ipv4.icmp_errors_use_inbound_ifaddr = 0
|
||||
net.ipv4.icmp_ignore_bogus_error_responses = 1
|
||||
net.ipv4.icmp_msgs_burst = 50
|
||||
net.ipv4.icmp_msgs_per_sec = 1000
|
||||
net.ipv4.icmp_ratelimit = 1000
|
||||
net.ipv4.icmp_ratemask = 6168
|
||||
net.ipv4.igmp_link_local_mcast_reports = 1
|
||||
net.ipv4.igmp_max_memberships = 20
|
||||
net.ipv4.igmp_max_msf = 10
|
||||
net.ipv4.igmp_qrv = 2
|
||||
net.ipv4.inet_peer_maxttl = 600
|
||||
net.ipv4.inet_peer_minttl = 120
|
||||
net.ipv4.inet_peer_threshold = 65664
|
||||
net.ipv4.ip_default_ttl = 64
|
||||
net.ipv4.ip_dynaddr = 0
|
||||
net.ipv4.ip_early_demux = 1
|
||||
net.ipv4.ip_forward = 0
|
||||
net.ipv4.ip_forward_use_pmtu = 0
|
||||
net.ipv4.ip_local_port_range = 32768 60999
|
||||
net.ipv4.ip_local_reserved_ports =
|
||||
net.ipv4.ip_no_pmtu_disc = 0
|
||||
net.ipv4.ip_nonlocal_bind = 0
|
||||
net.ipv4.ip_unprivileged_port_start = 1024
|
||||
net.ipv4.ipfrag_high_thresh = 262144
|
||||
net.ipv4.ipfrag_low_thresh = 196608
|
||||
net.ipv4.ipfrag_max_dist = 64
|
||||
net.ipv4.ipfrag_secret_interval = 0
|
||||
net.ipv4.ipfrag_time = 30
|
||||
net.ipv4.neigh.default.anycast_delay = 100
|
||||
net.ipv4.neigh.default.app_solicit = 0
|
||||
net.ipv4.neigh.default.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.default.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.default.gc_interval = 30
|
||||
net.ipv4.neigh.default.gc_stale_time = 60
|
||||
net.ipv4.neigh.default.gc_thresh1 = 128
|
||||
net.ipv4.neigh.default.gc_thresh2 = 512
|
||||
net.ipv4.neigh.default.gc_thresh3 = 1024
|
||||
net.ipv4.neigh.default.locktime = 100
|
||||
net.ipv4.neigh.default.mcast_resolicit = 0
|
||||
net.ipv4.neigh.default.mcast_solicit = 3
|
||||
net.ipv4.neigh.default.proxy_delay = 80
|
||||
net.ipv4.neigh.default.proxy_qlen = 64
|
||||
net.ipv4.neigh.default.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.default.ucast_solicit = 3
|
||||
net.ipv4.neigh.default.unres_qlen = 101
|
||||
net.ipv4.neigh.default.unres_qlen_bytes = 212992
|
||||
net.ipv4.neigh.ens33.anycast_delay = 100
|
||||
net.ipv4.neigh.ens33.app_solicit = 0
|
||||
net.ipv4.neigh.ens33.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.ens33.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.ens33.gc_stale_time = 60
|
||||
net.ipv4.neigh.ens33.locktime = 100
|
||||
net.ipv4.neigh.ens33.mcast_resolicit = 0
|
||||
net.ipv4.neigh.ens33.mcast_solicit = 3
|
||||
net.ipv4.neigh.ens33.proxy_delay = 80
|
||||
net.ipv4.neigh.ens33.proxy_qlen = 64
|
||||
net.ipv4.neigh.ens33.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.ens33.ucast_solicit = 3
|
||||
net.ipv4.neigh.ens33.unres_qlen = 101
|
||||
net.ipv4.neigh.ens33.unres_qlen_bytes = 212992
|
||||
net.ipv4.neigh.lo.anycast_delay = 100
|
||||
net.ipv4.neigh.lo.app_solicit = 0
|
||||
net.ipv4.neigh.lo.base_reachable_time_ms = 30000
|
||||
net.ipv4.neigh.lo.delay_first_probe_time = 5
|
||||
net.ipv4.neigh.lo.gc_stale_time = 60
|
||||
net.ipv4.neigh.lo.locktime = 100
|
||||
net.ipv4.neigh.lo.mcast_resolicit = 0
|
||||
net.ipv4.neigh.lo.mcast_solicit = 3
|
||||
net.ipv4.neigh.lo.proxy_delay = 80
|
||||
net.ipv4.neigh.lo.proxy_qlen = 64
|
||||
net.ipv4.neigh.lo.retrans_time_ms = 1000
|
||||
net.ipv4.neigh.lo.ucast_solicit = 3
|
||||
net.ipv4.neigh.lo.unres_qlen = 101
|
||||
net.ipv4.neigh.lo.unres_qlen_bytes = 212992
|
||||
net.ipv4.ping_group_range = 1 0
|
||||
net.ipv4.route.error_burst = 1250
|
||||
net.ipv4.route.error_cost = 250
|
||||
net.ipv4.route.gc_elasticity = 8
|
||||
net.ipv4.route.gc_interval = 60
|
||||
net.ipv4.route.gc_min_interval = 0
|
||||
net.ipv4.route.gc_min_interval_ms = 500
|
||||
net.ipv4.route.gc_thresh = -1
|
||||
net.ipv4.route.gc_timeout = 300
|
||||
net.ipv4.route.max_size = 2147483647
|
||||
net.ipv4.route.min_adv_mss = 256
|
||||
net.ipv4.route.min_pmtu = 552
|
||||
net.ipv4.route.mtu_expires = 600
|
||||
net.ipv4.route.redirect_load = 5
|
||||
net.ipv4.route.redirect_number = 9
|
||||
net.ipv4.route.redirect_silence = 5120
|
||||
net.ipv4.tcp_abort_on_overflow = 0
|
||||
net.ipv4.tcp_adv_win_scale = 1
|
||||
net.ipv4.tcp_allowed_congestion_control = reno cubic
|
||||
net.ipv4.tcp_app_win = 31
|
||||
net.ipv4.tcp_autocorking = 1
|
||||
net.ipv4.tcp_available_congestion_control = reno cubic
|
||||
net.ipv4.tcp_available_ulp =
|
||||
net.ipv4.tcp_base_mss = 1024
|
||||
net.ipv4.tcp_challenge_ack_limit = 1000
|
||||
net.ipv4.tcp_congestion_control = cubic
|
||||
net.ipv4.tcp_dsack = 1
|
||||
net.ipv4.tcp_early_demux = 1
|
||||
net.ipv4.tcp_early_retrans = 3
|
||||
net.ipv4.tcp_ecn = 2
|
||||
net.ipv4.tcp_ecn_fallback = 1
|
||||
net.ipv4.tcp_fack = 0
|
||||
net.ipv4.tcp_fastopen = 1
|
||||
net.ipv4.tcp_fastopen_blackhole_timeout_sec = 3600
|
||||
net.ipv4.tcp_fin_timeout = 60
|
||||
net.ipv4.tcp_frto = 2
|
||||
net.ipv4.tcp_fwmark_accept = 0
|
||||
net.ipv4.tcp_invalid_ratelimit = 500
|
||||
net.ipv4.tcp_keepalive_intvl = 75
|
||||
net.ipv4.tcp_keepalive_probes = 9
|
||||
net.ipv4.tcp_keepalive_time = 7200
|
||||
net.ipv4.tcp_l3mdev_accept = 0
|
||||
net.ipv4.tcp_limit_output_bytes = 262144
|
||||
net.ipv4.tcp_low_latency = 0
|
||||
net.ipv4.tcp_max_orphans = 8192
|
||||
net.ipv4.tcp_max_reordering = 300
|
||||
net.ipv4.tcp_max_syn_backlog = 128
|
||||
net.ipv4.tcp_max_tw_buckets = 8192
|
||||
net.ipv4.tcp_mem = 22113 29485 44226
|
||||
net.ipv4.tcp_min_rtt_wlen = 300
|
||||
net.ipv4.tcp_min_snd_mss = 48
|
||||
net.ipv4.tcp_min_tso_segs = 2
|
||||
net.ipv4.tcp_moderate_rcvbuf = 1
|
||||
net.ipv4.tcp_mtu_probing = 0
|
||||
net.ipv4.tcp_no_metrics_save = 0
|
||||
net.ipv4.tcp_notsent_lowat = 4294967295
|
||||
net.ipv4.tcp_orphan_retries = 0
|
||||
net.ipv4.tcp_pacing_ca_ratio = 120
|
||||
net.ipv4.tcp_pacing_ss_ratio = 200
|
||||
net.ipv4.tcp_probe_interval = 600
|
||||
net.ipv4.tcp_probe_threshold = 8
|
||||
net.ipv4.tcp_recovery = 1
|
||||
net.ipv4.tcp_reordering = 3
|
||||
net.ipv4.tcp_retrans_collapse = 1
|
||||
net.ipv4.tcp_retries1 = 3
|
||||
net.ipv4.tcp_retries2 = 15
|
||||
net.ipv4.tcp_rfc1337 = 0
|
||||
net.ipv4.tcp_rmem = 4096 131072 6291456
|
||||
net.ipv4.tcp_sack = 1
|
||||
net.ipv4.tcp_slow_start_after_idle = 1
|
||||
net.ipv4.tcp_stdurg = 0
|
||||
net.ipv4.tcp_syn_retries = 6
|
||||
net.ipv4.tcp_synack_retries = 5
|
||||
net.ipv4.tcp_syncookies = 1
|
||||
net.ipv4.tcp_thin_linear_timeouts = 0
|
||||
net.ipv4.tcp_timestamps = 1
|
||||
net.ipv4.tcp_tso_win_divisor = 3
|
||||
net.ipv4.tcp_tw_reuse = 0
|
||||
net.ipv4.tcp_window_scaling = 1
|
||||
net.ipv4.tcp_wmem = 4096 16384 4194304
|
||||
net.ipv4.tcp_workaround_signed_windows = 0
|
||||
net.ipv4.udp_early_demux = 1
|
||||
net.ipv4.udp_l3mdev_accept = 0
|
||||
net.ipv4.udp_mem = 44226 58970 88452
|
||||
net.ipv4.udp_rmem_min = 4096
|
||||
net.ipv4.udp_wmem_min = 4096
|
||||
net.ipv4.xfrm4_gc_thresh = 32768
|
||||
net.ipv6.anycast_src_echo_reply = 0
|
||||
net.ipv6.auto_flowlabels = 1
|
||||
net.ipv6.bindv6only = 0
|
||||
net.ipv6.calipso_cache_bucket_size = 10
|
||||
net.ipv6.calipso_cache_enable = 1
|
||||
net.ipv6.conf.all.accept_dad = 0
|
||||
net.ipv6.conf.all.accept_ra = 1
|
||||
net.ipv6.conf.all.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.all.accept_ra_from_local = 0
|
||||
net.ipv6.conf.all.accept_ra_min_hop_limit = 1
|
||||
net.ipv6.conf.all.accept_ra_mtu = 1
|
||||
net.ipv6.conf.all.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.all.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.all.accept_ra_rt_info_min_plen = 0
|
||||
net.ipv6.conf.all.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.all.accept_redirects = 1
|
||||
net.ipv6.conf.all.accept_source_route = 0
|
||||
net.ipv6.conf.all.addr_gen_mode = 0
|
||||
net.ipv6.conf.all.autoconf = 1
|
||||
net.ipv6.conf.all.dad_transmits = 1
|
||||
net.ipv6.conf.all.disable_ipv6 = 0
|
||||
net.ipv6.conf.all.disable_policy = 0
|
||||
net.ipv6.conf.all.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv6.conf.all.drop_unsolicited_na = 0
|
||||
net.ipv6.conf.all.enhanced_dad = 1
|
||||
net.ipv6.conf.all.force_mld_version = 0
|
||||
net.ipv6.conf.all.force_tllao = 0
|
||||
net.ipv6.conf.all.forwarding = 0
|
||||
net.ipv6.conf.all.hop_limit = 64
|
||||
net.ipv6.conf.all.ignore_routes_with_linkdown = 0
|
||||
net.ipv6.conf.all.keep_addr_on_down = 0
|
||||
net.ipv6.conf.all.max_addresses = 16
|
||||
net.ipv6.conf.all.max_desync_factor = 600
|
||||
net.ipv6.conf.all.mc_forwarding = 0
|
||||
net.ipv6.conf.all.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.all.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.all.mtu = 1280
|
||||
net.ipv6.conf.all.ndisc_notify = 0
|
||||
net.ipv6.conf.all.ndisc_tclass = 0
|
||||
net.ipv6.conf.all.proxy_ndp = 0
|
||||
net.ipv6.conf.all.regen_max_retry = 3
|
||||
net.ipv6.conf.all.router_probe_interval = 60
|
||||
net.ipv6.conf.all.router_solicitation_delay = 1
|
||||
net.ipv6.conf.all.router_solicitation_interval = 4
|
||||
net.ipv6.conf.all.router_solicitation_max_interval = 3600
|
||||
net.ipv6.conf.all.router_solicitations = -1
|
||||
net.ipv6.conf.all.seg6_enabled = 0
|
||||
net.ipv6.conf.all.seg6_require_hmac = 0
|
||||
net.ipv6.conf.all.suppress_frag_ndisc = 1
|
||||
net.ipv6.conf.all.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.all.temp_valid_lft = 604800
|
||||
net.ipv6.conf.all.use_oif_addrs_only = 0
|
||||
net.ipv6.conf.all.use_tempaddr = 0
|
||||
net.ipv6.conf.default.accept_dad = 1
|
||||
net.ipv6.conf.default.accept_ra = 1
|
||||
net.ipv6.conf.default.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.default.accept_ra_from_local = 0
|
||||
net.ipv6.conf.default.accept_ra_min_hop_limit = 1
|
||||
net.ipv6.conf.default.accept_ra_mtu = 1
|
||||
net.ipv6.conf.default.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.default.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.default.accept_ra_rt_info_min_plen = 0
|
||||
net.ipv6.conf.default.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.default.accept_redirects = 1
|
||||
net.ipv6.conf.default.accept_source_route = 0
|
||||
net.ipv6.conf.default.addr_gen_mode = 0
|
||||
net.ipv6.conf.default.autoconf = 1
|
||||
net.ipv6.conf.default.dad_transmits = 1
|
||||
net.ipv6.conf.default.disable_ipv6 = 0
|
||||
net.ipv6.conf.default.disable_policy = 0
|
||||
net.ipv6.conf.default.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv6.conf.default.drop_unsolicited_na = 0
|
||||
net.ipv6.conf.default.enhanced_dad = 1
|
||||
net.ipv6.conf.default.force_mld_version = 0
|
||||
net.ipv6.conf.default.force_tllao = 0
|
||||
net.ipv6.conf.default.forwarding = 0
|
||||
net.ipv6.conf.default.hop_limit = 64
|
||||
net.ipv6.conf.default.ignore_routes_with_linkdown = 0
|
||||
net.ipv6.conf.default.keep_addr_on_down = 0
|
||||
net.ipv6.conf.default.max_addresses = 16
|
||||
net.ipv6.conf.default.max_desync_factor = 600
|
||||
net.ipv6.conf.default.mc_forwarding = 0
|
||||
net.ipv6.conf.default.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.default.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.default.mtu = 1280
|
||||
net.ipv6.conf.default.ndisc_notify = 0
|
||||
net.ipv6.conf.default.ndisc_tclass = 0
|
||||
net.ipv6.conf.default.proxy_ndp = 0
|
||||
net.ipv6.conf.default.regen_max_retry = 3
|
||||
net.ipv6.conf.default.router_probe_interval = 60
|
||||
net.ipv6.conf.default.router_solicitation_delay = 1
|
||||
net.ipv6.conf.default.router_solicitation_interval = 4
|
||||
net.ipv6.conf.default.router_solicitation_max_interval = 3600
|
||||
net.ipv6.conf.default.router_solicitations = -1
|
||||
net.ipv6.conf.default.seg6_enabled = 0
|
||||
net.ipv6.conf.default.seg6_require_hmac = 0
|
||||
net.ipv6.conf.default.suppress_frag_ndisc = 1
|
||||
net.ipv6.conf.default.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.default.temp_valid_lft = 604800
|
||||
net.ipv6.conf.default.use_oif_addrs_only = 0
|
||||
net.ipv6.conf.default.use_tempaddr = 0
|
||||
net.ipv6.conf.ens33.accept_dad = 1
|
||||
net.ipv6.conf.ens33.accept_ra = 0
|
||||
net.ipv6.conf.ens33.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.ens33.accept_ra_from_local = 0
|
||||
net.ipv6.conf.ens33.accept_ra_min_hop_limit = 1
|
||||
net.ipv6.conf.ens33.accept_ra_mtu = 1
|
||||
net.ipv6.conf.ens33.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.ens33.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.ens33.accept_ra_rt_info_min_plen = 0
|
||||
net.ipv6.conf.ens33.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.ens33.accept_redirects = 1
|
||||
net.ipv6.conf.ens33.accept_source_route = 0
|
||||
net.ipv6.conf.ens33.addr_gen_mode = 0
|
||||
net.ipv6.conf.ens33.autoconf = 1
|
||||
net.ipv6.conf.ens33.dad_transmits = 1
|
||||
net.ipv6.conf.ens33.disable_ipv6 = 0
|
||||
net.ipv6.conf.ens33.disable_policy = 0
|
||||
net.ipv6.conf.ens33.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv6.conf.ens33.drop_unsolicited_na = 0
|
||||
net.ipv6.conf.ens33.enhanced_dad = 1
|
||||
net.ipv6.conf.ens33.force_mld_version = 0
|
||||
net.ipv6.conf.ens33.force_tllao = 0
|
||||
net.ipv6.conf.ens33.forwarding = 0
|
||||
net.ipv6.conf.ens33.hop_limit = 64
|
||||
net.ipv6.conf.ens33.ignore_routes_with_linkdown = 0
|
||||
net.ipv6.conf.ens33.keep_addr_on_down = 0
|
||||
net.ipv6.conf.ens33.max_addresses = 16
|
||||
net.ipv6.conf.ens33.max_desync_factor = 600
|
||||
net.ipv6.conf.ens33.mc_forwarding = 0
|
||||
net.ipv6.conf.ens33.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.ens33.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.ens33.mtu = 1500
|
||||
net.ipv6.conf.ens33.ndisc_notify = 0
|
||||
net.ipv6.conf.ens33.ndisc_tclass = 0
|
||||
net.ipv6.conf.ens33.proxy_ndp = 0
|
||||
net.ipv6.conf.ens33.regen_max_retry = 3
|
||||
net.ipv6.conf.ens33.router_probe_interval = 60
|
||||
net.ipv6.conf.ens33.router_solicitation_delay = 1
|
||||
net.ipv6.conf.ens33.router_solicitation_interval = 4
|
||||
net.ipv6.conf.ens33.router_solicitation_max_interval = 3600
|
||||
net.ipv6.conf.ens33.router_solicitations = -1
|
||||
net.ipv6.conf.ens33.seg6_enabled = 0
|
||||
net.ipv6.conf.ens33.seg6_require_hmac = 0
|
||||
net.ipv6.conf.ens33.suppress_frag_ndisc = 1
|
||||
net.ipv6.conf.ens33.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.ens33.temp_valid_lft = 604800
|
||||
net.ipv6.conf.ens33.use_oif_addrs_only = 0
|
||||
net.ipv6.conf.ens33.use_tempaddr = 0
|
||||
net.ipv6.conf.lo.accept_dad = -1
|
||||
net.ipv6.conf.lo.accept_ra = 1
|
||||
net.ipv6.conf.lo.accept_ra_defrtr = 1
|
||||
net.ipv6.conf.lo.accept_ra_from_local = 0
|
||||
net.ipv6.conf.lo.accept_ra_min_hop_limit = 1
|
||||
net.ipv6.conf.lo.accept_ra_mtu = 1
|
||||
net.ipv6.conf.lo.accept_ra_pinfo = 1
|
||||
net.ipv6.conf.lo.accept_ra_rt_info_max_plen = 0
|
||||
net.ipv6.conf.lo.accept_ra_rt_info_min_plen = 0
|
||||
net.ipv6.conf.lo.accept_ra_rtr_pref = 1
|
||||
net.ipv6.conf.lo.accept_redirects = 1
|
||||
net.ipv6.conf.lo.accept_source_route = 0
|
||||
net.ipv6.conf.lo.addr_gen_mode = 0
|
||||
net.ipv6.conf.lo.autoconf = 1
|
||||
net.ipv6.conf.lo.dad_transmits = 1
|
||||
net.ipv6.conf.lo.disable_ipv6 = 0
|
||||
net.ipv6.conf.lo.disable_policy = 0
|
||||
net.ipv6.conf.lo.drop_unicast_in_l2_multicast = 0
|
||||
net.ipv6.conf.lo.drop_unsolicited_na = 0
|
||||
net.ipv6.conf.lo.enhanced_dad = 1
|
||||
net.ipv6.conf.lo.force_mld_version = 0
|
||||
net.ipv6.conf.lo.force_tllao = 0
|
||||
net.ipv6.conf.lo.forwarding = 0
|
||||
net.ipv6.conf.lo.hop_limit = 64
|
||||
net.ipv6.conf.lo.ignore_routes_with_linkdown = 0
|
||||
net.ipv6.conf.lo.keep_addr_on_down = 0
|
||||
net.ipv6.conf.lo.max_addresses = 16
|
||||
net.ipv6.conf.lo.max_desync_factor = 600
|
||||
net.ipv6.conf.lo.mc_forwarding = 0
|
||||
net.ipv6.conf.lo.mldv1_unsolicited_report_interval = 10000
|
||||
net.ipv6.conf.lo.mldv2_unsolicited_report_interval = 1000
|
||||
net.ipv6.conf.lo.mtu = 65536
|
||||
net.ipv6.conf.lo.ndisc_notify = 0
|
||||
net.ipv6.conf.lo.ndisc_tclass = 0
|
||||
net.ipv6.conf.lo.proxy_ndp = 0
|
||||
net.ipv6.conf.lo.regen_max_retry = 3
|
||||
net.ipv6.conf.lo.router_probe_interval = 60
|
||||
net.ipv6.conf.lo.router_solicitation_delay = 1
|
||||
net.ipv6.conf.lo.router_solicitation_interval = 4
|
||||
net.ipv6.conf.lo.router_solicitation_max_interval = 3600
|
||||
net.ipv6.conf.lo.router_solicitations = -1
|
||||
net.ipv6.conf.lo.seg6_enabled = 0
|
||||
net.ipv6.conf.lo.seg6_require_hmac = 0
|
||||
net.ipv6.conf.lo.suppress_frag_ndisc = 1
|
||||
net.ipv6.conf.lo.temp_prefered_lft = 86400
|
||||
net.ipv6.conf.lo.temp_valid_lft = 604800
|
||||
net.ipv6.conf.lo.use_oif_addrs_only = 0
|
||||
net.ipv6.conf.lo.use_tempaddr = -1
|
||||
net.ipv6.flowlabel_consistency = 1
|
||||
net.ipv6.flowlabel_reflect = 0
|
||||
net.ipv6.flowlabel_state_ranges = 0
|
||||
net.ipv6.fwmark_reflect = 0
|
||||
net.ipv6.icmp.ratelimit = 1000
|
||||
net.ipv6.idgen_delay = 1
|
||||
net.ipv6.idgen_retries = 3
|
||||
net.ipv6.ip6frag_high_thresh = 262144
|
||||
net.ipv6.ip6frag_low_thresh = 196608
|
||||
net.ipv6.ip6frag_secret_interval = 0
|
||||
net.ipv6.ip6frag_time = 60
|
||||
net.ipv6.ip_nonlocal_bind = 0
|
||||
net.ipv6.max_dst_opts_length = 2147483647
|
||||
net.ipv6.max_dst_opts_number = 8
|
||||
net.ipv6.max_hbh_length = 2147483647
|
||||
net.ipv6.max_hbh_opts_number = 8
|
||||
net.ipv6.mld_max_msf = 64
|
||||
net.ipv6.mld_qrv = 2
|
||||
net.ipv6.neigh.default.anycast_delay = 100
|
||||
net.ipv6.neigh.default.app_solicit = 0
|
||||
net.ipv6.neigh.default.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.default.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.default.gc_interval = 30
|
||||
net.ipv6.neigh.default.gc_stale_time = 60
|
||||
net.ipv6.neigh.default.gc_thresh1 = 128
|
||||
net.ipv6.neigh.default.gc_thresh2 = 512
|
||||
net.ipv6.neigh.default.gc_thresh3 = 1024
|
||||
net.ipv6.neigh.default.locktime = 0
|
||||
net.ipv6.neigh.default.mcast_resolicit = 0
|
||||
net.ipv6.neigh.default.mcast_solicit = 3
|
||||
net.ipv6.neigh.default.proxy_delay = 80
|
||||
net.ipv6.neigh.default.proxy_qlen = 64
|
||||
net.ipv6.neigh.default.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.default.ucast_solicit = 3
|
||||
net.ipv6.neigh.default.unres_qlen = 101
|
||||
net.ipv6.neigh.default.unres_qlen_bytes = 212992
|
||||
net.ipv6.neigh.ens33.anycast_delay = 100
|
||||
net.ipv6.neigh.ens33.app_solicit = 0
|
||||
net.ipv6.neigh.ens33.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.ens33.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.ens33.gc_stale_time = 60
|
||||
net.ipv6.neigh.ens33.locktime = 0
|
||||
net.ipv6.neigh.ens33.mcast_resolicit = 0
|
||||
net.ipv6.neigh.ens33.mcast_solicit = 3
|
||||
net.ipv6.neigh.ens33.proxy_delay = 80
|
||||
net.ipv6.neigh.ens33.proxy_qlen = 64
|
||||
net.ipv6.neigh.ens33.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.ens33.ucast_solicit = 3
|
||||
net.ipv6.neigh.ens33.unres_qlen = 101
|
||||
net.ipv6.neigh.ens33.unres_qlen_bytes = 212992
|
||||
net.ipv6.neigh.lo.anycast_delay = 100
|
||||
net.ipv6.neigh.lo.app_solicit = 0
|
||||
net.ipv6.neigh.lo.base_reachable_time_ms = 30000
|
||||
net.ipv6.neigh.lo.delay_first_probe_time = 5
|
||||
net.ipv6.neigh.lo.gc_stale_time = 60
|
||||
net.ipv6.neigh.lo.locktime = 0
|
||||
net.ipv6.neigh.lo.mcast_resolicit = 0
|
||||
net.ipv6.neigh.lo.mcast_solicit = 3
|
||||
net.ipv6.neigh.lo.proxy_delay = 80
|
||||
net.ipv6.neigh.lo.proxy_qlen = 64
|
||||
net.ipv6.neigh.lo.retrans_time_ms = 1000
|
||||
net.ipv6.neigh.lo.ucast_solicit = 3
|
||||
net.ipv6.neigh.lo.unres_qlen = 101
|
||||
net.ipv6.neigh.lo.unres_qlen_bytes = 212992
|
||||
net.ipv6.route.gc_elasticity = 9
|
||||
net.ipv6.route.gc_interval = 30
|
||||
net.ipv6.route.gc_min_interval = 0
|
||||
net.ipv6.route.gc_min_interval_ms = 500
|
||||
net.ipv6.route.gc_thresh = 1024
|
||||
net.ipv6.route.gc_timeout = 60
|
||||
net.ipv6.route.max_size = 4096
|
||||
net.ipv6.route.min_adv_mss = 1220
|
||||
net.ipv6.route.mtu_expires = 600
|
||||
net.ipv6.xfrm6_gc_thresh = 32768
|
||||
net.iw_cm.default_backlog = 256
|
||||
net.netfilter.nf_log.0 = NONE
|
||||
net.netfilter.nf_log.1 = NONE
|
||||
net.netfilter.nf_log.10 = NONE
|
||||
net.netfilter.nf_log.11 = NONE
|
||||
net.netfilter.nf_log.12 = NONE
|
||||
net.netfilter.nf_log.2 = NONE
|
||||
net.netfilter.nf_log.3 = NONE
|
||||
net.netfilter.nf_log.4 = NONE
|
||||
net.netfilter.nf_log.5 = NONE
|
||||
net.netfilter.nf_log.6 = NONE
|
||||
net.netfilter.nf_log.7 = NONE
|
||||
net.netfilter.nf_log.8 = NONE
|
||||
net.netfilter.nf_log.9 = NONE
|
||||
net.netfilter.nf_log_all_netns = 0
|
||||
net.unix.max_dgram_qlen = 512
|
||||
user.max_cgroup_namespaces = 7635
|
||||
user.max_inotify_instances = 1024
|
||||
user.max_inotify_watches = 8192
|
||||
user.max_ipc_namespaces = 7635
|
||||
user.max_mnt_namespaces = 7635
|
||||
user.max_net_namespaces = 7635
|
||||
user.max_pid_namespaces = 7635
|
||||
user.max_user_namespaces = 7635
|
||||
user.max_uts_namespaces = 7635
|
||||
vm.admin_reserve_kbytes = 8192
|
||||
vm.block_dump = 0
|
||||
vm.compact_unevictable_allowed = 1
|
||||
vm.dirty_background_bytes = 0
|
||||
vm.dirty_background_ratio = 10
|
||||
vm.dirty_bytes = 0
|
||||
vm.dirty_expire_centisecs = 3000
|
||||
vm.dirty_ratio = 20
|
||||
vm.dirty_writeback_centisecs = 500
|
||||
vm.dirtytime_expire_seconds = 43200
|
||||
vm.extfrag_threshold = 500
|
||||
vm.hugepages_treat_as_movable = 0
|
||||
vm.hugetlb_shm_group = 0
|
||||
vm.laptop_mode = 0
|
||||
vm.legacy_va_layout = 0
|
||||
vm.lowmem_reserve_ratio = 256 256 32 1
|
||||
vm.max_map_count = 65530
|
||||
vm.memory_failure_early_kill = 0
|
||||
vm.memory_failure_recovery = 1
|
||||
vm.min_free_kbytes = 45056
|
||||
vm.min_slab_ratio = 5
|
||||
vm.min_unmapped_ratio = 1
|
||||
vm.mmap_min_addr = 65536
|
||||
vm.nr_hugepages = 0
|
||||
vm.nr_hugepages_mempolicy = 0
|
||||
vm.nr_overcommit_hugepages = 0
|
||||
vm.numa_stat = 1
|
||||
vm.numa_zonelist_order = Node
|
||||
vm.oom_dump_tasks = 1
|
||||
vm.oom_kill_allocating_task = 0
|
||||
vm.overcommit_kbytes = 0
|
||||
vm.overcommit_memory = 0
|
||||
vm.overcommit_ratio = 50
|
||||
vm.page-cluster = 3
|
||||
vm.panic_on_oom = 0
|
||||
vm.percpu_pagelist_fraction = 0
|
||||
vm.stat_interval = 1
|
||||
vm.swappiness = 60
|
||||
vm.user_reserve_kbytes = 60643
|
||||
vm.vfs_cache_pressure = 100
|
||||
vm.watermark_scale_factor = 10
|
||||
vm.zone_reclaim_mode = 0
|
||||
@@ -17,6 +17,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/airport-I.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_10_14_6_airport_I_json = json.loads(f.read())
|
||||
|
||||
def test_airport_I_nodata(self):
|
||||
"""
|
||||
Test 'airport -I' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.airport.parse('', quiet=True), {})
|
||||
|
||||
def test_airport_I_osx_10_14_6(self):
|
||||
"""
|
||||
Test 'airport -I' on OSX 10.14.6
|
||||
|
||||
@@ -17,6 +17,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/airport-s.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_10_14_6_airport_s_json = json.loads(f.read())
|
||||
|
||||
def test_airport_s_nodata(self):
|
||||
"""
|
||||
Test 'airport -s' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.airport_s.parse('', quiet=True), [])
|
||||
|
||||
def test_airport_s_osx_10_14_6(self):
|
||||
"""
|
||||
Test 'airport -s' on OSX 10.14.6
|
||||
|
||||
@@ -71,6 +71,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/arp-a.json'), 'r', encoding='utf-8') as f:
|
||||
self.freebsd12_arp_a_json = json.loads(f.read())
|
||||
|
||||
def test_arp_nodata(self):
|
||||
"""
|
||||
Test 'arp' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.arp.parse('', quiet=True), [])
|
||||
|
||||
def test_arp_centos_7_7(self):
|
||||
"""
|
||||
Test 'arp' on Centos 7.7
|
||||
|
||||
@@ -71,6 +71,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/blkid-ip-udev-multi.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_blkid_ip_udev_multi_json = json.loads(f.read())
|
||||
|
||||
def test_blkid_nodata(self):
|
||||
"""
|
||||
Test 'blkid' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.blkid.parse('', quiet=True), [])
|
||||
|
||||
def test_blkid_centos_7_7(self):
|
||||
"""
|
||||
Test 'blkid' on Centos 7.7
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import unittest
|
||||
import pygments
|
||||
from pygments.token import (Name, Number, String, Keyword)
|
||||
import jc.cli
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
def test_cli(self):
|
||||
def test_cli_generate_magic_command(self):
|
||||
commands = {
|
||||
'jc -p systemctl list-sockets': 'systemctl list-sockets | jc --systemctl-ls -p',
|
||||
'jc -p systemctl list-unit-files': 'systemctl list-unit-files | jc --systemctl-luf -p',
|
||||
@@ -22,3 +24,156 @@ class MyTests(unittest.TestCase):
|
||||
|
||||
for command, expected_command in commands.items():
|
||||
self.assertEqual(jc.cli.generate_magic_command(command.split(' '))[1], expected_command)
|
||||
|
||||
def test_cli_set_env_colors(self):
|
||||
if pygments.__version__.startswith('2.3.'):
|
||||
env = {
|
||||
'': {
|
||||
Name.Tag: 'bold #ansidarkblue',
|
||||
Keyword: '#ansidarkgray',
|
||||
Number: '#ansipurple',
|
||||
String: '#ansidarkgreen'
|
||||
},
|
||||
' ': {
|
||||
Name.Tag: 'bold #ansidarkblue',
|
||||
Keyword: '#ansidarkgray',
|
||||
Number: '#ansipurple',
|
||||
String: '#ansidarkgreen'
|
||||
},
|
||||
'default,default,default,default': {
|
||||
Name.Tag: 'bold #ansidarkblue',
|
||||
Keyword: '#ansidarkgray',
|
||||
Number: '#ansipurple',
|
||||
String: '#ansidarkgreen'
|
||||
},
|
||||
'red,red,red,red': {
|
||||
Name.Tag: 'bold #ansidarkred',
|
||||
Keyword: '#ansidarkred',
|
||||
Number: '#ansidarkred',
|
||||
String: '#ansidarkred'
|
||||
},
|
||||
'red,red,yada,red': {
|
||||
Name.Tag: 'bold #ansidarkblue',
|
||||
Keyword: '#ansidarkgray',
|
||||
Number: '#ansipurple',
|
||||
String: '#ansidarkgreen'
|
||||
},
|
||||
'red,red,red': {
|
||||
Name.Tag: 'bold #ansidarkblue',
|
||||
Keyword: '#ansidarkgray',
|
||||
Number: '#ansipurple',
|
||||
String: '#ansidarkgreen'
|
||||
},
|
||||
'red,red,red,red,red,red': {
|
||||
Name.Tag: 'bold #ansidarkblue',
|
||||
Keyword: '#ansidarkgray',
|
||||
Number: '#ansipurple',
|
||||
String: '#ansidarkgreen'
|
||||
}
|
||||
}
|
||||
else:
|
||||
env = {
|
||||
'': {
|
||||
Name.Tag: 'bold ansiblue',
|
||||
Keyword: 'ansibrightblack',
|
||||
Number: 'ansimagenta',
|
||||
String: 'ansigreen'
|
||||
},
|
||||
' ': {
|
||||
Name.Tag: 'bold ansiblue',
|
||||
Keyword: 'ansibrightblack',
|
||||
Number: 'ansimagenta',
|
||||
String: 'ansigreen'
|
||||
},
|
||||
'default,default,default,default': {
|
||||
Name.Tag: 'bold ansiblue',
|
||||
Keyword: 'ansibrightblack',
|
||||
Number: 'ansimagenta',
|
||||
String: 'ansigreen'
|
||||
},
|
||||
'red,red,red,red': {
|
||||
Name.Tag: 'bold ansired',
|
||||
Keyword: 'ansired',
|
||||
Number: 'ansired',
|
||||
String: 'ansired'
|
||||
},
|
||||
'red,red,yada,red': {
|
||||
Name.Tag: 'bold ansiblue',
|
||||
Keyword: 'ansibrightblack',
|
||||
Number: 'ansimagenta',
|
||||
String: 'ansigreen'
|
||||
},
|
||||
'red,red,red': {
|
||||
Name.Tag: 'bold ansiblue',
|
||||
Keyword: 'ansibrightblack',
|
||||
Number: 'ansimagenta',
|
||||
String: 'ansigreen'
|
||||
},
|
||||
'red,red,red,red,red,red': {
|
||||
Name.Tag: 'bold ansiblue',
|
||||
Keyword: 'ansibrightblack',
|
||||
Number: 'ansimagenta',
|
||||
String: 'ansigreen'
|
||||
}
|
||||
}
|
||||
|
||||
for jc_colors, expected_colors in env.items():
|
||||
self.assertEqual(jc.cli.set_env_colors(jc_colors), expected_colors)
|
||||
|
||||
def test_cli_json_out(self):
|
||||
test_input = [
|
||||
None,
|
||||
{},
|
||||
[],
|
||||
'',
|
||||
{"key1": "value1", "key2": 2, "key3": None, "key4": 3.14, "key5": True},
|
||||
]
|
||||
|
||||
expected_output = [
|
||||
'\x1b[90mnull\x1b[39m',
|
||||
'{}',
|
||||
'[]',
|
||||
'\x1b[32m""\x1b[39m',
|
||||
'{\x1b[34;01m"key1"\x1b[39;00m: \x1b[32m"value1"\x1b[39m, \x1b[34;01m"key2"\x1b[39;00m: \x1b[35m2\x1b[39m, \x1b[34;01m"key3"\x1b[39;00m: \x1b[90mnull\x1b[39m, \x1b[34;01m"key4"\x1b[39;00m: \x1b[35m3.14\x1b[39m, \x1b[34;01m"key5"\x1b[39;00m: \x1b[90mtrue\x1b[39m}'
|
||||
]
|
||||
|
||||
for test_dict, expected_json in zip(test_input, expected_output):
|
||||
self.assertEqual(jc.cli.json_out(test_dict), expected_json)
|
||||
|
||||
def test_cli_json_out_mono(self):
|
||||
test_input = [
|
||||
None,
|
||||
{},
|
||||
[],
|
||||
'',
|
||||
{"key1": "value1", "key2": 2, "key3": None, "key4": 3.14, "key5": True},
|
||||
]
|
||||
|
||||
expected_output = [
|
||||
'null',
|
||||
'{}',
|
||||
'[]',
|
||||
'""',
|
||||
'{"key1": "value1", "key2": 2, "key3": null, "key4": 3.14, "key5": true}'
|
||||
]
|
||||
|
||||
for test_dict, expected_json in zip(test_input, expected_output):
|
||||
self.assertEqual(jc.cli.json_out(test_dict, mono=True), expected_json)
|
||||
|
||||
def test_cli_json_out_pretty(self):
|
||||
test_input = [
|
||||
{"key1": "value1", "key2": 2, "key3": None, "key4": 3.14, "key5": True},
|
||||
{"key1": [{"subkey1": "subvalue1"}, {"subkey2": [1, 2, 3]}], "key2": True}
|
||||
]
|
||||
|
||||
expected_output = [
|
||||
'{\n \x1b[34;01m"key1"\x1b[39;00m: \x1b[32m"value1"\x1b[39m,\n \x1b[34;01m"key2"\x1b[39;00m: \x1b[35m2\x1b[39m,\n \x1b[34;01m"key3"\x1b[39;00m: \x1b[90mnull\x1b[39m,\n \x1b[34;01m"key4"\x1b[39;00m: \x1b[35m3.14\x1b[39m,\n \x1b[34;01m"key5"\x1b[39;00m: \x1b[90mtrue\x1b[39m\n}',
|
||||
'{\n \x1b[34;01m"key1"\x1b[39;00m: [\n {\n \x1b[34;01m"subkey1"\x1b[39;00m: \x1b[32m"subvalue1"\x1b[39m\n },\n {\n \x1b[34;01m"subkey2"\x1b[39;00m: [\n \x1b[35m1\x1b[39m,\n \x1b[35m2\x1b[39m,\n \x1b[35m3\x1b[39m\n ]\n }\n ],\n \x1b[34;01m"key2"\x1b[39;00m: \x1b[90mtrue\x1b[39m\n}'
|
||||
]
|
||||
|
||||
for test_dict, expected_json in zip(test_input, expected_output):
|
||||
self.assertEqual(jc.cli.json_out(test_dict, pretty=True), expected_json)
|
||||
|
||||
def test_cli_about_jc(self):
|
||||
self.assertEqual(jc.cli.about_jc()['name'], 'jc')
|
||||
self.assertGreaterEqual(jc.cli.about_jc()['parser_count'], 50)
|
||||
|
||||
@@ -17,6 +17,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/crontab.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_crontab_json = json.loads(f.read())
|
||||
|
||||
def test_crontab_nodata(self):
|
||||
"""
|
||||
Test 'crontab' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.crontab.parse('', quiet=True), {})
|
||||
|
||||
def test_crontab_centos_7_7(self):
|
||||
"""
|
||||
Test 'crontab' on Centos 7.7
|
||||
|
||||
@@ -23,6 +23,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/crontab-u.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_crontab_u_json = json.loads(f.read())
|
||||
|
||||
def test_crontab_u_nodata(self):
|
||||
"""
|
||||
Test 'crontab' with no data (has a user field)
|
||||
"""
|
||||
self.assertEqual(jc.parsers.crontab_u.parse('', quiet=True), {})
|
||||
|
||||
def test_crontab_u_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'crontab' on Ubuntu 18.4 (has a user field)
|
||||
|
||||
@@ -65,6 +65,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_insurance_json = json.loads(f.read())
|
||||
|
||||
def test_csv_nodata(self):
|
||||
"""
|
||||
Test with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.csv.parse('', quiet=True), [])
|
||||
|
||||
def test_csv_biostats(self):
|
||||
"""
|
||||
Test 'biostats.csv' file
|
||||
|
||||
@@ -59,6 +59,12 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/df-h.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_10_14_6_df_h_json = json.loads(f.read())
|
||||
|
||||
def test_df_nodata(self):
|
||||
"""
|
||||
Test plain 'df' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.df.parse('', quiet=True), [])
|
||||
|
||||
def test_df_centos_7_7(self):
|
||||
"""
|
||||
Test plain 'df' on Centos 7.7
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user