Skip to content

Commit

Permalink
new services
Browse files Browse the repository at this point in the history
  • Loading branch information
boaglio committed Sep 25, 2017
1 parent 12d982d commit a27166c
Show file tree
Hide file tree
Showing 29 changed files with 518 additions and 104 deletions.
3 changes: 2 additions & 1 deletion appmon.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description":"app mon local",
"debug":true,
"debug":false,
"retentionSize":3,
"services":[
{"name":"Apache","port":80},
{"name":"Tomgato","port":8080},
Expand Down
3 changes: 2 additions & 1 deletion conf/appmon.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description":"app mon local",
"debug":true,
"debug":false,
"retentionSize":3,
"services":[
{"name":"Apache","port":80},
{"name":"Tomgato","port":8080},
Expand Down
9 changes: 9 additions & 0 deletions conf/appmon.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=appmon
After=syslog.target

[Service]
ExecStart=/opt/appmon/appmon.jar --server.port=34567

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions conf/boaglio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"description":"boaglio.com",
"debug":false,
"retentionSize":20,
"services":[
{"name":"FTP","port":21},
{"name":"Apache HTTP","port":80},
{"name":"Apache HTTPS","port":443},
{"name":"Net","port":2288},
{"name":"MySQL","port":3306},
{"name":"Pequeno Principe Bot","port":8080},
{"name":"Pra La","port":8090},
{"name":"MongoDB","port":27017}
]
}
13 changes: 13 additions & 0 deletions conf/srvcafe01.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"description":"srvcafe01",
"debug":false,
"retentionSize":20,
"services":[
{"name":"FTP","port":21},
{"name":"Apache HTTP","port":80},
{"name":"Apache HTTPS","port":443},
{"name":"Net","port":2288},
{"name":"MySQL","port":3306},
{"name":"PostgreSQL","port":5432}
]
}
11 changes: 11 additions & 0 deletions conf/srvhqbeds01.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description":"srvhqbeds01",
"debug":false,
"retentionSize":20,
"services":[
{"name":"Apache HTTP","port":80},
{"name":"Apache HTTPS","port":443},
{"name":"Net","port":2288},
{"name":"MySQL","port":3306}
]
}
13 changes: 13 additions & 0 deletions conf/srvhqbeds02.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"description":"srvhqbeds02",
"debug":false,
"retentionSize":20,
"services":[
{"name":"Apache HTTP","port":80},
{"name":"Apache HTTPS","port":443},
{"name":"Net","port":2288},
{"name":"JIRA","port":8005},
{"name":"JIRA","port":8080},
{"name":"Portainer","port":9000}
]
}
30 changes: 30 additions & 0 deletions conf/srvhqbeds03.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"description":"srvhqbeds03",
"debug":false,
"retentionSize":20,
"services":[
{"name":"Apache HTTP","port":80},
{"name":"Net","port":2288},
{"name":"Portainer","port":9000},
{"name":"Jenkins","port":9090},
{"name":"mariadb5","port":3300},
{"name":"hqbox1-mariadb","port":3301},
{"name":"hqbox2-mariadb","port":3302},
{"name":"hqbox-greenhaven-mariadb","port":3303},
{"name":"hqbox-beiramar-mariadb","port":3304},
{"name":"hqbox-bamboorio-mariadb","port":3305},
{"name":"apache-php5","port":11000},
{"name":"apache-php7","port":22000},
{"name":"hqbox1-php","port":50001},
{"name":"hqbox2-php","port":50002},
{"name":"hqbox-greenhaven-php","port":50003},
{"name":"hqbox-beiramar-php","port":50004},
{"name":"hqbox-bamboorio-php","port":50005},
{"name":"phpmyadmin-mariadb5","port":60000},
{"name":"hqbox1-phpmyadmin","port":60001},
{"name":"hqbox2-phpmyadmin","port":60002},
{"name":"hqbox-greenhaven-phpmyadmin","port":60003},
{"name":"hqbox-beiramar-phpmyadmin","port":60004},
{"name":"hqbox-bamboorio-phpmyadmin","port":60005}
]
}
33 changes: 25 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -56,26 +55,44 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- thymeleaf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
<!-- www -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7-1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.2.1</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
</dependencies>

