Lpstat - command lpstat
Parsers contains in this module are:
LpstatPrinters - command /usr/bin/lpstat -p
LpstatProtocol - command /usr/bin/lpstat -v
LpstatQueuedJobs - command /usr/bin/lpstat -o
- class insights.parsers.lpstat.LpstatPrinters(*args, **kwargs)[source]
Bases:
CommandParser
Class to parse
lpstat -p
command output. Parses the output oflpstat -p
, to get locally configured printers. Current available printer states are:IDLE (
PRINTER_STATUS_IDLE
)PROCESSING (
PRINTER_STATUS_PROCESSING
) -- printingDISABLED (
PRINTER_STATUS_DISABLED
)UNKNOWN (
PRINTER_STATUS_UNKNOWN
)
Sample output of the command:
printer idle_printer is idle. enabled since Fri 20 Jan 2017 09:55:50 PM CET printer disabled_printer disabled since Wed 15 Feb 2017 12:01:11 PM EST - reason unknown
- Raises:
ValueError -- Raised if any error occurs parsing the content.
Examples: >>> type(lpstat_printers) <class ‘insights.parsers.lpstat.LpstatPrinters’> >>> len(lpstat_printers.printers) 3 >>> lpstat_printers.printer_names_by_status(‘DISABLED’) [‘disabled_printer’]
- printer_names_by_status(status)[source]
Gives names of configured printers for a given status
- Parameters:
status (string)
- printers
Dictionary of locally configured printers, with keys ‘name’ and ‘status’
- Type:
dict
- class insights.parsers.lpstat.LpstatProtocol(context, extra_bad_lines=None)[source]
Bases:
CommandParser
,dict
Class to parse
lpstat -v
command output.Sample output of the command:
device for test_printer1: ipp device for test_printer2: ipp device for savtermhpc: implicitclass:savtermhpc device for A1: marshaA1:/tmp/A1
Examples
>>> type(lpstat_protocol) <class 'insights.parsers.lpstat.LpstatProtocol'> >>> lpstat_protocol['test_printer1'] 'ipp' >>> lpstat_protocol['savtermhpc'] 'implicitclass'
- class insights.parsers.lpstat.LpstatQueuedJobs(context)[source]
Bases:
Parser
Class to parse lpstat_queued_jobs_count datasource result to get the count of queued jobs.
Currently, this parser only provide one attribute count which returns the count of queued jobs but no detailed jobs are provided.
Sample output of the
/usr/bin/lpstat -o
command:Cups-PDF-1802 root 265443328 Tue 05 Sep 2023 02:21:19 PM CST Cups-PDF-1803 root 265443328 Tue 05 Sep 2023 02:21:21 PM CST Cups-PDF-1804 root 265443328 Tue 05 Sep 2023 02:21:22 PM CST
Examples
>>> type(lpstat_queued_jobs) <class 'insights.parsers.lpstat.LpstatQueuedJobs'> >>> lpstat_queued_jobs.count 3