Quantcast
Channel: VMware Communities : Popular Discussions - Hyperic SIGAR User Forum
Viewing all 9067 articles
Browse latest View live

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?


Using Sigar from Java on Redhat Enterprise Linux 6 - how?

$
0
0

Hi all,

 

RHEL6 comes with the native sigar library available:

 

http://rhn.redhat.com/errata/RHEA-2011-0670.html

 

This provides the following files:

 

# rpm -q -l sigar

/usr/lib64/libsigar.so

/usr/share/doc/sigar-1.6.5

/usr/share/doc/sigar-1.6.5/AUTHORS

/usr/share/doc/sigar-1.6.5/ChangeLog

/usr/share/doc/sigar-1.6.5/LICENSE

/usr/share/doc/sigar-1.6.5/NOTICE

/usr/share/doc/sigar-1.6.5/README

 

So far so good.

 

We are now trying to use sigar from java on this staging box, and we cannot get our test cases to run at all. we see the following two errors:

 

java.lang.NoClassDefFoundError: Could not initialize class org.hyperic.sigar.Sigar

java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Sigar.getNativeVersion()Ljava/lang/String;

 

Unfortunately neither error gives us a clue as to why Sigar is failing, the java.lang.UnsatisfiedLinkError message seems to be printing a bogus string instead of the actual error, so we remain in the dark.

 

Reverse engineering the sigar java binding, we find a complex library loading mechanism that attempts to introspect the architecture of the machine and load a custom-named library with the architecture of the machine embedded into it. This mechanism however doesn't seem to contain any mechanism to load a normal, ordinary system library as provided by the operating system as it is in this case.

 

My question is thus this:

 

- How do we use the sigar java bindings with the sigar library as shipped by Redhat?

- Is this even possible?

- Has Redhat done some kind of customisation to make this work, and if so is this documented anywhere?

- Has anyone got this to work?

 

To make things clear, we need to roll out this code on many nodes, we cannot use a custom hacked solution. We either need to discover what we're doing wrong and do it the right way, or if the java bindings can't work with Redhat's system sigar library at all, we will have to maintain a custom version of the sigar library with this bug fixed.

 

Can anyone shed any light on this?

 

Regards,

Graham

--

 

 

Calculating Cpu Percent Utilization (per process)

$
0
0
I'm trying to calculate cpu utilization for a list of processes returned via
a ProcessFinder, and I am hitting dead ends has anyone come across this yet,
or does anyone have any ideas?

Here is an example of what I have so far, (ala Java):
Sigar sigar = new Sigar();
ProcessFinder pf = new ProcessFinder(sigar);
long[] pids = pf.find("CredName.User.ew=root");
ProcTime ptime = new ProcTime();
long cpuTotal=0, cpuUser=0, cpuSys=0;

for(int i=0; i< pids.length(); i++){
ptime.gather(sigar, pids[i]);
cpuTotal += ptime.getTotal();
cpuUser += ptime.getUser();
cpuSys += ptime.getSys();
}
Cpu cpuTime = sigar.getCpu();

//note that this is just some inaccurate math as a place holder
double cpuTotalPercent = new Double( (((double) cpuTotal /
cpuTime.getTotal()) *100) );
double cpuUserPercent = new Double( (((double) cpuUser / cpuTime.getUser())
*100) );
double cpuSysPercent = new Double( (((double) cpuSys / cpuTime.getSys())
*100) );

In my research of this I decided to turn to some fun sections of the freebsd
source for ps, which has a friendly output from 'ps u' that does the same
thing per process on print (in C):
-------------------------->8----------------------
double getpcpu(k) KINFO *k; {
struct proc *p;
static int failure;

if (!nlistread)
failure = donlist();
if (failure)
return (0.0);

p = KI_PROC(k);
#define fxtofl(fixpt) ((double)(fixpt) / fscale)

/* XXX - I don't like this */
if (p->p_swtime == 0 || (p->p_flag & P_INMEM) == 0)
return (0.0);
if (rawcpu)
return (10000.0 / sysconf(_SC_CLK_TCK) *
fxtofl(p->p_pctcpu));
return (10000.0 / sysconf(_SC_CLK_TCK) * fxtofl(p->p_pctcpu) /
(1.0 - exp(p->p_swtime * log(fxtofl(ccpu)))));
}

