Monitor...formance(3)

πŸŽ€ NAME πŸŽ€

okay so this is the Monitor...formance(3) manual page from User Contributed Perl Documentation, and the main character is Monitoring::Plugin::Performance πŸ’… β€” class for handling Monitoring::Plugin performance data. periodt.


✨ SYNOPSIS ✨

  use Monitoring::Plugin::Performance use_die => 1;

  # Constructor (also accepts a 'threshold' obj instead of warning/critical)
  $p = Monitoring::Plugin::Performance->new(
      label     => 'size',
      value     => $value,
      uom       => "kB",
      warning   => $warning,
      critical  => $critical,
      min       => $min,
      max       => $max,
  );

  # Parser
  @perf = Monitoring::Plugin::Performance->parse_perfstring(
      "/=382MB;15264;15269;; /var=218MB;9443;9448"
  )
  or warn("Failed to parse perfstring");

  # Accessors
  for $p (@perf) {
    printf "label:    %s\n",   $p->label;
    printf "value:    %s\n",   $p->value;
    printf "uom:      %s\n",   $p->uom;
    printf "warning:  %s\n",   $p->warning;
    printf "critical: %s\n",   $p->critical;
    printf "min:      %s\n",   $p->min;
    printf "max:      %s\n",   $p->max;
    # Special accessor returning a threshold obj containing warning/critical
    $threshold = $p->threshold;
  }

  # Perfdata output format i.e. label=value[uom];[warn];[crit];[min];[max]
  print $p->perfoutput;

πŸ¦‹ DESCRIPTION πŸ¦‹

This is the Monitoring::Plugin class for handling performance data. It’s a public interface because performance graphing routines could absolutely use it β€” think nagiostat (http://nagiostat.sourceforge.net), perfparse (http://perfparse.sourceforge.net), nagiosgraph (http://nagiosgraph.sourceforge.net) or NagiosGrapher (http://www.nagiosexchange.org/NagiosGrapher.84.0.html) πŸ‘‘

Monitoring::Plugin::Performance gives you both a parsing interface (via parse_perfstring) for turning nagios performance output strings into their components, and a composition interface (via new) for turning components into perfdata strings. it’s giving duality, honestly 🫢


🫢 USE'ING THE MODULE 🫢

If you’re using this module for the purposes of parsing perf data, you will probably want to set use_die => 1 at use time. This forces &Monitoring::Plugin::Functions::plugin_exit to call die() β€” rather than exit() β€” when an error occurs. That makes it trappable by an eval ✨

lowkey important, bestie: if you don’t set use_die, then an error in these modules will cause your script to exit πŸ’€

πŸ› οΈ CLASS METHODS πŸ› οΈ

Monitoring::Plugin::Performance->new(%attributes)

Instantiates a new Monitoring::Plugin::Performance object with the given attributes. constructor slay πŸ’…

Monitoring::Plugin::Performance->parse_perfstring($string)

Returns an array of Monitoring::Plugin::Performance objects based on the string entered. If there is an error parsing the string β€” which may consist of several sets of data β€” it will return an array with all the successfully parsed sets. no cap, it keeps what it can parse πŸ“

If values are input with commas instead of periods, due to different locale settings, then it will still be parsed, but the commas will be converted to periods. little localization moment 🌈


πŸ‘‘ OBJECT METHODS (ACCESSORS) πŸ‘‘

label, value, uom, warning, critical, min, max

These all return scalars. min and max are not well supported yet β€” so don’t come for them, they’re doing their best 😭

threshold

Returns a Monitoring::Plugin::Threshold object holding the warning and critical ranges for this performance data (if any). threshold object realness βœ…

rrdlabel

Returns a string based on 'label' that is suitable for use as dataset name of an RRD i.e. munges label to be 1-19 characters long with only characters [a-zA-Z0-9_]. so demure, so RRD-ready πŸŽ€

This calls $self->clean_label and then truncates to 19 characters.

There is no guarantee that multiple N:P:Performance objects will have unique rrdlabels. yeah bestie, that’s the official caveat πŸ™ˆ

clean_label

Returns a "clean" label for use as a dataset name in RRD, ie, it converts characters that are not [a-zA-Z0-9_] to _. scrub scrub 🧚

It also converts "/" to "root" and "/{name}" to "{name}". iconic path-to-label behavior πŸ’œ

perfoutput

Outputs the data in Monitoring::Plugin perfdata format i.e. label=value[uom];[warn];[crit];[min];[max]. that’s the whole format, no cap πŸ”₯


🌈 SEE ALSO 🌈


🌸 AUTHOR 🌸

This code is maintained by the Monitoring Plugin Development Team: see https://monitoring-plugins.org πŸ’–


Copyright (C) 2014 by Monitoring Plugin Team

Copyright (C) 2006-2014 by Nagios Plugin Development Team

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


okay that’s the whole page, bestie 🫢 the footer vibes say perl v5.42.0, dated 2018-08-02 β€” vintage manual realness, and we ate πŸ’…βœ¨

πŸ“¦ where this page comes from