| 1 | //go:build cgo |
| 2 | |
| 3 | package db2 |
| 4 | |
| 5 | import "github.com/netdata/netdata/go/plugins/plugin/ibm.d/modules/db2/contexts" |
| 6 | |
| 7 | func (c *Collector) exportSystemMetrics() { |
| 8 | labels := contexts.EmptyLabels{} |
| 9 | |
| 10 | interval := int64(c.Config.UpdateEvery) |
| 11 | if interval <= 0 { |
| 12 | interval = 1 |
| 13 | } |
| 14 | |
| 15 | contexts.System.ServiceHealth.Set(c.State, labels, contexts.SystemServiceHealthValues{ |
| 16 | Connection: c.mx.CanConnect, |
| 17 | Database: c.mx.DatabaseStatus, |
| 18 | }) |
| 19 | |
| 20 | contexts.System.Connections.Set(c.State, labels, contexts.SystemConnectionsValues{ |
| 21 | Total: c.mx.ConnTotal, |
| 22 | Active: c.mx.ConnActive, |
| 23 | Executing: c.mx.ConnExecuting, |
| 24 | Idle: c.mx.ConnIdle, |
| 25 | Max_allowed: c.mx.ConnMax, |
| 26 | }) |
| 27 | |
| 28 | contexts.System.Locking.Set(c.State, labels, contexts.SystemLockingValues{ |
| 29 | Waits: c.mx.LockWaits, |
| 30 | Timeouts: c.mx.LockTimeouts, |
| 31 | Escalations: c.mx.LockEscalations, |
| 32 | }) |
| 33 | |
| 34 | contexts.System.Deadlocks.Set(c.State, labels, contexts.SystemDeadlocksValues{ |
| 35 | Deadlocks: c.mx.Deadlocks, |
| 36 | }) |
| 37 | |
| 38 | contexts.System.LockDetails.Set(c.State, labels, contexts.SystemLockDetailsValues{ |
| 39 | Active: c.mx.LockActive, |
| 40 | Waiting_agents: c.mx.LockWaitingAgents, |
| 41 | Memory_pages: c.mx.LockMemoryPages, |
| 42 | }) |
| 43 | |
| 44 | contexts.System.LockWaitTime.Set(c.State, labels, contexts.SystemLockWaitTimeValues{ |
| 45 | Wait_time: c.mx.LockWaitTime, |
| 46 | }) |
| 47 | |
| 48 | contexts.System.Sorting.Set(c.State, labels, contexts.SystemSortingValues{ |
| 49 | Sorts: c.mx.TotalSorts, |
| 50 | Overflows: c.mx.SortOverflows, |
| 51 | }) |
| 52 | |
| 53 | contexts.System.RowActivity.Set(c.State, labels, contexts.SystemRowActivityValues{ |
| 54 | Read: c.mx.RowsRead / interval, |
| 55 | Returned: c.mx.RowsReturned / interval, |
| 56 | Modified: c.mx.RowsModified / interval, |
| 57 | }) |
| 58 | |
| 59 | contexts.System.BufferpoolHitRatio.Set(c.State, labels, contexts.SystemBufferpoolHitRatioValues{ |
| 60 | Hits: c.mx.BufferpoolHits, |
| 61 | Misses: c.mx.BufferpoolMisses, |
| 62 | }) |
| 63 | |
| 64 | contexts.System.BufferpoolDataHitRatio.Set(c.State, labels, contexts.SystemBufferpoolDataHitRatioValues{ |
| 65 | Hits: c.mx.BufferpoolDataHits, |
| 66 | Misses: c.mx.BufferpoolDataMisses, |
| 67 | }) |
| 68 | |
| 69 | contexts.System.BufferpoolIndexHitRatio.Set(c.State, labels, contexts.SystemBufferpoolIndexHitRatioValues{ |
| 70 | Hits: c.mx.BufferpoolIndexHits, |
| 71 | Misses: c.mx.BufferpoolIndexMisses, |
| 72 | }) |
| 73 | |
| 74 | contexts.System.BufferpoolXDAHitRatio.Set(c.State, labels, contexts.SystemBufferpoolXDAHitRatioValues{ |
| 75 | Hits: c.mx.BufferpoolXDAHits, |
| 76 | Misses: c.mx.BufferpoolXDAMisses, |
| 77 | }) |
| 78 | |
| 79 | contexts.System.BufferpoolColumnHitRatio.Set(c.State, labels, contexts.SystemBufferpoolColumnHitRatioValues{ |
| 80 | Hits: c.mx.BufferpoolColumnHits, |
| 81 | Misses: c.mx.BufferpoolColumnMisses, |
| 82 | }) |
| 83 | |
| 84 | contexts.System.BufferpoolReads.Set(c.State, labels, contexts.SystemBufferpoolReadsValues{ |
| 85 | Logical: c.mx.BufferpoolLogicalReads, |
| 86 | Physical: c.mx.BufferpoolPhysicalReads, |
| 87 | }) |
| 88 | |
| 89 | contexts.System.BufferpoolDataReads.Set(c.State, labels, contexts.SystemBufferpoolDataReadsValues{ |
| 90 | Logical: c.mx.BufferpoolDataLogicalReads, |
| 91 | Physical: c.mx.BufferpoolDataPhysicalReads, |
| 92 | }) |
| 93 | |
| 94 | contexts.System.BufferpoolIndexReads.Set(c.State, labels, contexts.SystemBufferpoolIndexReadsValues{ |
| 95 | Logical: c.mx.BufferpoolIndexLogicalReads, |
| 96 | Physical: c.mx.BufferpoolIndexPhysicalReads, |
| 97 | }) |
| 98 | |
| 99 | contexts.System.BufferpoolXDAReads.Set(c.State, labels, contexts.SystemBufferpoolXDAReadsValues{ |
| 100 | Logical: c.mx.BufferpoolXDALogicalReads, |
| 101 | Physical: c.mx.BufferpoolXDAPhysicalReads, |
| 102 | }) |
| 103 | |
| 104 | contexts.System.BufferpoolColumnReads.Set(c.State, labels, contexts.SystemBufferpoolColumnReadsValues{ |
| 105 | Logical: c.mx.BufferpoolColumnLogicalReads, |
| 106 | Physical: c.mx.BufferpoolColumnPhysicalReads, |
| 107 | }) |
| 108 | |
| 109 | contexts.System.BufferpoolWrites.Set(c.State, labels, contexts.SystemBufferpoolWritesValues{ |
| 110 | Writes: c.mx.BufferpoolWrites, |
| 111 | }) |
| 112 | |
| 113 | contexts.System.LogSpace.Set(c.State, labels, contexts.SystemLogSpaceValues{ |
| 114 | Used: c.mx.LogUsedSpace, |
| 115 | Available: c.mx.LogAvailableSpace, |
| 116 | }) |
| 117 | |
| 118 | contexts.System.LogUtilization.Set(c.State, labels, contexts.SystemLogUtilizationValues{ |
| 119 | Utilization: c.mx.LogUtilization, |
| 120 | }) |
| 121 | |
| 122 | contexts.System.LogIO.Set(c.State, labels, contexts.SystemLogIOValues{ |
| 123 | Reads: c.mx.LogIOReads, |
| 124 | Writes: c.mx.LogIOWrites, |
| 125 | }) |
| 126 | |
| 127 | contexts.System.LogOperations.Set(c.State, labels, contexts.SystemLogOperationsValues{ |
| 128 | Commits: c.mx.LogCommits, |
| 129 | Rollbacks: c.mx.LogRollbacks, |
| 130 | Reads: c.mx.LogOpReads, |
| 131 | Writes: c.mx.LogOpWrites, |
| 132 | }) |
| 133 | |
| 134 | contexts.System.LogTiming.Set(c.State, labels, contexts.SystemLogTimingValues{ |
| 135 | Avg_commit: c.mx.LogAvgCommitTime, |
| 136 | Avg_read: c.mx.LogAvgReadTime, |
| 137 | Avg_write: c.mx.LogAvgWriteTime, |
| 138 | }) |
| 139 | |
| 140 | contexts.System.LogBufferEvents.Set(c.State, labels, contexts.SystemLogBufferEventsValues{ |
| 141 | Buffer_full: c.mx.LogBufferFullEvents, |
| 142 | }) |
| 143 | |
| 144 | contexts.System.LongRunningQueries.Set(c.State, labels, contexts.SystemLongRunningQueriesValues{ |
| 145 | Total: c.mx.LongRunningQueries, |
| 146 | Warning: c.mx.LongRunningQueriesWarning, |
| 147 | Critical: c.mx.LongRunningQueriesCritical, |
| 148 | }) |
| 149 | |
| 150 | contexts.System.BackupStatus.Set(c.State, labels, contexts.SystemBackupStatusValues{ |
| 151 | Status: c.mx.LastBackupStatus, |
| 152 | }) |
| 153 | |
| 154 | contexts.System.BackupAge.Set(c.State, labels, contexts.SystemBackupAgeValues{ |
| 155 | Full: c.mx.LastFullBackupAge, |
| 156 | Incremental: c.mx.LastIncrementalBackupAge, |
| 157 | }) |
| 158 | |
| 159 | contexts.System.FederationConnections.Set(c.State, labels, contexts.SystemFederationConnectionsValues{ |
| 160 | Active: c.mx.FedConnectionsActive, |
| 161 | Idle: c.mx.FedConnectionsIdle, |
| 162 | }) |
| 163 | |
| 164 | contexts.System.FederationOperations.Set(c.State, labels, contexts.SystemFederationOperationsValues{ |
| 165 | Rows_read: c.mx.FedRowsRead, |
| 166 | Selects: c.mx.FedSelectStmts, |
| 167 | Waits: c.mx.FedWaitsTotal, |
| 168 | }) |
| 169 | |
| 170 | contexts.System.DatabaseStatus.Set(c.State, labels, contexts.SystemDatabaseStatusValues{ |
| 171 | Active: c.mx.DatabaseStatusActive, |
| 172 | Inactive: c.mx.DatabaseStatusInactive, |
| 173 | }) |
| 174 | |
| 175 | contexts.System.DatabaseCount.Set(c.State, labels, contexts.SystemDatabaseCountValues{ |
| 176 | Active: c.mx.DatabaseCountActive, |
| 177 | Inactive: c.mx.DatabaseCountInactive, |
| 178 | }) |
| 179 | |
| 180 | contexts.System.CPUUsage.Set(c.State, labels, contexts.SystemCPUUsageValues{ |
| 181 | User: c.mx.CPUUser, |
| 182 | System: c.mx.CPUSystem, |
| 183 | Idle: c.mx.CPUIdle, |
| 184 | Iowait: c.mx.CPUIowait, |
| 185 | }) |
| 186 | |
| 187 | contexts.System.ActiveConnections.Set(c.State, labels, contexts.SystemActiveConnectionsValues{ |
| 188 | Active: c.mx.ConnectionsActive, |
| 189 | Total: c.mx.ConnectionsTotal, |
| 190 | }) |
| 191 | |
| 192 | contexts.System.MemoryUsage.Set(c.State, labels, contexts.SystemMemoryUsageValues{ |
| 193 | Database: c.mx.MemoryDatabaseCommitted, |
| 194 | Instance: c.mx.MemoryInstanceCommitted, |
| 195 | Bufferpool: c.mx.MemoryBufferpoolUsed, |
| 196 | Shared_sort: c.mx.MemorySharedSortUsed, |
| 197 | }) |
| 198 | |
| 199 | contexts.System.SQLStatements.Set(c.State, labels, contexts.SystemSQLStatementsValues{ |
| 200 | Selects: c.mx.OpsSelectStmts, |
| 201 | Modifications: c.mx.OpsUIDStmts, |
| 202 | }) |
| 203 | |
| 204 | contexts.System.TransactionActivity.Set(c.State, labels, contexts.SystemTransactionActivityValues{ |
| 205 | Committed: c.mx.OpsTransactions, |
| 206 | Aborted: c.mx.OpsActivitiesAborted, |
| 207 | }) |
| 208 | |
| 209 | contexts.System.TimeSpent.Set(c.State, labels, contexts.SystemTimeSpentValues{ |
| 210 | Direct_read: c.mx.TimeAvgDirectRead, |
| 211 | Direct_write: c.mx.TimeAvgDirectWrite, |
| 212 | Pool_read: c.mx.TimeAvgPoolRead, |
| 213 | Pool_write: c.mx.TimeAvgPoolWrite, |
| 214 | }) |
| 215 | } |