github.com/sacloud/iaas-api-go@v1.12.0/naked/simple_monitor.go (about)

     1  // Copyright 2022-2023 The sacloud/iaas-api-go Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package naked
    16  
    17  import (
    18  	"time"
    19  
    20  	"github.com/sacloud/iaas-api-go/types"
    21  )
    22  
    23  // SimpleMonitor シンプル監視
    24  type SimpleMonitor struct {
    25  	ID           types.ID               `json:",omitempty" yaml:"id,omitempty" structs:",omitempty"`
    26  	Name         string                 `json:",omitempty" yaml:"name,omitempty" structs:",omitempty"`
    27  	Description  string                 `yaml:"description"`
    28  	Tags         types.Tags             `yaml:"tags"`
    29  	Icon         *Icon                  `json:",omitempty" yaml:"icon,omitempty" structs:",omitempty"`
    30  	CreatedAt    *time.Time             `json:",omitempty" yaml:"created_at,omitempty" structs:",omitempty"`
    31  	ModifiedAt   *time.Time             `json:",omitempty" yaml:"modified_at,omitempty" structs:",omitempty"`
    32  	Availability types.EAvailability    `json:",omitempty" yaml:"availability,omitempty" structs:",omitempty"`
    33  	ServiceClass string                 `json:",omitempty" yaml:"service_class,omitempty" structs:",omitempty"`
    34  	Provider     *Provider              `json:",omitempty" yaml:"provider,omitempty" structs:",omitempty"`
    35  	Settings     *SimpleMonitorSettings `json:",omitempty" yaml:"settings,omitempty" structs:",omitempty"`
    36  	SettingsHash string                 `json:",omitempty" yaml:"settings_hash,omitempty" structs:",omitempty"`
    37  	Status       *SimpleMonitorStatus   `json:",omitempty" yaml:"status,omitempty" structs:",omitempty"`
    38  }
    39  
    40  // SimpleMonitorSettingsUpdate シンプル監視
    41  type SimpleMonitorSettingsUpdate struct {
    42  	Settings     *SimpleMonitorSettings `json:",omitempty" yaml:"settings,omitempty" structs:",omitempty"`
    43  	SettingsHash string                 `json:",omitempty" yaml:"settings_hash,omitempty" structs:",omitempty"`
    44  }
    45  
    46  // SimpleMonitorSettings シンプル監視セッティング
    47  type SimpleMonitorSettings struct {
    48  	SimpleMonitor *SimpleMonitorSetting `json:",omitempty" yaml:"simple_monitor,omitempty" structs:",omitempty"`
    49  }
    50  
    51  // SimpleMonitorSetting シンプル監視セッティング
    52  type SimpleMonitorSetting struct {
    53  	DelayLoop        int                       `json:",omitempty" yaml:"delay_loop,omitempty" structs:",omitempty"`
    54  	MaxCheckAttempts int                       `json:",omitempty" yaml:"max_check_attempts,omitempty" structs:",omitempty"`
    55  	RetryInterval    int                       `json:",omitempty" yaml:"retry_interval,omitempty" structs:",omitempty"`
    56  	HealthCheck      *SimpleMonitorHealthCheck `json:",omitempty" yaml:"health_check,omitempty" structs:",omitempty"`
    57  	Enabled          types.StringFlag          `yaml:"enabled"`
    58  	NotifyEmail      *SimpleMonitorNotifyEmail `json:",omitempty" yaml:"notify_email,omitempty" structs:",omitempty"`
    59  	NotifySlack      *SimpleMonitorNotifySlack `json:",omitempty" yaml:"notify_slack,omitempty" structs:",omitempty"`
    60  	NotifyInterval   int                       `json:",omitempty" yaml:"notify_interval,omitempty" structs:",omitempty"` // 再通知間隔(秒単位)
    61  	Timeout          int                       `json:",omitempty" yaml:"timeout,omitempty" structs:",omitempty"`
    62  }
    63  
    64  // SimpleMonitorHealthCheck シンプル監視 ヘルスチェック
    65  type SimpleMonitorHealthCheck struct {
    66  	Protocol          types.ESimpleMonitorProtocol `json:",omitempty" yaml:"protocol,omitempty" structs:",omitempty"`            // プロトコル
    67  	Port              types.StringNumber           `json:",omitempty" yaml:"port,omitempty" structs:",omitempty"`                // ポート
    68  	Path              string                       `json:",omitempty" yaml:"path,omitempty" structs:",omitempty"`                // HTTP/HTTPS監視の場合のリクエストパス
    69  	Status            types.StringNumber           `json:",omitempty" yaml:"status,omitempty" structs:",omitempty"`              // HTTP/HTTPS監視の場合の期待ステータスコード
    70  	SNI               types.StringFlag             `yaml:"sni"`                                                                  // HTTPS監視時のSNI有効/無効
    71  	Host              string                       `json:",omitempty" yaml:"host,omitempty" structs:",omitempty"`                // 対象ホスト(IP or FQDN)
    72  	BasicAuthUsername string                       `json:",omitempty" yaml:"basic_auth_username,omitempty" structs:",omitempty"` // HTTP/HTTPS監視の場合のBASIC認証 ユーザー名
    73  	BasicAuthPassword string                       `json:",omitempty" yaml:"basic_auth_password,omitempty" structs:",omitempty"` // HTTP/HTTPS監視の場合のBASIC認証 パスワード
    74  	ContainsString    string                       `json:",omitempty" yaml:"contains_string,omitempty" structs:",omitempty"`     // HTTP/HTTPS監視の場合にBODY中に含まれるべき文字列
    75  	QName             string                       `json:",omitempty" yaml:"qname,omitempty" structs:",omitempty"`               // DNS監視の場合の問い合わせFQDN
    76  	ExpectedData      string                       `json:",omitempty" yaml:"expected_data,omitempty" structs:",omitempty"`       // DNS/SNMP監視の場合の期待値
    77  	Community         string                       `json:",omitempty" yaml:"community,omitempty" structs:",omitempty"`           // SNMP監視の場合のコミュニティ名
    78  	SNMPVersion       string                       `json:",omitempty" yaml:"snmp_version,omitempty" structs:",omitempty"`        // SNMP監視 SNMPバージョン
    79  	OID               string                       `json:",omitempty" yaml:"oid,omitempty" structs:",omitempty"`                 // SNMP監視 OID
    80  	RemainingDays     int                          `json:",omitempty" yaml:"remaining_days,omitempty" structs:",omitempty"`      // SSL証明書 有効残日数
    81  	HTTP2             types.StringFlag             `yaml:"http2"`                                                                // HTTPS監視の場合にHTTP/2を利用するか
    82  	FTPS              types.ESimpleMonitorFTPS     `yaml:"ftps"`                                                                 // FTP監視の場合のFTPS接続のimplicit/explicit,値は空になり得る
    83  	VerifySNI         types.StringFlag             `yaml:"verify_sni"`
    84  }
    85  
    86  // SimpleMonitorNotifyEmail Eメールでの通知設定
    87  type SimpleMonitorNotifyEmail struct {
    88  	Enabled types.StringFlag `yaml:"enabled"` // 有効/無効
    89  	HTML    types.StringFlag `yaml:"html"`    // メール通知の場合のHTMLメール有効フラグ
    90  }
    91  
    92  // SimpleMonitorNotifySlack Slackでの通知設定
    93  type SimpleMonitorNotifySlack struct {
    94  	Enabled             types.StringFlag `yaml:"enabled"`                                                                // 有効/無効
    95  	IncomingWebhooksURL string           `json:",omitempty" yaml:"incoming_webhooks_url,omitempty" structs:",omitempty"` // Slack通知の場合のWebhook URL
    96  }
    97  
    98  // SimpleMonitorStatus シンプル監視 設定状況
    99  type SimpleMonitorStatus struct {
   100  	Target string `json:",omitempty" yaml:"target,omitempty" structs:",omitempty"` // 対象のIPアドレス or ホスト名
   101  }
   102  
   103  // SimpleMonitorHealthCheckStatus シンプル監視ステータス
   104  type SimpleMonitorHealthCheckStatus struct {
   105  	LastCheckedAt       *time.Time                 `json:",omitempty" yaml:"last_checked_at,omitempty" structs:",omitempty"`
   106  	LastHealthChangedAt *time.Time                 `json:",omitempty" yaml:"last_health_changed_at,omitempty" structs:",omitempty"`
   107  	Health              types.ESimpleMonitorHealth `json:",omitempty" yaml:"health,omitempty" structs:",omitempty"`
   108  	LatestLogs          []string                   `json:",omitempty" yaml:"latest_logs,omitempty" structs:",omitempty"`
   109  }