pub fn fq_codel_stats(qdisc: &str) -> Result<FqCodelCounters, String> {
    let output = process::Command::new("tc")
        .arg("-s")
        .arg("qdisc")
        .arg("show")
        .arg("dev")
        .arg(qdisc)
        .output()
        .map_err(|e| format!("Failed to execute tc: {}", e))?;
    let output =
        String::from_utf8(output.stdout).map_err(|e| format!("failed to parse stdout: {}", e))?;
    let lines: Vec<&str> = output.split('\n').collect();
    if lines.len() < 3 {
        return Err("output is shorter than expected".to_owned());
    }
    let tokens: Vec<&str> = lines[0].split_whitespace().collect();
    if tokens[1] != "fq_codel" {
        return Err(format!("qdisc type {} is unsupported", tokens[1]));
    }
    let stats: Vec<&str> = lines[1].split_whitespace().collect();

    let tmp: Vec<&str> = stats[6].split(',').collect();
    let dropped = tmp[0]
        .parse()
        .map_err(|e| format!("failed to parse dropped: {}", e))?;

    let overlimits = stats[8]
        .parse()
        .map_err(|e| format!("failed to parse overlimits: {}", e))?;

    let tmp: Vec<&str> = stats[10].split(')').collect();
    let requeues = tmp[0]
        .parse()
        .map_err(|e| format!("failed to parse requeues: {}", e))?;

    Ok(FqCodelCounters {
        dropped,
        overlimits,
        requeues,
    })
}
/// grab the `fq_codel` counters from tc
grab the `fq_codel` counters from tc
grab the ` fq_codel ` counters from tc
pub fn fq_codel_stats(qdisc: &str) -> Result<FqCodelCounters, String> {
    let output = process::Command::new("tc")
        .arg("-s")
        .arg("qdisc")
        .arg("show")
        .arg("dev")
        .arg(qdisc)
        .output()
        .map_err(|e| format!("Failed to execute tc: {}", e))?;
    let output =
        String::from_utf8(output.stdout).map_err(|e| format!("failed to parse stdout: {}", e))?;
    let lines: Vec<&str> = output.split('\n').collect();
    if lines.len() < 3 {
        return Err("output is shorter than expected".to_owned());
    }
    let tokens: Vec<&str> = lines[0].split_whitespace().collect();
    if tokens[1] != "fq_codel" {
        return Err(format!("qdisc type {} is unsupported", tokens[1]));
    }
    let stats: Vec<&str> = lines[1].split_whitespace().collect();
    let tmp: Vec<&str> = stats[6].split(',').collect();
    let dropped = tmp[0]
        .parse()
        .map_err(|e| format!("failed to parse dropped: {}", e))?;
    let overlimits = stats[8]
        .parse()
        .map_err(|e| format!("failed to parse overlimits: {}", e))?;
    let tmp: Vec<&str> = stats[10].split(')').collect();
    let requeues = tmp[0]
        .parse()
        .map_err(|e| format!("failed to parse requeues: {}", e))?;
    Ok(FqCodelCounters {
        dropped,
        overlimits,
        requeues,
    })
}
pub fn fq_codel_stats ( qdisc : & str ) -> Result < FqCodelCounters , String > { let output = process :: Command :: new ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( qdisc ) . output ( ) . map_err ( | e | format ! ( " " e ) ) ? ; let output = String :: from_utf8 ( output . stdout ) . map_err ( | e | format ! ( " " e ) ) ? ; let lines : Vec < & str > = output . split ( '\n' ) . collect ( ) ; if lines . len ( ) < 3 { return Err ( " " . to_owned ( ) ) ; } let tokens : Vec < & str > = lines [ 0 ] . split_whitespace ( ) . collect ( ) ; if tokens [ 1 ] != " " { return Err ( format ! ( " " tokens [ 1 ] ) ) ; } let stats : Vec < & str > = lines [ 1 ] . split_whitespace ( ) . collect ( ) ; let tmp : Vec < & str > = stats [ 6 ] . split ( ',' ) . collect ( ) ; let dropped = tmp [ 0 ] . parse ( ) . map_err ( | e | format ! ( " " e ) ) ? ; let overlimits = stats [ 8 ] . parse ( ) . map_err ( | e | format ! ( " " e ) ) ? ; let tmp : Vec < & str > = stats [ 10 ] . split ( ')' ) . collect ( ) ; let requeues = tmp [ 0 ] . parse ( ) . map_err ( | e | format ! ( " " e ) ) ? ; Ok ( FqCodelCounters { dropped , overlimits , requeues , } ) }
grab the `fq_codel` counters from tc
grab the ` fq_codel ` counters from tc
qdisc
&str
qdisc
&str