github.com/therealbill/libredis@v0.0.0-20161227004305-7d50abda5ccf/structures/info.go (about)

     1  package structures
     2  
     3  // InfoServer is a struct for the results returned from an 'INFO server'
     4  // command
     5  //
     6  // Currently the members defined by redis are as follows.
     7  // redis_version
     8  // redis_git_sha1
     9  // redis_git_dirty
    10  // redis_build_id
    11  // redis_mode
    12  // os
    13  // arch_bits
    14  // multiplexing_api
    15  // gcc_version
    16  // process_id
    17  // run_id
    18  // tcp_port
    19  // uptime_in_seconds
    20  // uptime_in_days
    21  // hz
    22  // lru_clock
    23  // config_file
    24  //
    25  type InfoServer struct {
    26  	Version         string `redis:"redis_version"`
    27  	Git_sha1        int    `redis:"redis_git_sha1"`
    28  	Git_dirty       bool   `redis:"redis_git_dirty"`
    29  	RedisBuildId    string `redis:"redis_build_id"`
    30  	Mode            string `redis:"redis_mode"`
    31  	OS              string `redis:"os"`
    32  	Arch_bits       int    `redis:"arch_bits"`
    33  	Multiplexing    string `redis:"multiplexing_api"`
    34  	GCC_version     string `redis:"gcc_version"`
    35  	ProcessId       int    `redis:"process_id"`
    36  	TCPPort         int    `redis:"tcp_port"`
    37  	UptimeInSeconds int    `redis:"uptime_in_seconds"`
    38  	UptimeInDays    int    `redis:"uptime_in_days"`
    39  	Hz              int    `redis:"hz"`
    40  	LRU_clock       int    `redis:"lru_clock"`
    41  	Executable      string `redis:"executable"`
    42  	ConfigFile      string `redis:"config_file"`
    43  }
    44  
    45  // InfoCluster is a struct representing the Cluster section of Redis Info
    46  type InfoCluster struct {
    47  	Enabled bool
    48  }
    49  
    50  // InfoMemory is the struct returning the memory section for Redis Info
    51  type InfoMemory struct {
    52  	UsedMemory               int     `redis:"used_memory"`
    53  	UsedMemoryHuman          string  `redis:"used_memory_human"`
    54  	UsedMemoryRss            int     `redis:"used_memory_rss"`
    55  	UsedMemoryPeak           int     `redis:"used_memory_peak"`
    56  	UsedMemoryPeakHuman      string  `redis:"used_memory_peak_human"`
    57  	TotalSystemMemory        int     `redis:"total_system_memory"`
    58  	TotalSystemMemoryHuman   string  `redis:"total_system_memory_human"`
    59  	UsedMemoryLua            int     `redis:"used_memory_lua"`
    60  	UsedMemoryLuaHuman       int     `redis:"used_memory_lua_human"`
    61  	MaxMemory                int     `redis:"maxmemory"`
    62  	MaxMemoryHuman           int     `redis:"maxmemory_human"`
    63  	MaxMemoryPolicy          int     `redis:"maxmemory_policy"`
    64  	MemoryFragmentationRatio float64 `redis:"mem_fragmentation_ratio"`
    65  	MemoryAllocator          string  `redis:"mem_allocator"`
    66  }
    67  
    68  // InfoClients represents the Client section of Redis INFO
    69  type InfoClients struct {
    70  	ConnectedClients         int `redis:"connected_clients"`
    71  	ClientLongestOutputList  int `redis:"client_longest_output_list"`
    72  	ClientBiggestInputBuffer int `redis:"client_biggest_input_buf"`
    73  	BlockedClients           int `redis:"blocked_clients"`
    74  }
    75  
    76  //InfoPersistence reprsents the Perisstence section of Redis INFO
    77  type InfoPersistence struct {
    78  	Loading                     bool   `redis:"loading"`
    79  	ChangesSinceSave            int    `redis:"rdb_changes_since_last_save"`
    80  	BGSavesInProgress           bool   `redis:"rdb_bgsave_in_progress"`
    81  	LastSaveTime                uint   `redis:"rdb_last_save_time"`
    82  	LastBGSaveStatus            string `redis:"rdb_last_bgsave_status"`
    83  	LastBGSaveTime              uint   `redis:"rdb_last_bgsave_time_sec"`
    84  	CurrentBGSaveTime           uint   `redis:"rdb_current_bgsave_time_sec"`
    85  	AOFEnabled                  bool   `redis:"aof_enabled"`
    86  	FRewriteInProgress          bool   `redis:"aof_rewrite_in_progress"`
    87  	RewriteScheduled            bool   `redis:"aof_rewrite_scheduled"`
    88  	LastRewriteTimeInSeconds    int    `redis:"aof_last_rewrite_time_sec"`
    89  	CurrentRewriteTimeInSeconds int    `redis:"aof_current_rewrite_time_sec"`
    90  	LastBGRewriteStatus         string `redis:"aof_last_bgrewrite_status"`
    91  	LastAOFWriteSTats           string `redis:"aof_last_write_status"`
    92  }
    93  
    94  // InfoStats represents the Stats section of Redis INFO
    95  type InfoStats struct {
    96  	TotalConnectionsReceived int     `redis:"total_connections_received"`
    97  	TotalCommandsProcessed   int     `redis:"total_commands_processed"`
    98  	InstanteousOpsPerSecond  int     `redis:"instantaneous_ops_per_sec"`
    99  	TotalNetInputBytes       int     `redis:"total_net_input_bytes"`
   100  	TotalNetOutputBytes      int     `redis:"total_net_output_bytes"`
   101  	InstanteousInputKbps     float64 `redis:"instantaneous_input_kbps"`
   102  	InstanteousOutputKbps    float64 `redis:"instantaneous_output_kbps"`
   103  	RejectedConnections      int     `redis:"rejected_connections"`
   104  	SyncFull                 int     `redis:"sync_full"`
   105  	SyncPartialOk            int     `redis:"sync_partial_ok"`
   106  	SyncPartialErr           int     `redis:"sync_partial_err"`
   107  	ExpiredKeys              int     `redis:"expired_keys"`
   108  	EvictedKeys              int     `redis:"evicted_keys"`
   109  	KeyspaceHits             int     `redis:"keyspace_hits"`
   110  	KeyspaceMisses           int     `redis:"keyspace_misses"`
   111  	PubSubChannels           int     `redis:"pubsub_channels"`
   112  	PubSubPatterns           int     `redis:"pubsub_patterns"`
   113  	LatestForkUsec           int     `redis:"latest_fork_usec"`
   114  	MigrateCachedSockets     int     `redis:"migrate_cached_sockets"`
   115  }
   116  
   117  // InfoReplication represents the Replication section of Redis INFO
   118  type InfoReplication struct {
   119  	Role                        string       `redis:"role"`
   120  	ConnectedSlaves             int          `redis:"connected_slaves"`
   121  	MasterReplicationOffset     int          `redis:"master_repl_offset"`
   122  	ReplicationBacklogActive    int          `redis:"repl_backlog_active"`
   123  	ReplicationBacklogSize      int          `redis:"repl_backlog_size"`
   124  	ReplicationBacklogFirstByte int          `redis:"repl_backlog_first_byte_offset"`
   125  	ReplicationBacklogHistLen   int          `redis:"repl_backlog_histlen"`
   126  	MasterHost                  string       `redis:"master_host"`
   127  	MasterPort                  int          `redis:"master_port"`
   128  	MasterLinkStatus            string       `redis:"master_link_status"`
   129  	MasterLastIOSecondsAgo      int          `redis:"master_last_io_seconds_ago"`
   130  	MasterSyncInProgress        bool         `redis:"master_sync_in_progress"`
   131  	SlaveReplicationOffset      int          `redis:"slave_repl_offset"`
   132  	SlavePriority               int          `redis:"slave_priority"`
   133  	SlaveReadOnly               bool         `redis:"slave_read_only"`
   134  	Slaves                      []InfoSlaves `redis:"slave*"`
   135  }
   136  
   137  // InfoCPU represents the CPU section of Redis INFO
   138  type InfoCPU struct {
   139  	UsedCPUSystem       float64 `redis:"used_cpu_sys"`
   140  	UsedCPUUser         float64 `redis:"used_cpu_user"`
   141  	UsedCPUChildren     float64 `redis:"used_cpu_sys_children"`
   142  	UsedCPUUserChildren float64 `redis:"used_cpu_user_children"`
   143  }
   144  
   145  // InfoKeyspace represents the Keyspace section of Redis INFO
   146  type InfoKeyspace struct {
   147  	Databases []map[string]int64
   148  }
   149  
   150  // InfoCommandStats represents the CommandStats section of Redis INFO
   151  type InfoCommandStats struct {
   152  	Stats map[string]map[string]float64 `redis:"cmdstat_del"`
   153  }
   154  
   155  // RedisInfoAll is a struct containing structs for each redis section
   156  type RedisInfoAll struct {
   157  	Server       InfoServer       `section:"server"`
   158  	CPU          InfoCPU          `section:"cpu"`
   159  	Client       InfoClients      `section:"client"`
   160  	Replication  InfoReplication  `section:"replication"`
   161  	Memory       InfoMemory       `section:"memory"`
   162  	Stats        InfoStats        `section:"stats"`
   163  	Persistence  InfoPersistence  `section:"persistence"`
   164  	Keyspace     InfoKeyspace     `section:"keyspace"`
   165  	Commandstats InfoCommandStats `section:"commandstats"`
   166  }
   167  
   168  // AllInfoConfig is used to contain the RedisInfoAll struct and the data parsed
   169  // from the info command
   170  type AllInfoConfig struct {
   171  	Input map[string]map[string]string
   172  	Info  RedisInfoAll
   173  }
   174  
   175  //InfoSlaves represents the slave identity in the replication section of the
   176  //Redis INFO command
   177  type InfoSlaves struct {
   178  	IP     string
   179  	Port   int
   180  	State  string
   181  	Offset int
   182  	Lag    int
   183  }