Skip to content

Commit

Permalink
Merge pull request #9 from squzy/feat/SSL
Browse files Browse the repository at this point in the history
Feat/ssl
  • Loading branch information
PxyUp authored Jan 23, 2021
2 parents 0686e5d + 253b040 commit 779aa9b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/shared/enums/schedulers.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum Types {
HTTP = 3,
SITE_MAP = 4,
HTTP_JSON_VALUE = 5,
SSL_EXPIRATION = 6,
}

export enum SelectorTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@
</mat-form-field>
<ng-container [ngSwitch]="form.get('type').value">
<ng-container formGroupName="config">
<ng-container *ngSwitchCase="SslExpirationType" formGroupName="sslExpirationConfig">
<mat-form-field>
<input
matInput
placeholder="{{ 'MODULES.MODALS.ADD_CHECKER.SELECT_HOST' | translate}}"
formControlName="host"
>
<mat-error
*ngIf="sslExpirationConfig.get('host').hasError('required')"
>{{ 'ERRORS.REQUIRED' | translate }}</mat-error>
<mat-error
*ngIf="sslExpirationConfig.get('host').hasError('pattern')"
>{{ 'ERRORS.notValidHost' | translate }}</mat-error>
</mat-form-field>
<mat-form-field>
<input
matInput
type="number"
placeholder="{{ 'MODULES.MODALS.ADD_CHECKER.SELECT_PORT' | translate}}"
formControlName="port"
>
<mat-error
*ngIf="sslExpirationConfig.get('port').hasError('required')"
>{{ 'ERRORS.REQUIRED' | translate }}</mat-error>
<mat-error
*ngIf="sslExpirationConfig.get('port').hasError('min')"
>{{ 'ERRORS.minInterval' | translate }}</mat-error>
<mat-error
*ngIf="sslExpirationConfig.get('port').hasError('notInteger')"
>{{ 'ERRORS.integer' | translate }}</mat-error>
<mat-error
*ngIf="sslExpirationConfig.get('port').hasError('max')"
>{{ 'ERRORS.maxPort' | translate }}</mat-error>
</mat-form-field>
</ng-container>
<ng-container *ngSwitchCase="TcpType" formGroupName="tcpConfig">
<mat-form-field>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ export class AddCheckerFormComponent implements OnDestroy {

HttpJsonValueType = Types.HTTP_JSON_VALUE;

SslExpirationType = Types.SSL_EXPIRATION;

schdedulerTypes = [
this.HttpType,
this.TcpType,
this.GrpcType,
this.SiteMapType,
this.HttpJsonValueType,
this.SslExpirationType,
];

methods = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE'];
Expand Down Expand Up @@ -87,6 +90,19 @@ export class AddCheckerFormComponent implements OnDestroy {
],
});

sslExpirationConfig = this.fb.group({
host: ['', Validators.compose([Validators.required, Validators.pattern(HOST_REGEXP)])],
port: [
null,
Validators.compose([
Validators.required,
Validators.min(1),
Validators.max(65535),
integerValidator,
]),
],
});

grpcConfig = this.fb.group({
service: [''],
host: ['', Validators.compose([Validators.required, Validators.pattern(HOST_REGEXP)])],
Expand Down Expand Up @@ -122,6 +138,9 @@ export class AddCheckerFormComponent implements OnDestroy {
[Types.HTTP_JSON_VALUE]: this.fb.group({
httpValueConfig: this.httpValueConfig,
}),
[Types.SSL_EXPIRATION]: this.fb.group({
sslExpirationConfig: this.sslExpirationConfig,
}),
};

form = this.fb.group({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ mat-card {
margin-top: 10px;
display: flex;
}
textarea {
min-height: 100px;
}
.example-item {
&:hover {
background-color: mat-color($primary, 50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ export class AddRuleFormComponent implements OnDestroy {
description: 'MODULES.MODALS.ADD_RULE.EXAMPLE_SCHEDULER_DURATION',
value: 'any(map(Last(2), { Duration(#)}), { # > 30 })',
},
{
description: 'MODULES.MODALS.ADD_RULE.EXAMPLE_SCHEDULER_SSL_EXPIRATION',
value: `Index(-1).Code == Error || (
Index(-1).Code == Ok &&
durationLess(
timeDiff(unixNanoToTime(float64ToInt64(getValue(Index(-1)).GetNumberValue())), NowTime()),
mulDuration(4,Week)
)
)`,
},
],
[`${OwnerType.INCIDENT_OWNER_TYPE_AGENT}`]: [
{
Expand Down
6 changes: 4 additions & 2 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
"2": "Grpc",
"3": "Http",
"4": "SiteMap",
"5": "Json value"
"5": "Json value",
"6": "SSL expiration"
},
"STATUS": {
"0": "Unspecified",
Expand All @@ -160,7 +161,7 @@
"AGENTS_TITLE": "Squzy Agents",
"AGENTS_DESCRIPTION": "Monitroing of host. Get CPU/MEMORY/DISK/NET metric and visualize them.",
"CHECKERS_TITLE": "Squzy Checkers",
"CHECKERS_DESCRIPTION": "Periodical monitoring of the external/internal resources. Supports TCP/HTTP/HTTPS/GRPC/SITEMAP/VALUE types",
"CHECKERS_DESCRIPTION": "Periodical monitoring of the external/internal resources. Supports TCP/HTTP/HTTPS/GRPC/SITEMAP/VALUE/SSL types",
"APPLICATION_TITLE": "Squzy Application Monitoring",
"APPLICATION_DESCRIPTION": "Collect metrict from application transactions + custom metrics",
"INCIDENTS_TITLE": "Squzy Incidents Manager",
Expand Down Expand Up @@ -218,6 +219,7 @@
"EXAMPLE_AGENT_DISK_LOAD": "In last 1 check disk '/System/Volumes/Data' used percent more than 50%",
"EXAMPLE_APPLICATION_FAILED_TRANSACTION": "Last two transaction with name '/times' was failed",
"EXAMPLE_APPLICATION_DURATION_TRANSACTION": "Last two transation with name '/times' and method 'GET' was more than 3000msec",
"EXAMPLE_SCHEDULER_SSL_EXPIRATION": "SSL check return error, or certificate expire in less than 4 weeks",
"TITLE": "Add rule",
"SELECT_NAME": "Provide name",
"NAME_HINT": "Better provide uniq name",
Expand Down
4 changes: 3 additions & 1 deletion src/assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
"2": "Grpc",
"3": "Http",
"4": "SiteMap",
"5": "Json value"
"5": "Json value",
"6": "SSL expiration"
},
"STATUS": {
"0": "Неопределенный",
Expand Down Expand Up @@ -239,6 +240,7 @@
"EXAMPLE_AGENT_DISK_LOAD": "В последней проверке диск '/System/Volumes/Data' заполнен больше чем на 50%",
"EXAMPLE_APPLICATION_FAILED_TRANSACTION": "Две последнии транзакции с именем '/times' были с ошибкой",
"EXAMPLE_APPLICATION_DURATION_TRANSACTION": "Две последнии транзакции с именем '/times' и методов 'GET' были дольше чем 3000мсек",
"EXAMPLE_SCHEDULER_SSL_EXPIRATION": "SSL проверка вернула ошибку, или сертификат истекает в течении 4 недель",
"AUTOCLOSE": "Закрывать автоматически инцидент",
"NAME_HINT": "Лучше выбирать уникальное имя",
"PROVIDE_RULE": "Укажите правило инцидента",
Expand Down

0 comments on commit 779aa9b

Please sign in to comment.