Python script to get patching information

Hi to all, i’m very new to BigFix but i need to export data related to server patching status.
I’ve this script with this query:

qr.expr = """
  (
   " fixlet_id=" & item 0 of it as string &
   " name=" & item 1 of it as string &
   " site=" & item 2 of it as string &
   " category=" & item 3 of it as string &
   " type=" & item 4 of it as string &
   " open_action_count=" & item 5 of it as string &
   " custom_flag=" & item 6 of it as string &
   " custom_site_flag=" & item 7 of it as string &
   " source_severity=" & item 8 of it as string &
   " source_fix=" & item 9 of it as string &
   " source_release_date=" & item 10 of it as string &
   " cve=" & item 16 of it as string &
   " source_id=" & item 17 of it as string &
   " scanned_count=" & item 11 of it as string &
   " passed_count=" & item 12 of it as string &
   " failed_count=" & item 13 of it as string &
   " patched_count=" & item 14 of it as string &
   " mean_time_to_patch=" & (if (nan of item 15 of it) then "" else item 15 of it as string) &
   " bigfix_server=" & item 18 of it &
   " soap_url=" & "{url}" &
   " soap_user=" & "{user}"
  ) of (
   id of item 0 of it,
   "%22" & (concatenation "%27" of (substrings separated by "%22" of name of item 0 of it)) & "%22",
   "%22" & display name of site of item 0 of it & "%22",
   (if (exists category of item 0 of it) then "%22" & category of item 0 of it & "%22" else ""),
   type of item 0 of it,
   open action count of item 0 of it,
   custom flag of item 0 of it,
   custom site flag of item 0 of it,
   (if (exists source severity of item 0 of it) then "%22" & source severity of item 0 of it & "%22" else ""),
   (if (exists source of item 0 of it) then "%22" & source of item 0 of it & "%22" else ""),
   (if (exists source release date of item 0 of it) then "%22" & source release date of item 0 of it as string & "%22" else ""),
   item 1 of it,
   item 1 of it - number of results whose (relevant flag of it = True) of item 0 of it,
   number of results whose (relevant flag of it = True) of item 0 of it,
   number of results whose (relevant flag of it = False and exists last became nonrelevant of it) of item 0 of it,
   mean of ((it / hour) of (last became nonrelevant of it - last became relevant of it) of results whose (relevant flag of it = False and exists last became nonrelevant of it) of item 0 of it),
   (if (exists cve id list of item 0 of it) then "%22" & cve id list of item 0 of it & "%22" else ""),
   (if (exists source id of item 0 of it) then "%22" & source id of item 0 of it & "%22" else ""),
   item 2 of it
  ) of (
   fixlets whose ((True)
     and (name of it as lowercase does not contain "superseded")
     and (name of it as lowercase does not contain "corrupt patch")) of item 0 of it,
   item 1 of it,
   item 2 of it
  ) of (
   it,
   number of subscribed computers of it,
   (database name of it & "," & database id of it as string) of current bes server
  ) 
  of bes sites whose (name of it contains \"""" + sites[i] + """\")

This query works, but in the result events i have not the computer name.
Can someone please help me how to get also computer name?

Thanks and regards.

You should be able to get that with names of applicable computers of bes fixlet

Hi, first of all thanks for the answer.
I’m not the author of this script, so i have no idea where and how to put what you wrote.
Could you please give me some more help? This is totally out of my usual work, but i was asked to solve this issue…

Thanks again!

Try this…

qr.expr = """
  (
   " fixlet_id=" & item 0 of it as string &
   " name=" & item 1 of it as string &
   " site=" & item 2 of it as string &
   " category=" & item 3 of it as string &
   " type=" & item 4 of it as string &
   " open_action_count=" & item 5 of it as string &
   " custom_flag=" & item 6 of it as string &
   " custom_site_flag=" & item 7 of it as string &
   " source_severity=" & item 8 of it as string &
   " source_fix=" & item 9 of it as string &
   " source_release_date=" & item 10 of it as string &
   " cve=" & item 16 of it as string &
   " source_id=" & item 17 of it as string &
   " names of applicable computers = " & item 18 of it & 
   " scanned_count=" & item 11 of it as string &
   " passed_count=" & item 12 of it as string &
   " failed_count=" & item 13 of it as string &
   " patched_count=" & item 14 of it as string &
   " mean_time_to_patch=" & (if (nan of item 15 of it) then "" else item 15 of it as string) &
   " bigfix_server=" & item 19 of it &
   " soap_url=" & "{url}" &
   " soap_user=" & "{user}"
  ) of (
   id of item 0 of it,
   "%22" & (concatenation "%27" of (substrings separated by "%22" of name of item 0 of it)) & "%22",
   "%22" & display name of site of item 0 of it & "%22",
   (if (exists category of item 0 of it) then "%22" & category of item 0 of it & "%22" else ""),
   type of item 0 of it,
   open action count of item 0 of it,
   custom flag of item 0 of it,
   custom site flag of item 0 of it,
   (if (exists source severity of item 0 of it) then "%22" & source severity of item 0 of it & "%22" else ""),
   (if (exists source of item 0 of it) then "%22" & source of item 0 of it & "%22" else ""),
   (if (exists source release date of item 0 of it) then "%22" & source release date of item 0 of it as string & "%22" else ""),
   item 1 of it,
   item 1 of it - number of results whose (relevant flag of it = True) of item 0 of it,
   number of results whose (relevant flag of it = True) of item 0 of it,
   number of results whose (relevant flag of it = False and exists last became nonrelevant of it) of item 0 of it,
   mean of ((it / hour) of (last became nonrelevant of it - last became relevant of it) of results whose (relevant flag of it = False and exists last became nonrelevant of it) of item 0 of it),
   (if (exists cve id list of item 0 of it) then "%22" & cve id list of item 0 of it & "%22" else ""),
   (if (exists source id of item 0 of it) then "%22" & source id of item 0 of it & "%22" else ""),
   (if (exists applicable computers of item 0 of it) then ("%22" & concatenation ";" of names of applicable computers of item 0 of it & "%22") else ""),
   item 2 of it
  ) of (
   fixlets whose ((True)
     and (name of it as lowercase does not contain "superseded")
     and (name of it as lowercase does not contain "corrupt patch")) of item 0 of it,
   item 1 of it,
   item 2 of it
  ) of (
   it,
   number of subscribed computers of it,
   (database name of it & "," & database id of it as string) of current bes server
  ) 
  of bes sites whose (name of it contains \"""" + sites[i] + """\")

Hi, wonderful! It works, thanks very, very much!
Is there a good point to start to learn this language?
i have this link: https://support.bigfix.com/inspectors/Session%20Objects_Any.html
is it correct?

Thanks again for help

The best place to start is probably https://developer.bigfix.com

Along with the downloadable guides at https://www.ibm.com/support/knowledgecenter/SSQL82_9.5.0/com.ibm.bigfix.doc/welcome/BigFix_Platform_welcome.html
The newer versions are at bigfix.developer.com, but I find it handy to download the PDF of the Relevance Guide and the Action Guide to get started.