Quantcast
Channel: VMware Communities : Popular Discussions - Hyperic User Forums
Viewing all articles
Browse latest Browse all 52618

SigarPermissionDeniedException at ProcCpu.gather()

$
0
0

Hi,

 

I'm trying to run the following code:

 

 

import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.Sigar
public class PerformanceMonitor {
     public static void main(String[] args) throws SigarException, InterruptedException {
          for(long pid: new Sigar().getProcList())
               System.out.println(formatProcInfo(sigar, pid));
     }
     private static String formatProcInfo(Sigar sigar, long pid) throws SigarException {
          return String.format("%d - %s - %d%% - %d - %d",
                                   pid,
                                   sigar.getProcState(pid).getName(),
                                   sigar.getProcCpu(pid).getPercent(),
                                   sigar.getProcMem(pid).getResident(),
                                   sigar.getProcMem(pid).getSize());
    }
}

 

I get the following Exception:

 

Exception in thread "main" org.hyperic.sigar.SigarPermissionDeniedException: m Files\Common Files     at org.hyperic.sigar.ProcCpu.gather(Native Method)     at org.hyperic.sigar.ProcCpu.fetch(ProcCpu.java:30)     at org.hyperic.sigar.Sigar.getProcCpu(Sigar.java:488)     at perfMon.PerformanceMonitor.formatProcInfo(PerformanceMonitor.java:37)     at perfMon.PerformanceMonitor.main(PerformanceMonitor.java:29)

 

I'm running the code on a Winows 8 x86 machine.

What am I doing wrong?


Viewing all articles
Browse latest Browse all 52618

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>