Documentation ¶
Overview ¶
Package maintenance package is responsible for maintenance mode handling for the GC SAP Agent. It contains functions to configure maintenance mode, display the current value for maintenance mode. Package maintenance implements processmetrics.Collector interface to collect below custom metric:-
- /sap/mntmode - A custom metric representing the current value of maintenancemode.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadMaintenanceMode ¶
func ReadMaintenanceMode(fr FileReader) ([]string, error)
ReadMaintenanceMode reads the current value for the SIDs under maintenance persisted in maintenance.json file, If the file is empty or it does not exist no sid is considered under maintenace. An unsuccessful call will return nil, err
func UpdateMaintenanceMode ¶
func UpdateMaintenanceMode(mntmode bool, sid string, fr FileReader, fw FileWriter) ([]string, error)
UpdateMaintenanceMode updates the maintenance.json file by appending / removing the sid passed in the arguments based on the mntmode value passed.
Types ¶
type FileReader ¶
type FileReader interface { // Read method is responsible for reading the contents of the file name // passed. It returns the bytes of the file content in a successful call // with a nil error. In case of unsuccessful call it returns nil, error. Read(fileName string) ([]byte, error) }
FileReader interface provides abstraction on the file reading methods.
type FileWriter ¶
type FileWriter interface { // Write method is responsible for writing the data passed into the // filename passed in the given permission mode. It returns an error in // case of an unsuccessful call. Write(fileName string, data []byte, perm os.FileMode) error // MakeDirs method is responsible for creating the directory named path. // It returns an error if unable to do so. MakeDirs(path string, perm os.FileMode) error }
FileWriter interface provides abstraction on the file writing methods.
type InstanceProperties ¶
type InstanceProperties struct { Config *cnfpb.Configuration Client cloudmonitoring.TimeSeriesCreator Reader FileReader Sids map[string]bool }
InstanceProperties have the necessary context for maintenance mode metric collection
func (*InstanceProperties) Collect ¶
func (p *InstanceProperties) Collect(ctx context.Context) []*mrpb.TimeSeries
Collect is a MaintenanceMode implementation of the Collector interface from processmetrics. It returns the value of current maintenancemode configured per sid as a metric list.
type ModeReader ¶
type ModeReader struct{}
ModeReader is a concrete type responsible for reading the contents of maintenance.json file.
type ModeWriter ¶
type ModeWriter struct{}
ModeWriter is a concrete type responsible for writing the value into the maintenance.json file.