or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mdcore-api.mdindex.mdparsers.mdstreaming.mdutilities.md

parsers.mddocs/

0

# Individual Parsers

1

2

Over 240 specialized parsers for converting output from specific commands, file formats, and data patterns to structured JSON. Each parser follows a consistent interface and includes metadata about compatibility and usage.

3

4

## Parser Interface

5

6

All parsers follow the same standard interface pattern:

7

8

```python { .api }

9

def parse(

10

data: str,

11

quiet: bool = False,

12

raw: bool = False

13

) -> Union[Dict[str, Any], List[Dict[str, Any]]]:

14

"""

15

Parse command output or file content into structured JSON.

16

17

Parameters:

18

- data: Input string to parse

19

- quiet: Suppress warning messages if True

20

- raw: Output preprocessed JSON if True

21

22

Returns:

23

- Dictionary or List of Dictionaries containing parsed data

24

"""

25

26

# Parser metadata object

27

info: ParserInfoType # Contains parser metadata and compatibility information

28

```

29

30

## Parser Categories

31

32

### System Information Parsers

33

34

Parse output from system information and status commands.

35

36

**Available Parsers:**

37

- `uname` - Parse uname command output

38

- `uptime` - Parse uptime command output

39

- `free` - Parse free command output

40

- `df` - Parse df command output

41

- `mount` - Parse mount command output

42

- `lsblk` - Parse lsblk command output

43

- `dmidecode` - Parse dmidecode command output

44

- `systeminfo` - Parse Windows systeminfo command output

45

46

### Network Parsers

47

48

Parse output from network diagnostic and configuration commands.

49

50

**Available Parsers:**

51

- `dig` - Parse dig DNS lookup output

52

- `host` - Parse host DNS lookup output

53

- `ping` - Parse ping command output

54

- `netstat` - Parse netstat command output

55

- `ss` - Parse ss socket statistics output

56

- `ifconfig` - Parse ifconfig network interface output

57

- `ip-address` - Parse ip address command output

58

- `ip-route` - Parse ip route command output

59

- `arp` - Parse arp table output

60

- `route` - Parse route table output

61

62

### Process and System Monitoring

63

64

Parse output from process monitoring and system statistics commands.

65

66

**Available Parsers:**

67

- `ps` - Parse ps process list output

68

- `top` - Parse top command output

69

- `iostat` - Parse iostat I/O statistics

70

- `vmstat` - Parse vmstat virtual memory statistics

71

- `mpstat` - Parse mpstat processor statistics

72

- `pidstat` - Parse pidstat process statistics

73

- `w` - Parse w logged users output

74

- `who` - Parse who logged users output

75

- `last` - Parse last login history output

76

77

### File System Parsers

78

79

Parse file system information and file content.

80

81

**Available Parsers:**

82

- `ls` - Parse ls directory listing output

83

- `find` - Parse find command output

84

- `file` - Parse file type identification output

85

- `stat` - Parse stat file information output

86

- `lsattr` - Parse lsattr file attributes output

87

- `du` - Parse du disk usage output

88

- `fstab` - Parse /etc/fstab file content

89

- `hosts` - Parse /etc/hosts file content

90

91

### Package Management

92

93

Parse output from package management commands.

94

95

**Available Parsers:**

96

- `apt-cache-show` - Parse apt-cache show output

97

- `apt-get-sqq` - Parse apt-get -sqq output

98

- `dpkg-l` - Parse dpkg -l package list

99

- `rpm-qi` - Parse rpm -qi package info

100

- `pip-list` - Parse pip list output

101

- `pip-show` - Parse pip show package details

102

103

### Configuration Files

104

105

Parse various configuration file formats.

106

107

**Available Parsers:**

108

- `ini` - Parse INI configuration files

109

- `yaml` - Parse YAML files

110

- `xml` - Parse XML files

111

- `csv` - Parse CSV files

112

- `json` - Parse JSON files (with validation)

113

- `toml` - Parse TOML files

114

- `plist` - Parse Apple plist files

115

116

### Security and Certificates

117

118

Parse security-related command output and certificate information.

119

120

**Available Parsers:**

121

- `x509-cert` - Parse X.509 certificate information

122

- `x509-csr` - Parse X.509 certificate signing requests

123

- `gpg` - Parse GPG command output

124

- `ssh-conf` - Parse SSH configuration files

125

- `sshd-conf` - Parse SSH daemon configuration

126

127

### Streaming Parsers

128

129

Real-time parsers for continuous data processing (append `-s` to parser name).

130

131

**Available Streaming Parsers:**

132

- `ping-s` - Stream ping output in real-time

133

- `syslog-s` - Stream syslog entries

134

- `clf-s` - Stream Common Log Format entries

135

- `csv-s` - Stream CSV data

136

- `top-s` - Stream top command output

137

138

## Universal Parser Utilities

139

140

Helper functions for building custom parsers:

141

142

```python { .api }

143

# From jc.parsers.universal module

144

def simple_table_parse(data: Iterable[str]) -> List[Dict]:

145

"""

146

Parse simple tables with no blank cells.

147

148

Parameters:

149

- data: Text data split into lines, with item 0 as header row

150

151

Returns:

152

- List of dictionaries representing table rows

153

"""

154

155

def sparse_table_parse(data: Iterable[str], delim: str = '\u2063') -> List[Dict]:

156

"""

157

Parse tables that may contain blank cells.

158

159

Parameters:

160

- data: Text data split into lines

161

- delim: Delimiter character for sparse fields

162

163

Returns:

164

- List of dictionaries representing table rows

165

"""

166

```

167

168

## Usage Examples

169

170

### Direct Parser Access

171

172

```python

173

# Method 1: Via main parse function

174

import jc

175

data = jc.parse('dig', dig_output)

176

177

# Method 2: Via get_parser

178

jc_dig = jc.get_parser('dig')

179

data = jc_dig.parse(dig_output)

180

181

# Method 3: Direct module import

182

import jc.parsers.dig

183

data = jc.parsers.dig.parse(dig_output)

184

```

185

186

### Streaming Parser Usage

187

188

```python

189

import jc

190

191

# Parse streaming data

192

ping_lines = ['PING example.com (93.184.216.34): 56 data bytes',

193

'64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms']

194

195

ping_stream = jc.parse('ping-s', ping_lines)

196

for parsed_line in ping_stream:

197

if parsed_line.get('time_ms'):

198

print(f"Response time: {parsed_line['time_ms']} ms")

199

```

200

201

### Parser Information

202

203

```python

204

import jc

205

206

# Get parser metadata

207

dig_info = jc.parser_info('dig')

208

print(f"Description: {dig_info['description']}")

209

print(f"Compatible: {dig_info['compatible']}")

210

print(f"Version: {dig_info['version']}")

211

212

# Check if parser supports streaming

213

if dig_info.get('streaming'):

214

print("Supports streaming")

215

216

# Get all parsers supporting a specific tag

217

all_info = jc.all_parser_info()

218

slurpable_parsers = [p['name'] for p in all_info if 'slurpable' in p.get('tags', [])]

219

```

220

221

### Custom Parser Development

222

223

```python

224

# Example parser structure (for plugin development)

225

"""jc - JSON Convert my_custom_parser"""

226

227

info = {

228

'name': 'my_custom',

229

'description': 'Custom parser for my data format',

230

'author': 'Your Name',

231

'version': '1.0',

232

'compatible': ['linux', 'darwin', 'win32'],

233

'tags': ['command']

234

}

235

236

def parse(data, quiet=False, raw=False):

237

\"\"\"Parse custom data format\"\"\"

238

# Parser implementation

239

return parsed_data

240

```