[printer-scraping] Save server responses for debugging purposes.
All checks were successful
Check flake syntax / flake-check (push) Successful in 4m42s

I'll remove this later
This commit is contained in:
2025-10-27 12:04:27 +01:00
parent d52e47f88b
commit ae2ec0d7b2

View File

@@ -13,7 +13,7 @@ get_cookie () {
if [[ $1 == "-d" ]]; then if [[ $1 == "-d" ]]; then
cookie=$(cat request_example_1.txt) cookie=$(cat request_example_1.txt)
else else
cookie=$(curl -D - -X GET http://192.168.1.42/wcd/index.html) cookie=$(curl -s -D - -X GET http://192.168.1.42/wcd/index.html)
fi fi
exitCode="$?" exitCode="$?"
@@ -26,7 +26,9 @@ get_cookie () {
echo "Something went wrong" echo "Something went wrong"
exit 1 exit 1
fi fi
#DEBUG; DELETE LATER
echo "$cookie" > /home/malobeo/cookie.txt
cookie=$(echo "$cookie" | grep Set-Cookie | grep -oP "ID=\K[^.]+" ) cookie=$(echo "$cookie" | grep Set-Cookie | grep -oP "ID=\K[^.]+" )
if [[ $cookie == "" ]] if [[ $cookie == "" ]]
then then
@@ -101,8 +103,10 @@ echo "Start extract from system_counter"
if [[ $1 == "-d" ]]; then if [[ $1 == "-d" ]]; then
system_counter_data=$(cat system_counter.xml |xq) system_counter_data=$(cat system_counter.xml |xq)
else else
system_counter_data=$(curl -X GET http://192.168.1.42/wcd/system_counter.xml -H "Cookie: ID=\"$cookie\"" |xq) system_counter_data=$(curl -s -X GET http://192.168.1.42/wcd/system_counter.xml -H "Cookie: ID=\"$cookie\"" |xq)
fi fi
#DEBUG; DELETE LATER
echo "$system_counter_data" > /home/malobeo/system_counter_data.txt
get_values ".MFP.Count.UserCounterInfo.TotalCounterList.TotalCounter" system_counter_TotalCounter_keys TotalCounter get_values ".MFP.Count.UserCounterInfo.TotalCounterList.TotalCounter" system_counter_TotalCounter_keys TotalCounter
@@ -124,13 +128,16 @@ echo "Start extract from system_consumables"
if [[ $1 == "-d" ]]; then if [[ $1 == "-d" ]]; then
system_consumables_data=$(cat system_consumables.xml |xq) system_consumables_data=$(cat system_consumables.xml |xq)
else else
system_consumables_data=$(curl -X GET http://192.168.1.42/wcd/system_counter.xml -H "Cookie: ID=\"$cookie\"") system_consumables_data=$(curl -s -X GET http://192.168.1.42/wcd/system_counter.xml -H "Cookie: ID=\"$cookie\"")
fi fi
#DEBUG; DELETE LATER
echo "$system_consumables_data" > /home/malobeo/system_consumables_data.txt
get_values_consumables system_consumables_base_keys Consumables get_values_consumables system_consumables_base_keys Consumables
echo "Stop extract from system_consumables" echo "Stop extract from system_consumables"
echo "$valueStore" | curl --data-binary @- http://localhost:9091/metrics/job/printer echo "$valueStore" | curl -s --data-binary @- http://localhost:9091/metrics/job/printer
echo "Success!" echo "Success!"
exit 0 exit 0