├── manual.pdf ├── sc-list.txt ├── cAdmin ├── data │ ├── Databases.cls.xml │ ├── Database.cls.xml │ ├── DevTools.cls.xml │ ├── Process.cls.xml │ ├── Sensors.cls.xml │ └── cconsolelog.cls.xml ├── Utils.cls.xml └── WebSocket.cls.xml └── README.md /manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intersystems-community/cAdmin-Server/master/manual.pdf -------------------------------------------------------------------------------- /sc-list.txt: -------------------------------------------------------------------------------- 1 | cAdmin 2 | cAdmin.WebSocket.CLS 3 | cAdmin.Utils.CLS 4 | cAdmin.data.CconsoleLog.CLS 5 | cAdmin.data.Database.CLS 6 | cAdmin.data.Databases.CLS 7 | cAdmin.data.DevTools.CLS 8 | cAdmin.data.Process.CLS 9 | cAdmin.data.Sensors.CLS 10 | -------------------------------------------------------------------------------- /cAdmin/data/Databases.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %RegisteredObject 5 | 63239,41438.998191 6 | 7 | 8 | 9 | List of all cAdmin.data.Database objects 10 | Database 11 | list 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /cAdmin/data/Database.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | This class contins all information about database 6 | %RegisteredObject 7 | 63239,39736.109086 8 | 9 | 10 | 11 | String, containig name of the database 12 | %String 13 | 14 | 15 | 16 | 17 | String, containig path to the database 18 | %String 19 | 20 | 21 | 22 | 23 | Availible free space for the database 24 | %Integer 25 | 26 | 27 | 28 | 29 | Writes per minute to the listed mounted database 30 | %Integer 31 | 32 | 33 | 34 | 35 | Reads per minute from the listed mounted database 36 | %Integer 37 | 38 | 39 | 40 | 41 | Milliseconds to complete a random read from the listed mounted database 42 | %Integer 43 | 44 | 45 | 46 | %Numeric 47 | 48 | 49 | 50 | 51 | Size of database in mb 52 | %Integer 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /cAdmin/data/DevTools.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Various tools for developement purposes 6 | %RegisteredObject 7 | 63243,41024.029871 8 | 9 | 10 | 11 | Get a random number 12 | 1 13 | %Integer 14 | 16 | 17 | 18 | 19 | 20 | Get a random string 21 | 1 22 | %String 23 | 25 | 26 | 27 | 28 | 29 | Increments number from 0 to 100, then starts from 0 30 | 1 31 | %Integer 32 | 36 | 37 | 38 | 39 | 40 | Add random message to cconsole.log 41 | 1 42 | %String 43 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cAdmin-Server 2 | ============= 3 | 4 | InterSystems Caché Administration Mobile tool - Server side. Bundled with project https://github.com/ShmidtIvan/cAdmin. 5 | 6 | Installation guide
7 | 1. Create new Namespace cAdmin with new database cAdmin with new access resource %DB_cAdmin
8 | 2. Into your new namespace cAdmin mirror package SYS from database CACHESYS
9 | 3. Create new resource %cAdmin with public USE on
10 | 4. Create new role cAdminRole, containing %cAdmin resource (step 3) and %Admin_Manage resource
11 | 5. Import all Cache classes from this repository https://github.com/eduard93/cAdmin-Server/ Either download zip or clone git
12 | 6. In cAdmin.WebSocket class modify resource parameter to match %cAdmin resource
13 | 7. Compile all classes
14 | 8. Create new user cAdminUser with roles %DB_cAdmin (step 1), cAdminRole (step 4) and %Admin_Manage role
15 | 9. For user cAdminUser on tab SQL Tables add access to Select and Delete for table cAdmin_data.CconsoleLog from cAdmin namespace
16 | 17 | Use (JavaScript)
18 | ws = new WebSocket("ws://<server ip>:<server port>/csp/<Namespace>/cAdmin.WebSocket.cls");
19 | ws.onopen = function(){ ws.send(JSON.stringify({User:" cAdminUser ",Password:" cAdminUserPassword"}))};

