Skip to content

Commit

Permalink
layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Aug 27, 2021
1 parent c45669e commit 8772b30
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 195 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ All you need is a configuration file defining the targets to monitor.
<smtp>...</smtp>
</mail>
<targets>
<target type="http">
<source>http://xxxxx</source>
<monitor>
<object type="web" >
<target>https://www.imixs.org</target>
<pattern>Imixs-Workflow supports the BPMN 2.0 standard</pattern>
</object>
<object type="web">
<target>https://foo.com/</target>
<pattern>my-data</pattern>
<auth type="basic">
<user>yyy</user>
<password>xxx</password>
</auth>
<expected>....regex...</expected>
</target>
</targets>
</object>
</monitor>
</muluk-def>


Expand Down
290 changes: 150 additions & 140 deletions src/main/java/org/imixs/muluk/MonitorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,145 +46,155 @@
@SessionScoped
public class MonitorController implements Serializable {

private static final long serialVersionUID = 1L;

private static Logger logger = Logger.getLogger(MonitorController.class.getName());

@Inject
MonitorService monitorService;

public MonitorController() {
super();

}

/**
* This method start the system setup during deployment
*
* @throws AccessDeniedException
*/
@PostConstruct
public void init() {
logger.info("...started");

logger.info("app start=" + monitorService.getStarted());

}

public Date getStarted() {
return monitorService.getStarted();
}

/**
* Returns the object availiblity
* @return
*/
public double getAvailability() {
double pings = getConfig().getObjectPings();
double errors = getConfig().getObjectErrors();
double total = pings + errors;
double result = 0;
if (total > 0) {
result = pings / total * 100;
}
return result;
}

/**
* Returns the cluster availability
*/
public double getClusterAvailability() {
double pings = getConfig().getClusterPings();
double errors = getConfig().getClusterErrors();
double total = pings + errors;
double result = 0;
if (total > 0) {
result = pings / total * 100;
}
return result;
}


/**
* Returns the objects.
*
* @return
*/
public XMLConfig getConfig() {
return monitorService.getConfig();
}

public String getName() {
return monitorService.getConfig().getCluster().getName();
}

/**
* Returns the objects.
*
* @return
*/
public XMLObject[] getObjects() {
return monitorService.getConfig().getMonitor().getObject();
}

public int getObjectsTotal() {
return monitorService.getConfig().getMonitor().getObject().length;
}

public int getObjectsUp() {
int result = 0;
XMLObject[] objects = monitorService.getConfig().getMonitor().getObject();
for (XMLObject obj : objects) {
if ("OK".equals(obj.getStatus())) {
result++;
}
}
return result;
}

public String getUptime() {

long different = System.currentTimeMillis() - monitorService.getStarted().getTime();
long secondsInMilli = 1000;
long minutesInMilli = secondsInMilli * 60;
long hoursInMilli = minutesInMilli * 60;
long daysInMilli = hoursInMilli * 24;
long elapsedDays = different / daysInMilli;
different = different % daysInMilli;

long elapsedHours = different / hoursInMilli;
different = different % hoursInMilli;

long elapsedMinutes = different / minutesInMilli;
different = different % minutesInMilli;

long elapsedSeconds = different / secondsInMilli;

String uptime = "";

if (elapsedDays > 0) {
uptime = uptime + elapsedDays + " days, ";
}
if (elapsedHours > 0) {
uptime = uptime + elapsedHours + " hours, ";
}

if (elapsedMinutes > 0) {
uptime = uptime + elapsedMinutes + " minutes, ";
}

uptime = uptime + elapsedSeconds + " seconds";

return uptime;

}

public int getClusterSize() {
return monitorService.getConfig().getCluster().getNode().length;
}

public XMLObject[] getClusterNodes() {
return monitorService.getConfig().getCluster().getNode();
}
private static final long serialVersionUID = 1L;

private static Logger logger = Logger.getLogger(MonitorController.class.getName());

@Inject
MonitorService monitorService;

public MonitorController() {
super();

}

/**
* This method start the system setup during deployment
*
* @throws AccessDeniedException
*/
@PostConstruct
public void init() {
logger.info("...started");

logger.info("app start=" + monitorService.getStarted());

}

public Date getStarted() {
return monitorService.getStarted();
}

/**
* Returns the object availiblity
*
* @return
*/
public double getAvailability() {
double pings = getConfig().getObjectPings();
double errors = getConfig().getObjectErrors();
double total = pings + errors;
double result = 0;
if (total > 0) {
result = pings / total * 100;
}
return result;
}

/**
* Returns the cluster availability
*/
public double getClusterAvailability() {
double pings = getConfig().getClusterPings();
double errors = getConfig().getClusterErrors();
double total = pings + errors;
double result = 0;
if (total > 0) {
result = pings / total * 100;
}
return result;
}

/**
* Returns the objects.
*
* @return
*/
public XMLConfig getConfig() {
return monitorService.getConfig();
}

public String getName() {
return monitorService.getConfig().getCluster().getName();
}

/**
* Returns the objects.
*
* @return
*/
public XMLObject[] getObjects() {
return monitorService.getConfig().getMonitor().getObject();
}

public int getObjectsTotal() {
return monitorService.getConfig().getMonitor().getObject().length;
}

public int getObjectsUp() {
int result = 0;
XMLObject[] objects = monitorService.getConfig().getMonitor().getObject();
for (XMLObject obj : objects) {
if ("OK".equals(obj.getStatus())) {
result++;
}
}
return result;
}

public String getUptime() {

long different = System.currentTimeMillis() - monitorService.getStarted().getTime();
long secondsInMilli = 1000;
long minutesInMilli = secondsInMilli * 60;
long hoursInMilli = minutesInMilli * 60;
long daysInMilli = hoursInMilli * 24;
long elapsedDays = different / daysInMilli;
different = different % daysInMilli;

long elapsedHours = different / hoursInMilli;
different = different % hoursInMilli;

long elapsedMinutes = different / minutesInMilli;
different = different % minutesInMilli;

long elapsedSeconds = different / secondsInMilli;

String uptime = "";

if (elapsedDays > 0) {
uptime = uptime + elapsedDays + " days, ";
}
if (elapsedHours > 0) {
uptime = uptime + elapsedHours + " hours, ";
}

if (elapsedMinutes > 0) {
uptime = uptime + elapsedMinutes + " minutes, ";
}

uptime = uptime + elapsedSeconds + " seconds";

return uptime;

}

public int getClusterSize() {
return monitorService.getConfig().getCluster().getNode().length;
}

public int getClusterUp() {
int result = 0;
for (XMLObject obj : monitorService.getConfig().getCluster().getNode()) {
if (MonitorService.STATUS_OK.equalsIgnoreCase(obj.getStatus())) {
result++;
}
}
return result;
}

public XMLObject[] getClusterNodes() {
return monitorService.getConfig().getCluster().getNode();
}

}
26 changes: 26 additions & 0 deletions src/main/webapp/css/dark/muluk.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ body {
box-shadow: inset 0 0 0.4em yellow, 0 0 0.4em yellow;
}



.container-panel:before {
border-left: 0.2em solid #ffff33;
border-right: 0.2em solid #ffff33;
Expand All @@ -134,6 +136,30 @@ body {
color: #ffff99;
}


.container-panel.red {
border: 0.2em solid #ff3333;
box-shadow: inset 0 0 0.4em red, 0 0 0.4em red;
}
.container-panel.red:before {
border-left: 0.2em solid #ff3333;
border-right: 0.2em solid #ff3333;
color: #ff9999;
text-shadow: 0 0 0.4em red;
}

.container-panel.green {
border: 0.2em solid #64ff47;
box-shadow: inset 0 0 0.4em #39ff14, 0 0 0.4em #39ff14;
}
.container-panel.green:before {
border-left: 0.2em solid #64ff47;
border-right: 0.2em solid #64ff47;
color: #baffad;
text-shadow: 0 0 0.4em #39ff14;
}


.container-panel p {
font-weight: bold;
}
Expand Down
Loading

0 comments on commit 8772b30

Please sign in to comment.