Skip to main content

Bash function to check validation URLs

Here's a simple bash function that with the use of the 'curl' command can run some simple tests to see if your application is actually up and running. We know in the monitoring world of Hyperion it's not enough to just check the port. The java process could be bound and listening to a port but the Java webapp might not have initialized due to many possible reasons.
This function actually checks to see if the web server returns a http code 200 for the page. The URL to run the checks again will come from the registry.html file. More specifically the validationContext entry for all components that have one. We first parse the registry.html file (assuming we have one already) and pull out all the matching validation values.

cat $EPM_ORACLE_INSTANCE/diagnostics/reports/registry.html | grep validation | cut -d'>' -f5 | cut -d'<' -f1

Using a for loop we construct a test URL using the systems hostname, assumed port of 19000, and the validation URL. The magic comes in when we plug all that data into the curl command and ask to get back some simple details that we can print out on the console.

check_url () {
  #check the url based on the validation context taken from the registry.html file
  local host=$(hostname)
  local port=19000
    if [ -e $EPM_ORACLE_INSTANCE/diagnostics/reports/registry.html ]
    then
      printf "response time | http status code | URL\n"
      printf -- "-----------------------------------------\n"
      for url in $(cat $EPM_ORACLE_INSTANCE/diagnostics/reports/registry.html | grep validation | cut -d'>' -f5 | cut -d'<' -f1)
      do
        curl -fL $(hostname):19000/$url -w '%{time_total} | %{http_code} | %{url_effective}' -o /dev/null
      done
    else
      printf  "Failed to read registry.html file. Please ensure one is generated before running this function\n"
    fi
  }

When we run the function we get output similar to the output below. From left to right the first field is the total time (in seconds) reported by curl that it took to load the URL. The second field is the HTTP status code, and the third field is the URL that the check was performed on.

--------------------EXAMPLE-------------------

response time | http status code | URL
----------------------------------------------------
0.038 | 200 | http://server.example.com:19000/workspace/status
0.004 | 200 | http://server.example.com:19000/HyperionPlanning/
0.003 | 200 | http://server.example.com:19000/calcmgr/index.htm
0.004 | 200 | http://server.example.com:19000/interop/
12.019 | 503 | http://server.example.com:19000/WebAnalysis
0.003 | 200 | http://server.example.com:19000/hr/status.jsp
0.002 | 200 | http://server.example.com:19000/awb/conf/AwbConfig.xml
0.004 | 200 | http://server.example.com:19000/easconsole/console.html
0.002 | 200 | http://server.example.com:19000/aps/APS
0.001 | 403 | http://server.example.com:19000/essbase-webservices/AdminService
0.003 | 200 | http://server.example.com:19000/DataSync/
0.002 | 200 | http://server.example.com:19000/DataSync/
0.013 | 200 | http://server.example.com:19000/hyperion-bpma-server/Applications.asmx
8.843 | 200 | http://server.example.com:19000/HyperionFDM/AuthorizedPages/LogonPage.aspx?ReturnUrl=%2fHyperionFDM%2fdefault.aspx
0.002 | 200 | http://server.example.com:19000/raframework/index.jsp

This function becomes useful when you load it into the shell at login time so that you can call it from the command line at any time regardless of your location within the file system. You can do this by putting the function in a ,bashrc file or some chose to put functions in .bash_functions file. Just ensure whatever file you put it in that its going to get sourced at login time.

This function is not finished. I have some big ideas in taking this forward and being able to perform some more checks. stay tuned....

That's all I have for now. Take care and,



...Happy Hacking Hyperion!

Comments

Popular posts from this blog

Remote Validation URL Check

So I decided today that I wanted to be able to check validation URLs much like the previous post I wrote Bash Check Validation URLs  but this time I didn't want to have to login to each EPM environment to do it. I simply wanted to open a terminal and run a command to check the validationContext URL's that are stored in the registry.html file. In order to do this

bash function to run MaxL scripts & error handling

Lately I've been working on creating a function in bash so that I can generically call MaxL scripts and process return codes from them so that I can do some error handling and possibly send a notification via email or SMS message depending on the situation. How the essbase_run_task function works is like this: