Module: check_mk
Branch: master
Commit: 96b70f77aca82c14869d65cee6b8d0ae824b3cbe
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=96b70f77aca82c…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Feb 15 16:02:46 2013 +0100
fixed crash in iReport plugin on empty livestatus columns
---
.../classes/livestatus/LivestatusDatasource.class | Bin 3658 -> 3565 bytes
.../livestatus/LivestatusFieldsProvider.class | Bin 3304 -> 3584 bytes
.../livestatus/LivestatusQueryExecuter.class | Bin 5356 -> 7050 bytes
.../LivestatusQueryExecuterFactory.class | Bin 847 -> 1117 bytes
doc/jasperreports/livestatus.jar | Bin 10341 -> 8488 bytes
doc/jasperreports/src/LivestatusDatasource.java | 2 +-
.../src/LivestatusFieldsProvider.java | 2 -
doc/jasperreports/src/LivestatusQueryExecuter.java | 42 ++++++++++++--------
8 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/doc/jasperreports/classes/livestatus/LivestatusDatasource.class
b/doc/jasperreports/classes/livestatus/LivestatusDatasource.class
index 9479d59..d1d73b9 100644
Binary files a/doc/jasperreports/classes/livestatus/LivestatusDatasource.class and
b/doc/jasperreports/classes/livestatus/LivestatusDatasource.class differ
diff --git a/doc/jasperreports/classes/livestatus/LivestatusFieldsProvider.class
b/doc/jasperreports/classes/livestatus/LivestatusFieldsProvider.class
index 342f9a7..7a5fac7 100644
Binary files a/doc/jasperreports/classes/livestatus/LivestatusFieldsProvider.class and
b/doc/jasperreports/classes/livestatus/LivestatusFieldsProvider.class differ
diff --git a/doc/jasperreports/classes/livestatus/LivestatusQueryExecuter.class
b/doc/jasperreports/classes/livestatus/LivestatusQueryExecuter.class
index 120c792..666a83b 100644
Binary files a/doc/jasperreports/classes/livestatus/LivestatusQueryExecuter.class and
b/doc/jasperreports/classes/livestatus/LivestatusQueryExecuter.class differ
diff --git a/doc/jasperreports/classes/livestatus/LivestatusQueryExecuterFactory.class
b/doc/jasperreports/classes/livestatus/LivestatusQueryExecuterFactory.class
index f5ffb0d..cfb8bfe 100644
Binary files a/doc/jasperreports/classes/livestatus/LivestatusQueryExecuterFactory.class
and b/doc/jasperreports/classes/livestatus/LivestatusQueryExecuterFactory.class differ
diff --git a/doc/jasperreports/livestatus.jar b/doc/jasperreports/livestatus.jar
index f42084a..f6c48bd 100644
Binary files a/doc/jasperreports/livestatus.jar and b/doc/jasperreports/livestatus.jar
differ
diff --git a/doc/jasperreports/src/LivestatusDatasource.java
b/doc/jasperreports/src/LivestatusDatasource.java
index b64c026..5170e43 100644
--- a/doc/jasperreports/src/LivestatusDatasource.java
+++ b/doc/jasperreports/src/LivestatusDatasource.java
@@ -60,7 +60,7 @@ public class LivestatusDatasource implements JRDataSource,
JRRewindableDataSourc
if( column < 0 || column >= data.get(0).size() ) {
throw new JRException("Unknown Field:" + fieldname);
}
-
+
String value = (data.get(m_nIdx)).get(column);
// Cast string value according to type
if( map_fieldtypes.containsKey(fieldname) ){
diff --git a/doc/jasperreports/src/LivestatusFieldsProvider.java
b/doc/jasperreports/src/LivestatusFieldsProvider.java
index e85763d..0d5218a 100644
--- a/doc/jasperreports/src/LivestatusFieldsProvider.java
+++ b/doc/jasperreports/src/LivestatusFieldsProvider.java
@@ -1,14 +1,12 @@
package livestatus;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import net.sf.jasperreports.engine.JRDataset;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
-import net.sf.jasperreports.engine.JRValueParameter;
import net.sf.jasperreports.engine.design.JRDesignField;
import com.jaspersoft.ireport.designer.FieldsProvider;
diff --git a/doc/jasperreports/src/LivestatusQueryExecuter.java
b/doc/jasperreports/src/LivestatusQueryExecuter.java
index d465e28..93279f5 100644
--- a/doc/jasperreports/src/LivestatusQueryExecuter.java
+++ b/doc/jasperreports/src/LivestatusQueryExecuter.java
@@ -40,17 +40,25 @@ public class LivestatusQueryExecuter implements JRQueryExecuter{
public static void main(String[] args){
try {
//new LivestatusQueryExecuter("localhost 6561\nGET services\nColumns: host_name
check_command").createDatasource();
- String query = "localhost 6561\n"+
- "GET statehist\n" +
- "Columns: host_name service_description\n"+
- "Filter: time >= 1344195720\n"+
- "Filter: time <= 1344195776\n"+
- "Filter: host_name = localhost\n"+
- "Stats: sum duration_ok\n"+
- "Stats: sum duration_warning\n"+
- "Stats: sum duration_critical";
-
+// String query = "localhost 6557\n"+
+// "GET statehist\n" +
+// "Columns: host_name service_description\n"+
+// "Filter: time >= 1344195720\n"+
+// "Filter: time <= 1344195776\n"+
+// "Filter: host_name = localhost\n"+
+// "Stats: sum duration_ok\n"+
+// "Stats: sum duration_warning\n"+
+// "Stats: sum duration_critical";
+ String query = "localhost 6557\n"+
+ "GET statehist\n" +
+ "Columns: service_description time state duration duration_part
log_output\n" +
+// "Filter: service_description ~ /fshome" +
+ "Filter: time >= 1351724400";
+
+
JRDataSource sourci = new LivestatusQueryExecuter(query, null).createDatasource();
+
+
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -61,12 +69,13 @@ public class LivestatusQueryExecuter implements JRQueryExecuter{
public LivestatusQueryExecuter(String query, Map parameters) {
this.jasper_query = query;
this.parameters = new HashMap<String,String>();
- for ( Object key : parameters.keySet() ) {
- if ( parameters.get(key) == null ) {
- continue;
+ if (parameters != null)
+ for ( Object key : parameters.keySet() ) {
+ if ( parameters.get(key) == null ) {
+ continue;
+ }
+ this.parameters.put(key.toString(), parameters.get(key).toString());
}
- this.parameters.put(key.toString(), parameters.get(key).toString());
- }
// LivestatusQueryExecuterFactory.logFile(this.jasper_query);
// for (String key : this.parameters.keySet())
@@ -161,7 +170,6 @@ public class LivestatusQueryExecuter implements JRQueryExecuter{
// setup socket and in/output streams
setupSocket();
-
// query the column types and their descriptions
String table_name = livestatus_query.split("\n")[0].split("
")[1];
String desc_query = String.format("GET columns\nFilter: table =
%s\nColumnHeaders: off\nResponseHeader: fixed16\nOutputFormat: csv\nSeparators: 10 1 44
124\nKeepAlive: on\n\n", table_name);
@@ -219,7 +227,7 @@ public class LivestatusQueryExecuter implements JRQueryExecuter{
if( line == null )
break;
ArrayList<String> tmp_array = new ArrayList<String>();
- for( String field : line.split("\001") ){
+ for( String field : line.split("\001",-1) ){
tmp_array.add(field);
}
livestatus_data.add(tmp_array);