diff options
-rw-r--r--[-rwxr-xr-x] | files/munin/apc_nis | 322 |
1 files changed, 122 insertions, 200 deletions
diff --git a/files/munin/apc_nis b/files/munin/apc_nis index 0a7278d..8691fe9 100755..100644 --- a/files/munin/apc_nis +++ b/files/munin/apc_nis @@ -1,200 +1,122 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - - - - - <head> - <title> - apc_nis.in in munin/plugins/node.d - – Munin - </title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <!--[if IE]><script type="text/javascript"> - if (/^#__msie303:/.test(window.location.hash)) - window.location.replace(window.location.hash.replace(/^#__msie303:/, '#')); - </script><![endif]--> - <link rel="search" href="/search" /> - <link rel="help" href="/wiki/TracGuide" /> - <link rel="alternate" href="/browser/munin/plugins/node.d/apc_nis.in?format=txt" type="text/plain" title="Plain Text" /><link rel="alternate" href="/export/03951617bef5282f2eee51da426b7612551e6943/munin/plugins/node.d/apc_nis.in" type="application/x-perl; charset=utf-8" title="Original Format" /> - <link rel="next" href="/browser/munin/plugins/node.d/apc_nis.in?rev=334b69108d942308d245529ec16877458fcdd844" title="Revision 334b691" /> - <link rel="start" href="/wiki" /> - <link rel="stylesheet" href="/chrome/common/css/trac.css" type="text/css" /><link rel="stylesheet" href="/chrome/common/css/code.css" type="text/css" /><link rel="stylesheet" href="/pygments/trac.css" type="text/css" /><link rel="stylesheet" href="/chrome/common/css/browser.css" type="text/css" /> - <link rel="prev" href="/browser/munin/plugins/node.d/apc_nis.in?rev=bebe375d6ec7de3fe03120c124b8d581e93b2f5f" title="Revision bebe375" /> - <link rel="shortcut icon" href="/export/master/munin/resources/favicon.ico" type="image/x-icon" /> - <link rel="icon" href="/export/master/munin/resources/favicon.ico" type="image/x-icon" /> - <link type="application/opensearchdescription+xml" rel="search" href="/search/opensearch" title="Search Munin" /> - <script type="text/javascript" charset="utf-8" src="/chrome/common/js/jquery.js"></script> - <script type="text/javascript" charset="utf-8" src="/chrome/common/js/babel.js"></script> - <script type="text/javascript" charset="utf-8" src="/chrome/common/js/trac.js"></script> - <script type="text/javascript" charset="utf-8" src="/chrome/common/js/search.js"></script> - <script type="text/javascript" src="/chrome/common/js/folding.js"></script> - <script type="text/javascript"> - jQuery(document).ready(function($) { - $(".trac-toggledeleted").show().click(function() { - $(this).siblings().find(".trac-deleted").toggle(); - return false; - }).click(); - $("#jumploc input").hide(); - $("#jumploc select").change(function () { - this.parentNode.parentNode.submit(); - }); - $('#preview table.code').enableCollapsibleColumns($('#preview table.code thead th.content')); - }); - </script> - </head> - <body> - <div id="banner"> - <div id="header"> - <a id="logo" href="http://munin-monitoring.org/"><img src="/site/munin.png" alt="Munin" /></a> - </div> - <form id="search" action="/search" method="get"> - <div> - <label for="proj-search">Search:</label> - <input type="text" id="proj-search" name="q" size="18" value="" /> - <input type="submit" value="Search" /> - </div> - </form> - <div id="metanav" class="nav"> - <ul> - <li class="first"><a href="/login">Login</a></li><li><a href="/prefs">Preferences</a></li><li><a href="/wiki/TracGuide">Help/Guide</a></li><li><a href="/about">About Trac</a></li><li class="last"><a href="/register">Register</a></li> - </ul> - </div> - </div> - <div id="mainnav" class="nav"> - <ul> - <li class="first"><a class="ext-link" href="http://munin.readthedocs.org/"><span class="icon"></span>book</a></li><li><a href="/wiki">Wiki</a></li><li><a href="/timeline">Timeline</a></li><li><a href="/roadmap">Roadmap</a></li><li class="active"><a href="/browser">Browse Source</a></li><li><a href="/report">View Tickets</a></li><li class="last"><a href="/search">Search</a></li> - </ul> - </div> - <div id="main"> - <div id="ctxtnav" class="nav"> - <h2>Context Navigation</h2> - <ul> - <li class="first"><span>← <a class="prev" href="/browser/munin/plugins/node.d/apc_nis.in?rev=bebe375d6ec7de3fe03120c124b8d581e93b2f5f" title="Revision bebe375">Previous Revision</a></span></li><li><span><a class="next" href="/browser/munin/plugins/node.d/apc_nis.in?rev=334b69108d942308d245529ec16877458fcdd844" title="Revision 334b691">Next Revision</a> →</span></li><li><a href="/browser/munin/plugins/node.d/apc_nis.in?annotate=blame" title="Annotate each line with the last changed revision (this can be time consuming...)">Blame</a></li><li class="last"><a href="/log/munin/plugins/node.d/apc_nis.in">Revision Log</a></li> - </ul> - <hr /> - </div> - <div id="content" class="browser"> - <h1> - -<a class="pathentry first" href="/browser?order=name" title="Go to repository index">source:</a> -<a class="pathentry" href="/browser/munin?order=name" title="View munin">munin</a><span class="pathentry sep">/</span><a class="pathentry" href="/browser/munin/plugins?order=name" title="View plugins">plugins</a><span class="pathentry sep">/</span><a class="pathentry" href="/browser/munin/plugins/node.d?order=name" title="View node.d">node.d</a><span class="pathentry sep">/</span><a class="pathentry" href="/browser/munin/plugins/node.d/apc_nis.in?order=name" title="View apc_nis.in">apc_nis.in</a> -<br style="clear: both" /> - - </h1> - <div id="diffrev"> - <form action="/changeset" method="get"> - <div> - <label title="Show the diff against a specific revision"> - View diff against: <input type="text" name="old" size="6" /> - <input type="hidden" name="old_path" value="munin/plugins/node.d/apc_nis.in" /> - <input type="hidden" name="new" /> - <input type="hidden" name="new_path" value="munin/plugins/node.d/apc_nis.in" /> - </label> - </div> - </form> - </div> - <div id="jumprev"> - <form action="" method="get"> - <div> - <label for="rev"> - View revision:</label> - <input type="text" id="rev" name="rev" size="6" /> - </div> - </form> - </div> - <div id="jumploc"> - <form action="" method="get"> - <div style="display:none;"><input type="text" name="sfp_email" value="" /><input type="hidden" name="sfph_mail" value="" /></div><div class="buttons"> - <label for="preselected">Visit:</label> - <select id="preselected" name="preselected"> - <option selected="selected"></option> - <optgroup label="branches"> - <option value="/browser/munin/?rev=ce075ce508d22849dde9cbe0c531ee7d65c0559c">master</option><option value="/browser/munin/?rev=5c3f97ec4bc225aaf729a9a78ed6e9cf5031da3a">debian</option><option value="/browser/munin/?rev=03951617bef5282f2eee51da426b7612551e6943">devel</option><option value="/browser/munin/?rev=2b0b145f59bf30676e04ddd82e6a45194c742472">stable-2.0</option><option value="/browser/munin/?rev=0709ae958937b446a3519031d6f2c279e52b0198">test-wikilinks</option><option value="/browser/munin/?rev=b5369a4322a62b340b3eac971c8a5379213efa05">unit-tests</option> - </optgroup><optgroup label="tags"> - <option value="/browser/munin/?rev=0.9.9r7">0.9.9r7</option><option value="/browser/munin/?rev=1.0.0">1.0.0</option><option value="/browser/munin/?rev=1.0.0pre1">1.0.0pre1</option><option value="/browser/munin/?rev=1.0.0pre2">1.0.0pre2</option><option value="/browser/munin/?rev=1.0.0pre3">1.0.0pre3</option><option value="/browser/munin/?rev=1.0.0pre4">1.0.0pre4</option><option value="/browser/munin/?rev=1.0.0pre5">1.0.0pre5</option><option value="/browser/munin/?rev=1.0.1">1.0.1</option><option value="/browser/munin/?rev=1.0.2">1.0.2</option><option value="/browser/munin/?rev=1.0.3">1.0.3</option><option value="/browser/munin/?rev=1.0.4">1.0.4</option><option value="/browser/munin/?rev=1.0.5">1.0.5</option><option value="/browser/munin/?rev=1.1.0">1.1.0</option><option value="/browser/munin/?rev=1.1.1">1.1.1</option><option value="/browser/munin/?rev=1.1.2">1.1.2</option><option value="/browser/munin/?rev=1.1.3">1.1.3</option><option value="/browser/munin/?rev=1.1.4">1.1.4</option><option value="/browser/munin/?rev=1.1.5">1.1.5</option><option value="/browser/munin/?rev=1.1.6">1.1.6</option><option value="/browser/munin/?rev=1.1.7">1.1.7</option><option value="/browser/munin/?rev=1.1.8">1.1.8</option><option value="/browser/munin/?rev=1.1.9">1.1.9</option><option value="/browser/munin/?rev=1.2.0">1.2.0</option><option value="/browser/munin/?rev=1.2.0rc1">1.2.0rc1</option><option value="/browser/munin/?rev=1.2.0rc2">1.2.0rc2</option><option value="/browser/munin/?rev=1.2.1">1.2.1</option><option value="/browser/munin/?rev=1.2.2">1.2.2</option><option value="/browser/munin/?rev=1.2.3">1.2.3</option><option value="/browser/munin/?rev=1.2.4">1.2.4</option><option value="/browser/munin/?rev=1.2.5">1.2.5</option><option value="/browser/munin/?rev=1.2.6">1.2.6</option><option value="/browser/munin/?rev=1.2.6rc0">1.2.6rc0</option><option value="/browser/munin/?rev=1.2.6rc1">1.2.6rc1</option><option value="/browser/munin/?rev=1.2.6rc2">1.2.6rc2</option><option value="/browser/munin/?rev=1.3.0">1.3.0</option><option value="/browser/munin/?rev=1.3.1">1.3.1</option><option value="/browser/munin/?rev=1.3.2">1.3.2</option><option value="/browser/munin/?rev=1.3.3">1.3.3</option><option value="/browser/munin/?rev=1.3.3rc">1.3.3rc</option><option value="/browser/munin/?rev=1.3.4">1.3.4</option><option value="/browser/munin/?rev=1.4.0">1.4.0</option><option value="/browser/munin/?rev=1.4.0-alpha">1.4.0-alpha</option><option value="/browser/munin/?rev=1.4.0-alpha2">1.4.0-alpha2</option><option value="/browser/munin/?rev=1.4.0-beta">1.4.0-beta</option><option value="/browser/munin/?rev=1.4.1">1.4.1</option><option value="/browser/munin/?rev=1.4.2">1.4.2</option><option value="/browser/munin/?rev=1.4.3">1.4.3</option><option value="/browser/munin/?rev=1.4.4">1.4.4</option><option value="/browser/munin/?rev=1.4.5">1.4.5</option><option value="/browser/munin/?rev=1.4.6">1.4.6</option><option value="/browser/munin/?rev=1.4.7">1.4.7</option><option value="/browser/munin/?rev=2.0-alpha1">2.0-alpha1</option><option value="/browser/munin/?rev=2.0-alpha2">2.0-alpha2</option><option value="/browser/munin/?rev=2.0-beta1">2.0-beta1</option><option value="/browser/munin/?rev=2.0-beta2">2.0-beta2</option><option value="/browser/munin/?rev=2.0-beta3">2.0-beta3</option><option value="/browser/munin/?rev=2.0-beta4">2.0-beta4</option><option value="/browser/munin/?rev=2.0-beta5">2.0-beta5</option><option value="/browser/munin/?rev=2.0-beta6">2.0-beta6</option><option value="/browser/munin/?rev=2.0-beta7">2.0-beta7</option><option value="/browser/munin/?rev=2.0-rc1">2.0-rc1</option><option value="/browser/munin/?rev=2.0-rc2">2.0-rc2</option><option value="/browser/munin/?rev=2.0-rc3">2.0-rc3</option><option value="/browser/munin/?rev=2.0-rc4">2.0-rc4</option><option value="/browser/munin/?rev=2.0-rc5">2.0-rc5</option><option value="/browser/munin/?rev=2.0-rc6">2.0-rc6</option><option value="/browser/munin/?rev=2.0-rc7">2.0-rc7</option><option value="/browser/munin/?rev=2.0.0">2.0.0</option><option value="/browser/munin/?rev=2.0.0-1">2.0.0-1</option><option value="/browser/munin/?rev=2.0.0-test1">2.0.0-test1</option><option value="/browser/munin/?rev=2.0.1">2.0.1</option><option value="/browser/munin/?rev=2.0.1-1">2.0.1-1</option><option value="/browser/munin/?rev=2.0.10">2.0.10</option><option value="/browser/munin/?rev=2.0.11">2.0.11</option><option value="/browser/munin/?rev=2.0.11.1">2.0.11.1</option><option value="/browser/munin/?rev=2.0.12">2.0.12</option><option value="/browser/munin/?rev=2.0.13">2.0.13</option><option value="/browser/munin/?rev=2.0.14">2.0.14</option><option value="/browser/munin/?rev=2.0.15">2.0.15</option><option value="/browser/munin/?rev=2.0.16">2.0.16</option><option value="/browser/munin/?rev=2.0.2">2.0.2</option><option value="/browser/munin/?rev=2.0.2-1">2.0.2-1</option><option value="/browser/munin/?rev=2.0.3">2.0.3</option><option value="/browser/munin/?rev=2.0.4">2.0.4</option><option value="/browser/munin/?rev=2.0.5">2.0.5</option><option value="/browser/munin/?rev=2.0.5-1">2.0.5-1</option><option value="/browser/munin/?rev=2.0.6">2.0.6</option><option value="/browser/munin/?rev=2.0.6-1">2.0.6-1</option><option value="/browser/munin/?rev=2.0.6-1_bpo60%2B1">2.0.6-1_bpo60+1</option><option value="/browser/munin/?rev=2.0.7">2.0.7</option><option value="/browser/munin/?rev=2.0.8">2.0.8</option><option value="/browser/munin/?rev=2.0.9">2.0.9</option><option value="/browser/munin/?rev=2.0rc3">2.0rc3</option><option value="/browser/munin/?rev=2.1.2">2.1.2</option> - </optgroup> - </select> - <input type="submit" value="Go!" title="Jump to the chosen preselected path" /> - </div> - </form> - </div> - <div class="trac-tags"> - <span class="branch head" title="Branch head">devel</span> - </div> - <table id="info" summary="Revision info"> - <tr> - <th> - <a href="/changeset/1c1624ed88b8de3f20c4355d9d1152aa2e4fca57/munin/plugins/node.d/apc_nis.in" title="View differences">Last change</a> - on this file was - <a href="/changeset/1c1624ed88b8de3f20c4355d9d1152aa2e4fca57/munin" title="View changeset 1c1624e">1c1624e</a>, - checked in by Kenyon Ralph <kenyon@…>, <a class="timeline" href="/timeline?from=2013-05-04T20%3A30%3A14%2B02%3A00&precision=second" title="See timeline at 05/04/13 20:30:14">6 weeks ago</a> - </th> - </tr> - <tr> - <td class="message searchable"> - <p> -plugins/node.d/apc_nis: improve maximum limits<br /> -</p> -<p> -Battery charge is a percentage, so can't be over 100. There's no<br /> -reason to limit load, time left, or temperature; doing so just creates<br /> -graphs with missing values when you have actual values over these<br /> -arbitrary limits.<br /> -</p> - </td> - </tr> - <tr> - <td colspan="2"> - <ul class="props"> - <li> - Property <strong>mode</strong> set to - <em><code>100644</code></em> - </li> - </ul> - </td> - </tr> - <tr><td colspan="2"> - <strong>File size:</strong> - <span title="3218 bytes">3.1 KB</span> - </td></tr> - </table> - <div id="preview" class="searchable"> - - <table class="code"><thead><tr><th class="lineno" title="Line numbers">Line</th><th class="content"> </th></tr></thead><tbody><tr><th id="L1"><a href="#L1">1</a></th><td><span class="c1">#!@@PERL@@ -w</span></td></tr><tr><th id="L2"><a href="#L2">2</a></th><td><span class="c1"># -*- perl -*-</span></td></tr><tr><th id="L3"><a href="#L3">3</a></th><td></td></tr><tr><th id="L4"><a href="#L4">4</a></th><td><span class="cm">=head1 NAME</span></td></tr><tr><th id="L5"><a href="#L5">5</a></th><td><span class="cm"></span></td></tr><tr><th id="L6"><a href="#L6">6</a></th><td><span class="cm">apc_nis - Plugin to monitor APC UPS via the nis port of apcupsd</span></td></tr><tr><th id="L7"><a href="#L7">7</a></th><td><span class="cm"></span></td></tr><tr><th id="L8"><a href="#L8">8</a></th><td><span class="cm">=head1 CONFIGURATION</span></td></tr><tr><th id="L9"><a href="#L9">9</a></th><td><span class="cm"></span></td></tr><tr><th id="L10"><a href="#L10">10</a></th><td><span class="cm">The following configuration parameters are used by this plugin</span></td></tr><tr><th id="L11"><a href="#L11">11</a></th><td><span class="cm"></span></td></tr><tr><th id="L12"><a href="#L12">12</a></th><td><span class="cm"> [apc_nis]</span></td></tr><tr><th id="L13"><a href="#L13">13</a></th><td><span class="cm"> env.host - hostname to connect to</span></td></tr><tr><th id="L14"><a href="#L14">14</a></th><td><span class="cm"> env.port - port number to connect to</span></td></tr><tr><th id="L15"><a href="#L15">15</a></th><td><span class="cm"></span></td></tr><tr><th id="L16"><a href="#L16">16</a></th><td><span class="cm">=head2 DEFAULT CONFIGURATION</span></td></tr><tr><th id="L17"><a href="#L17">17</a></th><td><span class="cm"></span></td></tr><tr><th id="L18"><a href="#L18">18</a></th><td><span class="cm"> [apc_nis]</span></td></tr><tr><th id="L19"><a href="#L19">19</a></th><td><span class="cm"> env.host 127.0.0.1</span></td></tr><tr><th id="L20"><a href="#L20">20</a></th><td><span class="cm"> env.port 3551</span></td></tr><tr><th id="L21"><a href="#L21">21</a></th><td><span class="cm"></span></td></tr><tr><th id="L22"><a href="#L22">22</a></th><td><span class="cm">=head1 MAGIC MARKERS</span></td></tr><tr><th id="L23"><a href="#L23">23</a></th><td><span class="cm"></span></td></tr><tr><th id="L24"><a href="#L24">24</a></th><td><span class="cm"> #%# family=contrib</span></td></tr><tr><th id="L25"><a href="#L25">25</a></th><td><span class="cm"> #%# capabilities=autoconf</span></td></tr><tr><th id="L26"><a href="#L26">26</a></th><td><span class="cm"></span></td></tr><tr><th id="L27"><a href="#L27">27</a></th><td><span class="cm">=cut</span></td></tr><tr><th id="L28"><a href="#L28">28</a></th><td></td></tr><tr><th id="L29"><a href="#L29">29</a></th><td><span class="k">use</span> <span class="nn">IO::</span>Socket<span class="p">;</span></td></tr><tr><th id="L30"><a href="#L30">30</a></th><td><span class="k">use</span> strict<span class="p">;</span></td></tr><tr><th id="L31"><a href="#L31">31</a></th><td></td></tr><tr><th id="L32"><a href="#L32">32</a></th><td><span class="k">if</span><span class="p">(</span><span class="nv">$ARGV</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="nv">$ARGV</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">eq</span> <span class="s">"autoconf"</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L33"><a href="#L33">33</a></th><td> <span class="k">print</span> <span class="s">"yes\n"</span><span class="p">;</span></td></tr><tr><th id="L34"><a href="#L34">34</a></th><td> <span class="nb">exit</span> <span class="mi">0</span><span class="p">;</span></td></tr><tr><th id="L35"><a href="#L35">35</a></th><td><span class="p">}</span></td></tr><tr><th id="L36"><a href="#L36">36</a></th><td></td></tr><tr><th id="L37"><a href="#L37">37</a></th><td><span class="k">my</span> <span class="nv">$host</span> <span class="o">=</span> <span class="nb">exists</span> <span class="nv">$ENV</span><span class="p">{</span><span class="s">'host'</span><span class="p">}</span> <span class="p">?</span> <span class="nv">$ENV</span><span class="p">{</span><span class="s">'host'</span><span class="p">}</span> <span class="p">:</span> <span class="s">"127.0.0.1"</span><span class="p">;</span></td></tr><tr><th id="L38"><a href="#L38">38</a></th><td><span class="k">my</span> <span class="nv">$port</span> <span class="o">=</span> <span class="nb">exists</span> <span class="nv">$ENV</span><span class="p">{</span><span class="s">'port'</span><span class="p">}</span> <span class="p">?</span> <span class="nv">$ENV</span><span class="p">{</span><span class="s">'port'</span><span class="p">}</span> <span class="p">:</span> <span class="s">"3551"</span><span class="p">;</span></td></tr><tr><th id="L39"><a href="#L39">39</a></th><td></td></tr><tr><th id="L40"><a href="#L40">40</a></th><td><span class="k">my</span> <span class="nv">$sock</span> <span class="o">=</span> <span class="k">new</span> <span class="nn">IO::Socket::</span>INET <span class="p">(</span></td></tr><tr><th id="L41"><a href="#L41">41</a></th><td> PeerAddr <span class="o">=></span> <span class="nv">$host</span><span class="p">,</span></td></tr><tr><th id="L42"><a href="#L42">42</a></th><td> PeerPort <span class="o">=></span> <span class="nv">$port</span><span class="p">,</span></td></tr><tr><th id="L43"><a href="#L43">43</a></th><td> Proto <span class="o">=></span> <span class="s">'tcp'</span></td></tr><tr><th id="L44"><a href="#L44">44</a></th><td> <span class="p">);</span></td></tr><tr><th id="L45"><a href="#L45">45</a></th><td></td></tr><tr><th id="L46"><a href="#L46">46</a></th><td><span class="nb">die</span> <span class="s">"Could not create socket: $!\n"</span> <span class="k">unless</span> <span class="nv">$sock</span><span class="p">;</span></td></tr><tr><th id="L47"><a href="#L47">47</a></th><td></td></tr><tr><th id="L48"><a href="#L48">48</a></th><td><span class="k">my</span> <span class="nv">$buf</span> <span class="o">=</span> <span class="nb">pack</span><span class="p">(</span><span class="s">"CC"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">6</span><span class="p">);</span></td></tr><tr><th id="L49"><a href="#L49">49</a></th><td><span class="k">print</span> <span class="nv">$sock</span> <span class="nv">$buf</span><span class="p">;</span></td></tr><tr><th id="L50"><a href="#L50">50</a></th><td><span class="k">print</span> <span class="nv">$sock</span> <span class="s">"status\n"</span><span class="p">;</span></td></tr><tr><th id="L51"><a href="#L51">51</a></th><td></td></tr><tr><th id="L52"><a href="#L52">52</a></th><td><span class="k">if</span><span class="p">(</span><span class="nv">$ARGV</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="nv">$ARGV</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">eq</span> <span class="s">"config"</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L53"><a href="#L53">53</a></th><td> <span class="c1"># Test for some capabilities.</span></td></tr><tr><th id="L54"><a href="#L54">54</a></th><td> <span class="k">my</span> <span class="nv">$has_temperature</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="k">my</span> <span class="nv">$line_volt_min</span><span class="p">,</span> <span class="k">my</span> <span class="nv">$line_volt_max</span><span class="p">;</span></td></tr><tr><th id="L55"><a href="#L55">55</a></th><td> <span class="k">my</span> <span class="nv">$line</span><span class="p">;</span></td></tr><tr><th id="L56"><a href="#L56">56</a></th><td> <span class="k">do</span> <span class="p">{</span></td></tr><tr><th id="L57"><a href="#L57">57</a></th><td> <span class="nv">$line</span> <span class="o">=</span> <span class="sr"><$sock></span><span class="p">;</span></td></tr><tr><th id="L58"><a href="#L58">58</a></th><td> <span class="nb">chomp</span><span class="p">(</span><span class="nv">$line</span><span class="p">);</span></td></tr><tr><th id="L59"><a href="#L59">59</a></th><td> <span class="k">if</span> <span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WITEMP /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L60"><a href="#L60">60</a></th><td> <span class="nv">$has_temperature</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span></td></tr><tr><th id="L61"><a href="#L61">61</a></th><td> <span class="p">}</span> <span class="k">elsif</span> <span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WLOTRANS /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L62"><a href="#L62">62</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L63"><a href="#L63">63</a></th><td> <span class="nv">$line_volt_min</span> <span class="o">=</span> <span class="nv">$line</span><span class="p">;</span></td></tr><tr><th id="L64"><a href="#L64">64</a></th><td> <span class="p">}</span> <span class="k">elsif</span> <span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WHITRANS /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L65"><a href="#L65">65</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L66"><a href="#L66">66</a></th><td> <span class="nv">$line_volt_max</span> <span class="o">=</span> <span class="nv">$line</span><span class="p">;</span></td></tr><tr><th id="L67"><a href="#L67">67</a></th><td> <span class="p">}</span></td></tr><tr><th id="L68"><a href="#L68">68</a></th><td> <span class="p">}</span> <span class="k">while</span><span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /END APC/</span><span class="p">));</span></td></tr><tr><th id="L69"><a href="#L69">69</a></th><td></td></tr><tr><th id="L70"><a href="#L70">70</a></th><td> <span class="nb">close</span><span class="p">(</span><span class="nv">$sock</span><span class="p">);</span></td></tr><tr><th id="L71"><a href="#L71">71</a></th><td></td></tr><tr><th id="L72"><a href="#L72">72</a></th><td> <span class="k">print</span> <span class="s">"graph_title APC UPS measurements\n"</span><span class="p">;</span></td></tr><tr><th id="L73"><a href="#L73">73</a></th><td> <span class="k">print</span> <span class="s">"graph_args -l 0 --base 1000\n"</span><span class="p">;</span></td></tr><tr><th id="L74"><a href="#L74">74</a></th><td> <span class="k">print</span> <span class="s">"graph_vlabel A bit of all (Volt, time, %)\n"</span><span class="p">;</span></td></tr><tr><th id="L75"><a href="#L75">75</a></th><td> <span class="k">print</span> <span class="s">"graph_info Values received for apcupsd available at $host:$port\n"</span><span class="p">;</span></td></tr><tr><th id="L76"><a href="#L76">76</a></th><td> <span class="k">print</span> <span class="s">"battery_volt.label batt volt (V)\n"</span><span class="p">;</span></td></tr><tr><th id="L77"><a href="#L77">77</a></th><td> <span class="k">print</span> <span class="s">"battery_volt.type GAUGE\n"</span><span class="p">;</span></td></tr><tr><th id="L78"><a href="#L78">78</a></th><td> <span class="k">print</span> <span class="s">"battery_volt.max 300\n"</span><span class="p">;</span></td></tr><tr><th id="L79"><a href="#L79">79</a></th><td> <span class="k">print</span> <span class="s">"battery_charge.label batt charge (%)\n"</span><span class="p">;</span></td></tr><tr><th id="L80"><a href="#L80">80</a></th><td> <span class="k">print</span> <span class="s">"battery_charge.type GAUGE\n"</span><span class="p">;</span></td></tr><tr><th id="L81"><a href="#L81">81</a></th><td> <span class="k">print</span> <span class="s">"battery_charge.max 100\n"</span><span class="p">;</span></td></tr><tr><th id="L82"><a href="#L82">82</a></th><td> <span class="k">print</span> <span class="s">"line_volt.label line (V)\n"</span><span class="p">;</span></td></tr><tr><th id="L83"><a href="#L83">83</a></th><td> <span class="k">print</span> <span class="s">"line_volt.type GAUGE\n"</span><span class="p">;</span></td></tr><tr><th id="L84"><a href="#L84">84</a></th><td> <span class="k">print</span> <span class="s">"line_volt.max 300\n"</span><span class="p">;</span></td></tr><tr><th id="L85"><a href="#L85">85</a></th><td> <span class="k">print</span> <span class="s">"line_volt.warning ${line_volt_min}:${line_volt_max}\n"</span><span class="p">;</span></td></tr><tr><th id="L86"><a href="#L86">86</a></th><td> <span class="k">print</span> <span class="s">"load.label ups load (%)\n"</span><span class="p">;</span></td></tr><tr><th id="L87"><a href="#L87">87</a></th><td> <span class="k">print</span> <span class="s">"load.type GAUGE\n"</span><span class="p">;</span></td></tr><tr><th id="L88"><a href="#L88">88</a></th><td> <span class="k">print</span> <span class="s">"time_left.label time left (min)\n"</span><span class="p">;</span></td></tr><tr><th id="L89"><a href="#L89">89</a></th><td> <span class="k">print</span> <span class="s">"time_left.type GAUGE\n"</span><span class="p">;</span></td></tr><tr><th id="L90"><a href="#L90">90</a></th><td> <span class="k">if</span> <span class="p">(</span><span class="nv">$has_temperature</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L91"><a href="#L91">91</a></th><td> <span class="k">print</span> <span class="s">"temperature.label internal temperature (°C)\n"</span><span class="p">;</span></td></tr><tr><th id="L92"><a href="#L92">92</a></th><td> <span class="k">print</span> <span class="s">"temperature.type GAUGE\n"</span><span class="p">;</span></td></tr><tr><th id="L93"><a href="#L93">93</a></th><td> <span class="p">}</span></td></tr><tr><th id="L94"><a href="#L94">94</a></th><td> <span class="nb">exit</span> <span class="mi">0</span><span class="p">;</span></td></tr><tr><th id="L95"><a href="#L95">95</a></th><td><span class="p">}</span></td></tr><tr><th id="L96"><a href="#L96">96</a></th><td></td></tr><tr><th id="L97"><a href="#L97">97</a></th><td><span class="k">my</span> <span class="nv">$line</span><span class="p">;</span></td></tr><tr><th id="L98"><a href="#L98">98</a></th><td><span class="k">do</span> <span class="p">{</span></td></tr><tr><th id="L99"><a href="#L99">99</a></th><td> <span class="nv">$line</span> <span class="o">=</span> <span class="sr"><$sock></span><span class="p">;</span></td></tr><tr><th id="L100"><a href="#L100">100</a></th><td> <span class="nb">chomp</span><span class="p">(</span><span class="nv">$line</span><span class="p">);</span></td></tr><tr><th id="L101"><a href="#L101">101</a></th><td> <span class="k">if</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WBATTV /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L102"><a href="#L102">102</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L103"><a href="#L103">103</a></th><td> <span class="k">print</span> <span class="s">"battery_volt.value $line\n"</span><span class="p">;</span></td></tr><tr><th id="L104"><a href="#L104">104</a></th><td> <span class="p">}</span> <span class="k">elsif</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WLINEV /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L105"><a href="#L105">105</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L106"><a href="#L106">106</a></th><td> <span class="k">print</span> <span class="s">"line_volt.value $line\n"</span><span class="p">;</span></td></tr><tr><th id="L107"><a href="#L107">107</a></th><td> <span class="p">}</span> <span class="k">elsif</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WLOADPCT /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L108"><a href="#L108">108</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L109"><a href="#L109">109</a></th><td> <span class="k">print</span> <span class="s">"load.value $line\n"</span><span class="p">;</span></td></tr><tr><th id="L110"><a href="#L110">110</a></th><td> <span class="p">}</span> <span class="k">elsif</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WBCHARGE /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L111"><a href="#L111">111</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L112"><a href="#L112">112</a></th><td> <span class="k">print</span> <span class="s">"battery_charge.value $line\n"</span><span class="p">;</span></td></tr><tr><th id="L113"><a href="#L113">113</a></th><td> <span class="p">}</span> <span class="k">elsif</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WTIMELEFT /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L114"><a href="#L114">114</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L115"><a href="#L115">115</a></th><td> <span class="k">print</span> <span class="s">"time_left.value $line\n"</span><span class="p">;</span></td></tr><tr><th id="L116"><a href="#L116">116</a></th><td> <span class="p">}</span> <span class="k">elsif</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /\WITEMP /</span><span class="p">)</span> <span class="p">{</span></td></tr><tr><th id="L117"><a href="#L117">117</a></th><td> <span class="nv">$line</span> <span class="o">=~</span> <span class="sr">s/.* (\d+.\d+).*/$1/</span><span class="p">;</span></td></tr><tr><th id="L118"><a href="#L118">118</a></th><td> <span class="k">print</span> <span class="s">"temperature.value $line\n"</span><span class="p">;</span></td></tr><tr><th id="L119"><a href="#L119">119</a></th><td> <span class="p">}</span></td></tr><tr><th id="L120"><a href="#L120">120</a></th><td><span class="p">}</span> <span class="k">while</span><span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nv">$line</span> <span class="o">=~</span><span class="sr"> /END APC/</span><span class="p">));</span></td></tr><tr><th id="L121"><a href="#L121">121</a></th><td></td></tr><tr><th id="L122"><a href="#L122">122</a></th><td><span class="nb">close</span><span class="p">(</span><span class="nv">$sock</span><span class="p">);</span></td></tr></tbody></table> - - </div> - <div id="anydiff"> - <form action="/diff" method="get"> - <div style="display:none;"><input type="text" name="sfp_email" value="" /><input type="hidden" name="sfph_mail" value="" /></div><div class="buttons"> - <input type="hidden" name="new_path" value="/munin/plugins/node.d/apc_nis.in" /> - <input type="hidden" name="old_path" value="/munin/plugins/node.d/apc_nis.in" /> - <input type="hidden" name="new_rev" /> - <input type="hidden" name="old_rev" /> - <input type="submit" value="View changes..." title="Select paths and revs for Diff" /> - </div> - </form> - </div> - <div id="help"><strong>Note:</strong> See <a href="/wiki/TracBrowser">TracBrowser</a> - for help on using the repository browser.</div> - </div> - <div id="altlinks"> - <h3>Download in other formats:</h3> - <ul> - <li class="first"> - <a rel="nofollow" href="/browser/munin/plugins/node.d/apc_nis.in?format=txt">Plain Text</a> - </li><li class="last"> - <a rel="nofollow" href="/export/03951617bef5282f2eee51da426b7612551e6943/munin/plugins/node.d/apc_nis.in">Original Format</a> - </li> - </ul> - </div> - </div> - <div id="footer" lang="en" xml:lang="en"><hr /> - <a id="tracpowered" href="http://trac.edgewall.org/"><img src="/chrome/common/trac_logo_mini.png" height="30" width="107" alt="Trac Powered" /></a> - <p class="left">Powered by <a href="/about"><strong>Trac 1.0</strong></a><br /> - By <a href="http://www.edgewall.org/">Edgewall Software</a>.</p> - <p class="right">Visit the Munin open project at<br /><a href="http://munin-monitoring.org/">http://munin-monitoring.org/</a></p> - </div> - </body> -</html>
\ No newline at end of file +#!@@PERL@@ -w +# -*- perl -*- + +=head1 NAME + +apc_nis - Plugin to monitor APC UPS via the nis port of apcupsd + +=head1 CONFIGURATION + +The following configuration parameters are used by this plugin + + [apc_nis] + env.host - hostname to connect to + env.port - port number to connect to + +=head2 DEFAULT CONFIGURATION + + [apc_nis] + env.host 127.0.0.1 + env.port 3551 + +=head1 MAGIC MARKERS + + #%# family=contrib + #%# capabilities=autoconf + +=cut + +use IO::Socket; +use strict; + +if($ARGV[0] and $ARGV[0] eq "autoconf") { + print "yes\n"; + exit 0; +} + +my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1"; +my $port = exists $ENV{'port'} ? $ENV{'port'} : "3551"; + +my $sock = new IO::Socket::INET ( + PeerAddr => $host, + PeerPort => $port, + Proto => 'tcp' + ); + +die "Could not create socket: $!\n" unless $sock; + +my $buf = pack("CC", 0, 6); +print $sock $buf; +print $sock "status\n"; + +if($ARGV[0] and $ARGV[0] eq "config") { + # Test for some capabilities. + my $has_temperature = 0, my $line_volt_min, my $line_volt_max; + my $line; + do { + $line = <$sock>; + chomp($line); + if ($line =~ /\WITEMP /) { + $has_temperature = 1; + } elsif ($line =~ /\WLOTRANS /) { + $line =~ s/.* (\d+.\d+).*/$1/; + $line_volt_min = $line; + } elsif ($line =~ /\WHITRANS /) { + $line =~ s/.* (\d+.\d+).*/$1/; + $line_volt_max = $line; + } + } while(!($line =~ /END APC/)); + + close($sock); + + print "graph_title APC UPS measurements\n"; + print "graph_args -l 0 --base 1000\n"; + print "graph_vlabel A bit of all (Volt, time, %)\n"; + print "graph_info Values received for apcupsd available at $host:$port\n"; + print "battery_volt.label batt volt (V)\n"; + print "battery_volt.type GAUGE\n"; + print "battery_volt.max 300\n"; + print "battery_charge.label batt charge (%)\n"; + print "battery_charge.type GAUGE\n"; + print "battery_charge.max 100\n"; + print "line_volt.label line (V)\n"; + print "line_volt.type GAUGE\n"; + print "line_volt.max 300\n"; + print "line_volt.warning ${line_volt_min}:${line_volt_max}\n"; + print "load.label ups load (%)\n"; + print "load.type GAUGE\n"; + print "time_left.label time left (min)\n"; + print "time_left.type GAUGE\n"; + if ($has_temperature) { + print "temperature.label internal temperature (°C)\n"; + print "temperature.type GAUGE\n"; + } + exit 0; +} + +my $line; +do { + $line = <$sock>; + chomp($line); + if($line =~ /\WBATTV /) { + $line =~ s/.* (\d+.\d+).*/$1/; + print "battery_volt.value $line\n"; + } elsif($line =~ /\WLINEV /) { + $line =~ s/.* (\d+.\d+).*/$1/; + print "line_volt.value $line\n"; + } elsif($line =~ /\WLOADPCT /) { + $line =~ s/.* (\d+.\d+).*/$1/; + print "load.value $line\n"; + } elsif($line =~ /\WBCHARGE /) { + $line =~ s/.* (\d+.\d+).*/$1/; + print "battery_charge.value $line\n"; + } elsif($line =~ /\WTIMELEFT /) { + $line =~ s/.* (\d+.\d+).*/$1/; + print "time_left.value $line\n"; + } elsif($line =~ /\WITEMP /) { + $line =~ s/.* (\d+.\d+).*/$1/; + print "temperature.value $line\n"; + } +} while(!($line =~ /END APC/)); + +close($sock); |