Package org.elasticsearch.monitor.sigar

Examples of org.elasticsearch.monitor.sigar.SigarService


    @Override protected void configure() {
        boolean sigarLoaded = false;
        try {
            settings.getClassLoader().loadClass("org.hyperic.sigar.Sigar");
            SigarService sigarService = new SigarService(settings);
            if (sigarService.sigarAvailable()) {
                bind(SigarService.class).toInstance(sigarService);
                bind(ProcessProbe.class).to(SigarProcessProbe.class).asEagerSingleton();
                bind(OsProbe.class).to(SigarOsProbe.class).asEagerSingleton();
                bind(NetworkProbe.class).to(SigarNetworkProbe.class).asEagerSingleton();
                sigarLoaded = true;
View Full Code Here


            });
            when(nodeEnv.nodeDataLocations()).thenReturn(dataLocations);
            bind(NodeEnvironment.class).toInstance(nodeEnv);

            Sigar sigar = mock(Sigar.class);
            SigarService sigarService = mock(SigarService.class);
            when(sigarService.sigarAvailable()).then(new Answer<Boolean>() {
                @Override
                public Boolean answer(InvocationOnMock invocation) throws Throwable {
                    return sigarAvailable;
                }
            });

            FileSystem fsFoo = mock(FileSystem.class);
            when(fsFoo.getDevName()).thenReturn("/dev/sda1");
            when(fsFoo.getDirName()).thenReturn("/foo");
            when(fsFoo.getType()).thenReturn(FileSystem.TYPE_LOCAL_DISK);

            FileSystem fsBar = mock(FileSystem.class);
            when(fsBar.getDevName()).thenReturn("/dev/sda2");
            when(fsBar.getDirName()).thenReturn("/bar");
            when(fsBar.getType()).thenReturn(FileSystem.TYPE_LOCAL_DISK);


            FileSystem fsFiltered = mock(FileSystem.class);
            when(fsFiltered.getType()).thenReturn(FileSystem.TYPE_UNKNOWN);
            when(fsFiltered.getDevName()).thenReturn(("/dev/filtered"));
            when(fsFiltered.getDirName()).thenReturn(("/filtered"));

            FileSystemMap map = mock(FileSystemMap.class);
            when(map.getMountPoint("/foo")).thenReturn(fsFoo);
            when(map.getMountPoint("/bar")).thenReturn(fsBar);
            when(map.getMountPoint("/filtered")).thenReturn(fsFiltered);
            FileSystemUsage usage = mock(FileSystemUsage.class, new Answer<Long>() {
                @Override
                public Long answer(InvocationOnMock invocation) throws Throwable {
                    return 42L;
                }
            });

            try {
                when(sigar.getFileSystemList()).thenReturn(new FileSystem[]{fsFoo, fsBar, fsFiltered});
                when(sigar.getFileSystemMap()).thenReturn(map);
                when(sigar.getFileSystemUsage(anyString())).thenReturn(usage);
                assertThat(sigar.getFileSystemUsage("/"), is(usage));
            } catch (SigarException e) {
                e.printStackTrace();
            }
            when(sigarService.sigar()).thenReturn(sigar);
            bind(SigarService.class).toInstance(sigarService);
            try {
                assertThat(sigarService.sigar().getFileSystemMap(), is(map));
            } catch (SigarException e) {
                e.printStackTrace();
            }

            HttpInfo httpInfo = mock(HttpInfo.class);
View Full Code Here

    @Test
    public void testValuesSmokeScreen() throws IOException {
        internalCluster().ensureAtMostNumDataNodes(5);
        internalCluster().ensureAtLeastNumDataNodes(1);
        SigarService sigarService = internalCluster().getInstance(SigarService.class);
        index("test1", "type", "1", "f", "f");
        /*
         * Ensure at least one shard is allocated otherwise the FS stats might
         * return 0. This happens if the File#getTotalSpace() and friends is called
         * on a directory that doesn't exist or has not yet been created.
         */
        ensureYellow("test1");
        ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
        String msg = response.toString();
        assertThat(msg, response.getTimestamp(), Matchers.greaterThan(946681200000l)); // 1 Jan 2000
        assertThat(msg, response.indicesStats.getStore().getSizeInBytes(), Matchers.greaterThan(0l));

        assertThat(msg, response.nodesStats.getFs().getTotal().bytes(), Matchers.greaterThan(0l));
        assertThat(msg, response.nodesStats.getJvm().getVersions().size(), Matchers.greaterThan(0));
        if (sigarService.sigarAvailable()) {
            // We only get those if we have sigar
            assertThat(msg, response.nodesStats.getOs().getAvailableProcessors(), Matchers.greaterThan(0));
            assertThat(msg, response.nodesStats.getOs().getAvailableMemory().bytes(), Matchers.greaterThan(0l));
            assertThat(msg, response.nodesStats.getOs().getCpus().size(), Matchers.greaterThan(0));
        }
View Full Code Here

    @Override
    protected void configure() {
        boolean sigarLoaded = false;
        try {
            settings.getClassLoader().loadClass("org.hyperic.sigar.Sigar");
            SigarService sigarService = new SigarService(settings);
            if (sigarService.sigarAvailable()) {
                bind(SigarService.class).toInstance(sigarService);
                bind(ProcessProbe.class).to(SigarProcessProbe.class).asEagerSingleton();
                bind(OsProbe.class).to(SigarOsProbe.class).asEagerSingleton();
                bind(NetworkProbe.class).to(SigarNetworkProbe.class).asEagerSingleton();
                bind(FsProbe.class).to(SigarFsProbe.class).asEagerSingleton();
View Full Code Here

TOP

Related Classes of org.elasticsearch.monitor.sigar.SigarService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.