MCPcopy Create free account
hub / github.com/apache/trafficserver / setNetStat

Function setNetStat

plugins/experimental/system_stats/system_stats.cc:153–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153static void
154setNetStat(TSMutex stat_creation_mutex, const char *interface, const char *entry, const char *subdir, bool subdirstatname)
155{
156 char sysfs_name[PATH_MAX];
157 char stat_name[255];
158 char data[255];
159
160 memset(&stat_name[0], 0, sizeof(stat_name));
161 memset(&sysfs_name[0], 0, sizeof(sysfs_name));
162 memset(&data[0], 0, sizeof(data));
163
164 if ((interface == nullptr) || (entry == nullptr)) {
165 TSError("%s: nullptr subdir or entry", DEBUG_TAG);
166 return;
167 }
168
169 // Generate the ATS stats name
170 if (subdirstatname) {
171 snprintf(&stat_name[0], sizeof(stat_name), "%s%s.%s.%s", NET_STATS, interface, subdir, entry);
172 } else {
173 snprintf(&stat_name[0], sizeof(stat_name), "%s%s.%s", NET_STATS, interface, entry);
174 }
175
176 // Determine if this is a toplevel netdev stat, or one from statistics.
177 if (subdir == nullptr) {
178 snprintf(&sysfs_name[0], sizeof(sysfs_name), "%s/%s/%s", NET_STATS_DIR, interface, entry);
179 } else {
180 snprintf(&sysfs_name[0], sizeof(sysfs_name), "%s/%s/%s/%s", NET_STATS_DIR, interface, subdir, entry);
181 }
182
183 if (getFile(&sysfs_name[0], &data[0], sizeof(data)) < 0) {
184 Dbg(dbg_ctl, "Error reading file %s", sysfs_name);
185 } else {
186 statSet(stat_name, atol(data), stat_creation_mutex);
187 }
188}
189
190static void
191setBondingStat(TSMutex stat_creation_mutex, const char *interface)

Callers 2

setBondingStatFunction · 0.85
netStatsInfoFunction · 0.85

Calls 4

memsetFunction · 0.85
getFileFunction · 0.85
statSetFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected