Skip to content

pfcon command: hello

Rudolph Pienaar edited this page Jul 3, 2017 · 21 revisions

pfcon command: hello

Abstract

This page describes the hello command to pfcon. It is used to simply test if a pfcon service is running and responding to requests and talking to the remote backend services pman and pfioh.

Preconditions

  • This page assumes that pfcon is listening on: 172.17.0.2:5055.
  • Make sure that pfcon has been started (see here for more info)
pfcon --forever --httpResponse
  • Make sure that the remote pman and pfioh services have been started.
  • Make sure that the internal pfcon dictionary variable Gd_internalvar has a valid entry for the pman and pfioh services (beyond the scope of this current page).

msg summary

The msg payload of the REST interaction with pfcon is:

 {  "action": "hello",
         "meta": {
                 "askAbout":     "sysinfo",
                 "echoBack":     "Hi there!",
                 "service":      "name/ip of machine hosting pman/pfioh"
         }
 } 

Pay particular attention to the service setting. More on this below.

hello

pfurl calling syntax

Assuming satisfied preconditions, let's say hello to pfcon. It will in turn ask each of pfioh and pman hello and return the response.

./pfurl --verb POST --raw --http 10.17.24.163:5005/api/v1/cmd --httpResponseBodyParse --jsonwrapper 'payload' --msg \
'{  "action": "hello",
    "meta": {
                "askAbout":     "sysinfo",
                "echoBack":      "Hi there!",
                "service":       "megalodon"
            }
}'

Note the service setting in the pfurl JSON payload. This designates the internal pfcon configuration that describes the location/machine hosting the remote pman and pfioh services.

Using the dockerized version of pfurl

To use the dockerized version of pfurl, and assuming a pfcon on the given IP:

Using the source repo

If you have cloned the source repo, you can cd to the root directory and execute the docker helper scripts in the docker-bin directory.

docker-bin/pfurl --verb POST --raw --http 172.17.0.2:5005/api/v1/cmd --httpResponseBodyParse --jsonwrapper 'payload' --msg \
 '{  "action": "hello",
         "meta": {
                 "askAbout":     "sysinfo",
                 "echoBack":     "Hi there!",
                 "service":      "megalodon"
         }
 }' --quiet --jsonpprintindent 4 
calling docker directly
docker run --name pfcon -v /home:/Users --rm -ti fnndsc/pfcon --verb POST \ 
           --raw --http 172.17.0.2:5005/api/v1/cmd \ 
           --httpResponseBodyParse --jsonwrapper 'payload' \ 
           --msg \
 '{  "action": "hello",
         "meta": {
                 "askAbout":     "sysinfo",
                 "echoBack":     "Hi there!",
                 "service":      "megalodon"
         }
 }' --quiet --jsonpprintindent 4 

return payload

The returned JSON string from the call:

{
    "d_ret": {
        "sysinfo": {
            "platform": "Linux-4.10.0-26-generic-x86_64-with-Ubuntu-17.04-zesty",
            "hostname": "pangea",
            "cpu_percent": 7.6,
            "loadavg": [
                3.95,
                3.54,
                3.53
            ],
            "memory": [
                67429609472,
                56682147840,
                15.9,
                9461198848,
                52895141888,
                10287566848,
                2281156608,
                972627968,
                4100640768,
                537202688
            ],
            "system": "Linux",
            "cpucount": 24,
            "machine": "x86_64",
            "uname": [
                "Linux",
                "pangea",
                "4.10.0-26-generic",
                "#30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017",
                "x86_64",
                "x86_64"
            ],
            "version": "#30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017"
        }
    },
    "status": true,
    "d_remote": {
        "d_ret": {
            "megalodon-compute": {
                "d_ret": {
                    "megalodon-compute": {
                        "client_json_payload": "{\"payload\": {\"meta\": {\"echoBack\": \"Hi there!\", \"service\": \"megalodon\", \"askAbout\": \"sysinfo\"}, \"action\": \"hello\"}}",
                        "d_ret": {
                            "sysinfo": {
                                "hostname": "megalodon",
                                "machine": "x86_64",
                                "loadavg": [
                                    0.23,
                                    0.33,
                                    0.33
                                ],
                                "system": "Linux",
                                "cpu_percent": 4.7,
                                "memory": [
                                    67508088832,
                                    61551775744,
                                    8.8,
                                    5079625728,
                                    55537459200,
                                    6923558912,
                                    3967168512,
                                    1066659840,
                                    5824344064,
                                    125284352
                                ],
                                "cpucount": 8,
                                "version": "#28-Ubuntu SMP Wed Jun 14 08:14:34 UTC 2017",
                                "uname": [
                                    "Linux",
                                    "megalodon",
                                    "4.10.0-24-generic",
                                    "#28-Ubuntu SMP Wed Jun 14 08:14:34 UTC 2017",
                                    "x86_64",
                                    "x86_64"
                                ],
                                "platform": "Linux-4.10.0-24-generic-x86_64-with-Ubuntu-17.04-zesty"
                            },
                            "name": "pman",
                            "version": "1.2.0"
                        },
                        "meta": {
                            "service": "megalodon",
                            "echoBack": "Hi there!",
                            "askAbout": "sysinfo"
                        },
                        "status": true,
                        "client_json_len": 114,
                        "RESTheader": "POST //api/v1/cmd/ HTTP/1.1\r",
                        "path": "//api/v1/cmd",
                        "payloadsize": 114,
                        "receivedByServer": [
                            "POST //api/v1/cmd/ HTTP/1.1\r",
                            "Host: 10.23.131.183:5010\r",
                            "User-Agent: PycURL/7.43.0 libcurl/7.52.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) librtmp/2.3\r",
                            "Accept: */*\r",
                            "Content-Length: 114\r",
                            "Content-Type: application/x-www-form-urlencoded\r",
                            "Via: 1.1 bdcnetsg1\r",
                            "Connection: Keep-Alive\r",
                            "X-BlueCoat-Via: c76e5a8a3a50519c\r",
                            "\r",
                            "{\"payload\": {\"meta\": {\"echoBack\": \"Hi there!\", \"service\": \"megalodon\", \"askAbout\": \"sysinfo\"}, \"action\": \"hello\"}}"
                        ],
                        "action": "hello",
                        "RESTverb": "POST"
                    }
                },
                "serviceName": "megalodon"
            },
            "megalodon-data": {
                "d_ret": {
                    "megalodon-data": {
                        "d_ret": {
                            "sysinfo": {
                                "hostname": "megalodon",
                                "machine": "x86_64",
                                "loadavg": [
                                    0.23,
                                    0.33,
                                    0.33
                                ],
                                "system": "Linux",
                                "cpu_percent": 4.7,
                                "memory": [
                                    67508088832,
                                    61551775744,
                                    8.8,
                                    5079625728,
                                    55537459200,
                                    6923558912,
                                    3967168512,
                                    1066659840,
                                    5824344064,
                                    125284352
                                ],
                                "cpucount": 8,
                                "version": "#28-Ubuntu SMP Wed Jun 14 08:14:34 UTC 2017",
                                "uname": [
                                    "Linux",
                                    "megalodon",
                                    "4.10.0-24-generic",
                                    "#28-Ubuntu SMP Wed Jun 14 08:14:34 UTC 2017",
                                    "x86_64",
                                    "x86_64"
                                ],
                                "platform": "Linux-4.10.0-24-generic-x86_64-with-Ubuntu-17.04-zesty"
                            },
                            "name": "pfioh",
                            "version": "1.2.9"
                        },
                        "status": true
                    }
                },
                "serviceName": "megalodon",
                "status": true
            }
        },
        "status": true,
        "serviceNameData": "megalodon",
        "serviceNameCompute": "megalodon"
    }
}

--30--