void
pcpu(k, ve)
KINFO *k;
VARENT *ve;
{
VAR *v;

v = ve->var;
(void)printf("%*.1f", v->width, getpcpu(k));
}
-----------------------8<------------------------

So now that I have attacked everyone's senses with code, can anyone point me
to an algorithm to calculate this that does not require me to dig up the
number of ticks per second of the cpu, and can hopefully be encompassed
within the methods offered by SIGAR?
Thanks in advance for all your help, John

John Buren Southerland
Principal Consultant
Southerland Consulting
801.467.8090(office)
214.734.8099(cell)
john@southerland-consulting.com



Embedding SIGAR

$
0
0
I am trying to deploy SIGAR into an OSGi container.  If I set the proper system property and provide the lib relative to my container, I can get SIGAR to work as expected, but I can't assume I would have this wort of control.

is there an 'acceptable' way to embed SIGAR and provide, possibly with the loader, all the information SIGAR would need?

Thanks!

Birch

Announced sigar-amd64-winnt.dll missing in sourceforge's distributive

$
0
0
Hi!

In fact all the question is in subject. On SIGAR documentation you write that Windows amd64 is supported platform and sigar-amd64-winnt.dll library is included into binary distribution. But this file is missing in binary distribution downloaded from http://sourceforge.net/project/showfiles.php?group_id=172552 and as a result CIGAR fails when running on 64-bit Windows via 64-bit JVM.

sigar.getProcState(pid) returns process state Running for killed processes

$
0
0
I am trying to find state of a background process which is a perl script, code given below:
#!/usr/bin/perl
print "In process script Before sleep...\n";
sleep(300);
print "In process script After sleep...\n";


Now I am starting this script as a background process.
I am using "ps -ef" to get this process, pid.
Next I am trying to find state of the process using:

Sigar sigar = new Sigar();
ProcState procState = sigar.getProcState(pid);
System.out.println(procState.getName() + ": " +procState.toString());


and expecting to get SLEEPING, I get the state as RUNNING.
Even if I kill this process or the process is terminated normally I still get its state as RUNNING instead of STOPPED.
Is it a bug or I am missing something ???

sigar and multi-core/multi-cpu installations

$
0
0
so, how's sigar with that? i tried to run it on Pentium D (double core) and it shows only one CPU (both using getCpuPercList and getCpuList from a simple junit test and from command line, running sigar.jar). is it supported? or it only takes into account the CPU the JVM is run with?

java.lang.UnsatisfiedLinkError error on Linux 64-bit

$
0
0
Hi.

Any idea what I should do with Linux shared libraries, in order to resolve the "java.lang.UnsatisfiedLinkError" message?

I tried placing them in system lib directory, but it didn't work out.

Thanks in advance!

Adding sigar to j2ee application

$
0
0
Hi,
I would like to ask 2 questions regarding sigar:

1. When trying to test it on linux OS (see full information below) using your given example CpuInfo.java using the following commands from the hyperic-sigar-1.6.4/sigar-bin/lib directory:

javac -classpath ./sigar.jar CpuInfo.java
java -cp .;./sigar.jar CpuInfo

I am getting the following error:
Segmentation fault
./sigar.jar: line 1: PK: command not found
./sigar.jar: line 2: META-INF/?PK: No such file or directory
./sigar.jar: line 23: syntax error near unexpected token `('
./sigar.jar: line 23: `s#לM:¯y/f±

2. How can I add the Sigar to my j2eee application ? is it enough to only add the sigar.jar to the classpath ?

Thanks in advance.

System information:
Sigar version.......java=1.6.4.129, native=1.6.4.129
Build date..........java=04/28/2010 04:26 PM, native=04/28/2010 04:26 PM
SCM rev.............java=4b67f57, native=4b67f57
Archlib.............libsigar-amd64-linux.so
Current fqdn........192.168.168.117
Hostname............nglinux
Current user........esb7

OS description......Red Hat Enterprise Linux 5
OS name.............Linux
OS arch.............x86_64
OS machine..........x86_64
OS version..........2.6.18-194.3.1.el5
OS patch level......unknown
OS vendor...........Red Hat
OS vendor version...Enterprise Linux 5
OS code name........Tikanga
OS data model.......64
OS cpu endian.......null
Java vm version.....2.4
Java vm vendor......IBM Corporation
Java home.........../opt/IBM/WebSphere/ESB7/java/jre

Sigar on FreeBSD 10

