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

Hello, thanks for the reply,

Yes I think your answer was really much closer to what I was wondering for. Thanks again.

What I would just like to verify is if the the system_diagnostic_page in UI pages and the script include Diagnostics are the one that is also used by stats.do to display the its data right?

find_real_file.png

find_real_file.png

find_real_file.png

Thanks in advance.

 

Hello,

Just an additional question, is the UI page: system_diagnostic_page that is used in this script the same page that is displayed in stats.do?

Thanks in advance

scott barnard1
Kilo Sage

Hi Ronald

I use the diagnostics script include and have a dashboard where I have a bunch of widgets. One is for Clusternodes.

find_real_file.png

The line for memory gives you a value of allocated vs capacity.

 

Regards

Hello, 

How were you able to display all those values in widgets? I am still fairly new to servicenow so I am still not that very well versed on manipulating the artifacts. 

Thanks.