<commit_before>package eu.cloudopting.monitoring;

import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import eu.cloudopting.monitoring.zabbix.DefaultZabbixApi;
import eu.cloudopting.monitoring.zabbix.Request;
import eu.cloudopting.monitoring.zabbix.RequestBuilder;

@Service
public class MonitoringService {
	private final Logger log = LoggerFactory.getLogger(MonitoringService.class);

	@Value("${zabbix.user}")
	private String zabbix_user;

	@Value("${zabbix.password}")
	private String zabbix_password;

	@Value("${zabbix.endpoint}")
	private String zabbix_endpoint;

	private DefaultZabbixApi zabbixApi;

	public void testZabbix() {
		String url = "http://tst-zabbix-opendata.odsp.csi.it/zabbix/api_jsonrpc.php";
		DefaultZabbixApi zabbixApi = new DefaultZabbixApi(url);
		zabbixApi.init();

		boolean login = zabbixApi.login(this.zabbix_user, this.zabbix_password);
		System.err.println("login:" + login);

		String host = "tst-zabbix-opendata.odsp.csi.it";
		JSONObject filter = new JSONObject();

		try {
			filter.put("host", new String[] { host });
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Request getRequest = RequestBuilder.newBuilder().method("host.get").paramEntry("filter", filter).build();
		JSONObject getResponse = this.zabbixApi.call(getRequest);
		System.err.println(getResponse);
		String hostid = null;
		try {
			hostid = getResponse.getJSONArray("result").getJSONObject(0).getString("hostid");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.err.println(hostid);

	}

	public boolean loginZabbix() {
		this.zabbixApi = new DefaultZabbixApi(this.zabbix_endpoint);
		this.zabbixApi.init();
		boolean login = zabbixApi.login(this.zabbix_user, this.zabbix_password);
		System.err.println("login:" + login);

		return login;
	}

	public JSONArray getHostId(String host) {

		JSONObject filter = new JSONObject();

		try {
			filter.put("host", new String[] { host });
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Request getRequest = RequestBuilder.newBuilder().method("host.get").paramEntry("filter", filter).build();

		JSONObject getResponse = this.zabbixApi.call(getRequest);
		JSONArray hosts = null;
		System.err.println(getResponse);
		String hostid = null;
		try {
//			hostid = getResponse.getJSONArray("result").getJSONObject(0).getString("hostid");
			hosts = getResponse.getJSONArray("result");
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.err.println(hostid);
		return hosts;
	}

	public JSONArray getItems(String hostid) {
		Request getRequest = RequestBuilder.newBuilder().method("item.get").paramEntry("output", "extend")
				.paramEntry("hostids", hostid).paramEntry("sortfield", "name").build();

		JSONObject getResponse = this.zabbixApi.call(getRequest);
		System.err.println(getResponse);
		JSONArray items = null;

		try {
			items = getResponse.getJSONArray("result");
			for (int i = 0; i < items.length(); i++) {
				JSONObject info = items.getJSONObject(i);
				log.debug(info.getString("description"));
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return items;
	}
	
	public JSONArray getDataHistory(String itemid) {
		return getDataHistory(itemid, "clock", "DESC", "100");
	}<commit_msg>Getting just integer values from zabbix<commit_after>package eu.cloudopting.monitoring;

import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import eu.cloudopting.monitoring.zabbix.DefaultZabbixApi;
import eu.cloudopting.monitoring.zabbix.Request;
import eu.cloudopting.monitoring.zabbix.RequestBuilder;

@Service
public class MonitoringService {
	private final Logger log = LoggerFactory.getLogger(MonitoringService.class);

	@Value("${zabbix.user}")
	private String zabbix_user;

	@Value("${zabbix.password}")
	private String zabbix_password;

	@Value("${zabbix.endpoint}")
	private String zabbix_endpoint;

	private DefaultZabbixApi zabbixApi;

	public void testZabbix() {
		String url = "http://tst-zabbix-opendata.odsp.csi.it/zabbix/api_jsonrpc.php";
		DefaultZabbixApi zabbixApi = new DefaultZabbixApi(url);
		zabbixApi.init();

		boolean login = zabbixApi.login(this.zabbix_user, this.zabbix_password);
		System.err.println("login:" + login);

		String host = "tst-zabbix-opendata.odsp.csi.it";
		JSONObject filter = new JSONObject();

		try {
			filter.put("host", new String[] { host });
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Request getRequest = RequestBuilder.newBuilder().method("host.get").paramEntry("filter", filter).build();
		JSONObject getResponse = this.zabbixApi.call(getRequest);
		System.err.println(getResponse);
		String hostid = null;
		try {
			hostid = getResponse.getJSONArray("result").getJSONObject(0).getString("hostid");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.err.println(hostid);

	}

	public boolean loginZabbix() {
		this.zabbixApi = new DefaultZabbixApi(this.zabbix_endpoint);
		this.zabbixApi.init();
		boolean login = zabbixApi.login(this.zabbix_user, this.zabbix_password);
		System.err.println("login:" + login);

		return login;
	}

	public JSONArray getHostId(String host) {

		JSONObject filter = new JSONObject();

		try {
			filter.put("host", new String[] { host });
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Request getRequest = RequestBuilder.newBuilder().method("host.get").paramEntry("filter", filter).build();

		JSONObject getResponse = this.zabbixApi.call(getRequest);
		JSONArray hosts = null;
		System.err.println(getResponse);
		String hostid = null;
		try {
//			hostid = getResponse.getJSONArray("result").getJSONObject(0).getString("hostid");
			hosts = getResponse.getJSONArray("result");
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.err.println(hostid);
		return hosts;
	}

	public JSONArray getItems(String hostid) {

		// just get integer values
		JSONObject filter = new JSONObject();
		try {
			filter.put("value_type", "3");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Request getRequest = RequestBuilder.newBuilder().method("item.get").paramEntry("output", "extend")
				.paramEntry("hostids", hostid).paramEntry("sortfield", "name").paramEntry("search", filter).build();

		JSONObject getResponse = this.zabbixApi.call(getRequest);
		System.err.println(getResponse);
		JSONArray items = null;

		try {
			items = getResponse.getJSONArray("result");
			for (int i = 0; i < items.length(); i++) {
				JSONObject info = items.getJSONObject(i);
				log.debug(info.getString("description"));
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return items;
	}
	
	public JSONArray getDataHistory(String itemid) {
		return getDataHistory(itemid, "clock", "DESC", "100");
	}
{'fraction_non_alphanumeric': 0.13543182118767358, 'fraction_numerical': 0.0022483798439359875, 'mean_word_length': 4.664419475655431, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7395459', 'n_tokens_mistral': 2666, 'n_tokens_neox': 2421, 'n_words': 475}