Skip to content

get_psutil_disk_io_total(), ERROR: ValueError: not sure how to interpret line #638

Answered by HangDazon
HangDazon asked this question in Q&A
Discussion options

You must be logged in to vote

now working fine after modified the function, thanks for your help.

CREATE OR REPLACE FUNCTION public.get_psutil_disk_io_total(
    OUT read_count double precision, 
    OUT write_count double precision, 
    OUT read_bytes double precision, 
    OUT write_bytes double precision
) RETURNS record 
LANGUAGE plpython3u 
AS $$
try:
    # Read /proc/diskstats
    with open("/proc/diskstats", "r") as f:
        lines = f.readlines()

    # Initialize counters
    total_read_count = 0
    total_write_count = 0
    total_read_bytes = 0
    total_write_bytes = 0

    for line in lines:
        parts = line.split()
        
        # Ensure the line has at least 14 columns
        if len(parts) >= …

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@HangDazon
Comment options

Answer selected by pashagolub
@pashagolub
Comment options

@HangDazon
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #637 on February 07, 2025 11:46.