Rev 23724 | Rev 23731 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.smartdukaan.cron.monitored;import java.text.SimpleDateFormat;import java.util.Date;import java.util.HashMap;import java.util.Map;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.ComponentScan;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;import com.spice.profitmandi.common.enumuration.SchemeType;import com.spice.profitmandi.common.web.client.RestClient;@Component@ComponentScan("com.smartdukaan.cron.*")@ComponentScan("com.spice.profitmandi.common.*")public class NagiosMonitorTasks {private static final Logger log = LoggerFactory.getLogger(NagiosMonitorTasks.class);private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");@Autowiredprivate RestClient restClient;@Scheduled(fixedRate = 5000)public void reportCurrentTime() {log.info("The time is now {}", dateFormat.format(new Date()));}@Scheduled(fixedRate = 5 * 60 * 1000)public void reportSmsCount() throws Throwable {String htmlpage;int currentBalance = 0;String uri = "/MessagingGateway/LoginAction";Map<String, String> params = new HashMap<>();params.put("user", "srlsaholic");params.put("password", "sr18mar");String response = restClient.post(SchemeType.HTTP, "103.15.179.45", 8085, uri, params, new HashMap<>());// System.out.println("response Html"+response);if (response.length() > 0) {htmlpage = response.substring(response.indexOf("Current Balance"), response.indexOf("</div>")).substring((response.substring(response.indexOf("Current Balance"), response.indexOf("</div>")).indexOf(">"))+ 1,response.substring(response.indexOf("Current Balance"), response.indexOf("</div>")).length()).trim();/// System.out.println(htmlpage);currentBalance = Integer.parseInt(htmlpage);log.info("Got successfully parsed {}", currentBalance);}}}