UNPKG

jchaos

Version:

module to access chaos resources

1,496 lines (996 loc) 34.3 kB
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> # JCHAOS This javascript module can be used, both in HTML or as nodejs library to access !CHAOS resources. This package bundles some !CHAOS utility and management applications. ## Install Global installation: **npm** install -g jchaos NPM Will install library and applications ## Repository [git@baltig.infn.it:chaos-lnf-control/jchaos.git](git@baltig.infn.it:chaos-lnf-control/jchaos.git) ## Application ### jchaosctl This application will perform management operation on chaos. The basic usage is: ``` bash /usr/bin/jchaosctl <--server server:port> [--upload <config to upload>] [--download <config output>>] [--findlive < cu | us | agent | mds | webui | variable | snapshotsof | snapshots | script | zone | class >] [--find < cu | us | agent | mds | webui | variable | snapshotsof | snapshots | script | zone | class >] [--op < start | stop | init | deinit| load | unload | kill | shutdown |health>] [--uid <!CHAOS node UID>] [--help] ``` ### jchaos library ### Table of Contents - [jchaos][1] - [options][2] - [Properties][3] - [print][4] - [Parameters][5] - [perror][6] - [Parameters][7] - [rmtCreateProcess][8] - [Parameters][9] - [rmtDownload][10] - [Parameters][11] - [rmtUploadScript][12] - [Parameters][13] - [rmtSetConsole][14] - [Parameters][15] - [rmtGetConsole][16] - [Parameters][17] - [progressBar][18] - [Parameters][19] - [addLongKey][20] - [Parameters][21] - [getLongLong][22] - [Parameters][23] - [setLongLong][24] - [Parameters][25] - [normalizeDataset][26] - [Parameters][27] - [getUS][28] - [Parameters][29] - [loadScript][30] - [Parameters][31] - [manageInstanceScript][32] - [Parameters][33] - [saveScript][34] - [Parameters][35] - [rmScript][36] - [Parameters][37] - [searchScriptInstance][38] - [Parameters][39] - [updateScriptInstance][40] - [Parameters][41] - [setAttribute][42] - [Parameters][43] - [okcb][44] - [Parameters][45] - [badcb][46] - [Parameters][47] - [cmdPar][48] - [Properties][49] - [varpath][50] - [Properties][51] - [channelid][52] - [call][53] - [Properties][54] - [createLibrary][55] - [decodeCUPath][56] - [Parameters][57] - [toHHMMSS][58] - [Parameters][59] - [setOption][60] - [Parameters][61] - [basicRmt][62] - [Parameters][63] - [rmtGetEnvironment][64] - [Parameters][65] - [rmtSetProp][66] - [Parameters][67] - [rmtCreateProcess][68] - [Parameters][69] - [rmtCreateProcess][70] - [Parameters][71] - [rmtUploadScript][72] - [Parameters][73] - [rmtListProcess][74] - [Parameters][75] - [rmtKill][76] - [Parameters][77] - [rmtPurge][78] - [Parameters][79] - [basicPost][80] - [Parameters][81] - [registerCU][82] - [Parameters][83] - [pushCU][84] - [Parameters][85] - [mdsBase][86] - [Parameters][87] - [tag][88] - [Parameters][89] - [Examples][90] - [checkRestore][91] - [Parameters][92] - [checkBurstRunning][93] - [Parameters][94] - [Examples][95] - [checkEndBurst][96] - [Parameters][97] - [Examples][98] - [snapshot][99] - [Parameters][100] - [Examples][101] - [node][102] - [Parameters][103] - [Examples][104] - [variable][105] - [Parameters][106] - [Examples][107] - [log][108] - [Parameters][109] - [Examples][110] - [search][111] - [Parameters][112] - [Examples][113] - [findCUByImplementation][114] - [Parameters][115] - [Examples][116] - [getCUStatus][117] - [Parameters][118] - [convertArray2CSV][119] - [Parameters][120] - [getChannel][121] - [Parameters][122] - [Examples][123] - [setProperty][124] - [Parameters][125] - [loadUnload][126] - [Parameters][127] - [sendCUCmd][128] - [Parameters][129] - [sendCUFullCmd][130] - [Parameters][131] - [getHistory][132] - [Parameters][133] - [fetchHistoryToZip][134] - [Parameters][135] - [checkPeriodiocally][136] - [Parameters][137] - [saveFullConfig][138] - [Examples][139] - [restoreFullConfigFromFile][140] - [restoreFullConfig][141] - [Parameters][142] - [activeAgentList][143] - [Parameters][144] - [Examples][145] - [getAllProcessInfo][146] - [Parameters][147] - [findBestServer][148] - [Parameters][149] - [Examples][150] - [runScript][151] - [Parameters][152] - [encodeName][153] - [Parameters][154] - [checkLive][155] - [Parameters][156] - [Examples][157] ## jchaos !CHAOS REST Library **Meta** - **version**: 1.0 - **author**: Andrea Michelotti ### options #### Properties - `updateEachCall` **[boolean][158]** =true choose if update each call of history operation - `uri` **[string][159]** =localhost:8081 REST server URI - `async` **[boolean][158]** =true if false force the call to be synchronous, otherwise depend if the callback is definedd - `limit_on_going` **integer** =10000 limits the concurrent operations - `history_page_len` **integer** =1000 default history page len - `timeout` **integer** =5000 default timeout for operation - `console_log` **callback** redirected on console.log - `console_err` **callback** redirected on console.error ### print Prints a String on the configured console #### Parameters - `str` **[string][159]** ### perror Prints a String on the configured console error #### Parameters - `str` **[string][159]** ### rmtCreateProcess #### Parameters - `server` - `name` - `cmdline` - `ptype` - `workdir` - `handler` - `badhandler` ### rmtDownload Retrive a process working directory return a zip file #### Parameters - `server` - `uid` - `workdir` - `handler` - `badhandler` ### rmtUploadScript #### Parameters - `server` - `name` - `ptype` - `content` - `handler` - `badhandler` ### rmtSetConsole Write on the remote console of the specified process #### Parameters - `server` **[string][159]** rest process remote management server - `uid` **[string][159]** the process uid returned by the rmtCreateProcess - `str` **[string][159]** line to send - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure ### rmtGetConsole Reads the console of the specified process uid #### Parameters - `server` **[string][159]** rest process remote management server - `uid` **[string][159]** the process uid returned by the rmtCreateProcess - `fromline` **integer** get from this line - `toline` **integer** until this line (-1 means end) - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure ### progressBar #### Parameters - `msg` - `id` - `lab` ### addLongKey #### Parameters - `obj` - `key` - `valuestr` ### getLongLong #### Parameters - `obj` - `key` ### setLongLong #### Parameters - `obj` - `key` - `val` ### normalizeDataset #### Parameters - `obj` ### getUS get a US description #### Parameters - `_name` ### loadScript #### Parameters - `_name` - `seqid` - `handleFunc` - `errFunc` ### manageInstanceScript #### Parameters - `script_name` - `script_seq` - `instance_name` - `create` - `handleFunc` ### saveScript #### Parameters - `value` - `handleFunc` ### rmScript #### Parameters - `value` - `handleFunc` ### searchScriptInstance #### Parameters - `script_name` - `search_string` - `handleFunc` - `errfunc` ### updateScriptInstance #### Parameters - `script_instance` - `script_base_description` - `handleFunc` ### setAttribute #### Parameters - `devs` **([string][159] \| [Array][162]&lt;[string][159]>)** CU or array of CU - `attr` **[string][159]** attribute name - `value` **[string][159]** attribute value - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `handleFuncErr` **[badcb][161]?** bad callback ## okcb Callback in asynchronous operations called when the operation is ok Type: [Function][163] ### Parameters - `data` **[object][164]** depend on the operation (typically a dataset) ## badcb Callback in asynchronous operations called when the operation is fails Type: [Function][163] ### Parameters - `data` **([string][159] \| [object][164])** description of the error ## cmdPar The command object for sendCU commands Type: [Object][164] ### Properties - `cmd` **[string][159]** command name - `prio` **integer** Priority - `mode` **integer** mode ## varpath CU variable path Type: [Object][164] ### Properties - `cu` **[string][159]** CU PATH - `dir` **[string][159]** direction (input,output) - `var` **[string][159]** variable dataset name - `const` **[string][159]** constantco:String - `origin` **[string][159]** full path ## channelid Channel idintification mapping: \-1 : all 0: output 1: input 2: custom 3: system 4: health 5: cu alarms 6: device alarms 128: status 255: health+system+ alarams Type: integer ## call Type: [object][164] ### Properties - `updateEachCall` **[boolean][158]** history update each call - `uri` **[string][159]** address:port of the REST server ## createLibrary Creates a new jchaos object. ## decodeCUPath Decode a CU dataset element path and return an object ### Parameters - `cupath` **[string][159]** Returns **[varpath][165]** ## toHHMMSS translate seconds in days hours minutes seconds string ### Parameters - `sec_num` **integer** Returns **[string][159]** return string xx days hh:mm:ss ## setOption Set Library options options ### Parameters - `opt` **[object][164]** ## basicRmt Helper function to post commands on the process remote management ### Parameters - `server` **[string][159]** rest process remote management server - `func` **[string][159]** REST function - `param` **[object][164]** REST function parameters - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure ## rmtGetEnvironment Retrive a given environemnt variable ### Parameters - `server` **[string][159]** rest process remote management server - `varname` **[string][159]** environment variable name - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure Returns **any** the value on the specified handler. ## rmtSetProp Set the specified propery ### Parameters - `server` **[string][159]** rest process remote management server - `prop` **{uid: [String][159], propname: [String][159]}** property name - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure Returns **any** the value on the specified handler. ## rmtCreateProcess Launch a process the specified process on the given remote server return a process structure ### Parameters - `server` **[string][159]** rest process remote management server - `name` **[string][159]** program name - `cmdline` **[string][159]** command line - `ptype` **[string][159]** type ("exec": binary, "C++": C++ script") - `workdir` **[string][159]** remote local directory - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure Returns **[object][164]** return a process object with many status and information ## rmtCreateProcess Return a zip file contaning the working directory of the specified process can be used to retrieve outputs of remote runs ### Parameters - `server` **[string][159]** rest process remote management server - `uid` **[string][159]** the process uid returned by the rmtCreateProcess - `workdir` **[string][159]** working dir to retrieve and zip - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure ## rmtUploadScript Upload a script/executable on the remote server return the path ### Parameters - `server` **[string][159]** rest process remote management server - `name` **[string][159]** program name - `ptype` **[string][159]** type ("exec": binary, "C++": C++ script") - `content` **[string][159]** base64 encoded content to upload - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure Returns **[object][164]** return the path of the remote process ## rmtListProcess Return a list of process on the given server ### Parameters - `server` **[string][159]** rest process remote management server - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure Returns **[Array][162]&lt;[object][164]>** return a list of process descriptors ## rmtKill Kill the specified process ### Parameters - `server` **[string][159]** rest process remote management server - `uid` **[string][159]** the process uid returned by the rmtCreateProcess - `handler` **[okcb][160]** handler on success - `badhandler` **[badcb][161]** handler on failure ## rmtPurge Purge a list of process to a given level (0 soft (EXCEPTION), 1 medium (ENDED and EXCEPTION), 2 hard (ALL) ### Parameters - `server` **[string][159]** rest process remote management server - `level` **integer** purge level - `handler` **[okcb][160]?** handler on success - `badhandler` **[badcb][161]?** handler on failure ## basicPost Helper function that is the base of all commands to the !CHAOS REST SERVER the server is specified in the option ### Parameters - `func` **[string][159]** REST function to perform - `params` **[string][159]** parameters - `handler` **[okcb][160]?** handler on success, if present the call will be asynchronous - `badhandler` **[badcb][161]?** handler on failure - `server` **[string][159]?** override the default server ## registerCU Registers a CU dataset using REST ### Parameters - `cuid` **[string][159]** - `obj` **[object][164]** the CU dataset to register/push - `handleFunc` **[okcb][160]?** handler on success, if present the call will be asynchronous - `badhandler` **[badcb][161]?** handler on failure ## pushCU Push a CU dataset using REST ### Parameters - `cuid` **[string][159]** - `obj` **[object][164]** the CU dataset to register/push - `handleFunc` **[okcb][160]?** handler on success, if present the call will be asynchronous - `badhandler` **[badcb][161]?** handler on failure ## mdsBase Helper function that wrap basic post used for query that regards generic MDS operations ### Parameters - `cmd` **[string][159]** command to send - `opt` **[object][164]** options - `handleFunc` **[okcb][160]?** handler on success, if present the call will be asynchronous - `errFunc` **[badcb][161]?** handler on failure ## tag Start tagging a list of nodes for an interval of given time, expressed in cycles or ms ### Parameters - `tagname` **[string][159]** - `node_list` **([string][159] \| [Array][162]&lt;[string][159]>)** - `tag_type` **integer** (2= time in ms, 1=cycles) - `tag_value` **integer** numer of ms or cycles - `handleFunc` **[okcb][160]?** handler on success, if present the call will be asynchronous - `nok` **[badcb][161]?** handler on failure ### Examples ```javascript //tagging for 10s two CU (cameras), give the name burstbyseconds var camera_list=["TEST/FLAME/CMP/CAMERA/FLACMPFF","TEST/FLAME/CMP/CAMERA/FLMCMP01"]; jchaos.tag("burstbyseconds",camera_list,2,10000,function(d){jchaos.print("tagging started");}); ``` ## checkRestore Check if a lists of CU have done a correct snapshot restore, the check is performed every timeout/10 ms for maximum timeout ### Parameters - `_tagname` **[string][159]** name of the tag - `_node_list` **([string][159] \| [Array][162]&lt;[string][159]>)** list of nodes - `_timeout` **integer** timeout - `_okhandler` **[okcb][160]?** - `_nokhandler` **[badcb][161]?** ## checkBurstRunning Helper function to check if a burst is running ### Parameters - `_tagname` **[string][159]** name of the tag - `_node_list` **([string][159] \| [Array][162]&lt;[string][159]>)** list of nodes - `_timeout` **integer** timeout - `_okhandler` **[okcb][160]?** - `_nokhandler` **[badcb][161]?** ### Examples ```javascript // check the burst is running var camera_list=["TEST/FLAME/CMP/CAMERA/FLACMPFF","TEST/FLAME/CMP/CAMERA/FLMCMP01"]; jchaos.checkBurstRunning("burstbyseconds",camera_list,10000,function(){jchaos.print("OK");},function(){chaos.error("BAD");}) ``` ## checkEndBurst Check if a list of CU ended correct burst, the check is performed every timeout/10 ms for maximum timeout ### Parameters - `_tagname` **[string][159]** name of the tag - `_node_list` **([string][159] \| [Array][162]&lt;[string][159]>)** list of nodes - `_timeout` **integer** timeout - `_okhandler` **[okcb][160]?** - `_nokhandler` **[badcb][161]?** ### Examples ```javascript // check the burst is running var camera_list=["TEST/FLAME/CMP/CAMERA/FLACMPFF","TEST/FLAME/CMP/CAMERA/FLMCMP01"]; jchaos.checkEndBurst(camera_list,10000,function(){jchaos.print("OK");},function(){chaos.error("BAD");}) ``` ## snapshot - **See: tag ** Performs snapshot operations <pre><code> create (create a new snapshot of the given list of CUs) load (retrive a create snapshot) set (create a snapshot from a value) delete (delete a snapshot) restore (restore a snapshot) burst (perform a burst tag operation see <b>tag</b>) </code></pre> ### Parameters - `_name` **[string][159]** name of the snapshot - `_what` **(`"create"` \| `"load"` \| `"set"` \| `"delete"` \| `"restore"` \| `"burst"`)** operation to perform - `_node_list` **([string][159] \| [Array][162]&lt;[string][159]>)** nodes to snapshot - `value_` **[object][164]?** parameter for set command - `handleFunc` **[okcb][160]?** - `nok` **[badcb][161]?** ### Examples ```javascript // create a set point programmatically of a set of powersupply var ps=["BTF/QUADRUPOLE/QUATB001","BTF/QUADRUPOLE/QUATB002","BTF/QUADRUPOLE/QUATB003"]; var powersupply_setpoint = { "input": { "ndk_uid": "undefined", "current": 0.1, "stby": true, "polarity": 1 }, "output": { "ndk_uid": "undefined", "current": 0.1, "stby": true, "polarity": 1, "local": false } }; var snapshot_set = []; var polarity = 1; var current = Number(0.0000001); ps.forEach(function (elem) { var snap = powersupply_setpoint; snap.input.stby = true; snap.input.current = current; snap.input.ndk_uid = elem; snap.input.polarity = polarity; snap.output.ndk_uid = elem; snap.output.polarity = polarity; snap.output.stby = true; snap.output.current = current; polarity = polarity > 0 ? -1 : 1; jchaos.snapshot("zero-stby", "set", "", snap, function (d) { jchaos.print("set setpoint OK:"+JSON.stringify(snap)); }); }); ``` ## node Perform and operation specified by '\_what' onthe nodes of '\_name' of type :'\_type' ### Parameters - `_name` **([string][159] \| [Array][162]&lt;[string][159]>)** the name of the nodes where to perform the operation - `_what` **(`"init"` \| `"deinit"` \| `"start"` \| `"stop"` \| `"get"` \| `"set"` \| `"del"` \| `"killcmd"` \| `"shutdown"` \| `"kill"` \| `"restart"` \| `"desc"` \| `"getlog"` \| `"health"` \| `"info"`)** operation type - `_type` **(`"us"` \| `"cu"` \| `"agent"`)** target type of the command - `_parent` **[string][159]?** some commands needs a parent node to be specified - `value_` **[object][164]?** some commands needs a parameter - `handleFunc` **[okcb][160]** - `nok` **[badcb][161]** ### Examples ```javascript // stop|start|init|deinit a cu jchaos.node("BTF/QUADRUPOLE/QUATB001","stop","cu"); jchaos.node("BTF/QUADRUPOLE/QUATB001","start","cu"); ``` ## variable Allows to manage variables that are persistent (on DB) ### Parameters - `_name` **([string][159] \| [Array][162]&lt;[string][159]>)** - `_what` **(`"set"` \| `"get"` \| `"del"` \| `"search"`)** operation type - `value_` **[object][164]?** in case of set the object - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `handleFunc` **[badcb][161]?** callback if failure ### Examples ```javascript // store an object var point={x:10.34,y:14.0}; jchaos.variable("mypoint","set",point); // perform list jchaos.variable("mypoint","search",function(ls){jchaos.print(JSON.stringify(ls));}); // get and visualize variable stored jchaos.variable("mypoint","get",function(ls){jchaos.print(JSON.stringify(ls));}); // delete variable jchaos.variable("mypoint","del"); ``` ## log Search logs for the given CUs ### Parameters - `devs` **([string][159] \| [Array][162]&lt;[string][159]>)** to search - `_what` **`"search"`** operation to perform - `_type` **(`"all"` \| `"Info"` \| `"error"` \| `"warning"` \| `"log"` \| `"command"`)** specify log type - `_start` **integer** epoch in ms start of the search - `_end` **integer** epoch md end of the search (-1 is now) - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `handlerr` **[badcb][161]?** callback if error ### Examples ```javascript // retrieve all logs for a given CU till now jchaos.log("BTF/QUADRUPOLE/QUATB001","search","all",0,-1,function(ls){jchaos.print(JSON.stringify(ls));}); ``` ## search ### Parameters - `_name` **[string][159]** is the substring of what you want search - `_what` **(`"cu"` \| `"us"` \| `"agent"` \| `"cds"` \| `"webui"` \| `"variable"` \| `"snapshotsof"` \| `"snapshots"` \| `"script"` \| `"zone"` \| `"class"`)** operation type - `_alive` **[boolean][158]** search among alive (true) or all(false) - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `handlerr` **[badcb][161]?** callback if error ### Examples ```javascript // search all CU alive jchaos.search("","cu",true,function(ls){jchaos.print(JSON.stringify(ls));}); ``` Returns **any** an array of strings or objects ## findCUByImplementation Find an array of CU with the given implementation ### Parameters - `impl` **[string][159]** C++ implementation name to find - `alive` **bool** search from alive or all - `handleFunc` **[okcb][160]?** callback if ok, enable async mode ### Examples ```javascript // find implementation that starts with SCA(ctuators) jchaos.findCUByImplementation("SCA",true,function(ls){jchaos.print(JSON.stringify(ls));}); ``` ## getCUStatus Return an array of CU that match a given status ### Parameters - `status_to_search` **[string][159]** - `handleFunc` **[okcb][160]?** callback if ok, enable async mode ## convertArray2CSV convert an array into a CommaSepareted elements ### Parameters - `devs` **[Array][162]&lt;[string][159]>** array Returns **[string][159]** ## getChannel Retrive the specified dataset correspoding to a given CU ### Parameters - `devs` **([String][159] \| [Array][162]&lt;[String][159]>)** CU or array of CU - `channel_id` **[channelid][166]** (-1: all,0: output, 1: input, 2:custom,3:system, 4: health, 5 cu alarm, 6 dev alarms,128 status) - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `badfunc` **[badcb][161]?** bad callback ### Examples ```javascript //retrive all channels of a give CU chaos.getChannel("BTF/QUADRUPOLE/QUATB001",-1,function(ls){jchaos.print(JSON.stringify(ls));}); ``` Returns **[object][164]** the specified dataset ## setProperty Set a CU property ### Parameters - `dev` **([string][159] \| [Array][162]&lt;[string][159]>)** CU or array of CU - `prop` **[string][159]** property name - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `errFunc` **[badcb][161]?** bad callback ## loadUnload Load or Unload a CU ### Parameters - `dev` **([string][159] \| [Array][162]&lt;[string][159]>)** CU or array of CU - `loadunload` **bool** (true = load, false=unload) - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `nok` **[badcb][161]?** bad callback ## sendCUCmd Sends a command to a CU ### Parameters - `devs` **([string][159] \| [Array][162]&lt;[string][159]>)** CU or array of CU - `cmd` **[cmdPar][167]** command to send - `param` **[object][164]?** optional and my be included into cmd - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `handleFuncErr` **[badcb][161]?** bad callback ## sendCUFullCmd Sends a command to a CU, with explicit params ### Parameters - `devs` **([string][159] \| [Array][162]&lt;[string][159]>)** CU or array of CU - `cmd` **[string][159]** command to send - `param` **([string][159] \| [object][164])?** - `force` **integer** - `prio` **integer** - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `handleFuncErr` **[badcb][161]?** bad callback ## getHistory Retrive history of a channel dataset of a group of devices ### Parameters - `devs` **([string][159] \| [Array][162]&lt;[string][159]>)** CU or array of CU - `channel` **integer** channel to retrieve - `start` **(integer | [string][159])** epoch timestamp in ms (GMT) of start of search - `stop` **(integer | [string][159])** epoch timestamp in ms (GMT) of start of search - `varname` **[string][159]?** optional name of the variable to retrieve (instead of all) - `handleFunc` **[okcb][160]?** callback if ok, enable async mode - `tagsv` **([string][159] \| [Array][162]&lt;[string][159]>)?** optional tags - `funcerr` **[badcb][161]?** optional bad callback ## fetchHistoryToZip Retrive history and write a local zip ### Parameters - `zipname` **[string][159]** - `cams` **([string][159] \| [Array][162]&lt;[string][159]>)** array of CU - `start` **(integer | [string][159])** epoch timestamp in ms (GMT) of start of search - `stop` **(integer | [string][159])** epoch timestamp in ms (GMT) of start of search - `tagsv` **[Array][162]&lt;[string][159]>?** tags - `updateCall` **[okcb][160]** - `errCall` **[badcb][161]** ## checkPeriodiocally - **See: checkLive ** - **See: checkBurstRunning ** Helper function th check a periodically a condition the difference with check live is the check function don't receive a dataset in input ### Parameters - `str` **[string][159]** string to display each time the check is performed - `retry` **integer** retry the check for a maximum of number of time - `checkFreq` **integer** check frequency in ms - `checkFunc` **[okcb][160]** check function, should return true if ok or false if fails - `okhandle` **[okcb][160]** callback to call if test succeed - `nokhandle` **[badcb][161]** callback to call if fails ## saveFullConfig saveFullConfig Save to local disk the state of fundamental configurations ### Examples ```javascript //save the infrastructure info. saveFullConfig(); ``` ## restoreFullConfigFromFile Restore a full configuration from file ## restoreFullConfig Restore a previously a configuration into the infrastructure ### Parameters - `config` **[object][164]** - `configToRestore` **[Array][162]&lt;[string][159]>** array of things to restore "us","agents","snapshots","graphs","custom_group","cu_templates" ## activeAgentList activeAgentList return a list of agents addresses in the callback ### Parameters - `cb` **[okcb][160]** callback called with the agent object list ### Examples ```javascript jchaos.activeAgentList(function(cb){jchaos.print(JSON.stringify(cb));}) ``` Returns **[Array][162]&lt;[object][164]>** return in the callback the list descriptor of the agents ## getAllProcessInfo Return a vector of process information in the callback ### Parameters - `agl` **[Array][162]&lt;[string][159]>** list of agents info - `cb` **[okcb][160]** callback called with the agent object list ## findBestServer findBestServer return a list of agents ordered by occupation in the callback NOTE: this function use a tcp port the is different from REST server one (it goes directly on the server) ### Parameters - `cb` **[okcb][160]** : return a list of active agents ### Examples ```javascript // find the best server to run a script: jchaos.findBestServer(function(cb){jchaos.print(JSON.stringify(cb));}) ``` Returns **[string][159]** return the best server ## runScript runScript Run the specified script on the chaos infrastructure ### Parameters - `name` **[string][159]** the name of the script present in the DB - `parm` **[object][164]?** optional parameters - `okhandle` **[okcb][160]?** called when ok - `errorhandle` **[badcb][161]?** called when failed ## encodeName Encode a path name removes trailing ### Parameters - `str` **[string][159]** string to encode Returns **[string][159]** encoded string ## checkLive This function used mainly in tests. It checks for a variable change on a 'devlist', for 'retry' times, checking every 'checkFreq' 'checkFunc' takes in input the live and realize the check okhandle is called if success nokhandle if fails ### Parameters - `str` **[string][159]** string to display when the check is peformed - `devlist` **[Array][162]&lt;[string][159]>** list of CU to check - `retry` **integer** retry the ckeck for the given number of times - `checkFreq` **integer** check frequency expressed in ms - `checkFunc` **[okcb][160]** call back to call that perform the check, it takes in input the dataset to check, should return true if the check succeed or false if not - `okhandle` **[okcb][160]** callback to call if the test complete successfully - `nokhandle` **[badcb][161]** callback to call if the test fails ### Examples ```javascript // check if the list of CUs are in start var cu_status=["BTF/QUADRUPOLE/QUATB001","BTF/QUADRUPOLE/QUATB002","BTF/QUADRUPOLE/QUATB003"]; jchaos.checkLive('check Start',cu_status, 20, 1000, function (ds) {jchaos.print("testing..."); return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Start"); }, function () { jchaos.print("CHECK OK"); }, function () { jchaos.error("CHECK FAILED"); }); ``` [1]: #jchaos [2]: #options [3]: #properties [4]: #print [5]: #parameters [6]: #perror [7]: #parameters-1 [8]: #rmtcreateprocess [9]: #parameters-2 [10]: #rmtdownload [11]: #parameters-3 [12]: #rmtuploadscript [13]: #parameters-4 [14]: #rmtsetconsole [15]: #parameters-5 [16]: #rmtgetconsole [17]: #parameters-6 [18]: #progressbar [19]: #parameters-7 [20]: #addlongkey [21]: #parameters-8 [22]: #getlonglong [23]: #parameters-9 [24]: #setlonglong [25]: #parameters-10 [26]: #normalizedataset [27]: #parameters-11 [28]: #getus [29]: #parameters-12 [30]: #loadscript [31]: #parameters-13 [32]: #manageinstancescript [33]: #parameters-14 [34]: #savescript [35]: #parameters-15 [36]: #rmscript [37]: #parameters-16 [38]: #searchscriptinstance [39]: #parameters-17 [40]: #updatescriptinstance [41]: #parameters-18 [42]: #setattribute [43]: #parameters-19 [44]: #okcb [45]: #parameters-20 [46]: #badcb [47]: #parameters-21 [48]: #cmdpar [49]: #properties-1 [50]: #varpath [51]: #properties-2 [52]: #channelid [53]: #call [54]: #properties-3 [55]: #createlibrary [56]: #decodecupath [57]: #parameters-22 [58]: #tohhmmss [59]: #parameters-23 [60]: #setoption [61]: #parameters-24 [62]: #basicrmt [63]: #parameters-25 [64]: #rmtgetenvironment [65]: #parameters-26 [66]: #rmtsetprop [67]: #parameters-27 [68]: #rmtcreateprocess-1 [69]: #parameters-28 [70]: #rmtcreateprocess-2 [71]: #parameters-29 [72]: #rmtuploadscript-1 [73]: #parameters-30 [74]: #rmtlistprocess [75]: #parameters-31 [76]: #rmtkill [77]: #parameters-32 [78]: #rmtpurge [79]: #parameters-33 [80]: #basicpost [81]: #parameters-34 [82]: #registercu [83]: #parameters-35 [84]: #pushcu [85]: #parameters-36 [86]: #mdsbase [87]: #parameters-37 [88]: #tag [89]: #parameters-38 [90]: #examples [91]: #checkrestore [92]: #parameters-39 [93]: #checkburstrunning [94]: #parameters-40 [95]: #examples-1 [96]: #checkendburst [97]: #parameters-41 [98]: #examples-2 [99]: #snapshot [100]: #parameters-42 [101]: #examples-3 [102]: #node [103]: #parameters-43 [104]: #examples-4 [105]: #variable [106]: #parameters-44 [107]: #examples-5 [108]: #log [109]: #parameters-45 [110]: #examples-6 [111]: #search [112]: #parameters-46 [113]: #examples-7 [114]: #findcubyimplementation [115]: #parameters-47 [116]: #examples-8 [117]: #getcustatus [118]: #parameters-48 [119]: #convertarray2csv [120]: #parameters-49 [121]: #getchannel [122]: #parameters-50 [123]: #examples-9 [124]: #setproperty [125]: #parameters-51 [126]: #loadunload [127]: #parameters-52 [128]: #sendcucmd [129]: #parameters-53 [130]: #sendcufullcmd [131]: #parameters-54 [132]: #gethistory [133]: #parameters-55 [134]: #fetchhistorytozip [135]: #parameters-56 [136]: #checkperiodiocally [137]: #parameters-57 [138]: #savefullconfig [139]: #examples-10 [140]: #restorefullconfigfromfile [141]: #restorefullconfig [142]: #parameters-58 [143]: #activeagentlist [144]: #parameters-59 [145]: #examples-11 [146]: #getallprocessinfo [147]: #parameters-60 [148]: #findbestserver [149]: #parameters-61 [150]: #examples-12 [151]: #runscript [152]: #parameters-62 [153]: #encodename [154]: #parameters-63 [155]: #checklive [156]: #parameters-64 [157]: #examples-13 [158]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [159]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [160]: #okcb [161]: #badcb [162]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array [163]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function [164]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [165]: #varpath [166]: #channelid [167]: #cmdpar