From a36efb94d9a8144a1a39b45e2ccc1187472b6584 Mon Sep 17 00:00:00 2001 From: ahtlon Date: Wed, 22 Oct 2025 20:46:06 +0200 Subject: [PATCH] Faster extraction and also levels of toner --- pull_info.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pull_info.sh b/pull_info.sh index 8a34529..e559a13 100644 --- a/pull_info.sh +++ b/pull_info.sh @@ -1,7 +1,22 @@ #curl -X GET http://192.168.1.42/wcd/system_consumable.xml -H "Cookie: ID=vGeeQa3qLQtd7sxYwl2jFOFUmQqIbuYN" +echo "Start extract from system_counter" data=$(cat system_counter.xml) -for i in "Total" "DuplexTotal" "Document" "Paper" "TotalLarge" "PaperSizeA3" "PaperSizeA4"; +data=$(echo "$data" | xq ".MFP.Count.UserCounterInfo.TotalCounterList.TotalCounter | .[]") +for key in "Total" "DuplexTotal" "Document" "Paper" "TotalLarge" "PaperSizeA3" "PaperSizeA4"; do - value=$(cat system_counter.xml | xq ".MFP.Count.UserCounterInfo.TotalCounterList.TotalCounter | .[] | select(.Type==\"$i\") | .Count") - echo "Key: $i; Value: $value" -done \ No newline at end of file + value=$(echo "$data" | jq "select(.Type==\"$key\") | .Count") + echo "Key: $key; Value: $value" +done +echo "Stop extract from system_counter" +echo +echo "Start extract from system_consumables" + +data=$(cat system_consumables.xml) +data=$(echo "$data" | xq ".[] |.DeviceInfo.ConsumableList.Consumable | .[]") +for key in "Toner (Yellow)" "Toner (Magenta)" "Toner (Cyan)" "Toner (Black)" "Drum Cartridge (Cyan)" "Developer Cartridge (Cyan)" "Drum Cartridge (Magenta)" "Developer Cartridge (Magenta)" "Drum Cartridge (Yellow)" "Developer Cartridge (Yellow)" "Drum Cartridge (Black)" "Developer Cartridge (Black)" "Fusing Unit" "Image Transfer Belt Unit" "Transfer Roller Unit"; +do + value=$(echo "$data" | jq "select(.Name==\"$key\") | .CurrentLevel.LevelPer") + echo "Key: $key; Level: $value" +done +echo "Stop extract from system_consumables" +exit 0 \ No newline at end of file