simple_monitor.go raw

   1  // Copyright 2022-2025 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  	MonitoringSuiteLog *MonitoringSuiteLogString `json:",omitempty" yaml:"monitoring_suite_log,omitempty" structs:",omitempty"`
  63  }
  64  
  65  // SimpleMonitorHealthCheck シンプル監視 ヘルスチェック
  66  type SimpleMonitorHealthCheck struct {
  67  	Protocol          types.ESimpleMonitorProtocol `json:",omitempty" yaml:"protocol,omitempty" structs:",omitempty"`            // プロトコル
  68  	Port              types.StringNumber           `json:",omitempty" yaml:"port,omitempty" structs:",omitempty"`                // ポート
  69  	Path              string                       `json:",omitempty" yaml:"path,omitempty" structs:",omitempty"`                // HTTP/HTTPS監視の場合のリクエストパス
  70  	Status            types.StringNumber           `json:",omitempty" yaml:"status,omitempty" structs:",omitempty"`              // HTTP/HTTPS監視の場合の期待ステータスコード
  71  	SNI               types.StringFlag             `yaml:"sni"`                                                                  // HTTPS監視時のSNI有効/無効
  72  	Host              string                       `json:",omitempty" yaml:"host,omitempty" structs:",omitempty"`                // 対象ホスト(IP or FQDN)
  73  	BasicAuthUsername string                       `json:",omitempty" yaml:"basic_auth_username,omitempty" structs:",omitempty"` // HTTP/HTTPS監視の場合のBASIC認証 ユーザー名
  74  	BasicAuthPassword string                       `json:",omitempty" yaml:"basic_auth_password,omitempty" structs:",omitempty"` // HTTP/HTTPS監視の場合のBASIC認証 パスワード
  75  	ContainsString    string                       `json:",omitempty" yaml:"contains_string,omitempty" structs:",omitempty"`     // HTTP/HTTPS監視の場合にBODY中に含まれるべき文字列
  76  	QName             string                       `json:",omitempty" yaml:"qname,omitempty" structs:",omitempty"`               // DNS監視の場合の問い合わせFQDN
  77  	ExpectedData      string                       `json:",omitempty" yaml:"expected_data,omitempty" structs:",omitempty"`       // DNS/SNMP監視の場合の期待値
  78  	Community         string                       `json:",omitempty" yaml:"community,omitempty" structs:",omitempty"`           // SNMP監視の場合のコミュニティ名
  79  	SNMPVersion       string                       `json:",omitempty" yaml:"snmp_version,omitempty" structs:",omitempty"`        // SNMP監視 SNMPバージョン
  80  	OID               string                       `json:",omitempty" yaml:"oid,omitempty" structs:",omitempty"`                 // SNMP監視 OID
  81  	RemainingDays     int                          `json:",omitempty" yaml:"remaining_days,omitempty" structs:",omitempty"`      // SSL証明書 有効残日数
  82  	HTTP2             types.StringFlag             `yaml:"http2"`                                                                // HTTPS監視の場合にHTTP/2を利用するか
  83  	FTPS              types.ESimpleMonitorFTPS     `yaml:"ftps"`                                                                 // FTP監視の場合のFTPS接続のimplicit/explicit,値は空になり得る
  84  	VerifySNI         types.StringFlag             `yaml:"verify_sni"`
  85  }
  86  
  87  // SimpleMonitorNotifyEmail Eメールでの通知設定
  88  type SimpleMonitorNotifyEmail struct {
  89  	Enabled types.StringFlag `yaml:"enabled"` // 有効/無効
  90  	HTML    types.StringFlag `yaml:"html"`    // メール通知の場合のHTMLメール有効フラグ
  91  }
  92  
  93  // SimpleMonitorNotifySlack Slackでの通知設定
  94  type SimpleMonitorNotifySlack struct {
  95  	Enabled             types.StringFlag `yaml:"enabled"`                                                                // 有効/無効
  96  	IncomingWebhooksURL string           `json:",omitempty" yaml:"incoming_webhooks_url,omitempty" structs:",omitempty"` // Slack通知の場合のWebhook URL
  97  }
  98  
  99  // SimpleMonitorStatus シンプル監視 設定状況
 100  type SimpleMonitorStatus struct {
 101  	Target string `json:",omitempty" yaml:"target,omitempty" structs:",omitempty"` // 対象のIPアドレス or ホスト名
 102  }
 103  
 104  // SimpleMonitorHealthCheckStatus シンプル監視ステータス
 105  type SimpleMonitorHealthCheckStatus struct {
 106  	LastCheckedAt       *time.Time                 `json:",omitempty" yaml:"last_checked_at,omitempty" structs:",omitempty"`
 107  	LastHealthChangedAt *time.Time                 `json:",omitempty" yaml:"last_health_changed_at,omitempty" structs:",omitempty"`
 108  	Health              types.ESimpleMonitorHealth `json:",omitempty" yaml:"health,omitempty" structs:",omitempty"`
 109  	LatestLogs          []string                   `json:",omitempty" yaml:"latest_logs,omitempty" structs:",omitempty"`
 110  }
 111