NetXMS Support Forum

English Support => General Support => Topic started by: Legoman on July 14, 2016, 10:47:08 AM

Title: CPU instance discovery
Post by: Legoman on July 14, 2016, 10:47:08 AM
Hi,

I considered this great product, thank you for the job.

I try to add CPU usage on template and I would like to add a CPU usage per CPU with instance discovery (the same way I've done with disk usage and FileSystem.MountPoints). Is it possible ?

Thank you.
Title: Re: CPU instance discovery
Post by: Alex Kirhenshtein on July 14, 2016, 11:54:11 AM
Yes, it's possible.

Create script which query System.CPU.Count from the node and return indexes it as array (e.g. 4 cpu == [0, 1, 2, 3]), then use this script in instance discovery.
Title: Re: CPU instance discovery
Post by: tomaskir on July 14, 2016, 12:04:54 PM
Here is the script I use:

cpuCount = AgentReadParameter($node, "System.CPU.Count");

if (cpuCount == null || cpuCount == 1)
  return null;

array cpuArray;

for (i = 0; i < cpuCount; i++)
  cpuArray[i] = i;

return cpuArray;
Title: Re: CPU instance discovery
Post by: Legoman on July 14, 2016, 02:17:51 PM
Excellent. It works ! Thank you.
Title: Re: CPU instance discovery
Post by: rainerh on October 06, 2016, 05:28:35 PM
Hello,

I tried the script, but it does not work:

Configuration like this:

General:
   Description = Average CPU {instance} utilization for last Minute
   Data Parameter = System.CPU.Usage({instance})    from NetXMS Agent (Integer)

Instance Discovery:
   Instance Discovery method = Script
   next line = System.CPU.Count
   Instance discovery filter script = your script

Thank you
Rainer
Title: Re: CPU instance discovery
Post by: zsing82 on January 22, 2017, 09:05:45 PM
Create the script in the Script Library.

Open the DCI in the template and go to Instance Discovery.
Instance discovery method = Script
Next line = name of script in Script Library
Instance discovery filter script should be left blank.  Your script will be called from the Script Library as long you entered the script name in the line above.

Force an instance discovery poll to see if it works.
Title: Re: CPU instance discovery
Post by: rainerh on March 19, 2017, 02:19:24 PM
Thank you, now the script and instance discovery works fine