<build>
<finalName>appmon</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/","/home","/stats").permitAll()
.antMatchers("/","/home","/stats**","/stats/**","/detail/**","/metrics").permitAll()
.antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/images/**", "/webjars/**").permitAll()
.anyRequest().authenticated()
.and()
Expand Down
42 changes: 38 additions & 4 deletions src/main/java/com/boaglio/appmon/controller/LoginController.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
package com.boaglio.appmon.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import com.boaglio.appmon.dto.Config;
import com.boaglio.appmon.dto.FullStats;
import com.boaglio.appmon.dto.ServiceStats;
import com.boaglio.appmon.dto.ServiceStatsWithTime;
import com.boaglio.appmon.dto.Stats;

@Controller
public class LoginController {

@Autowired
public LoginController(FullStats fullStats) {
this.fullStats = fullStats;
}

private FullStats fullStats;

@GetMapping("/login")
public String login() {
return "/login";
Expand All @@ -27,13 +46,28 @@ public String logoutPage(HttpServletRequest request,HttpServletResponse response
}

@GetMapping("/")
public String home1() {
return "/home";
public ModelAndView homeRoot() {
return new ModelAndView("/home","description",Config.getInstance().getDescription());
}

@GetMapping("/home")
public String home() {
return "/home";
public ModelAndView home() {
return new ModelAndView("/home","description",Config.getInstance().getDescription());
}

@GetMapping("/detail/{service}")
public ModelAndView detail(@PathVariable("service") String service) {

List<ServiceStatsWithTime> list = new ArrayList<ServiceStatsWithTime>();
for (Stats s : fullStats.getAllStats()) {
for (ServiceStats ss : s.getServiceStats()) {
if (ss.getService().getName().equalsIgnoreCase(service)) {
list.add(new ServiceStatsWithTime(ss.getService(),ss.getStatus(),s.getDate()));
}
}
}
return new ModelAndView("/detail","list",list);

}

@GetMapping("/403")
Expand Down
32 changes: 21 additions & 11 deletions src/main/java/com/boaglio/appmon/controller/StatsController.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.boaglio.appmon.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.boaglio.appmon.dto.FullStats;
import com.boaglio.appmon.dto.ServiceStats;
import com.boaglio.appmon.dto.ServiceStatsWithTime;
import com.boaglio.appmon.dto.Stats;
import com.boaglio.appmon.util.FileSystemUtil;

Expand All @@ -20,20 +26,24 @@ public StatsController(FileSystemUtil fileSystemUtil,FullStats fullStats) {
this.fullStats = fullStats;
}

@GetMapping("/stats-online")
public Stats statsOnline() {
Stats stats = new Stats();
stats.setFileSystem(fileSystemUtil.refresh());
return stats;
}

@GetMapping("/stats-full")
public FullStats statsFull() {
return fullStats;
@GetMapping("/stats/{service}")
public List<ServiceStatsWithTime> statsByService(@PathVariable("service") String service) {

List<ServiceStatsWithTime> list = new ArrayList<ServiceStatsWithTime>();
for (Stats s : fullStats.getAllStats()) {
for (ServiceStats ss : s.getServiceStats()) {
if (ss.getService().getName().equalsIgnoreCase(service)) {
list.add(new ServiceStatsWithTime(ss.getService(),ss.getStatus(),s.getDate()));
}
}
}
return list;
}

@GetMapping("/stats")
public Stats stats() {
return fullStats.getLastStats();
Stats stats = fullStats.getLastStats();
stats.setFileSystem(fileSystemUtil.refresh());
return stats;
}
}
21 changes: 15 additions & 6 deletions src/main/java/com/boaglio/appmon/domain/Partition.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.boaglio.appmon.domain;

import com.boaglio.appmon.util.FormatUtil;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -23,16 +24,24 @@ public String getName() {
return name;
}

public long getTotalSpace() {
return totalSpace;
public String getTotalSpace() {
return FormatUtil.humanReadableByteCount(totalSpace);
}

public long getUsabledSpace() {
return usabledSpace;
public String getUsabledSpace() {
return FormatUtil.humanReadableByteCount(usabledSpace);
}

public long getUsedSpace() {
return usedSpace;
public int getUsabledSpacePercent() {
return (int) (usabledSpace * 100 / totalSpace);
}

public String getUsedSpace() {
return FormatUtil.humanReadableByteCount(usedSpace);
}

public int getUsedSpacePercent() {
return (int) (usedSpace * 100 / totalSpace);
}

}
12 changes: 11 additions & 1 deletion src/main/java/com/boaglio/appmon/dto/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class Config implements Serializable {

private static final long serialVersionUID = 1297479827022295470L;
private static final long serialVersionUID = -8517384012883814458L;

private static Config instance = new Config();

Expand All @@ -19,6 +19,8 @@ public static void updateInstance(Config c) {

private Config() {}

private Integer retentionSize;

private String description;

private List<com.boaglio.appmon.domain.Service> services;
Expand Down Expand Up @@ -49,6 +51,14 @@ public void setDebug(Boolean debug) {
this.debug = debug;
}

public Integer getRetentionSize() {
return retentionSize;
}

public void setRetentionSize(Integer retentionSize) {
this.retentionSize = retentionSize;
}

@Override
public String toString() {
return "Config [description=" + description + ", services=" + services + ", debug=" + debug + "]";
Expand Down
Loading

0 comments on commit a27166c

Please sign in to comment.