MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Format

Method Format

lib/base/perfdatavalue.cpp:346–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344});
345
346String PerfdataValue::Format() const
347{
348 std::ostringstream result;
349
350 if (GetLabel().FindFirstOf(" ") != String::NPos)
351 result << "'" << GetLabel() << "'";
352 else
353 result << GetLabel();
354
355 result << "=" << Convert::ToString(GetValue());
356
357 String unit;
358
359 if (GetCounter()) {
360 unit = "c";
361 } else {
362 auto myUnit (GetUnit());
363 auto uom (l_FormatUoMs.find(myUnit.GetData()));
364
365 if (uom != l_FormatUoMs.end()) {
366 unit = uom->second;
367 }
368 }
369
370 result << unit;
371
372 std::string interm(";");
373 if (!GetWarn().IsEmpty()) {
374 result << interm << Convert::ToString(GetWarn());
375 interm.clear();
376 }
377
378 interm += ";";
379 if (!GetCrit().IsEmpty()) {
380 result << interm << Convert::ToString(GetCrit());
381 interm.clear();
382 }
383
384 interm += ";";
385 if (!GetMin().IsEmpty()) {
386 result << interm << Convert::ToString(GetMin());
387 interm.clear();
388 }
389
390 interm += ";";
391 if (!GetMax().IsEmpty()) {
392 result << interm << Convert::ToString(GetMax());
393 }
394
395 return result.str();
396}
397
398Value PerfdataValue::ParseWarnCritMinMaxToken(const std::vector<String>& tokens, std::vector<String>::size_type index, const String& description)
399{

Callers

nothing calls this directly

Calls 5

FindFirstOfMethod · 0.80
findMethod · 0.80
endMethod · 0.45
IsEmptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected