mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-11 01:10:37 +02:00
add tune2fs parser
This commit is contained in:
@ -288,6 +288,7 @@ option.
|
|||||||
| `--top-s` | `top -b` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top_s) |
|
| `--top-s` | `top -b` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top_s) |
|
||||||
| `--tracepath` | `tracepath` and `tracepath6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
|
| `--tracepath` | `tracepath` and `tracepath6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
|
||||||
| `--traceroute` | `traceroute` and `traceroute6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
|
| `--traceroute` | `traceroute` and `traceroute6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
|
||||||
|
| `--tune2fs` | `tune2fs -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tune2fs) |
|
||||||
| `--udevadm` | `udevadm info` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/udevadm) |
|
| `--udevadm` | `udevadm info` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/udevadm) |
|
||||||
| `--ufw` | `ufw status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
| `--ufw` | `ufw status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
||||||
| `--ufw-appinfo` | `ufw app info [application]` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
|
| `--ufw-appinfo` | `ufw app info [application]` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
|
||||||
|
@ -3,8 +3,8 @@ _jc()
|
|||||||
local cur prev words cword jc_commands jc_parsers jc_options \
|
local cur prev words cword jc_commands jc_parsers jc_options \
|
||||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||||
|
|
||||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||||
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||||
jc_about_options=(--about -a)
|
jc_about_options=(--about -a)
|
||||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||||
|
@ -9,7 +9,7 @@ _jc() {
|
|||||||
jc_help_options jc_help_options_describe \
|
jc_help_options jc_help_options_describe \
|
||||||
jc_special_options jc_special_options_describe
|
jc_special_options jc_special_options_describe
|
||||||
|
|
||||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||||
jc_commands_describe=(
|
jc_commands_describe=(
|
||||||
'acpi:run "acpi" command with magic syntax.'
|
'acpi:run "acpi" command with magic syntax.'
|
||||||
'airport:run "airport" command with magic syntax.'
|
'airport:run "airport" command with magic syntax.'
|
||||||
@ -96,6 +96,7 @@ _jc() {
|
|||||||
'tracepath6:run "tracepath6" command with magic syntax.'
|
'tracepath6:run "tracepath6" command with magic syntax.'
|
||||||
'traceroute:run "traceroute" command with magic syntax.'
|
'traceroute:run "traceroute" command with magic syntax.'
|
||||||
'traceroute6:run "traceroute6" command with magic syntax.'
|
'traceroute6:run "traceroute6" command with magic syntax.'
|
||||||
|
'tune2fs:run "tune2fs" command with magic syntax.'
|
||||||
'udevadm:run "udevadm" command with magic syntax.'
|
'udevadm:run "udevadm" command with magic syntax.'
|
||||||
'ufw:run "ufw" command with magic syntax.'
|
'ufw:run "ufw" command with magic syntax.'
|
||||||
'uname:run "uname" command with magic syntax.'
|
'uname:run "uname" command with magic syntax.'
|
||||||
@ -112,7 +113,7 @@ _jc() {
|
|||||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||||
'zpool:run "zpool" command with magic syntax.'
|
'zpool:run "zpool" command with magic syntax.'
|
||||||
)
|
)
|
||||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||||
jc_parsers_describe=(
|
jc_parsers_describe=(
|
||||||
'--acpi:`acpi` command parser'
|
'--acpi:`acpi` command parser'
|
||||||
'--airport:`airport -I` command parser'
|
'--airport:`airport -I` command parser'
|
||||||
@ -295,6 +296,7 @@ _jc() {
|
|||||||
'--top-s:`top -b` command streaming parser'
|
'--top-s:`top -b` command streaming parser'
|
||||||
'--tracepath:`tracepath` and `tracepath6` command parser'
|
'--tracepath:`tracepath` and `tracepath6` command parser'
|
||||||
'--traceroute:`traceroute` and `traceroute6` command parser'
|
'--traceroute:`traceroute` and `traceroute6` command parser'
|
||||||
|
'--tune2fs:`tune2fs -l` command parser'
|
||||||
'--udevadm:`udevadm info` command parser'
|
'--udevadm:`udevadm info` command parser'
|
||||||
'--ufw:`ufw status` command parser'
|
'--ufw:`ufw status` command parser'
|
||||||
'--ufw-appinfo:`ufw app info [application]` command parser'
|
'--ufw-appinfo:`ufw app info [application]` command parser'
|
||||||
|
@ -194,6 +194,7 @@ parsers: List[str] = [
|
|||||||
'top-s',
|
'top-s',
|
||||||
'tracepath',
|
'tracepath',
|
||||||
'traceroute',
|
'traceroute',
|
||||||
|
'tune2fs',
|
||||||
'udevadm',
|
'udevadm',
|
||||||
'ufw',
|
'ufw',
|
||||||
'ufw-appinfo',
|
'ufw-appinfo',
|
||||||
|
299
jc/parsers/tune2fs.py
Normal file
299
jc/parsers/tune2fs.py
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
"""jc - JSON Convert `tune2fs -l` command output parser
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ tune2fs -l /dev/xvda4 | jc --tune2fs
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc tune2fs -l /dev/xvda4
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('tune2fs', tune2fs_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"version": string,
|
||||||
|
"filesystem_volume_name": string,
|
||||||
|
"last_mounted_on": string,
|
||||||
|
"filesystem_uuid": string,
|
||||||
|
"filesystem_magic_number": string,
|
||||||
|
"filesystem_revision_number": string,
|
||||||
|
"filesystem_features": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"filesystem_flags": string,
|
||||||
|
"default_mount_options": string,
|
||||||
|
"filesystem_state": string,
|
||||||
|
"errors_behavior": string,
|
||||||
|
"filesystem_os_type": string,
|
||||||
|
"inode_count": integer,
|
||||||
|
"block_count": integer,
|
||||||
|
"reserved_block_count": integer,
|
||||||
|
"free_blocks": integer,
|
||||||
|
"free_inodes": integer,
|
||||||
|
"first_block": integer,
|
||||||
|
"block_size": integer,
|
||||||
|
"fragment_size": integer,
|
||||||
|
"group_descriptor_size": integer,
|
||||||
|
"reserved_gdt_blocks": integer,
|
||||||
|
"blocks_per_group": integer,
|
||||||
|
"fragments_per_group": integer,
|
||||||
|
"inodes_per_group": integer,
|
||||||
|
"inode_blocks_per_group": integer,
|
||||||
|
"flex_block_group_size": integer,
|
||||||
|
"filesystem_created": string,
|
||||||
|
"filesystem_created_epoch": integer,
|
||||||
|
"filesystem_created_epoch_utc": integer,
|
||||||
|
"last_mount_time": string,
|
||||||
|
"last_mount_time_epoch": integer,
|
||||||
|
"last_mount_time_epoch_utc": integer,
|
||||||
|
"last_write_time": string,
|
||||||
|
"last_write_time_epoch": integer,
|
||||||
|
"last_write_time_epoch_utc": integer,
|
||||||
|
"mount_count": integer,
|
||||||
|
"maximum_mount_count": integer,
|
||||||
|
"last_checked": string,
|
||||||
|
"last_checked_epoch": integer,
|
||||||
|
"last_checked_epoch_utc": integer,
|
||||||
|
"check_interval": string,
|
||||||
|
"lifetime_writes": string,
|
||||||
|
"reserved_blocks_uid": string,
|
||||||
|
"reserved_blocks_gid": string,
|
||||||
|
"first_inode": integer,
|
||||||
|
"inode_size": integer,
|
||||||
|
"required_extra_isize": integer,
|
||||||
|
"desired_extra_isize": integer,
|
||||||
|
"journal_inode": integer,
|
||||||
|
"default_directory_hash": string,
|
||||||
|
"directory_hash_seed": string,
|
||||||
|
"journal_backup": string,
|
||||||
|
"checksum_type": string,
|
||||||
|
"checksum": string
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ tune2fs | jc --tune2fs -p
|
||||||
|
{
|
||||||
|
"version": "1.46.2 (28-Feb-2021)",
|
||||||
|
"filesystem_volume_name": "<none>",
|
||||||
|
"last_mounted_on": "/home",
|
||||||
|
"filesystem_uuid": "5fb78e1a-b214-44e2-a309-8e35116d8dd6",
|
||||||
|
"filesystem_magic_number": "0xEF53",
|
||||||
|
"filesystem_revision_number": "1 (dynamic)",
|
||||||
|
"filesystem_features": [
|
||||||
|
"has_journal",
|
||||||
|
"ext_attr",
|
||||||
|
"resize_inode",
|
||||||
|
"dir_index",
|
||||||
|
"filetype",
|
||||||
|
"needs_recovery",
|
||||||
|
"extent",
|
||||||
|
"64bit",
|
||||||
|
"flex_bg",
|
||||||
|
"sparse_super",
|
||||||
|
"large_file",
|
||||||
|
"huge_file",
|
||||||
|
"dir_nlink",
|
||||||
|
"extra_isize",
|
||||||
|
"metadata_csum"
|
||||||
|
],
|
||||||
|
"filesystem_flags": "signed_directory_hash",
|
||||||
|
"default_mount_options": "user_xattr acl",
|
||||||
|
"filesystem_state": "clean",
|
||||||
|
"errors_behavior": "Continue",
|
||||||
|
"filesystem_os_type": "Linux",
|
||||||
|
"inode_count": 3932160,
|
||||||
|
"block_count": 15728640,
|
||||||
|
"reserved_block_count": 786432,
|
||||||
|
"free_blocks": 15198453,
|
||||||
|
"free_inodes": 3864620,
|
||||||
|
"first_block": 0,
|
||||||
|
"block_size": 4096,
|
||||||
|
"fragment_size": 4096,
|
||||||
|
"group_descriptor_size": 64,
|
||||||
|
"reserved_gdt_blocks": 1024,
|
||||||
|
"blocks_per_group": 32768,
|
||||||
|
"fragments_per_group": 32768,
|
||||||
|
"inodes_per_group": 8192,
|
||||||
|
"inode_blocks_per_group": 512,
|
||||||
|
"flex_block_group_size": 16,
|
||||||
|
"filesystem_created": "Mon Apr 6 15:10:37 2020",
|
||||||
|
"last_mount_time": "Mon Sep 19 15:16:20 2022",
|
||||||
|
"last_write_time": "Mon Sep 19 15:16:20 2022",
|
||||||
|
"mount_count": 14,
|
||||||
|
"maximum_mount_count": -1,
|
||||||
|
"last_checked": "Fri Apr 8 15:24:22 2022",
|
||||||
|
"check_interval": "0 (<none>)",
|
||||||
|
"lifetime_writes": "203 GB",
|
||||||
|
"reserved_blocks_uid": "0 (user root)",
|
||||||
|
"reserved_blocks_gid": "0 (group root)",
|
||||||
|
"first_inode": 11,
|
||||||
|
"inode_size": 256,
|
||||||
|
"required_extra_isize": 32,
|
||||||
|
"desired_extra_isize": 32,
|
||||||
|
"journal_inode": 8,
|
||||||
|
"default_directory_hash": "half_md4",
|
||||||
|
"directory_hash_seed": "67d5358d-723d-4ce3-b3c0-30ddb433ad9e",
|
||||||
|
"journal_backup": "inode blocks",
|
||||||
|
"checksum_type": "crc32c",
|
||||||
|
"checksum": "0x7809afff",
|
||||||
|
"filesystem_created_epoch": 1586211037,
|
||||||
|
"filesystem_created_epoch_utc": null,
|
||||||
|
"last_mount_time_epoch": 1663625780,
|
||||||
|
"last_mount_time_epoch_utc": null,
|
||||||
|
"last_write_time_epoch": 1663625780,
|
||||||
|
"last_write_time_epoch_utc": null,
|
||||||
|
"last_checked_epoch": 1649456662,
|
||||||
|
"last_checked_epoch_utc": null
|
||||||
|
}
|
||||||
|
|
||||||
|
$ tune2fs | jc --tune2fs -p -r
|
||||||
|
{
|
||||||
|
"version": "1.46.2 (28-Feb-2021)",
|
||||||
|
"filesystem_volume_name": "<none>",
|
||||||
|
"last_mounted_on": "/home",
|
||||||
|
"filesystem_uuid": "5fb78e1a-b214-44e2-a309-8e35116d8dd6",
|
||||||
|
"filesystem_magic_number": "0xEF53",
|
||||||
|
"filesystem_revision_number": "1 (dynamic)",
|
||||||
|
"filesystem_features": "has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum",
|
||||||
|
"filesystem_flags": "signed_directory_hash",
|
||||||
|
"default_mount_options": "user_xattr acl",
|
||||||
|
"filesystem_state": "clean",
|
||||||
|
"errors_behavior": "Continue",
|
||||||
|
"filesystem_os_type": "Linux",
|
||||||
|
"inode_count": "3932160",
|
||||||
|
"block_count": "15728640",
|
||||||
|
"reserved_block_count": "786432",
|
||||||
|
"free_blocks": "15198453",
|
||||||
|
"free_inodes": "3864620",
|
||||||
|
"first_block": "0",
|
||||||
|
"block_size": "4096",
|
||||||
|
"fragment_size": "4096",
|
||||||
|
"group_descriptor_size": "64",
|
||||||
|
"reserved_gdt_blocks": "1024",
|
||||||
|
"blocks_per_group": "32768",
|
||||||
|
"fragments_per_group": "32768",
|
||||||
|
"inodes_per_group": "8192",
|
||||||
|
"inode_blocks_per_group": "512",
|
||||||
|
"flex_block_group_size": "16",
|
||||||
|
"filesystem_created": "Mon Apr 6 15:10:37 2020",
|
||||||
|
"last_mount_time": "Mon Sep 19 15:16:20 2022",
|
||||||
|
"last_write_time": "Mon Sep 19 15:16:20 2022",
|
||||||
|
"mount_count": "14",
|
||||||
|
"maximum_mount_count": "-1",
|
||||||
|
"last_checked": "Fri Apr 8 15:24:22 2022",
|
||||||
|
"check_interval": "0 (<none>)",
|
||||||
|
"lifetime_writes": "203 GB",
|
||||||
|
"reserved_blocks_uid": "0 (user root)",
|
||||||
|
"reserved_blocks_gid": "0 (group root)",
|
||||||
|
"first_inode": "11",
|
||||||
|
"inode_size": "256",
|
||||||
|
"required_extra_isize": "32",
|
||||||
|
"desired_extra_isize": "32",
|
||||||
|
"journal_inode": "8",
|
||||||
|
"default_directory_hash": "half_md4",
|
||||||
|
"directory_hash_seed": "67d5358d-723d-4ce3-b3c0-30ddb433ad9e",
|
||||||
|
"journal_backup": "inode blocks",
|
||||||
|
"checksum_type": "crc32c",
|
||||||
|
"checksum": "0x7809afff"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
from typing import List, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
|
class info():
|
||||||
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.0'
|
||||||
|
description = '`tune2fs -l` command parser'
|
||||||
|
author = 'Kelly Brazil'
|
||||||
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
compatible = ['linux']
|
||||||
|
tags = ['command']
|
||||||
|
magic_commands = ['tune2fs -l']
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (Dictionary) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
int_list = {'inode_count', 'block_count', 'reserved_block_count', 'free_blocks',
|
||||||
|
'free_inodes', 'first_block', 'block_size', 'fragment_size',
|
||||||
|
'group_descriptor_size', 'reserved_gdt_blocks', 'blocks_per_group',
|
||||||
|
'fragments_per_group', 'inodes_per_group', 'inode_blocks_per_group',
|
||||||
|
'flex_block_group_size', 'mount_count', 'maximum_mount_count',
|
||||||
|
'first_inode', 'inode_size', 'required_extra_isize', 'desired_extra_isize',
|
||||||
|
'journal_inode'}
|
||||||
|
|
||||||
|
datetime_list = {'filesystem_created', 'last_mount_time', 'last_write_time', 'last_checked'}
|
||||||
|
|
||||||
|
for key in proc_data:
|
||||||
|
if key in int_list:
|
||||||
|
proc_data[key] = jc.utils.convert_to_int(proc_data[key])
|
||||||
|
|
||||||
|
for key in proc_data.copy():
|
||||||
|
if key in datetime_list:
|
||||||
|
dt = jc.utils.timestamp(proc_data[key], (1000,))
|
||||||
|
proc_data[key + '_epoch'] = dt.naive
|
||||||
|
proc_data[key + '_epoch_utc'] = dt.utc
|
||||||
|
|
||||||
|
if 'filesystem_features' in proc_data:
|
||||||
|
proc_data['filesystem_features'] = proc_data['filesystem_features'].split()
|
||||||
|
|
||||||
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: Dict = {}
|
||||||
|
|
||||||
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
|
for line in filter(None, data.splitlines()):
|
||||||
|
|
||||||
|
if line.startswith('tune2fs '):
|
||||||
|
raw_output['version'] = line.split(maxsplit=1)[1]
|
||||||
|
continue
|
||||||
|
|
||||||
|
linesplit = line.split(':', maxsplit=1)
|
||||||
|
key = linesplit[0].lower().replace(' ', '_').replace('#', 'number')
|
||||||
|
val = linesplit[1].strip()
|
||||||
|
raw_output[key] = val
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output)
|
7
man/jc.1
7
man/jc.1
@ -1,4 +1,4 @@
|
|||||||
.TH jc 1 2023-11-21 1.23.7 "JSON Convert"
|
.TH jc 1 2023-11-23 1.23.7 "JSON Convert"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
|
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
|
||||||
and strings
|
and strings
|
||||||
@ -947,6 +947,11 @@ TOML file parser
|
|||||||
\fB--traceroute\fP
|
\fB--traceroute\fP
|
||||||
`traceroute` and `traceroute6` command parser
|
`traceroute` and `traceroute6` command parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--tune2fs\fP
|
||||||
|
`tune2fs -l` command parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--udevadm\fP
|
\fB--udevadm\fP
|
||||||
|
1
tests/fixtures/generic/tune2fs-l.json
vendored
Normal file
1
tests/fixtures/generic/tune2fs-l.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":"1.46.2 (28-Feb-2021)","filesystem_volume_name":"<none>","last_mounted_on":"/home","filesystem_uuid":"5fb78e1a-b214-44e2-a309-8e35116d8dd6","filesystem_magic_number":"0xEF53","filesystem_revision_number":"1 (dynamic)","filesystem_features":["has_journal","ext_attr","resize_inode","dir_index","filetype","needs_recovery","extent","64bit","flex_bg","sparse_super","large_file","huge_file","dir_nlink","extra_isize","metadata_csum"],"filesystem_flags":"signed_directory_hash","default_mount_options":"user_xattr acl","filesystem_state":"clean","errors_behavior":"Continue","filesystem_os_type":"Linux","inode_count":3932160,"block_count":15728640,"reserved_block_count":786432,"free_blocks":15198453,"free_inodes":3864620,"first_block":0,"block_size":4096,"fragment_size":4096,"group_descriptor_size":64,"reserved_gdt_blocks":1024,"blocks_per_group":32768,"fragments_per_group":32768,"inodes_per_group":8192,"inode_blocks_per_group":512,"flex_block_group_size":16,"filesystem_created":"Mon Apr 6 15:10:37 2020","last_mount_time":"Mon Sep 19 15:16:20 2022","last_write_time":"Mon Sep 19 15:16:20 2022","mount_count":14,"maximum_mount_count":-1,"last_checked":"Fri Apr 8 15:24:22 2022","check_interval":"0 (<none>)","lifetime_writes":"203 GB","reserved_blocks_uid":"0 (user root)","reserved_blocks_gid":"0 (group root)","first_inode":11,"inode_size":256,"required_extra_isize":32,"desired_extra_isize":32,"journal_inode":8,"default_directory_hash":"half_md4","directory_hash_seed":"67d5358d-723d-4ce3-b3c0-30ddb433ad9e","journal_backup":"inode blocks","checksum_type":"crc32c","checksum":"0x7809afff","filesystem_created_epoch":1586211037,"filesystem_created_epoch_utc":null,"last_mount_time_epoch":1663625780,"last_mount_time_epoch_utc":null,"last_write_time_epoch":1663625780,"last_write_time_epoch_utc":null,"last_checked_epoch":1649456662,"last_checked_epoch_utc":null}
|
48
tests/fixtures/generic/tune2fs-l.out
vendored
Normal file
48
tests/fixtures/generic/tune2fs-l.out
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
tune2fs 1.46.2 (28-Feb-2021)
|
||||||
|
Filesystem volume name: <none>
|
||||||
|
Last mounted on: /home
|
||||||
|
Filesystem UUID: 5fb78e1a-b214-44e2-a309-8e35116d8dd6
|
||||||
|
Filesystem magic number: 0xEF53
|
||||||
|
Filesystem revision #: 1 (dynamic)
|
||||||
|
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
|
||||||
|
Filesystem flags: signed_directory_hash
|
||||||
|
Default mount options: user_xattr acl
|
||||||
|
Filesystem state: clean
|
||||||
|
Errors behavior: Continue
|
||||||
|
Filesystem OS type: Linux
|
||||||
|
Inode count: 3932160
|
||||||
|
Block count: 15728640
|
||||||
|
Reserved block count: 786432
|
||||||
|
Free blocks: 15198453
|
||||||
|
Free inodes: 3864620
|
||||||
|
First block: 0
|
||||||
|
Block size: 4096
|
||||||
|
Fragment size: 4096
|
||||||
|
Group descriptor size: 64
|
||||||
|
Reserved GDT blocks: 1024
|
||||||
|
Blocks per group: 32768
|
||||||
|
Fragments per group: 32768
|
||||||
|
Inodes per group: 8192
|
||||||
|
Inode blocks per group: 512
|
||||||
|
Flex block group size: 16
|
||||||
|
Filesystem created: Mon Apr 6 15:10:37 2020
|
||||||
|
Last mount time: Mon Sep 19 15:16:20 2022
|
||||||
|
Last write time: Mon Sep 19 15:16:20 2022
|
||||||
|
Mount count: 14
|
||||||
|
Maximum mount count: -1
|
||||||
|
Last checked: Fri Apr 8 15:24:22 2022
|
||||||
|
Check interval: 0 (<none>)
|
||||||
|
Lifetime writes: 203 GB
|
||||||
|
Reserved blocks uid: 0 (user root)
|
||||||
|
Reserved blocks gid: 0 (group root)
|
||||||
|
First inode: 11
|
||||||
|
Inode size: 256
|
||||||
|
Required extra isize: 32
|
||||||
|
Desired extra isize: 32
|
||||||
|
Journal inode: 8
|
||||||
|
Default directory hash: half_md4
|
||||||
|
Directory Hash Seed: 67d5358d-723d-4ce3-b3c0-30ddb433ad9e
|
||||||
|
Journal backup: inode blocks
|
||||||
|
Checksum type: crc32c
|
||||||
|
Checksum: 0x7809afff
|
||||||
|
|
47
tests/test_tune2fs.py
Normal file
47
tests/test_tune2fs.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
from jc.parsers.tune2fs import parse
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
f_in: Dict = {}
|
||||||
|
f_json: Dict = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
fixtures = {
|
||||||
|
'tune2fs': (
|
||||||
|
'fixtures/generic/tune2fs-l.out',
|
||||||
|
'fixtures/generic/tune2fs-l.json')
|
||||||
|
}
|
||||||
|
|
||||||
|
for file, filepaths in fixtures.items():
|
||||||
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||||
|
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||||
|
cls.f_in[file] = a.read()
|
||||||
|
cls.f_json[file] = json.loads(b.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_tune2fs_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'tune2fs' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse('', quiet=True), {})
|
||||||
|
|
||||||
|
|
||||||
|
def test_tune2fs_l(self):
|
||||||
|
"""
|
||||||
|
Test 'tune2fs -l'
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
parse(self.f_in['tune2fs'], quiet=True),
|
||||||
|
self.f_json['tune2fs']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Reference in New Issue
Block a user