Flow designer- how to calculate total disk space on a server?

Damhoej
Giga Guru

I am trying to figure out how I can create an action in flow designer that wil get me the total disk space on a server.

example:

The server has 3 disks that have different sizes (100, 200 and 300 Gb) that totales to 600 Gb.

I would like to sum these values when different servers have different number of disks?

When I get the total I can use this value further down my flow.

Any suggestions?

11 REPLIES 11

Community Alums
Not applicable

When you upgrade to Quebec you'll have "flow variables" that you can use for this purpose.

There's a couple of workarounds you can use in Paris, but none of them are great. You can use the inline scripting to calculate it later when you need it. 

I have now upgraded my personal instance to quebec, but I have an issue with my solution.
How do I get the variable to be the sum of "lookup records"? 

I guess I need some sort of adding all the sizes found in the lookup action, it doesn't work if I use "sum" in transformation 😉 
Somehow I need to build the array or do the math for each step.
 
This is how I imagine a flow for calculating disk space on a server:

find_real_file.png

Community Alums
Not applicable

Edit: forgive the typo of "totalDiskpace"... I only realised I'd missed the s after I'd done the screenshots :-). 

Size is actually a string field that's calculated on save, you'll want to do something like this to add up the bytes: 

find_real_file.png

And then you can use that value with the OOB script include that the size field uses, like this: 

 

find_real_file.png

Which returns: 

find_real_file.png

In this example I had two storage devices, one with 20 million bytes, and another with 50 million. 

Shao
ServiceNow Employee
ServiceNow Employee

One way you can do this is by creating a custom action to be used in your flow. 

Based on your use case:

  1. Create 3 action inputs, disk1, disk2, and disk3
  2. Create a script step
  3. Configure it like this:

find_real_file.png

24. Here's the script for reference:

a

(function execute(inputs, outputs) {
var num1 = parseInt(inputs.disk1);
var num2 = parseInt(inputs.disk2);
var num3 = parseInt(inputs.disk3);
var sum = num1+num2+num3;

outputs.totaldisk = sum;
})(inputs, outputs);

45. Create an output that takes the sum from the script step

56. You can then use the output to use in your flow to update a field.

57. Remember that you're passing the variable of disk 1 size, disk 2 size and disk 3 size from your initial flow to the inputs you've created.

 

Hope this solves your issue.