DX Unified Infrastructure Management

 View Only
  • 1.  Lua script to read nas.cfg

    Posted Mar 16, 2020 05:29 AM
    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?


  • 2.  RE: Lua script to read nas.cfg
    Best Answer

    Broadcom Employee
    Posted Mar 16, 2020 08:55 AM
    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
    ------------------------------



  • 3.  RE: Lua script to read nas.cfg

    Posted Mar 16, 2020 10:29 AM
    Thanks Gene, but I think the zip file linked in that article is missing. It gives me a 404 error.


  • 4.  RE: Lua script to read nas.cfg

    Broadcom Employee
    Posted Mar 16, 2020 10:36 AM
    scroll down to the very bottom there is a second link

    ------------------------------
    Gene Howard
    Principal Support Engineer
    Broadcom
    ------------------------------



  • 5.  RE: Lua script to read nas.cfg

    Posted Mar 16, 2020 10:39 AM
    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


  • 6.  RE: Lua script to read nas.cfg

    Posted Mar 31, 2020 07:14 AM
    Gene,

    I'd like to run the full probe audit. I'm fine until I hit the steps that says "then edit the Probe_audit_report.xlsx to point to your SQL database and the Probe_Audit_Report table and refresh."

    When I open that spreadsheet I can't see where to edit the DB.



  • 7.  RE: Lua script to read nas.cfg

    Posted Mar 31, 2020 09:16 AM
    Figured it out. Had to do install excel on a server that was inside the UIM DMZ.


  • 8.  RE: Lua script to read nas.cfg

    Broadcom Employee
    Posted Mar 31, 2020 09:25 AM
    Glad you got it to work

    ------------------------------
    Gene Howard
    Principal Support Engineer
    Broadcom
    ------------------------------