[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
cookie=$(cat request_example_1.txt)
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
exitCode="$?"
@@ -27,6 +27,8 @@ get_cookie () {
exit 1
fi
#DEBUG; DELETE LATER
echo "$cookie" > /home/malobeo/cookie.txt
cookie=$(echo "$cookie" | grep Set-Cookie | grep -oP "ID=\K[^.]+" )
if [[ $cookie == "" ]]
then
@@ -101,8 +103,10 @@ echo "Start extract from system_counter"
if [[ $1 == "-d" ]]; then
system_counter_data=$(cat system_counter.xml |xq)
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
#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
@@ -124,13 +128,16 @@ echo "Start extract from system_consumables"
if [[ $1 == "-d" ]]; then
system_consumables_data=$(cat system_consumables.xml |xq)
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
#DEBUG; DELETE LATER
echo "$system_consumables_data" > /home/malobeo/system_consumables_data.txt
get_values_consumables system_consumables_base_keys 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!"
exit 0