$
0
0

Hello,

 

Recently updated my FreeBSD 8.3 system to 10.0 and now realized that Sigar is not supported on this version.

 

This page https://lists.freebsd.org/pipermail/freebsd-ports/2014-April/091414.html says: "fails to build with new utmpx".

As far as I can see utmpx replaced utmph in 9.0 so the problem most likely exists for that version too.

 

Is there a roadmap to add support for these FreeBSD versions?

 

Thank you!

Zsolt

getFileSystemUsage

$
0
0

Hi,

I am new to SIGAR and I am using “getFileSystemUsage” to get different File System stats.

It seems to be working fine but it’s returning values for “total” “free” etc in Kilo Bytes and not in Bytes as mention in the document.

Where as if I use “getDirStat” it return data in Bytes.

My Question is how we know if data return is in Bytes or Kilo Bytes.

Thanks for your help.

Start a new Process using SIGAR?

$
0
0
is there a possibility to create a process using SIGAR, does SIGAR wraps the WIN32 createProcess API. I know SIGAR can be used for gathering monitoring related data by supplying pid. but how about programatically creating a process and acquiring the pid of submitted process to gather ?

The documentation on this issue is not clear/commented?
Are there plans to incorporate this feature?

problems with NetInterfaceConfig class

$
0
0
excuse my english,
i made a class but all the values that print are null and i dont know why
this is the class


import org.hyperic.sigar.NetInterfaceConfig;

public class NewClass {
   
    public static void main(String[]args){
       
        NetInterfaceConfig ni=new NetInterfaceConfig();
   
        System.out.println(ni.getAddress()+" direcion");
        System.out.println(ni.getBroadcast()+" broadcast");
        System.out.println(ni.getDescription()+" descripcion");
        System.out.println(ni.getHwaddr()+" mac");
        System.out.println(ni.getMetric()+" metric");
        System.out.println(ni.getName()+" nombre");
        System.out.println(ni.getType()+" tipo ");
       
       
    }
}

/////////////////////
this is the output


null direcion
null broadcast
null descripcion
null mac
0 metric
null nombre
null tipo

how to monitor a short-lived process using sigar?

$
0
0
Hi,

We are having problems getting process info from a short-lived process.

In java, if you use ProcessBuilder to create and start the chmod command: chmod +x <some file>, then checking for the process using sigar doesn't seem to work for us.

I am using ProcessQuery and PTLQ to lookup the process. If I wrap the invocation of chmod into a shell script and then lookup the process for the shell script, our code seems to detect that.

On the mac, the chmod command takes 0.003s, but the wrapper shell script takes 0.063s. So the current thinking is that the process being so short-lived may be the problem. However, maybe the query is the problem? Or something else?

I'm wondering if there is either a sigar limitation in detecting a short-lived process, or perhaps, there is another less obvious sigar technique to monitor a short-lived process like chmod?

Using our windows-only non-sigar solution to monitor a process, we can detect the short-lived processes; however, we would like a cross-platform solution using just sigar, if that is possible.

Thx,

Hyperguy

network bandwidth utilization

$
0
0

Hi, I am using the Java APIs of Sigar to get CPU load and free memory (as percentages) and there are also plenty of good examples on the provided sources demonstrating that kind of functionality. However, how could I use Sigar to obtain a similar percentage for the network utilization? There doesn't seem to be an example demonstrating how one could get that information. I understand that the metric is not very well defined but I was thinking something along the lines of sum of incoming and outgoing traffic as a percentage of the Network Interface Card's bandwidth. Windows 7 at least provides such a metric in Task Manager, tab "Networking" and I was trying to get something similar using Java and Sigar.


Process monitoring error. Sigar command works but not in the configuration

$
0
0
I am trying to monitor a java process, specifically tripwire. There are multiple java processes on this box so I used the sigar console to drill down the process I want to monitor. The query/output from sigar is as follows:

sigar> ps State.Name.eq=java,Args.*.ct=tripwire
25822   root    23:46   132M     58M    -       S       0:5     java:com.tripwire.space.bootstrap.BootstrapLauncher

When I enter the query in the process.query field, "State.Name.eq=java,Args.*.ct=tripwire", the following error is returned:

The configuration has not been set for this resource due to : Invalid configuration: Error retrieving value: Failed to invoke getProcMem[State.Name.eq=java,Args.*.ct=tripwire]: Query did not match any processes: State.Name.eq=java,Args.*.ct=tripwire

