Subversion Repositories SmartDukaan

Rev

Rev 23738 | Rev 23794 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23738 Rev 23755
Line 1... Line 1...
1
package com.smartdukaan.cron.monitored;
1
package com.smartdukaan.cron.monitored;
2
 
2
 
3
import java.text.SimpleDateFormat;
-
 
4
import java.util.Date;
-
 
5
import java.util.HashMap;
3
import java.util.HashMap;
6
import java.util.Map;
4
import java.util.Map;
7
 
5
 
8
import org.slf4j.Logger;
6
import org.apache.logging.log4j.LogManager;
9
import org.slf4j.LoggerFactory;
7
import org.apache.logging.log4j.Logger;
10
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.context.annotation.ComponentScan;
-
 
12
import org.springframework.scheduling.annotation.Scheduled;
-
 
13
import org.springframework.stereotype.Component;
9
import org.springframework.stereotype.Component;
14
import org.springframework.transaction.annotation.Transactional;
-
 
15
 
10
 
16
import com.spice.profitmandi.common.enumuration.SchemeType;
11
import com.spice.profitmandi.common.enumuration.SchemeType;
17
import com.spice.profitmandi.common.web.client.RestClient;
12
import com.spice.profitmandi.common.web.client.RestClient;
18
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
13
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
19
 
14
 
20
@Component
15
@Component
21
@Transactional(rollbackFor = Throwable.class)
-
 
22
public class NagiosMonitorTasks {
16
public class NagiosMonitorTasks {
23
 
17
 
24
	private static final Logger log = LoggerFactory.getLogger(NagiosMonitorTasks.class);
18
	private static final Logger log = LogManager.getLogger(NagiosMonitorTasks.class);
25
 
-
 
26
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
-
 
27
 
19
 
28
	@Autowired
20
	@Autowired
29
	private RestClient restClient;
21
	private RestClient restClient;
30
	
22
	
31
	@Autowired
23
	@Autowired
32
	ItemRepository itemRepository;
24
	ItemRepository itemRepository;
33
 
25
 
34
	@Scheduled(fixedRate = 5000)
-
 
35
	public void reportCurrentTime() {
-
 
36
		log.info("The time is now {}", dateFormat.format(new Date()));
-
 
37
	}
-
 
38
 
-
 
39
	@Scheduled(fixedRate = 30 * 60 * 1000)
-
 
40
	public void reportSmsCount() throws Throwable {
26
	public void reportSmsCount() throws Throwable {
41
		String htmlpage;
27
		String htmlpage;
42
		int currentBalance = 0;
28
		int currentBalance = 0;
43
		String uri = "/MessagingGateway/LoginAction";
29
		String uri = "/MessagingGateway/LoginAction";
44
		Map<String, String> params = new HashMap<>();
30
		Map<String, String> params = new HashMap<>();
Line 55... Line 41...
55
			/// System.out.println(htmlpage);
41
			/// System.out.println(htmlpage);
56
			currentBalance = Integer.parseInt(htmlpage);
42
			currentBalance = Integer.parseInt(htmlpage);
57
			log.info("Got successfully parsed {}", currentBalance);
43
			log.info("Got successfully parsed {}", currentBalance);
58
		}
44
		}
59
	}
45
	}
60
 
-
 
61
	@Scheduled(fixedRate = 30 * 60 * 1000)
-
 
62
	public void dbCheck() throws Throwable {
-
 
63
		log.info("Connected to database successfully {}", itemRepository.isExistById(23));
-
 
64
	}
-
 
65
}
46
}
66
47