Subversion Repositories SmartDukaan

Rev

Rev 23738 | Rev 23794 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23724 amit.gupta 1
package com.smartdukaan.cron.monitored;
23723 amit.gupta 2
 
3
import java.util.HashMap;
4
import java.util.Map;
5
 
23755 amit.gupta 6
import org.apache.logging.log4j.LogManager;
7
import org.apache.logging.log4j.Logger;
23723 amit.gupta 8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.stereotype.Component;
10
 
11
import com.spice.profitmandi.common.enumuration.SchemeType;
12
import com.spice.profitmandi.common.web.client.RestClient;
23731 amit.gupta 13
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
23723 amit.gupta 14
 
15
@Component
16
public class NagiosMonitorTasks {
17
 
23755 amit.gupta 18
	private static final Logger log = LogManager.getLogger(NagiosMonitorTasks.class);
23723 amit.gupta 19
 
20
	@Autowired
21
	private RestClient restClient;
23731 amit.gupta 22
 
23
	@Autowired
24
	ItemRepository itemRepository;
23723 amit.gupta 25
 
26
	public void reportSmsCount() throws Throwable {
27
		String htmlpage;
28
		int currentBalance = 0;
29
		String uri = "/MessagingGateway/LoginAction";
30
		Map<String, String> params = new HashMap<>();
31
		params.put("user", "srlsaholic");
32
		params.put("password", "sr18mar");
33
		String response = restClient.post(SchemeType.HTTP, "103.15.179.45", 8085, uri, params, new HashMap<>());
34
		// System.out.println("response Html"+response);
35
		if (response.length() > 0) {
36
			htmlpage = response.substring(response.indexOf("Current Balance"), response.indexOf("</div>")).substring(
37
					(response.substring(response.indexOf("Current Balance"), response.indexOf("</div>")).indexOf(">"))
38
							+ 1,
39
					response.substring(response.indexOf("Current Balance"), response.indexOf("</div>")).length())
40
					.trim();
41
			/// System.out.println(htmlpage);
42
			currentBalance = Integer.parseInt(htmlpage);
23730 amit.gupta 43
			log.info("Got successfully parsed {}", currentBalance);
23723 amit.gupta 44
		}
45
	}
46
}