Skip to Content
Technical Articles

Exploring CPI’s filesystem’s content

While I was doing more in-depth research on how CPI works, I became curious about the content of its own filesystem. In this post, I’ll tell you a little about its content and how you can explore it yourself.

One of the peculiarities of CPI, is that it is very flexible when it comes to establishing an HTTP communication. In this way, it is possible to imitate a web server by modifying some headers and the body of an “exchange”. Ultimately, a web server mainly serves GETs and POSTs requests. Using this technique, and including a couple of lines of groovy script, you can create a file explorer emulator. Logically, due to access privileges, it is not possible to browse all directories. Still, it is possible to get very interesting information and files of CPI. A lot of low hanging fruits.

As a word of warning, check first that you are not breaking any rules and keep in mind that there could be risks involved. I cannot be held responsible for how you use the information offered in this post. Also, beware that the explorer I am presenting is basic, rustic and buggy. Feel free to improve it and share your snippets. 🙂

Creating the Iflow

Short way: you can download the example from this url.
Normal way: we need to create a very simple iflow, with two independent communication channels and running groovy scripts. One channel will be in charge of reviewing the contents of the directories and the other will be responsible for downloading the files.
In my own iflow I have used the following configurations:




import java.util.HashMap

def Message browse(Message message) {
    def mapHeaders = message.getHeaders()
    String mainDir = mapHeaders.get("CamelHttpPath") 
    String mainUrl = mapHeaders.get("CamelHttpUrl") 
    String mainSrv = mapHeaders.get("CamelServletContextPath")
    String srvUrl  = mainUrl.minus(mainDir)
    String urlDown = srvUrl.minus(mainSrv)+"/amba/cpifilesystemdownload"
    File dir = new File(mainDir)
    StringBuilder strBuilder = new StringBuilder()
    strBuilder << '<meta charset="UTF-8"></br>'
    if (dir.parent != null){strBuilder << "<a href='${srvUrl}${dir.parent}'>&#x1F4C1 ..</a></br>"}
    dir.eachDir {strBuilder << "<a href='${mainUrl}/${}'>&#x1F4C1 ${}</a></br>"}
    dir.eachFile {if (it.isFile()) {strBuilder << "<a href='${urlDown}/${mainDir}/${}'>${}</a></br>" }}
    mapHeaders = ['content-type':'text/html']
    return message

def Message download(Message message) {
    def mapHeaders = message.getHeaders()
    String filePath = mapHeaders.get("CamelHttpPath") 
    StringBuilder strBuilder = new StringBuilder()
    File file = new File(filePath);byte[] fileContent = file.bytes
    strBuilder << fileContent.encodeBase64().toString()    
    mapHeaders = ['Content-Transfer-Encoding':'base64',
                  'Content-Disposition':'attachment; filename=${file.getName()}']
    return message

What directories can you explore?

It’s hard to give an answer, as I haven’t found a way to get available folders to explore. However, by analysing CPÎ’s environment variables, I have found the following directories with interesting information. Please, share your findings!

Folder Comments
/usr/sap/ljs/ CPI’s home?
/usr/lib/jvm SAP’s Java Virtual Machine
/usr/sap/ljs/configuration OSGI configuration area
/usr/sap/ljs/configuration/org.eclipse.osgi/bundles  Iflows Contents
/usr/sap/ljs/plugins CPI’s jar files
/tmp Standard Linux temporary folder
/proc       ? (not ‘real’ files) Process Information


How to use

Once you load the iflow, copy the endpoint that will give you the channel that scans the directories. Paste that address into your internet browser. At the end of the url, include the folder you want to explore. (Not all routes can be explored as already mentioned)



Please share your findings!


Ariel Bravo Ayala


You must be Logged on to comment or reply to a post.
  • That is pretty cool and useful. You can even find the error logs that way.

    Just a small modification to make it a little easier to navigate so you can get a table view and get size and last modified of the files.

    import java.text.SimpleDateFormat
    // and then this method. 
      SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        File dir = new File(mainDir)
        StringBuilder strBuilder = new StringBuilder()
        strBuilder << '<meta charset="UTF-8"></br><table>'
        if (dir.parent != null){strBuilder << "<tr><td><a href='${srvUrl}${dir.parent}'>&#x1F4C1 ..</a></br></td></tr>"}
        dir.eachDir {strBuilder << "<tr><td><a href='${mainUrl}/${}'>&#x1F4C1 ${}</a></td></tr>"}
        dir.eachFile {if (it.isFile()) {strBuilder << "<tr><td><a href='${urlDown}/${mainDir}/${}'>${}</a></td><td> ${it.length()}</td><td> ${sdf.format(new java.util.Date(it.lastModified()))}</td></tr>" }}
    • You can find many things. Even some leftovers from the SAP developers :-S

      Have you find something useful for daily usage?

      Thanks for the snippet improvement!



  • I am getting the following error


    An internal server error occured: /opt/karaf/*@ line 34 in script1.groovy.
    The MPL ID for the failed message is : AF4w4-UkDJKVIUIm7TF6QTNhMje4
    For more details please check tail log.
    i am accessing in browser https://<cpihost>/http/amba/cpifilesystem/*
    error in groovy at line  "dir.eachDir {strBuilder << "<a href='${mainUrl}/${}'>&#x1F4C1 ${}</a></br>"}"
    please let me know how to fix?
  • Hi, is this method still supported? I have downloaded the iFlow but am receiving the error message " An internal server error occured: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.processData() is applicable for argument types: ( values: []. The MPL ID for the failed message is : AGCr_MIXzDkzgJWbd5pNvNnhK3_V For more details please check tail log." when accessing the URL at ,<tenant>/http/amba/cpifilesystem//usr/sap/ljs.


    I would like to be able to access some of the information (i.e. CPU, memory, disk space, etc.) that this claims to provide, but so far have not been able to.


    • Hi Matt,

      I wrote this long ago, I am not sure if this is still valid. If so, a few points to consider:

      1.- The snippet implements the functions "browse" and "download". Your error implies you haven't changed the function names in the Groovy Script steps. (The default is processData)

      2.- This works(ed) in Neo. I did not test this in CF.

      3.- If your goal is to access the information like CPU, memory, etc, you have other alternatives, like using the operation APIs. This explorer will give you the info of the worker node that executes the request exclusively, but your tenant is likely to have multiple worker/management nodes.

      The operations APIs you could use are:
      https://{{{operationsURL}}}/ (Basic info of your account)
      https://{{{operationsURL}}}/ (Get the node IDs)
      https://{{{operationsURL}}}/ (Get the statistics of the nodes)

      I hope this helps.



      • Hi Ariel,


        Thank you for your response. You were exactly right with your diagnosis of the error. Once I added the script function it seems to be working as you showed in your original post. I'll also check out a blog post I see from you on the operations APIs to get more info on those. Thanks so much for your help and this great information!


        Best Regards,


  • Hello,

    It seems that for this iFlow to work in Cloud Foundry CPI we need to adjust the URL and script.

    The issue is that URL should not contain "//"

    1. Change the HTTP connections address and remove the '/' in end:
      • /amba/cpifilesystem*
      • /amba/cpifilesystemdownload*
    2. Change groovy script @ line 19
      • message.setBody(strBuilder.toString().replaceAll("//","/"))

    After this deploy and open like

    • Root directory: <host>/http/amba/cpifilesystem/
    • CPI app directory: <host>/http/amba/cpifilesystem/app