Re: accessing data from json array of json arrays
Xander Cage <[email protected]> Wed, 14 Jun 2023 00:02:34 -0700 (PDT)
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
My initial thougt was that i can do the data filtering directly in the json
array and ommit the intermediate legacy array. my existing promise splits
the output of the lslpp command into an array. as this command is somewhat
cpu intensive i contemplated with the inventory file solution. so i learned
data filtering is not possible in an json array.
bundle agent get_lpp_info(fileset)
{
vars:
"lslpp_info" string => execresult ("/usr/bin/lslpp -O u -cl $(fileset) |
/usr/bin/grep -v '^#'", "useshell"),
comment => "get info from lslpp fileset";
"info_array" slist => splitstring("$(lslpp_info)", ":", 8),
comment => "get each field from lslpp output";
"lpp_version" string => nth("info_array", 2);
"lpp_status" string => nth("info_array", 4);
"lpp_long_desc" string => nth("info_array", 6);
reports:
"Time: $(sys.date) - Bundle: $(this.bundle) - Message: [$(lslpp_info)]
reported by lslpp."
comment => "do not remove this report .. won't call lslpp otherwise ..";
"$(lslpp_info)" bundle_return_value_index => "0",
comment => "give output back as index[0] (makes grepping for 'not
installed' possible";
"$(lpp_version)" bundle_return_value_index => "1";
"$(lpp_status)" bundle_return_value_index => "2";
"$(lpp_long_desc)" bundle_return_value_index => "3";
}
On Tuesday, June 13, 2023 at 5:17:00 PM UTC+2 nick.a…@northern.tech wrote:
in the end, i need the version number to upgrade aix filesets if downlevel.
until now, i did this by exuting plain old system commands, but i thought
it would be cool to use the already existing inventory file. anyway…your
example helped a lot…. as always ;-) thank you for that
Cool, what specifically was enlightening in the example I posted?
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/0a6324f0-0f0d-4fb2-b3d4-f65e9487fc96n%40googlegroups.com.