Skip to content

Inspect processes and execute remote code

This page describes two kxsctl commands for inspecting and interacting with KX Sensors processes: status, for viewing process and service-class state, and exec, for executing remote q code.

Look up process and service states

Overview

Processes in KXS consist of two separate components: the process itself and the service class to which it is attached. In process.yaml you define the process' assigned service class, how the process initializes and receives data, how it reacts to EOX events, where it stores in-memory tables, etc. In manifest.yaml, you define the service class's operational properties such as the service class's base port, prefix, task set, number of threads and number of services to run.

There is no one-to-one relationship between processes and service classes. For example, if you have multiple RDB processes for different customers in different environments, you would still only need a single RDB service class to specify the operational properties for all RDB processes.

Look up the status of your processes/service classes

The kxsctl status command prints a summary grid, followed by a per-instance grid giving the process ID, name, active status and port of each process/service class that you report on. Problem states are highlighted in colour. Disabled and inactive nodes are included in the output. The four verbose levels show the following additional information:

  • processes registered by Discovery but inactive (v)
  • the process' state (inactive, active, initializing, busy, waiting, paused, error, etc.) (vv)
  • process not registered by Discovery (vvv)
  • the process's IP address (vvvv)
Syntax kxsctl status [target] [flags]
Flags -n (node)*
-p (process)*
-s (service class)*
system (shows all processes on all nodes)

*At least one node, process or service class must be specified

Example 1 – verbosity = 0

Shows PID, name and port of active registered processes only.

[root@kxsb /]# kxsctl status rdb
PID   Name       Active  Port
608   kxsRDB_A1  Y       20105
607   kxsRDB_A2  Y       20106
2562  kxsRDB_B1  Y       20105
2563  kxsRDB_B2  Y       20106

Example 2 – verbosity = v

Shows inactive processes as well (B1, B2). Inactive processes are not currently running and do not have a PID.

[root@kxsb /]# kxsctl status rdb -v
PID  Name       Active  Port
608  kxsRDB_A1  Y       20105
607  kxsRDB_A2  Y       20106
-    kxsRDB_B1  N       20105
-    kxsRDB_B2  N       20106

Example 3 – verbosity = vv

Shows process state as well. If the State column is blank, it means that kxsctl failed to connect to the process.

[root@kxsb /]# kxsctl status rdb -vv
PID  Name       Active  State   Port
608  kxsRDB_A1  Y       ACTIVE  20105
607  kxsRDB_A2  Y       ACTIVE  20106
-    kxsRDB_B1  N       -       20105
-    kxsRDB_B2  N       -       20106

Example 4 – verbosity = vvv

Shows non-registered inactive processes as well (C1, C2). C1/C2 occur when a process has never been started after a new install or a manifest change.

[root@kxsb /]# kxsctl status rdb -vvv
PID  Name       Active  State   Port
608  kxsRDB_A1  Y       ACTIVE  20105
607  kxsRDB_A2  Y       ACTIVE  20106
-    kxsRDB_B1  N       -       20105
-    kxsRDB_B2  N       -       20106
-    kxsRDB_C1          -
-    kxsRDB_C2          -

Example 5 – verbosity = vvvv

Shows IP address as well (if process has been discovered).

[root@kxsb /]# kxsctl status rdb -vvvv
PID  Name       Active  State   Addrs
608  kxsRDB_A1  Y       ACTIVE  :2887450628:20105
607  kxsRDB_A2  Y       ACTIVE  :2887450628:20106
-    kxsRDB_B1  N       -       :2887450629:20105
-    kxsRDB_B2  N       -       :2887450629:20106
-    kxsRDB_C1          -
-    kxsRDB_C2          -

The following output shows deactivated processes in the manifest, indicated by an asterisk:

-    kxsVEE_A1 *    -   -      -
-    kxsCDL_A1 *    -   -      -
-    kxsCP_A1 *     -   -      -
-root@kxs /]#

Execute remote code on a process

The exec command allows you to execute remote q code on a process or service class to retrieve information from that process/service class or do some quick debugging.

Syntax kxsctl exec [flags]
Flags -n (node)
Specify node/s
-p (process)
Specify process/es
-c (q code)
Enter q code to execute
-s (service class)
Specify service class/es

Example

[root@kxsa /]# kxsctl exec rdb idb -c 'string[.Q.w[]`used]'
kxsRDB_A1: "12902992"
kxsRDB_A2: "12902992"
kxsRDB_B1: "12902992"
kxsRDB_B2: "12902992"
kxsIDB_A1: "4124896"
kxsIDB_A2: "4124896"
kxsIDB_A3: "4124896"
kxsIDB_A4: "4124896"
kxsIDB_A5: "4124896"
kxsIDB_A6: "4124896"
kxsIDB_A7: "4124896"
kxsIDB_A8: "4124288"
kxsIDB_B1: "4124896"
kxsIDB_B2: "4124896"
kxsIDB_B3: "4124896"
kxsIDB_B4: "4124896"
kxsIDB_B5: "4124288"
kxsIDB_B6: "4124288"
kxsIDB_B7: "4124288"
kxsIDB_B8: "4124288"

Next steps