curl command to check system console up or not? | Community
Skip to main content
Level 3
May 12, 2020
Solved

curl command to check system console up or not?

  • May 12, 2020
  • 2 replies
  • 4551 views

Hi,

I am running below curl function status check from jump servers to verify whether system console is up and running or not across many publishers. We have almost 50+ publishers running across different environments (Prod/Dev/DTQ/SIT etc..).

Problem here is all environments doesn't have common 499 bundles active. Some publishers have 500 active and some have 497 active bundles and some other servers varies with count. 

 

I am looking for a curl command that checks and confirms system console is up and running and also 

all active bundles in total are running. Can someone please assist?

 

function status()
{
/bin/su - root -c "curl -u 'admin':'admin' http://localhost:41000/system/console/bundles/.json | cut -d':' -f2,3 | egrep 499 >> /dev/null"
EXIT_STATUS=`echo $?`
if [ $EXIT_STATUS != 0 ]
then
echo ""
echo "Service is not running"
else
echo ""
echo "Service is running"
fi
}

 

 

Sample Output of below curl

----------------------------

curl -u 'admin':'admin' http://localhost:41000/system/console/bundles/.json | cut -d':' -f2,3

 

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 93826 0 93826 0 0 3847k 0 --:--:-- --:--:-- --:--:-- 4363k
"Bundle information: 497 bundles in total - all 497 bundles active.","s"

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Theo_Pendle

Hello @surendarm613658 

Here, I wrote a script that does what you want. It relies on jq to parse the JSON response (you can play around with jq to learn its syntax and experiment for free by going here). It will need some adapting to iterate through your 50+ instances of course 🙂

instance="http://localhost:4502" echo "Checking bundle status for instance at ${instance}" # Store response JSON response=$(curl -u "admin:admin" "${instance}/system/console/bundles/.json") echo $(jq -r '.status' <<< ${response}) # The s property holds 5 items: # 1. the total number or bundles # 2. The number of active bundles # 3. The number of active fragments # 4. The number of resolved bundles # 5. The number of installed bundles # So to check if our bundles are active, we just need to make sure indexes 3 and 4 hold 0 bundles_active=$(jq -r 'if (.s[3] == 0 and .s[4] == 0) then true else false end' <<< ${response}) echo $bundles_active if $bundles_active; then echo "All bundles active" else # If there is an issue, print the total number of inactive bundles inactive_bundles=$(jq -r '.s[2] + .s[3]' <<< ${response}) echo "Warning, instance ${instance} has ${inactive_bundles} bundles inactive" fi

Here is the output for the following instance, which is not OK as it has 2 installed but inactive bundles:

$ ./bundle_status.sh Checking bundle status for instance at http://localhost:4502 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 130k 0 130k 0 0 6209k 0 --:--:-- --:--:-- --:--:-- 6209k Bundle information: 705 bundles in total, 699 bundles active, 4 bundles active fragments, 2 bundles installed. false Warning, instance http://localhost:4502 has 2 bundles inactive

 

 

2 replies

Level 3
May 14, 2020
Can someone please assist here?
Theo_Pendle
Theo_PendleAccepted solution
Level 8
May 14, 2020

Hello @surendarm613658 

Here, I wrote a script that does what you want. It relies on jq to parse the JSON response (you can play around with jq to learn its syntax and experiment for free by going here). It will need some adapting to iterate through your 50+ instances of course 🙂

instance="http://localhost:4502" echo "Checking bundle status for instance at ${instance}" # Store response JSON response=$(curl -u "admin:admin" "${instance}/system/console/bundles/.json") echo $(jq -r '.status' <<< ${response}) # The s property holds 5 items: # 1. the total number or bundles # 2. The number of active bundles # 3. The number of active fragments # 4. The number of resolved bundles # 5. The number of installed bundles # So to check if our bundles are active, we just need to make sure indexes 3 and 4 hold 0 bundles_active=$(jq -r 'if (.s[3] == 0 and .s[4] == 0) then true else false end' <<< ${response}) echo $bundles_active if $bundles_active; then echo "All bundles active" else # If there is an issue, print the total number of inactive bundles inactive_bundles=$(jq -r '.s[2] + .s[3]' <<< ${response}) echo "Warning, instance ${instance} has ${inactive_bundles} bundles inactive" fi

Here is the output for the following instance, which is not OK as it has 2 installed but inactive bundles:

$ ./bundle_status.sh Checking bundle status for instance at http://localhost:4502 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 130k 0 130k 0 0 6209k 0 --:--:-- --:--:-- --:--:-- 6209k Bundle information: 705 bundles in total, 699 bundles active, 4 bundles active fragments, 2 bundles installed. false Warning, instance http://localhost:4502 has 2 bundles inactive

 

 

Level 3
May 15, 2020
Hi - Thanks a lot for your efforts. It worked perfectly. Much appreciated!