|
| 1 | +// Copyright (c) 2022 Sorint.lab S.p.A. |
| 2 | +// |
| 3 | +// This program is free software: you can redistribute it and/or modify |
| 4 | +// it under the terms of the GNU General Public License as published by |
| 5 | +// the Free Software Foundation, either version 3 of the License, or |
| 6 | +// (at your option) any later version. |
| 7 | +// |
| 8 | +// This program is distributed in the hope that it will be useful, |
| 9 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | +// GNU General Public License for more details. |
| 12 | +// |
| 13 | +// You should have received a copy of the GNU General Public License |
| 14 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + |
| 16 | +package oracle |
| 17 | + |
| 18 | +import ( |
| 19 | + "bufio" |
| 20 | + "bytes" |
| 21 | + "strings" |
| 22 | + |
| 23 | + "github.com/ercole-io/ercole-agent-rhel5/marshal" |
| 24 | + "github.com/ercole-io/ercole-agent-rhel5/model" |
| 25 | +) |
| 26 | + |
| 27 | +// Partitionings returns information about database partitionings extracted |
| 28 | +// from the partitionings fetcher command output. |
| 29 | +func Partitionings(cmdOutput []byte) []model.OracleDatabasePartitioning { |
| 30 | + partitionings := []model.OracleDatabasePartitioning{} |
| 31 | + scanner := bufio.NewScanner(bytes.NewReader(cmdOutput)) |
| 32 | + |
| 33 | + for scanner.Scan() { |
| 34 | + partitioning := model.OracleDatabasePartitioning{} |
| 35 | + line := scanner.Text() |
| 36 | + splitted := strings.Split(line, "|||") |
| 37 | + if len(splitted) == 5 { |
| 38 | + partitioning.Owner = strings.TrimSpace(splitted[0]) |
| 39 | + partitioning.SegmentName = strings.TrimSpace(splitted[1]) |
| 40 | + partitioning.PartitionName = strings.TrimSpace(splitted[2]) |
| 41 | + partitioning.SegmentType = strings.TrimSpace(splitted[3]) |
| 42 | + partitioning.Mb = marshal.TrimParseFloat64(splitted[4]) |
| 43 | + |
| 44 | + partitionings = append(partitionings, partitioning) |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + return partitionings |
| 49 | +} |
0 commit comments