Skip to content

Commit

Permalink
feat: underlying server stats
Browse files Browse the repository at this point in the history
  • Loading branch information
pujavs committed Feb 11, 2022
1 parent a4a8784 commit 56b72e9
Show file tree
Hide file tree
Showing 13 changed files with 534 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package io.jans.configapi.model.status;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "memoryfree", "swapfree", "hostname", "ipaddress", "uptime", "free_disk_space", "load_average" })
public class FacterData {

@JsonProperty("memoryfree")
private String memoryfree;

@JsonProperty("swapfree")
private String swapfree;

@JsonProperty("hostname")
private String hostname;

@JsonProperty("ipaddress")
private String ipaddress;

@JsonProperty("uptime")
private String uptime;

@JsonProperty("free_disk_space")
private String freeDiskSpace;

@JsonProperty("load_average")
private String loadAverage;


@JsonProperty("memoryfree")
public String getMemoryfree() {
return memoryfree;
}

@JsonProperty("memoryfree")
public void setMemoryfree(String memoryfree) {
this.memoryfree = memoryfree;
}

@JsonProperty("swapfree")
public String getSwapfree() {
return swapfree;
}

@JsonProperty("swapfree")
public void setSwapfree(String swapfree) {
this.swapfree = swapfree;
}

@JsonProperty("hostname")
public String getHostname() {
return hostname;
}

@JsonProperty("hostname")
public void setHostname(String hostname) {
this.hostname = hostname;
}

@JsonProperty("ipaddress")
public String getIpaddress() {
return ipaddress;
}

@JsonProperty("ipaddress")
public void setIpaddress(String ipaddress) {
this.ipaddress = ipaddress;
}

@JsonProperty("uptime")
public String getUptime() {
return uptime;
}

@JsonProperty("uptime")
public void setUptime(String uptime) {
this.uptime = uptime;
}

@JsonProperty("free_disk_space")
public String getFreeDiskSpace() {
return freeDiskSpace;
}

@JsonProperty("free_disk_space")
public void setFreeDiskSpace(String freeDiskSpace) {
this.freeDiskSpace = freeDiskSpace;
}

@JsonProperty("load_average")
public String getLoadAverage() {
return loadAverage;
}

@JsonProperty("load_average")
public void setLoadAverage(String loadAverage) {
this.loadAverage = loadAverage;
}

@Override
public String toString() {
return "FacterData [memoryfree=" + memoryfree + ", swapfree=" + swapfree + ", hostname=" + hostname
+ ", ipaddress=" + ipaddress + ", uptime=" + uptime + ", freeDiskSpace=" + freeDiskSpace
+ ", loadAverage=" + loadAverage + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.jans.configapi.model.status;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import java.util.Date;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "dbType", "lastUpdate", "facterData", })
public class StatsData {

@JsonProperty("dbType")
private String dbType;

@JsonProperty("lastUpdate")
private Date lastUpdate;

@JsonProperty("facterData")
private FacterData facterData;

public String getDbType() {
return dbType;
}

public void setDbType(String dbType) {
this.dbType = dbType;
}

public Date getLastUpdate() {
return lastUpdate;
}

public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}

public FacterData getFacterData() {
return facterData;
}

public void setFacterData(FacterData facterData) {
this.facterData = facterData;
}

@Override
public String toString() {
return "StatsData [dbType=" + dbType + ", lastUpdate=" + lastUpdate + ", facterData=" + facterData + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private ApiConstants() {}
public static final String STATISTICS = "/stat";
public static final String USER = "/user";
public static final String ORG = "/org";
public static final String SERVER_STAT = "/server-stat";

public static final String LIMIT = "limit";
public static final String START_INDEX = "startIndex";
Expand Down
69 changes: 64 additions & 5 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tags:
- name: OAuth - Scopes
- name: Statistics - User
- name: Health - Check
- name: Server Stats
- name: SCIM - User Management
- name: SCIM - Config Management
- name: Organization Configuration
Expand Down Expand Up @@ -2378,6 +2379,23 @@ paths:
$ref: '#/components/schemas/HealthStatusItem'
'500':
description: Internal Server Error

/jans-config-api/api/v1/health/server-stat:
get:
summary: Returns application server status.
description: Returns application server status.
operationId: get-server-stat
tags:
- Server Stats
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/StatsData'
'500':
description: Internal Server Error

/jans-config-api/scim/user:
get:
Expand Down Expand Up @@ -2807,7 +2825,7 @@ paths:
$ref: '#/components/schemas/ErrorResponse'
security:
- oauth2: [https://jans.io/oauth/config/scim/users.read https://jans.io/scim/users.read]

/jans-config-api/scim/config:
get:
summary: Retrieves SCIM App configuration.
Expand Down Expand Up @@ -2860,7 +2878,7 @@ paths:
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'

/jans-config-api/api/v1/org:
get:
summary: Retrieves organization configuration.
Expand Down Expand Up @@ -2913,7 +2931,7 @@ paths:
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'

/jans-config-api/api/v1/jans-auth-server/health:
get:
summary: Returns auth server health status.
Expand Down Expand Up @@ -6598,7 +6616,7 @@ components:
useLocalCache:
type: boolean
description: Boolean value specifying whether to enable local in-memory cache.

Organization:
type: object
properties:
Expand Down Expand Up @@ -6640,5 +6658,46 @@ components:
jsFaviconPath:
type: string
description: Path to organization favicon image


FacterData:
type: object
properties:
memoryfree:
type: string
description: Server free memory
swapfree:
type: string
description: Server swap free
hostname:
type: string
description: Server hostname
ipaddress:
type: string
description: Server ipaddress
uptime:
type: string
description: Server uptime
free_disk_space:
type: string
description: Server free disk space
load_average:
type: string
description: Server average load time


StatsData:
type: object
properties:
dbType:
type: string
description: Jans Server DB type
lastUpdate:
type: string
description: Stats update time
facterData:
type: object
$ref: '#/components/schemas/FacterData'
description: Underlying Server stats


18 changes: 13 additions & 5 deletions jans-config-api/profiles/local/test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ test.scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/con
#test.issuer=https:// pujavs.jans.server3

# jans.server1
token.endpoint=https://jans.server1/jans-auth/restv1/token
token.grant.type=client_credentials
test.client.id=1800.ba5c72a0-733c-44e9-82fb-9c710e4e7408
test.client.secret=EcBbZAVoH8gr
test.issuer=https://jans.server1
#token.endpoint=https://jans.server1/jans-auth/restv1/token
#token.grant.type=client_credentials
#test.client.id=1800.df97feac-c94e-468d-9e22-48946da45403
#test.client.secret=OL13IYRG0IjV
#test.issuer=https://jans.server1

# jans.server2
#token.endpoint=https://jans.server2/jans-auth/restv1/token
Expand All @@ -59,3 +59,11 @@ test.issuer=https://jans.server1
#test.client.secret=aDiH4IuuGddZ
#test.issuer=https://jans.server3

# jans.server4
token.endpoint=https://jans.server4/jans-auth/restv1/token
token.grant.type=client_credentials
test.client.id=1800.7e78990f-fdae-40e9-9433-4fe20645851d
test.client.secret=GfUrIapPM71X
test.issuer=https://jans.server4


6 changes: 6 additions & 0 deletions jans-config-api/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@
<version>${jetty.version}</version>
</dependency>

<!-- Jython -->
<dependency>
<groupId>org.gluufederation</groupId>
<artifactId>jython-standalone</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Loading

0 comments on commit 56b72e9

Please sign in to comment.