To pick the important pieces out of the script that Gene provided:
This gets the config from the nas into a table of tables.
args = pds.create()
pds.putString(args,"name","nas")
local probe_config_get, rc = nimbus.request("/domain/centralhub/centralhubrobot/controller","probe_config_get",args)
A given section of the profile is accessed at this point with probe_local_config["full section path"]
So if you had a profile called "CloseOldAlerts" it would be accessed by probe_local_config["/auto_operator/definitions/CloseOldAlerts"].
And you could check if it was active with probe_local_config["/auto_operator/definitions/CloseOldAlerts"].active for instance.
To iterate over the contents of that given table use
for key,value in pairs(probe_config_get[section]) do
end
In this case something like
for key,value in pairs(probe_config_get["/auto_operator/definitions/CloseOldAlerts"]) do
print("section key " .. key .. " Value " .. value)
end
If you don't know the names of the sections ahead of time, you need to find them with something like this - the idea being that the section you are looking for will be named whatever the leading path is plus your section name with no trailing section separators ("/")
for section,section_table in pairs(probe_config_get) do
if (string.match(section, "^/auto_operator/definitions/([^/]+)$") ) ) then
do something with section_table
end
end
You then build your email body and use action.email() to send it
You also mentioned "preprocessor rules", the above addresses AO profiles which is probably what you were asking about but the preprocessor rules are in the <filters><custom> section but the same access methodology applies.
And you mentioned hostnames which doesn't make a lot of sense but maybe you meant the output of the nas callback "nameservice_list"?
Get that with results = nimbus.request("/domain/centralhub/centralhubrobot/controller","nameservice_list")
then process with the above for loop.
-Garin
Original Message:
Sent: 03-16-2020 08:54 AM
From: Gene HOWARD
Subject: Lua script to read nas.cfg
below has an example of how to loop through and read a config file from a probe.
https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=34707
------------------------------
Gene Howard
Principal Support Engineer
Broadcom
Original Message:
Sent: 03-16-2020 05:28 AM
From: Barber
Subject: Lua script to read nas.cfg
I want to have a nas script that reads the nas.cfg file, and emails me a list of pre-processing rules, and the hostnames.
I think the simplest way would be to parse the nas.cfg and filter out the rules I'm interested in.
How can I read the contents on nas.cfg in Lua?
Is there a better way?