fixed bug

for   default column - deviceID !!!
This commit is contained in:
snoop 2017-09-06 19:31:38 +09:00
parent dfe4de7128
commit 0cbf635c90
4 changed files with 145 additions and 6 deletions

View File

@ -115,8 +115,17 @@ public class WMICrawlerLinux extends WMICrawlerOS {
tempMap.put(columns.get(indexJ), datas[indexJ]); tempMap.put(columns.get(indexJ), datas[indexJ]);
} }
int tempSize = tempMap.size();
int metaSize = metaMap.size();
int resultSize = tempSize - metaSize;
int currentIdx = 0;
for (Map.Entry<String, Integer> info : metaMap.entrySet()) { for (Map.Entry<String, Integer> info : metaMap.entrySet()) {
row.set(info.getValue().intValue(), tempMap.get(info.getKey())); currentIdx = info.getValue().intValue();
if(currentIdx >= metaSize) {
currentIdx -= resultSize;
}
row.set(currentIdx, tempMap.get(info.getKey()));
} }

View File

@ -6,7 +6,7 @@ import com.jacob.com.EnumVariant;
import com.jacob.com.Variant; import com.jacob.com.Variant;
import com.loafle.overflow.crawler.config.Config; import com.loafle.overflow.crawler.config.Config;
import com.loafle.overflow.crawler.config.Item; import com.loafle.overflow.crawler.config.Item;
import com.loafle.overflow.crawler.config.Query; //import com.loafle.overflow.crawler.config.Query;
import com.loafle.overflow.crawler.result.OFResultSet; import com.loafle.overflow.crawler.result.OFResultSet;
import com.loafle.overflow.crawler.result.OFResultSetCol; import com.loafle.overflow.crawler.result.OFResultSetCol;

View File

@ -32,13 +32,13 @@ public class WMICrawlerTest {
} }
@Ignore // @Ignore
@Test @Test
public void testLinuxExe() throws Exception { public void testLinuxExe() throws Exception {
String command = "/home/snoop/temp/wmic"; String command = "/home/snoop/temp/wmic";
ProcessBuilder builder = new ProcessBuilder(command, "-U","administrator%!@#$qwer1234", "//192.168.1.1", "select * from Win32_OperatingSystem", "--namespace=root/cimv2", "--delimiter=||"); ProcessBuilder builder = new ProcessBuilder(command, "-U","administrator%dbseogns18", "//192.168.1.106", "SELECT Caption FROM Win32_LogicalDisk", "--namespace=root/cimv2", "--delimiter=||");
Process process = builder.start(); Process process = builder.start();
byte[] msg = new byte[1024]; byte[] msg = new byte[1024];
@ -117,13 +117,13 @@ public class WMICrawlerTest {
System.out.println(c); System.out.println(c);
} }
@Ignore // @Ignore
@Test @Test
public void testWMIJson() throws Exception { public void testWMIJson() throws Exception {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
ClassLoader classLoader = getClass().getClassLoader(); ClassLoader classLoader = getClass().getClassLoader();
String p = classLoader.getResource("config/example.json").getFile(); String p = classLoader.getResource("config/test.json").getFile();
Config c = mapper.readValue(new File(p),Config.class); Config c = mapper.readValue(new File(p),Config.class);
// Map<String, Object> map = new HashMap<>(); // Map<String, Object> map = new HashMap<>();

View File

@ -0,0 +1,130 @@
{
"id": "4",
"target": {
"auth": {
"pw": "dbseogns18",
"id": "administrator"
},
"connection": {
"ip": "192.168.1.106",
"port": "135",
"portType": "tcp",
"ssl": false
}
},
"schedule": {
"interval": "5"
},
"crawler": {
"name": "WMI_CRAWLER",
"container": "java_proxy"
},
"items": [{
"keys": [{
"metric": "cpu.usage.total.privilege",
"key": "PercentPrivilegedTime"
},
{
"metric": "cpu.usage.total.user",
"key": "PercentUserTime"
},
{
"metric": "cpu.usage.total.processor",
"key": "PercentProcessorTime"
},
{
"metric": "cpu.usage.total.idle",
"key": "PercentIdleTime"
}],
"queryInfo": {
"query": "SELECT PercentPrivilegedTime, PercentUserTime, PercentProcessorTime, PercentIdleTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name='_Total'",
"extend": {
"nameSpace": "root/cimv2",
"wmicPath": "/home/snoop/temp/wmic"
}
},
"mappingInfo": {
"parseDirection": "col",
"arrayColumns": null,
"keyColumns": null,
"valueColumn": null
}
},
{
"keys": [{
"metric": "disk.usage.free[$0]",
"key": "FreeSpace"
},
{
"metric": "disk.usage.total[$0]",
"key": "Size"
}],
"queryInfo": {
"query": "SELECT FreeSpace, Size, Caption FROM Win32_LogicalDisk",
"extend": {
"nameSpace": "root/cimv2",
"wmicPath": "/home/snoop/temp/wmic"
}
},
"mappingInfo": {
"parseDirection": "col",
"arrayColumns": ["Caption"],
"keyColumns": null,
"valueColumn": null
}
},
{
"keys": [{
"metric": "mem.usage.free.paging",
"key": "FreeSpaceInPagingFiles"
}],
"queryInfo": {
"query": "SELECT FreeSpaceInPagingFiles FROM Win32_OperatingSystem ",
"extend": {
"nameSpace": "root/cimv2",
"wmicPath": "/home/snoop/temp/wmic"
}
},
"mappingInfo": {
"parseDirection": "col",
"arrayColumns": null,
"keyColumns": null,
"valueColumn": null
}
},
{
"keys": [{
"metric": "mem.usage.free.physical",
"key": "FreePhysicalMemory"
},
{
"metric": "mem.usage.free.virtual",
"key": "FreeVirtualMemory"
},
{
"metric": "mem.usage.total.paging",
"key": "SizeStoredInPagingFiles"
},
{
"metric": "mem.usage.total.physical",
"key": "TotalVisibleMemorySize"
},
{
"metric": "mem.usage.total.virtual",
"key": "TotalVirtualMemorySize"
}],
"queryInfo": {
"query": "SELECT FreePhysicalMemory, FreeVirtualMemory, SizeStoredInPagingFiles, TotalVisibleMemorySize, TotalVirtualMemorySize FROM Win32_OperatingSystem",
"extend": {
"nameSpace": "root/cimv2",
"wmicPath": "/home/snoop/temp/wmic"
}
},
"mappingInfo": {
"parseDirection": "col",
"arrayColumns": null,
"keyColumns": null,
"valueColumn": null
}
}]
}