The following is the DEBUG output from the local agent:

2007-10-29 20:07:59,989 DEBUG [MeasurementCommandsServer] Getting real time measurement: Process:sigar:Type=ProcCpu,Arg=State.Name.eq%3Djava%2CArgs.
*.ct%3Dtripwire:Percent
2007-10-29 20:07:59,991 DEBUG [MeasurementCommandsServer] Error getting real time measurement 'Process:sigar:Type=ProcCpu,Arg=State.Name.eq%3Djava%2
CArgs.*.ct%3Dtripwire:Percent': Error retrieving value: Failed to invoke getProcCpu[State.Name.eq=java,Args.*.ct=tripwire]: Query did not match any
processes: State.Name.eq=java,Args.*.ct=tripwire
org.hyperic.hq.product.MetricNotFoundException: Failed to invoke getProcCpu[State.Name.eq=java,Args.*.ct=tripwire]: Query did not match any processe
s: State.Name.eq=java,Args.*.ct=tripwire
        at org.hyperic.hq.product.SigarMeasurementPlugin.getValue(SigarMeasurementPlugin.java:211)
        at org.hyperic.hq.product.MeasurementPluginManager.getPluginValue(MeasurementPluginManager.java:171)
        at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:269)
        at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:130)
        at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:122)
        at org.hyperic.hq.measurement.agent.server.MeasurementCommandsServer.getMeasurements(MeasurementCommandsServer.java:292)
        at org.hyperic.hq.measurement.agent.server.MeasurementCommandsServer.dispatchCommand(MeasurementCommandsServer.java:503)
        at org.hyperic.hq.agent.server.CommandDispatcher.processRequest(CommandDispatcher.java:112)
        at org.hyperic.hq.agent.server.CommandListener.listenLoop(CommandListener.java:203)
        at org.hyperic.hq.agent.server.AgentDaemon.start(AgentDaemon.java:680)
        at org.hyperic.hq.agent.server.AgentDaemon$RunnableAgent.run(AgentDaemon.java:744)
        at org.hyperic.hq.agent.server.AgentDaemon.main(AgentDaemon.java:762)
Caused by: org.hyperic.sigar.SigarException: Failed to invoke getProcCpu[State.Name.eq=java,Args.*.ct=tripwire]: Query did not match any processes:
State.Name.eq=java,Args.*.ct=tripwire
        at org.hyperic.sigar.SigarInvoker.invoke(SigarInvoker.java:243)
        at org.hyperic.sigar.SigarInvoker.invoke(SigarInvoker.java:213)
        at org.hyperic.sigar.jmx.SigarInvokerJMX.invoke(SigarInvokerJMX.java:196)
        at org.hyperic.hq.product.SigarMeasurementPlugin.getValue(SigarMeasurementPlugin.java:204)

Any suggestions? Thanks.

Find child processes

$
0
0
Hi all,

Given a PID, how can I find all the child processes using SIGAR?

Kind regards,

Mohammed

Sigar command systax parameters

$
0
0
Hi All-

I’m new to this from.  I have a question and am hoping some of you expert out there can help.  Actually, thinking about it, this might seems like a pretty dumb question..

Speaking from a non developer, don’t-know-java perspective, how do I know what parameter to pass into each sigar commands?  For example, when I get into the sigar cmd line – i type help, and I get a list of available commands.  While some commands are pretty straight fwd, other seems a bit confusing. (to me anyway)  For example, take a look @ ‘get’.  Seems like its expect 2 parameter, which it calls ‘key’.  What’s a key?  Get is just one example of many of these commands that I don’t understand.

Basically, my question is, for someone like who cannot read the API code nor doc (don’t know Java), how would I know what parameter to pass each command?
I tried “help get” (help pidof, etc), and was unable to get a help meun.  Also I read tho the 7 pages of sigar Q&As, and was unable to find an answer.

Would someone be able to assist?

Thank you
Danny