20 | ws.onmessage = function(m){console.log(m)};
21 | ws.send(‘devtools:RandomNumber’);
22 | 23 | In this example we, first, create new websocket object and point it to our websocket.
24 | Next, we specify what to send to server after establishing the connection – JSON, containing authorization information.
25 | After this use ws.send to send requests from request map
26 | Use ws.readyState to check that WebSocket is working
27 | 28 | Notes
29 | Please refer to included Caché documentation and manual.pdf for further information. 30 | -------------------------------------------------------------------------------- /cAdmin/data/Process.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | This class encapsulates all operations with processes. 6 | %RegisteredObject 7 | 63239,51725.448373 8 | 9 | 10 | 11 | Returns a list of all processes in JSON format 12 | 1 13 | %String 14 | 30 | 31 | 32 | 33 | 35 | Kills a process by sending it a halt messages.
36 | id - id of a process.
37 | If SendError is 1 the killed job will send error and logged in ^%ETN.
]]>
38 | 1 39 | id,withError=0 40 | %Status 41 | 51 |
52 | 53 | 54 | 56 | Put a process into a wait state so it stops executing code.
57 | id - id of a process.]]>
58 | 1 59 | id 60 | %Status 61 | 71 |
72 | 73 | 74 | 76 | Resumes a process after it had previously been suspended.
77 | id - id of a process.]]>
78 | 1 79 | id 80 | %Status 81 | 91 |
92 |
93 |
94 | -------------------------------------------------------------------------------- /cAdmin/Utils.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Various utility methods. 6 | %RegisteredObject 7 | 63273,59838.57564 8 | 9 | 10 | 11 | Sets all basic settings in ^cAdmin global 12 | 1 13 | 24 | 25 | 26 | 27 | pData as String using JSON notation 29 | pMetaData is a $List containing the names of the properties 30 | of the objects in the order in which they will appear.
31 | pData is an array containing the data. Each node in the array 32 | should be a $List containing values for properties. This should match the 33 | meta data provided in pMetaData. The array of data can use any subscript 34 | value its wants. It is possible to define a hierarchical array. In this case, 35 | children nodes are placed within a parent collection called children.
]]>
36 | 1 37 | 38 | 0 39 | %String 40 | 57 |
58 | 59 | 60 | pSQL is the SQL statement that is executed and provides the JSON content.
]]>
62 | 1 63 | SQL:%String 64 | 0 65 | %String 66 | 82 |
83 | 84 | 85 | 1 86 | 0 87 | 106 | 107 | 108 | 109 | 110 | Get directory size in bytes 111 | 1 112 | 1 113 | dir:%String,recursive:%Boolean="1" 114 | %Numeric 115 | 134 | 135 | 136 | 137 | 138 | Reference. Iterating over object properties 139 | 1 140 | 1 141 | 1 142 | 152 | 153 | 154 | 155 | len symbols in length]]> 157 | 1 158 | 1 159 | len:%Integer=10 160 | %String 161 | 168 | 169 |
170 |
171 | -------------------------------------------------------------------------------- /cAdmin/data/Sensors.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Class for working with SYS.Monitor.SystemSensors object. 6 | Create instance of this class and access the properties - 7 | they represent actual values at the time of accessing. 8 | %RegisteredObject 9 | 63242,50305.449154 10 | 11 | 12 | SYS.Monitor.SystemSensors 13 | 1 14 | 15 | 16 | 17 | %String 18 | 1 19 | 1 20 | 21 | 22 | 23 | 24 | System CPU usage (percent) 25 | %Integer 26 | 27 | 28 | 29 | 30 | Percentage of the lock table in use 31 | %Numeric 32 | 33 | 34 | 35 | 36 | Time (milliseconds) required to obtain a response from the listed CSP gateway server 37 | when fetching the metrics represented by the CSP sensor objects. 38 | %Numeric 39 | 40 | 41 | 42 | 43 | Percentage of the shared memory heap in use 44 | %Integer 45 | 46 | 47 | 48 | 49 | Free disk space, availible for journals 50 | %Numeric 51 | 52 | 53 | 54 | 55 | Free disk space, in percent to journal size 56 | %Numeric 57 | 58 | 59 | 60 | 61 | Cache Server Uptime in seconds 62 | %String 63 | 64 | 65 | 66 | 67 | Valid, Invalid, or Troubled (expiring) 68 | %String 69 | 70 | 71 | 72 | 73 | Active license expiration date 74 | %String 75 | 76 | 77 | 78 | 79 | Reason the key is invalid or in a troubled state 80 | %String 81 | 82 | 83 | 84 | NaN 85 | 86 | 87 | 88 | 89 | Get information about databases in JSON format 90 | %String 91 | 125 | 126 | 127 | 128 | 129 | Create and Initialyse System Sensors after object creation 130 | 1 131 | %Status 132 | 1 133 | 144 | 145 | 146 | 147 | 1 148 | 1 149 | %Status 150 | = 86400 155 | { 156 | set DaysUptime = SecondsUptime \ 86400 157 | } else { 158 | set DaysUptime = 0 159 | 160 | } 161 | set FractionSecondsUptime = SecondsUptime # 86400 162 | if $p(now,",",2)>=FractionSecondsUptime { 163 | set StartupDate=$p(now,",",1)-DaysUptime 164 | set StartupTime=$p(now,",",2)-FractionSecondsUptime 165 | } else { 166 | set StartupDate = $p(now,",",1)-DaysUptime-1 167 | set StartupTime = 86400 + $p(now,",",2)-FractionSecondsUptime 168 | } 169 | set i%SystemStartupDateTime=StartupDate_","_StartupTime 170 | } 171 | quit $$$OK 172 | ]]> 173 | 174 | 175 | 176 | 1 177 | %String 178 | $p(StartupDateTime,",",2) { 183 | set DaysUptime=$p(now,",",1)-$p(StartupDateTime,",",1) 184 | set FractionSecondsUptime=$p(now,",",2)-$p(StartupDateTime,",",2) 185 | } else { 186 | set DaysUptime=$p(now,",",1)-$p(StartupDateTime,",",1)-1 187 | set FractionSecondsUptime=86400 + $p(now,",",2)-$p(StartupDateTime,",",2) 188 | } 189 | 190 | quit DaysUptime*86400+FractionSecondsUptime 191 | ]]> 192 | 193 | 194 | 195 | 1 196 | %Integer 197 | 100 set CPU = 0 /// Overflows 205 | quit CPU 206 | ]]> 207 | 208 | 209 | 210 | 1 211 | %Numeric 212 | 224 | 225 | 226 | 227 | 1 228 | %Numeric 229 | 238 | 239 | 240 | 241 | 1 242 | %Numeric 243 | 253 | 254 | 255 | 256 | 1 257 | %Integer 258 | 267 | 268 | 269 | 270 | 1 271 | %Numeric 272 | 282 | 283 | 284 | 285 | 1 286 | %String 287 | 289 | 290 | 291 | 292 | 1 293 | %String 294 | 296 | 297 | 298 | 299 | 1 300 | %String 301 | 303 | 304 | 305 | 306 | -------------------------------------------------------------------------------- /cAdmin/data/cconsolelog.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Class for work with cconsole.log 6 | %Persistent 7 | 63243,34907.371349 8 | 9 | 10 | 11 | Date and Time of cconsole entry 12 | %TimeStamp 13 | 14 | 15 | 16 | 17 | Process id 18 | %Integer 19 | 20 | 21 | 22 | 23 | 0 (Information), 1 (Warning), 2 (Severe), 3 (Fatal) 24 | %Integer 25 | 26 | 27 | 28 | 29 | Text of cconsole entry 30 | %Text 31 | 32 | 33 | 34 | 35 | 36 | 37 | Maximal number of entries. Old ones would be deleted first 38 | 10000 39 | 40 | 41 | 42 | bitmap 43 | Message(KEYS) 44 | 45 | 46 | 47 | DateTime 48 | 49 | 50 | 51 | Pid 52 | 53 | 54 | 55 | Severity 56 | 57 | 58 | 59 | 63 | 64 | 65 | 66 | 67 | Path to cconsole.log. 68 | Requires resource %Admin_Manage 69 | 1 70 | %String 71 | 82 | 83 | 84 | 85 | 86 | Parse cconsole.log file, converting it lines into instances of this class 87 | 1 88 | 99 | 100 | 101 | 102 | 103 | Get new records from cconsole.log 104 | 1 105 | 153 | 154 | 155 | 156 | 157 | Add one new record to database 158 | 1 159 | line:%String 160 | 189 | 190 | 191 | 192 | MaxEntries]]> 194 | 1 195 | ..#MaxEntries 198 | { 199 | set delnumber = count * 0.2 200 | &sql(delete from cAdmin_data.CconsoleLog where id in (select top :delnumber id from cAdmin_data.CconsoleLog order by id asc)) 201 | } 202 | ]]> 203 | 204 | 205 | 206 | num entries from cconsole.log database]]> 208 | 1 209 | num:%Integer 210 | %String 211 | 215 | 216 | 217 | 218 | 219 | Get last id from cconsole.log database 220 | 1 221 | %Integer 222 | 226 | 227 | 228 | 229 | 230 | Get random entry from cconsole.log database 231 | 1 232 | %String 233 | 239 | 240 | 241 | 242 | query
244 | Example: 'alert','max']]>
245 | 1 246 | query:%String 247 | %String 248 | 252 |
253 | 254 | 255 | 256 | Search for all cconsole.log entries, from startdatetime to enddatetime 257 | Where startdatetime,enddatetime are TimeStamps - in yyyy-mm-dd hh:mm:ss.fff format. 258 | 1 259 | startdatetime:%TimeStamp,enddatetime:%TimeStamp 260 | %String 261 | 268 | 269 | 270 | 271 | %Library.CacheStorage 272 | ^cAdmin.data.CconsoleLogD 273 | CconsoleLogDefaultData 274 | ^cAdmin.data.CconsoleLogD 275 | ^cAdmin.data.CconsoleLogI 276 | ^cAdmin.data.CconsoleLogS 277 | 100000 278 | 279 | 280 | %%CLASSNAME 281 | 282 | 283 | DateTime 284 | 285 | 286 | Pid 287 | 288 | 289 | Severity 290 | 291 | 292 | Message 293 | 294 | 295 | 296 |
297 |
298 | -------------------------------------------------------------------------------- /cAdmin/WebSocket.cls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Web socket class. Manages all comunication with the client. 6 | %CSP.WebSocket 7 | 63236,45246.272996 8 | 9 | 10 | cAdmin.data.Sensors 11 | 12 | 13 | 14 | 15 | How long to wait for user when connection established 16 | 3600 17 | 18 | 19 | 20 | 21 | How long to wait for authorization key when connection established 22 | 5 23 | 24 | 25 | 26 | 27 | Resource name, required to access this websocket 28 | %Developement 29 | 30 | 31 | 32 | 33 | Buffer size in bytes 34 | 8192 35 | 36 | 37 | 38 | 40 | Authenticates user, checks that he has required resource. 41 | If all goes well, initialises sensors and forwards users' input to Choose Action]]> 42 | %Status 43 | 70 | 71 | 72 | 73 | 75 | containing Username and password in JSON format.
76 | Example : {User:"_SYSTEM",Password:"sys"}]]>
77 | %Status 78 | 87 |
88 | 89 | 90 | RequireAuthorization method) has required resourse]]> 92 | %Status 93 | 95 | 96 | 97 | 98 | 99 | Create new Sensors object 100 | 110 | 111 | 112 | 113 | 115 | Expected input:
116 | <action>
117 | <action>:<argument1,argument2,...,argumentN>
]]>
118 | data:%String 119 | %Status 120 | 136 |
137 | 138 | 139 | 141 | sensorslist - comma separated list of sensors
142 | Sends all sensors data if list is an empty string
143 | Example: CPU,LockTable,CSPGatewayLatency]]>
144 | sensorslist:%String 145 | %Status 146 | 169 |
170 | 171 | 172 | 173 | Writes Database information in JSON format 174 | %String 175 | 177 | 178 | 179 | 180 | 182 | action - action to perform. May be one of:
183 | cconsole-fulltextsearch, cconsole-filterdate, cconsole-alert.
184 | params, depending on methods are:
185 | ‘Term1’ ,’Term2’,...'TermN' - for cconsole-fulltextsearch
186 | yyyy-mm-dd hh:mm:ss.fff,YYYY-MM-DD HH:MM:SS.FFF - for cconsole-filterdate
187 | Empty string for cconsole-alert.
188 | Descriptions of methods are in documentation for cAdmin.data.CconsoleLog class
]]>
189 | action:%String,params:%String 190 | %Status 191 | lastid 223 | { 224 | 225 | set JSON = ##class(cAdmin.data.CconsoleLog).GetLast(newlastid-lastid) 226 | do ..WriteString($e(JSON,1,*-1)) 227 | set lastid=newlastid 228 | } 229 | } 230 | } 231 | quit $$$OK 232 | ]]> 233 |
234 | 235 | 236 | 238 | action - List, Kill, Suspend or Resume
239 | id - Id of a process to Kill, Suspend or Resume.]]>
240 | action:%String="List",id:%String 241 | %Status 242 | 250 |
251 | 252 | 253 | 255 | args - loop or RandomNumber or Increment or RandomString or AddToCconsoleLog.]]> 256 | args:%String="RandomNumber,Increment,RandomString" 257 | %Status 258 | 280 | 281 | 282 | 283 | 284 | Returns random cconsole.log entry every 10 seconds 285 | %Status 286 | 294 | 295 | 296 | 297 | 298 | Wraper of Write method for large strings - 299 | longer then Buffer parameter 300 | data:%String 301 | =buffer 310 | { 311 | 312 | do ..Write("{""parts"" : """_..DetermineParts($length(data))_"""}") 313 | hang 1 314 | } 315 | do ..Write(data) 316 | ]]> 317 | 318 | 319 | 320 | length:%Integer 321 | %Integer 322 | 341 | 342 |
343 |
344 | --------------------------------------------------------------------------------