Stats returns a map of stats.
()
| 16 | |
| 17 | // Stats returns a map of stats. |
| 18 | func (s *Store) Stats() (map[string]interface{}, error) { |
| 19 | finfos, err := ioutil.ReadDir(s.dir) |
| 20 | if err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | |
| 24 | var numBytesUsedDisk uint64 |
| 25 | for _, finfo := range finfos { |
| 26 | if !finfo.IsDir() { |
| 27 | numBytesUsedDisk += uint64(finfo.Size()) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | s.m.Lock() |
| 32 | totPersists := s.totPersists |
| 33 | totCompactions := s.totCompactions |
| 34 | totCompactionsPartial := s.totCompactionsPartial |
| 35 | numLastCompactionBeforeBytes := s.numLastCompactionBeforeBytes |
| 36 | numLastCompactionAfterBytes := s.numLastCompactionAfterBytes |
| 37 | totCompactionDecreaseBytes := s.totCompactionDecreaseBytes |
| 38 | totCompactionIncreaseBytes := s.totCompactionIncreaseBytes |
| 39 | maxCompactionDecreaseBytes := s.maxCompactionDecreaseBytes |
| 40 | maxCompactionIncreaseBytes := s.maxCompactionIncreaseBytes |
| 41 | totCompactionBeforeBytes := s.totCompactionBeforeBytes |
| 42 | totCompactionWrittenBytes := s.totCompactionWrittenBytes |
| 43 | s.m.Unlock() |
| 44 | |
| 45 | footer, err := s.snapshot() |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | |
| 50 | var numSegments uint64 |
| 51 | if footer != nil { |
| 52 | footer.m.Lock() |
| 53 | if footer.ss != nil { |
| 54 | numSegments = uint64(len(footer.ss.a)) |
| 55 | } |
| 56 | footer.m.Unlock() |
| 57 | } |
| 58 | |
| 59 | footer.Close() |
| 60 | |
| 61 | files, numFilesOpen := s.allFiles() |
| 62 | |
| 63 | return map[string]interface{}{ |
| 64 | "num_bytes_used_disk": numBytesUsedDisk, |
| 65 | "total_persists": totPersists, |
| 66 | "total_compactions": totCompactions, |
| 67 | "total_compactions_partial": totCompactionsPartial, |
| 68 | "total_compaction_before_bytes": totCompactionBeforeBytes, |
| 69 | "total_compaction_written_bytes": totCompactionWrittenBytes, |
| 70 | "num_segments": numSegments, |
| 71 | "num_last_compaction_before_bytes": numLastCompactionBeforeBytes, |
| 72 | "num_last_compaction_after_bytes": numLastCompactionAfterBytes, |
| 73 | "total_compaction_decrease_bytes": totCompactionDecreaseBytes, |
| 74 | "total_compaction_increase_bytes": totCompactionIncreaseBytes, |
| 75 | "max_compaction_decrease_bytes": maxCompactionDecreaseBytes, |