Accessing the Nimsoft Database cm_computer_system from Lua Script
search cancel

Accessing the Nimsoft Database cm_computer_system from Lua Script

book

Article ID: 10040

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM) Unified Infrastructure Management for Mainframe CA Unified Infrastructure Management SaaS (Nimsoft / UIM)

Issue/Introduction

Need info on how to access the Nimsoft/UIM database cm_computer_system table from a Lua Script.

Environment

- UIM Version 8.4 or above

Resolution

There are 2 different scripts:

database.open("provider=nis;database=nis;driver=none")

query = database.query("select * from cm_computer_system where maintenance = 1")
if query == nil then
   print ("Query did not complete, or had no results")
else
   for idx,row in pairs (query) do
      printf("Hostname: %s \t IP: %s",row['name'],row['ip'])
   end
end

This other Script will show the HTML Output.  

Modify the Recipient line at the bottom for your environment:

--Devices in Maintenance Mode
ROW_FORMAT = -- multi-line quote...
[[
<TR>
<TD>%s</TD>
<TD>%s</TD>
</TR>
]]
html = -- multi-line quote...
[[
<HTML>
<HEAD>
<TITLE>Devices in Maintenance Mode</TITLE>
</HEAD>
<BODY>
<H2>Devices in Maintenance Mode</H2>
<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5" width='50%'>
<TR>
<TH>Device Name</TH>
<TH>IP Address</TH>
</TR>
]]

database.open("provider=nis;database=nis;driver=none")

query = database.query("select * from cm_computer_system where maintenance = 1")
if query == nil then
title = "No Devices in Maintenance Mode"
html = ""
else
for idx,row in pairs (query) do
html = html..sprintf(ROW_FORMAT,row['name'],row['ip'])
end
end
html = html..
[[
</TABLE>
</BODY>
</HTML>
]]
-- [Modify your recipient name]  recipient = "Operator"
title = "Nimsoft - Devices in Maintenance Mode"
action.email(recipient,title,html)

Additional Information

NOTE: Scripting is outside the scope of Technical Support. If you need further help, please contact your Account Rep and/or the Field Services Team.