Monito...bility(3pm)

πŸ“¦
version 0.46 Β· 2 versions
, in ubuntu jammy

✨ Monitoring::Availability ✨

okay bestie, sit DOWN because we're talking about Monitoring::Availability (that's the 3pm perl module manual, if you were wondering which manual we're in πŸ’…). It's giving "I crunch Nagios/Icinga/Shinken logfiles and tell you how available your stuff actually was" and honestly? Iconic. Let's get into it 🫢


🌸 SYNOPSIS 🌸

use Monitoring::Availability;
my $ma = Monitoring::Availability->new();

that's it. that's the vibe check. you load it, you make an object, you go off πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so this module calculates the availability for hosts/server from given logfiles. and like, heads up: the Logfileformat is Nagios/Icinga only. no cap. don't come at it with something else, it's not gonna eat that πŸ“


πŸ’œ REPOSITORY πŸ’œ

Git: http://github.com/sni/Monitoring-Availability

πŸ‘‘ CONSTRUCTOR πŸ‘‘

✨ new ( [ARGS] ) ✨

Creates a Monitoring::Availability object. new takes at least the logs parameter β€” no logs, no party, fr fr. Arguments are in key-value pairs, like a little group chat where every name has its own reply πŸ’¬

  • rpttimeperiod β€” report timeperiod. defines a timeperiod for this report. Will use 24x7 if not specified. so if you don't say anything, it just assumes you're a 24/7 girlie ✨
  • assumeinitialstates β€” Assume the initial host/service state if none is found, default: yes
  • assumestateretention β€” Assume state retention, default: yes
  • assumestatesduringnotrunning β€” Assume state during times when the monitoring process is not running, default: yes
  • includesoftstates β€” Include soft states in the calculation. Only hard states are used otherwise, default: no. so soft states are lowkey excluded unless you say otherwise πŸ’…
  • initialassumedhoststate β€” Assumed host state if none is found, default: unspecified

valid options are: unspecified, current, up, down and unreachable

  • initialassumedservicestate β€” Assumed service state if none is found, default: unspecified

valid options are: unspecified, current, ok, warning, unknown and critical

  • backtrack β€” Go back this amount of days to find initial states, default: 4. it literally time-travels backward to find your states, main character energy πŸ•°οΈ
  • showscheduleddowntime β€” Include downtimes in calculation, default: yes
  • timeformat β€” Time format for the log output, default: %s
  • verbose β€” verbose mode. it talks more. we love a chatty icon πŸ—£οΈ
  • breakdown β€” Breakdown availability into 'months', 'weeks', 'days', 'none'

adds additional 'breakdown' hash to each result with broken down results


πŸ’– METHODS πŸ’–

🌈 calculate 🌈

calculate()

Calculate the availability ✨ Here's everything you can hand it:

  • start β€” Timestamp of start
  • end β€” Timestamp of end
  • log_string β€” String containing the logs
  • log_file β€” File containing the logs
  • log_dir β€” Directory containing *.log files
  • log_livestatus β€” Array with logs from a livestatus query

a sample query could be:

selectall_arrayref(GET logs...\nColumns: time type options, {Slice => 1})
  • log_iterator β€” Iterator object for logentry objects. For example a MongoDB::Cursor object.
  • hosts β€” array with hostnames for which the report should be generated
  • services β€” array with hashes of services for which the report should be generated. The array should look like this:
[{host => 'hostname', service => 'description'}, ...]
  • initial_states β€” if you use the "current" option for initialassumedservicestate or initialassumedhoststate you have to provide the current states with a hash like this:
{
  hosts => {
   'hostname' => 'ok',
   ...
  },
  services => {
   'hostname' => {
       'description' =>  'warning',
       ...
    }
  }
}

valid values for hosts are: up, down and unreachable

valid values for services are: ok, warning, unknown and critical

πŸŽ€ get_condensed_logs πŸŽ€

get_condensed_logs()

returns an array of hashes with the condensed log used for this report. condensed, like a little summary, cute and compact πŸ“

πŸ’… get_full_logs πŸ’…

get_full_logs()

returns an array of hashes with the full log used for this report. the full tea, unfiltered β˜•


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to <http://github.com/sni/Monitoring-Availability/issues>. don't suffer in silence bestie, tell the devs πŸ™ˆ


πŸ”₯ DEBUGING πŸ”₯

You may enable the debug mode by setting MONITORING_AVAILABILITY_DEBUG environment variable. This will create a logfile: /tmp/Monitoring-Availability-Debug.log which gets overwritten with every calculation β€” yes, EVERY time, so don't get attached to what's in there 😭. You will need the Log4Perl module to create this logfile.


⭐ SEE ALSO ⭐

You can also look for information at:

  • Search CPAN

<http://search.cpan.org/dist/Monitoring-Availability/>

  • Github

<http://github.com/sni/Monitoring-Availability>


πŸ‘‘ AUTHOR πŸ‘‘

Sven Nierlein, <nierlein@cpan.org> β€” absolute legend, we stan πŸ’œ


Copyright (C) 2010 by Sven Nierlein

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


and that's the whole page, bestie!! 🫢 this was perl v5.20.1, dated 2014-10-25, and it slayed then and it slays now. go calculate some availability, you got this πŸ’–βœ¨

πŸ“¦ where this page comes from