Documentation
¶
Index ¶
- Constants
- func BackupConfig(srcDir string, targetDir string, filename string) error
- func CheckDirectory(path string) (bool, error)
- func CheckFile(path string) (bool, error)
- func CheckProcess(pid int, keyword string) bool
- func CopyFile(srcPath, targetPath string) error
- func GetCurrentTime(sec int, dateFormat DateFormat) string
- func GetHostname() (string, error)
- func GetHostnameAlias(hostName string) (string, error)
- func GetParentAbsPath(inPath string, parentLevel int) (string, error)
- func GetParentPath(inPath string, parentLevel int) string
- func GetTimeString(dateFormat DateFormat, t time.Time) string
- func MakeContext(timeout int) (context.Context, context.CancelFunc)
- func ReadFileHead(filename string, maxRow int) ([]string, error)
- func Run(ctx context.Context, argv []string, stdout, stderr io.Writer) error
- func TrimPathSeparator(path string) string
- func Usage(msgs *[]string)
- type Collector
- type CommandInfo
- func (c *CommandInfo) ExecCommandNoRedirect() error
- func (c *CommandInfo) ExecCommandNoRedirectWithContext(ctx context.Context) error
- func (c *CommandInfo) ExecCommandRedirect() error
- func (c *CommandInfo) ExecCommandRedirectWithContext(ctx context.Context) error
- func (c *CommandInfo) PeriodicLoopCommand(ctx context.Context, cycle, step int) error
- type Config
- func (config *Config) ArchiveData(task *Task, datastore *Datastore) error
- func (config *Config) AuthLicense(expire int) error
- func (config *Config) CheckConfig() error
- func (config *Config) CheckDiskUtil() error
- func (config *Config) CheckExitFile() (string, error)
- func (config *Config) CheckHAStatus() error
- func (config *Config) CheckHostname(hostname string) bool
- func (config *Config) CheckLicense(expired int) error
- func (config Config) CheckPathInHome(path string) (bool, error)
- func (config *Config) CheckServiceExist(pid int) bool
- func (config Config) CheckWorkFile(filename string) (bool, error)
- func (config *Config) DownloadLicense() error
- func (config Config) GetArchivefilePath(filename string) string
- func (config *Config) GetCollector(statName string) *Collector
- func (config *Config) GetServiceOrHostName() string
- func (config Config) GetWorkfilePath(filename string) string
- func (c *Config) InitAgent() error
- func (c *Config) NewDatastore(statName string, start time.Time) (*Datastore, error)
- func (c *Config) NewDatastoreCurrent(statName string) (*Datastore, error)
- func (config *Config) PostTask(task *Task)
- func (config *Config) PrepareCollector(c *Collector) error
- func (config *Config) PurgeData(task *Task, datastore *Datastore) error
- func (config Config) ReadPid() (int, error)
- func (config Config) ReadWorkFile(filename string) ([]string, error)
- func (config Config) ReadWorkFileHead(filename string, maxRow int) ([]string, error)
- func (config Config) ReadWorkFileNumber(filename string) (int, error)
- func (config Config) RemoveArchiveFile(filename string) error
- func (config Config) RemoveWorkFile(filename string) error
- func (config *Config) Run() error
- func (config *Config) RunTask(c *Collector, count int, tasks chan<- *Task)
- func (config *Config) RunWithContext(ctx context.Context) error
- func (config *Config) SaveReport(task *Task, datastore *Datastore) error
- func (config *Config) SendCollectorData(zip string) error
- func (config *Config) SendCollectorDataAll(datastore *Datastore) error
- func (config *Config) Stop() error
- func (config *Config) UnzipSSLConf() error
- func (config Config) WriteLineWorkFile(filename, line string) error
- func (config Config) WriteWorkFile(filename string, lines []string) error
- func (config Config) WriteWorkFileNumber(filename string, num int) error
- type ConfigEnv
- type Datastore
- type DateFormat
- type DiskStatus
- type Job
- type ProcMode
- type ReportTask
- type ReportTaskJob
- type ReportTaskTime
- type Schedule
- type Task
- type TaskJob
Constants ¶
const ( DEFAULT_DISK_CAPACITY int = 10 DEFAULT_SAVE_HOUR = 3 DEFAULT_RECOVERY_HOUR = 3 DEFAULT_MAX_ERROR_LOG = 10 DEFAULT_COMMAND_TIMEOUT = 86400 LIMIT_MAX_ERROR_LOG = 10000 DEFAULT_PROXY_PORT = 8080 DEFAULT_LOG_LEVEL = 3 DEFAULT_LOG_SIZE = 100000 DEFAULT_LOG_ROTATION = 5 POLLER_INTERVAL = 60 )
Default set fo gcwin.yaml
Variables ¶
This section is empty.
Functions ¶
func BackupConfig ¶
BackupConfig は構成ファイルのバックアップをします。
func CheckDirectory ¶
CheckDirectory はディレクトリの存在確認をします。
func GetCurrentTime ¶
func GetCurrentTime(sec int, dateFormat DateFormat) string
GetCurrentTime は指定したフォーマット形式で何秒前の現在時刻を取得します。
func GetHostnameAlias ¶
GetHostnameAlias はホスト名の「.」以降の文字列はカットし、大文字は小文字に変換します。
func GetParentAbsPath ¶
GetParentPathAbs は実行パスから上位のディレクトリを絶対パスに変換して返します。
func GetParentPath ¶
GetParentPathAbs は実行パスから上位のディレクトリを絶対パスに変換して返します。
func GetTimeString ¶
func GetTimeString(dateFormat DateFormat, t time.Time) string
gpfDGetTimeString は指定したフォーマット形式で時刻を変換します。
GPF_DATE_FORMAT_DEFAULT 0 GPF_DATE_FORMAT_YYYYMMDD 1 GPF_DATE_FORMAT_HHMISS 2 GPF_DATE_FORMAT_YYYYMMDD_HHMISS 3 GPF_DATE_FORMAT_DIR 4
func MakeContext ¶
func MakeContext(timeout int) (context.Context, context.CancelFunc)
func ReadFileHead ¶
ReadFile はファイルを指定した行数分読み込みます。
func TrimPathSeparator ¶
TrimPathSeparator はパス名(/tmp/log/data/)から前後のセパレータを 取り除きます(tmp/log/data)
Types ¶
type Collector ¶
type Collector struct {
Id int /**< primary key(sequence) */
StatName string /**< Metric */
Status string
StatEnable bool /**< Enabled */
Build int /**< Build version */
StatStdoutLog bool /**< Standard output flag */
StatInterval int /**< Interval(sec) */
StatTimeout int /**< Timeout(sec) */
NextTimestamp time.Time
StatMode string /**< Stataus mode */
Jobs []*Job /**< First job */
}
func NewCollector ¶
type CommandInfo ¶
type CommandInfo struct {
CmdLine string
OutPath string
Timeout int
Executed bool
Pid int
ExitCode int
Status string
OutBuf string
}
func (*CommandInfo) ExecCommandNoRedirect ¶
func (c *CommandInfo) ExecCommandNoRedirect() error
func (*CommandInfo) ExecCommandNoRedirectWithContext ¶
func (c *CommandInfo) ExecCommandNoRedirectWithContext(ctx context.Context) error
func (*CommandInfo) ExecCommandRedirect ¶
func (c *CommandInfo) ExecCommandRedirect() error
func (*CommandInfo) ExecCommandRedirectWithContext ¶
func (c *CommandInfo) ExecCommandRedirectWithContext(ctx context.Context) error
func (*CommandInfo) PeriodicLoopCommand ¶
func (c *CommandInfo) PeriodicLoopCommand(ctx context.Context, cycle, step int) error
type Config ¶
type Config struct {
Module int // Module id(S:Scheduler, C:Collector, W:Worker)
ElapseTime int // Elapsed time(sec)
StartTime time.Time // Start time(UTC)
Mode ProcMode // Status(INIT, WAIT, RUN, ...)
ManagedPid int // Scheduler process id
DaemonFlag int // Daemon flag
Host string // Hostname(Convert to lowercase , except the domain part)
ServiceName string // HA service name
Pwd string // Current directory
Home string // Home directory
ParameterFile string // Parameter file
ProgramName string // Program name
ProgramPath string // Program path
OutDir string // Metric collection directory
WorkDir string // Work directory
WorkCommonDir string // Common work directory
ArchiveDir string // Archive directory
ScriptDir string // Script directory
BinDir string // Binary directory
LogDir string // Application log directory
ExitFlag string // Exit flag file
PidFile string // PID file
PidPath string // PID absolute path
// SslConfig *soap.SSLConfig // struct GPFSSLConfig_t *sslConfig; // SSL manager
// logConfig *LogConfig // struct GPFLogConfig_t *logConfig; // Log manager
Schedule *Schedule // struct GPFSchedule_t *schedule; // Scheduler
}
func (*Config) ArchiveData ¶
ArchiveDataは、指定したタスクのログに対して zip 圧縮をします。 * arc_{host}__{stat}_{date}_{time}.zip ファイル名作成を作成します。 * {stat}/{date}/{time} ディレクトリパスを作成します。 * ログ保存ディレクトリ(ODir)に移動します。 * 次のコマンドと同じ zip 圧縮。zip -r arcxxx.zip ODIR
func (*Config) AuthLicense ¶
func (*Config) CheckConfig ¶
func (*Config) CheckDiskUtil ¶
func (*Config) CheckExitFile ¶
func (*Config) CheckHAStatus ¶
func (*Config) CheckHostname ¶
func (*Config) CheckLicense ¶
CheckLicense はライセンスファイルをダウンロードし、ライセンスをチェックします
func (Config) CheckPathInHome ¶
CheckPathInHome はパスがホーム下を指定しているか、".."が含まれないかをチェックします。
func (*Config) CheckServiceExist ¶
func (Config) CheckWorkFile ¶
CheckWorkFile はワークファイルの確認の有無を確認します。
func (*Config) DownloadLicense ¶
func (Config) GetArchivefilePath ¶
func (*Config) GetCollector ¶
func (*Config) GetServiceOrHostName ¶
func (Config) GetWorkfilePath ¶
GetWorkfilePath はファイル名が'_'で始まる場合は共有ディレクトリ下のパスを、 そうでない場合はローカルディレクトリ下のパスを返します。
func (*Config) NewDatastore ¶
func (*Config) NewDatastoreCurrent ¶
func (*Config) PrepareCollector ¶
func (Config) ReadWorkFile ¶
ReadWorkFile はワークファイルを全行読み込みます。
func (Config) ReadWorkFileHead ¶
ReadWorkFile はワークファイルを指定した行数分読み込みます。
func (Config) ReadWorkFileNumber ¶
ReadWorkFileNumber はワークファイルから数値を読み込みます。
func (Config) RemoveArchiveFile ¶
func (Config) RemoveWorkFile ¶
RemoveWorkFile はワークファイルの削除をします。
func (*Config) SaveReport ¶
func (*Config) SendCollectorData ¶
func (*Config) SendCollectorDataAll ¶
func (*Config) UnzipSSLConf ¶
func (Config) WriteLineWorkFile ¶
func (Config) WriteWorkFile ¶
WriteWorkFile はークファイルの書き込みをします。
type ConfigEnv ¶
type ConfigEnv struct {
// contains filtered or unexported fields
}
func NewConfigEnvBase ¶
type Datastore ¶
type Datastore struct {
StartTime time.Time
StatName string
DateDir string
TimeDir string
OutDir string
}
func (*Datastore) InventoryZipFile ¶
type DateFormat ¶
type DateFormat int
const ( DEFAULT DateFormat = iota YYYYMMDD HHMISS YYYYMMDD_HHMISS DIR )
type DiskStatus ¶
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
Free uint64 `json:"free"`
}
func CheckDiskFree ¶
func CheckDiskFree(dir string) (DiskStatus, error)
CheckDiskFree は指定したディレクトリのディスク使用量[%]を取得します。
type Job ¶
type ReportTask ¶
type ReportTask struct {
Schedule ReportTaskTime
Jobs []ReportTaskJob
}
type ReportTaskJob ¶
type Schedule ¶
type Schedule struct {
DiskCapacity int /**< Disk free threshold(%) */
SaveHour int /**< Metric data retention(H) */
RecoveryHour int /**< Metric data retransmission(H) */
MaxErrorLog int /**< Max rows of error output */
Pid int /**< Scheduler process id */
Status int /**< Process status */
LogLevel int /**< Log level */
DebugConsole bool /**< Console log enabled */
LogSize int /**< Log size */
LogRotation int /**< Number of log rotation */
LogLocalize bool /**< Flag of Japanese log */
HanodeEnable bool /**< HA node check flag */
HanodeCmd string /**< HA node check script */
PostEnable bool /**< Post command enabled */
PostCmd string /**< Post command */
RemhostEnable bool /**< Remote transfer enabled */
UrlCM string /**< Web service URL (Configuration manager) */
UrlPM string /**< Web service URL (Performance manager) */
SoapTimeout int /**< Web service timeout */
SiteKey string /**< Site key */
ProxyEnable bool /**< HTTP proxy enabled */
ProxyHost string /**< Proxy host */
ProxyPort int /**< Proxy port */
LastUpdate time.Time /**< Last update of parameter file */
ParseFailed bool /**< Set true if parser failed */
Collectors map[string]*Collector // Collector pids
}
func NewSchedule ¶
func NewSchedule() *Schedule
func (*Schedule) AddCollector ¶
func (*Schedule) FindOrCreateCollector ¶
func (*Schedule) GetCollector ¶
type Task ¶
type Task struct {
Collector *Collector
Datastore *Datastore
Pid int /**< Collector process id */
Status ProcMode /**< Process status */
StatTimeout int
StartTime time.Time /**< Start time(UTC) */
EndTime time.Time /**< End time(UTC) */
// DateDir string /**< Date directory */
// TimeDir string /**< Time directory */
Odir string /**< Output directory */
ScriptDir string /**< Script directory */
TaskJobs []*TaskJob
}
func (*Task) MakeReport ¶
func (*Task) MakeReportTaskJobs ¶
func (t *Task) MakeReportTaskJobs() []ReportTaskJob
type TaskJob ¶
type TaskJob struct {
Job *Job
Seq int
Timeout int
MaxRow int
Odir string
ScriptDir string
CmdLine string
LoopCount int
CommandInfo *CommandInfo
Status ProcMode
StartTime time.Time
EndTime time.Time
}
func (*TaskJob) Run ¶
func (taskJob *TaskJob) Run() (*CommandInfo, error)
func (*TaskJob) RunWithContext ¶
func (taskJob *TaskJob) RunWithContext(ctx context.Context) (*CommandInfo, error)