Is it possible to fetch data from stats.do or servicenow performance dashboard via script?

Ronald11
Tera Expert

Hello experts,

Through other community answers, we are advised that there is no table to query data from for stats.do and servicenow performance dashboard. But is there a possible script which can fetch this data specially for data displayed for memory.

find_real_file.png

find_real_file.png

We would like to be able to catch data that our instance is having high memory utilization if possible and be able to send us a notification when a certain memory is utilized before our instance throw an OOM error. Is this possible via scripts

Thanks in advance

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

You can use this example to get the ball rolling:

var diag = new Diagnostics();
while (diag.nextNode()) {
var diagNode = diag.getNode();
var nodeName = diagNode.name;
var memUse = diagNode.stats['system.memory.in.use'];
var memFree = diagNode.stats['system.memory.pct.free'];
gs.info("Node name: " + nodeName + " Memory in use: " + memUse + " Memory % Free: " + memFree);
}

find_real_file.png

You can also refer to the UI Page: system_diagnostic_page for more information.

Then sort of take it from here.

The above is just an example to get you started.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

13 REPLIES 13

Thanks again for the help,

By the way, this line of code 

var memUse = diagNode.stats['system.memory.in.use'];

were able to get the memory in use, how were you able to come up with the system.memory.use, do you have any reference for looking through stats.do. Because for example we want to also display the allocated memory, how do we write it.

find_real_file.png

Or we want to get the other processor transaction values how do we modify the script for that.

Thanks

 

Hey,

All of the functions that are being used are all rolled into script include Diagnostics , you can review this once t o get all other details from the stats.do page

Best Regards
Aman Kumar

Hello,

Are these the one referenced in the script?

find_real_file.png

But when I looked for the content of it I can't seem to find how he was able to come up for which code to use to point for memory in use and what I can use for memory allocation.

Hello,

You're listening to other replies that are telling you slightly different information that what I used (which is why I wish people would simply reply in their own chain as my context is different than theirs). Please review my reply and the UI Page I mentioned which gives you additional information to consider.

There's multiple pieces to this that I covered already 🙂

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

It's a bit unfortunate I didn't see the notifications until now (my apologies for that) that you've responded and I wish others would reply to you in their own reply chain.

What I provided took a bit of time to gather and was not really found in any other thread on these forums. So I personally went and dug into this for you.

With that said, I've given example script as well as the UI Page. From there, you can surmise the API (Diagnostics()) and can look that up in the script include for further information and leverage what it's doing there 🙂

Please let me know if you still have any specific questions, but I felt I got you 90% of the way there. The rest was just up to you to format and use as you needed.

If so, and my reply above helped guide you Correctly, please mark it as Correct.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!