How to find UUIDs of an instance and database?
Hi,
First of all, do Cache instance and databases have UUIDs? If so, is there a simple way to obtain these from command line?
Thanks,
Raghu
Comments
The instance is assigned a GUID that you can retrieve using the InstanceGUID() method of the %SYS.System class:
USER>w ##class(%SYS.System).InstanceGUID()
C74E6F76-F21F-11E6-9BB8-A860B607521C
Databases are not assigned such an identifier.
Thanks for quick response.
Now, I am trying to run the following code on a Linux box as follows (CACHE is the instance name):
"csession CACHE -U"%SYS" "w ##class(%SYS.System).InstanceGUID()"
but it results in "<INVALID ARGUMENT>". Is this correct way of running objectscript code on Linux? Sorry if this comes across as a silly question but I am just getting familiar with Cache and its concepts.
Thanks,
Raghu
First run:
csession CACHE
Then:
w ##class(%SYS.System).InstanceGUID()
As %SYS is a % package it is available in every namespace.
As the last argument, you should use routine or classmethod, not command.
csession CACHE -U"%SYS" "##class(%SYS.System).InstanceGUID()"
You can get an output from a Caché routine provided it do some output to its principal device (= stdout), e.g. (approach #1):
$ csession CACHE "##class(%SYSTEM.License).CKEY()" Cache Key display: Based on the active key file '/vol/cachesys/mgr/cache.key' LicenseCapacity = Cache 2017.1 Enterpriser - Concurrent Users:1000000, Anything You Need CustomerName = ZAO XX.XXX OrderNumber = 9876543210 ExpirationDate = 10/15/2114 AuthorizationKey = 3141592653592718281828662607004081 MachineID = currently available = 9997 minimum available = 97 maximum available = 1000000 $
as there is no way to pass an arbitrary text from COS routine to OS directly. To bypass it, just incorporate into your shell script a calling sequence like this (approach #2):
#!/bin/bash csession CACHE <<EOF >output.txt write ##class(%SYS.System).InstanceGUID() halt EOF
After calling it, you will get output.txt like this:
Node: tdb01.xxxxx.com, Instance: CACHE USER> 8BCD407E-EE5E-11E4-B9C2-2EAEB3D6024F USER>
(Missing 'halt' command causes an error). All you have to do is to parse an output. To avoid this, you may want to write a small wrapper in COS that will provide an output as you need it, than you'll be able to follow an approach #1.
HTH.
Just to complete an exercise:
--- inst-guid.sh ---
#!/bin/bash
csession CACHE <<EOF | grep -E [0-9A-F\-]{36}
write ##class(%SYS.System).InstanceGUID()
halt
EOF
--------------------
$ ./inst-guid.sh
8BCD407E-EE5E-11E4-B9C2-2EAEB3D6024F
$
Excellent. Thanks to everyone who chimed in. Much appreciated.
Raghu.