EasyManuals Logo

Oracle ZFS Storage Appliance User Manual

Oracle ZFS Storage Appliance
650 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #46 background imageLoading...
Page #46 background image
Using the Run Function
Using the Run Function
1.
The simplest way for scripts to interact with the larger system is to use the "run"
function: it takes a command to run, and returns the output of that command as
a string. For example:
dory:> configuration version script dump(run('get boot_time'))
' boot_time = 2009-10-12 07:02:17\n'
2.
The built-in dump function dumps the argument out, without expanding any
embedded newlines. ECMAScript's string handling facilities can be used to take
apart output. For example, splitting the above based on whitespace:
dory:> configuration version script dump(run('get boot_time').split(/\s+/))
['', 'boot_time', '=', '2009-10-12', '07:02:17', '']
Using the Get Function
The run function is sufficiently powerful that it may be tempting to rely exclusively on parsing
output to get information about the system -- but this has the decided disadvantage that it leaves
scripts parsing human-readable output that may or may not change in the future. To more
robustly gather information about the system, use the built-in "get" function. In the case of
the boot_time property, this will return not the string but rather the ECMAScript Date object,
allowing the property value to be manipulated programmatically.
1.
For example, you might want to use the boot_time property in conjunction with
the current time to determine the time since boot:
script
run('configuration version');
now = new Date();
uptime = (now.valueOf() - get('boot_time').valueOf()) / 1000;
printf('up %d day%s, %d hour%s, %d minute%s, %d second%s\n',
d = uptime / 86400, d < 1 || d >= 2 ? 's' : '',
h = (uptime / 3600) % 24, h < 1 || h >= 2 ? 's': '',
m = (uptime / 60) % 60, m < 1 || m >= 2 ? 's': '',
s = uptime % 60, s < 1 || s >= 2 ? 's': '');
2.
Assuming the above is saved as a "uptime.aksh", you could run it this way:
% ssh root@dory < uptime.aksh
Pseudo-terminal will not be allocated because stdin is not a terminal.
Password:
up 2 days, 10 hours, 47 minutes, 48 seconds
46 Oracle ZFS Storage Appliance Administration Guide, Release OS8.6.x • September 2016

Table of Contents

Other manuals for Oracle ZFS Storage Appliance

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Oracle ZFS Storage Appliance and is the answer not in the manual?

Oracle ZFS Storage Appliance Specifications

General IconGeneral
Connectivity10GbE, 40GbE, InfiniBand, Fibre Channel
ProtocolsNFS, SMB, iSCSI, Fibre Channel, HTTP
Operating SystemOracle Solaris
Data Protectionsnapshots, clones, remote replication
Data ReductionInline compression, deduplication
High AvailabilityRedundant hardware components (controllers, power supplies, fans). Automatic failover between controllers. Hot-swappable drives and components. Cluster configurations for increased availability and scalability.
Management InterfaceWeb-based GUI, CLI, REST API
Storage TypeHybrid (SSD + HDD), All-Flash
Storage CapacityUp to several petabytes
EncryptionAES-256 encryption at rest

Related product manuals