Creating a propertySource to populate a NOC widget in a dashboard... need ## in a string.
The NOC widget items have a field that requires me to have the string "##RESOURCEGROUP##" pushed through the JSON into the NOC Item… since I’m using a propertySource to run the script on a schedule (I have a larger VM with a collector with a longer script timeout just for doing deeper scripted work through the API or Full Domain sweep types of things that will take more time), The LM System is going to try to replace that at run time rather than returning the explicit string.
Who knows the correct escape sequence for turning that into a string literal on its way into the RestApi Patch?
Scripting questions through support is best effort, and I don’t usually come with easy questions.
Cole McDonald
Posted 2 years ago·Last reply 2 years ago
5 comments
Cole McDonald
OP2 years ago… and warning! I use backticks as line continuations frequently to allow for a single “thing” per line in my scripts. I dev in Powershell ISE, so it’ll look best there with everything all lined up pretty. Style and spacing is closer to python than .net / C#
Cole McDonald
OP2 years agoHere’s the code I’m using to populate these Dashboards. The new UI (v4) displays this better if you expand/maximize the widget to fill the page (although filtering out SDT’d alerts doesn’t work currently). Dashboard is just a single widget dashboard with a NOC widget that fills the page. The only two non-dynamic parts are the name of the dashboard, which goes in $masterDash.name and the ID of the group you want as your source for the subgroups… in our case it’s the “/Clients” group… so the ID number from that goes in $parentGroupID
This is built off of my old API exploration / report generation powershell functions, which is, in turn, built from the API + Powershell documentation from LM. This doesn't require any external modules to be added to use the API, so can be deployed against a collector with no prior software installs needed beyond what you’ll already have done.
I recommend targeting your dataSource to a single collector, then increasing the timeout for the scripts. At some point, I’m going to add pre-filtering to the initial API requests for groups and dashboards to speed those parts a little bit, but it’s not too bad currently while grabbing everything.
DS runs 1/day to populate the widget, feel free to have it hit more frequently if needed. Only two datapoints currently, exitCode and executionTime. I’m probably going to add groupCount at some point.
Enjoy.
Cole McDonald
OP2 years agoChanged it to a dataSource with datapoints of execution time and exitCode… I may add a count of the client folders added.
LM User
·2 years agoYeah, PS escape character is backtick.
Cole McDonald
OP2 years agoSome testing shows that backticks are the winners:
“testoutput=`#`#RESOURCEGROUP`#`#”
shows ##RESOURCEGROUP## in the output window.