MENSAJE IMPORTANTE (Facturación electronica)
" +
+ "
Porcentaje Usabilidad Disco Servidor: " + ip + "
"+
+ "
"+
+ "Archivo Sistema | "+
+ "Tamaño | "+
+ "Usados | "+
+ "Disponibles | "+
+ "Uso% | "+
+ "Ubicacion |
";
+ int j = 0;
+ String valor = null;
+ log.info("Comenzando building template --> para envio getDiskInfo");
+ while((line = reader.readLine()) != null){
+ detalle.add(line);
+ output.append(line).append("\n");
+ if(j > 0){
+ try {
+ String[] parts = line.split("\\s+");
+ log.info("Longitud tuberia command info df -h -->" + parts.length);
+ if(parts.length == 1){
+ valor = parts[0];
+ } else if (parts.length == 6){
+ List partition = Arrays.stream(parts).collect(Collectors.toList());
+ if(parts[0] == null || parts[0].equals("")){
+ partition.set(0, valor);
+ }
+
+ if(Integer.parseInt(partition.get(4).replace("%","")) > Integer.parseInt(useDisk)){
+ this.templatePorcentajes += "Alerta: Se ha usado el " + partition.get(4) + " en la ubicación
"+ partition.get(5)+"
";
+ }
+
+ log.info("valor FileSystem template --> " + partition.get(0));
+ log.info("Longitud para crear template --> " + partition.size());
+ templateDetalle += ""+ partition.get(0) +" | ";
+ templateDetalle += ""+ partition.get(1)+" | ";
+ templateDetalle += ""+ partition.get(2)+" | ";
+ templateDetalle += ""+ partition.get(3)+" | ";
+ templateDetalle += ""+ partition.get(4)+" | ";
+ templateDetalle += ""+ partition.get(5)+" |
";
+
+ infoDisckDetalle.add(InfoCommanDTO.builder().fileSystem(partition.get(0))
+ .size(partition.get(1)).avail(partition.get(2)).used(partition.get(3)).usePercent(partition.get(4))
+ .mounted(partition.get(5)).build());
+ log.info("Creo objeto infoDisckDetalle --> " + partition.get(0));
+ }
+ } catch (Exception e){
+ log.info("Error creando template detalle" + e.getMessage());
+ }
+ }
+ j++;
+ }
+ log.info("--------------------------------------------------------------------");
+ log.info("IndoDisk -->" + infoDisckDetalle.toString());
+ log.info("Paso la creacion del detalle de disk server");
+ int i = 0;
+ String percentUse = "";
+ while((line = reader2.readLine()) != null){
+ if( i > 0 ){
+ String[] parts = line.split("\\s+");
+ if(parts.length > 1){
+ List info = Arrays.stream(parts).collect(Collectors.toList());
+ tokens = info;
+ percentUse = info.get(4);
+ }
+ }
+ i++;
+ }
+
+ templateDetalle += "
"+this.templatePorcentajes+"
";
+ log.info("Termino la creacion del template");
+ return InfoDisk.builder().serverInfo(output.toString()).ip(ip).percentageUse(percentUse)
+ .infoDiskHome(tokens.toString()).infoDetalle(infoDisckDetalle).template(templateDetalle).build();
+ }
+}
diff --git b/src/main/java/com/colsubsidio/monitor/failuresfe/business/failuresFe/FailuresBusiness.java a/src/main/java/com/colsubsidio/monitor/failuresfe/business/failuresFe/FailuresBusiness.java
new file mode 100644
index 0000000..9886295
--- /dev/null
+++ a/src/main/java/com/colsubsidio/monitor/failuresfe/business/failuresFe/FailuresBusiness.java
@@ -0,0 +1,11 @@
+package com.colsubsidio.monitor.failuresfe.business.failuresFe;
+
+import com.colsubsidio.monitor.failuresfe.dto.InfoDisk;
+import com.colsubsidio.monitor.failuresfe.dto.ResponseDTO;
+
+import java.io.IOException;
+
+public interface FailuresBusiness {
+ ResponseDTO cronExecuteFailuresFe() throws IOException;
+ ResponseDTO sendEmailInformation(InfoDisk infoDisk) throws IOException;
+}
diff --git b/src/main/java/com/colsubsidio/monitor/failuresfe/business/services/ApigeeService.java a/src/main/java/com/colsubsidio/monitor/failuresfe/business/services/ApigeeService.java
new file mode 100644
index 0000000..42765bb
--- /dev/null
+++ a/src/main/java/com/colsubsidio/monitor/failuresfe/business/services/ApigeeService.java
@@ -0,0 +1,75 @@
+package com.colsubsidio.monitor.failuresfe.business.services;
+
+import com.colsubsidio.monitor.failuresfe.dto.ApigeeTokenReqDTO;
+import com.colsubsidio.monitor.failuresfe.dto.ApigeeTokenResDTO;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.*;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+@Component
+public class ApigeeService {
+
+ @Value("${apigee.url}")
+ private String urlApi;
+
+ @Value("${apigee.token.clienteId}")
+ private String clienteId;
+
+ @Value("${apigee.token.clienteSecreto}")
+ private String clienteSecreto;
+
+ @Value("${apigee.token.maxTimeInMillis}")
+ private Long maxTimeInMillis;
+
+ @Value("${apigee.token.url}")
+ private String auth;
+
+ @Value("${apigee.path.logger}")
+ private String logger;
+
+ private String token;
+ private LocalDateTime tokenDate;
+
+ public String getToken() {
+ if (token == null) {
+ generateToken();
+ } else {
+ long tokenMillis = tokenDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
+ long currMillis = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
+ Long timeLive = currMillis - tokenMillis;
+ if (timeLive > maxTimeInMillis) {
+ generateToken();
+ }
+ }
+ return token;
+ }
+
+ private void generateToken() {
+ ApigeeTokenReqDTO request = new ApigeeTokenReqDTO();
+ request.setClienteId(clienteId);
+ request.setClienteSecreto(clienteSecreto);
+ token = postAccessToken(request).getAccess_token();
+ tokenDate = LocalDateTime.now();
+ }
+
+ public ApigeeTokenResDTO postAccessToken(ApigeeTokenReqDTO request) {
+ RestTemplate restTemplate = new RestTemplate();
+ UriComponentsBuilder uri = UriComponentsBuilder.fromHttpUrl(urlApi + auth);
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+
+ HttpEntity