sigar> help
Available commands:
        alias          - Create alias command
        cpuinfo        - Display cpu information
        df             - Report filesystem disk space usage
        du             - Display usage for a directory recursively
        free           - Display information about free and used memor
        fversion       - Display file version info
        get            - Get system properties
        help           - Gives help on shell commands
        ifconfig       - Network interface information
        iostat         - Report filesystem disk i/o
        kill           - Send signal to a process
        ls             - simple FileInfo test at the moment (like ls -
        mps            - Show multi process status
        netinfo        - Display network info
        netstat        - Display network connections
        nfsstat        - Display nfs stats
        pargs          - Show process command line arguments
        penv           - Show process environment
        pfile          - Display process file info
        pidof          - Find the process ID of a running program
        pinfo          - Display all process info
        pmodules       - Display process module info
        ps             - Show process status
        quit           - Terminate the shell
        route          - Kernel IP routing table
        service        - Windows service commands
        set            - Set system properties
        sleep          - Delay execution for the a number of seconds
        source         - Read a file, executing the contents
        sysinfo        - Display system information
        test           - Run sigar tests
        time           - Time command
        ulimit         - Display system resource limits
        uptime         - Display how long the system has been running
        version        - Display sigar and system version info
        who            - Show who is logged on
sigar> cpuinfo
Vendor.........Intel
Model..........Core(TM)2 CPU          4300  @ 1.80GHz
Mhz............1795
Total CPUs.....2

CPU 0.........
User Time.....0.0%
Sys Time......0.0%
Idle Time.....100.0%
Wait Time.....0.0%
Nice Time.....0.0%
Combined......0.0%
Irq Time......0.0%

CPU 1.........
User Time.....0.0%
Sys Time......0.0%
Idle Time.....100.0%
Wait Time.....0.0%
--More-- (Page 1 of 2)
Nice Time.....0.0%
Combined......0.0%
Irq Time......0.0%

Totals........
User Time.....0.0%
Sys Time......0.0%
Idle Time.....100.0%
Wait Time.....0.0%
Nice Time.....0.0%
Combined......0.0%
Irq Time......0.0%

sigar> get
get: Syntax: get <key1> [key2] ...
sigar>

Problem: SIGSEGV using SIGAR 1.6.2

$
0
0
Hi,

I am running into issues on both Linux (ubuntu 2.6.27) and OSX (10.5.6) using Java 6. The result is the JVM crashes. I have attached 2 files:

1. hs_err_pid24271.log : The crash file produced on Linux
2. java_2009-04-17-082543_CaneBay.crash :  The crash file generated on OSX

Both seem to point to the same problem:

j  org.hyperic.sigar.Cpu.gather(Lorg/hyperic/sigar/Sigar;)V+0
j  org.hyperic.sigar.Cpu.fetch(Lorg/hyperic/sigar/Sigar;)Lorg/hyperic/sigar/Cpu;+10
j  org.hyperic.sigar.Sigar.getCpu()Lorg/hyperic/sigar/Cpu;+1
j  org.hyperic.sigar.Sigar.getCpuPerc()Lorg/hyperic/sigar/CpuPerc;+8

Info on the machines that produced the issue:

OSX Machine
-------------------
Mac Pro, Quad-Core Intel Xeon, 8 cores

> uname -a
Darwin CaneBay.local 9.6.3 Darwin Kernel Version 9.6.3: Tue Jan 20 18:26:40 PST 2009; root:xnu-1228.10.33~1/RELEASE_I386 i386

> java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)

Linux Machine
-------------------
$ uname -a
Linux mahobay 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 GNU/Linux

$ java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

Hoping you can let me know if there is a workaround (aside from removing SIGAR from the runtime). Please let me know if I can provide or assist with any more information. If it would be easier to work this offline, please let me know that as well.

Regards

Dennis

Solaris sigar does not show all command line arguments

$
0
0
There are 5 java processes running on a Solaris 10 box that I have to monitor in Hyperic. The problem is that when doing a ps the command line gets cut off at 80 characters and the first 80 characters are all the same. When looking at the processes within sigar I see the same problem. IE

sigar> pargs 2967
pid=2967
exe=
cwd=
0=>/usr/jdk/instances/jdk1.5.0/bin/sparcv9/java<=
1=>-Xms3500M<=
2=>-Xmx3500M<=
3=>-classpath<=
4=>/op<=

At the moment we cannot change the way these get run becasue they belong to someone else and we cannot get them changed. My job is just to monitor them in hyperic, long term we might be able to get them changed but for now we need to be able to distinguish these 5 processes yet they all say the same thing is sigar becasue the rest of the command line arguments are missing.

Any Ideas?
Viewing all 9067 articles
Browse latest View live


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