From 7c8bd1e3945386c433b5e08478a1873d74bcd0e7 Mon Sep 17 00:00:00 2001 From: runesk Date: Mon, 11 Jun 2007 15:45:16 +0000 Subject: [PATCH] Import git-svn-id: svn://svn.code.sf.net/p/muninlite/code/muninlite@1 35caa317-6b62-4e8a-81c0-b04f0c356266 --- CREDITS | 37 ++++ Changelog | 34 ++++ LICENSE | 341 ++++++++++++++++++++++++++++++++++ Makefile | 46 +++++ README | 171 +++++++++++++++++ TODO | 2 + VERSION | 1 + doc/Working-distributions.txt | 12 ++ examples/hosts.allow | 1 + examples/hosts.deny | 1 + examples/inetd.busybox | 1 + examples/inetd.conf | 1 + examples/xinetd.d/munin | 11 ++ munin-node.in | 103 ++++++++++ plugins/cpu | 83 +++++++++ plugins/df | 24 +++ plugins/if_ | 21 +++ plugins/if_err_ | 21 +++ plugins/interrupts | 22 +++ plugins/irqstats | 36 ++++ plugins/load | 15 ++ plugins/memory | 185 ++++++++++++++++++ plugins/netstat | 41 ++++ plugins/processes | 13 ++ plugins/swap | 27 +++ plugins/uptime | 11 ++ 26 files changed, 1261 insertions(+) create mode 100644 CREDITS create mode 100644 Changelog create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100644 TODO create mode 100644 VERSION create mode 100644 doc/Working-distributions.txt create mode 100644 examples/hosts.allow create mode 100644 examples/hosts.deny create mode 100644 examples/inetd.busybox create mode 100644 examples/inetd.conf create mode 100644 examples/xinetd.d/munin create mode 100755 munin-node.in create mode 100644 plugins/cpu create mode 100644 plugins/df create mode 100644 plugins/if_ create mode 100644 plugins/if_err_ create mode 100644 plugins/interrupts create mode 100644 plugins/irqstats create mode 100644 plugins/load create mode 100644 plugins/memory create mode 100644 plugins/netstat create mode 100644 plugins/processes create mode 100644 plugins/swap create mode 100644 plugins/uptime diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..4f91dd2 --- /dev/null +++ b/CREDITS @@ -0,0 +1,37 @@ +As MuninLite has close bounds to munin-node code, some of the plugin +code is borrowed from the Linux plugins. As most of the code checkins +are done by previous Munin maintainer, Jimmy Olsen , +some credits might be missing. + +MuninLite hearby credits the following people for their contribution +to Munin or MuninLite + +Jimmy Olsen + - df plugin in Munin + - cpu plugin in Munin + - if_ and if_err_ plugin in Munin + - load plugin in Munin + - memory plugin in Munin + - processes plugin in Munin + - interupts plugin in Munin + +Mike Fedyk + - memory plugin in Munin + - context switch graphing in interupts plugin in Munin + +Nicolas Salles + - uptime plugin in Munin + +Ragnar Wisløff + - Idea and base for interupts plugin in Munin + +Dagfinn Ilmari Mannsåker + - irqstats plugin in Munin + +Kai Ove Gran + - Help regarding available features in busybox in floppyfw + - Build script (muninlite.mk) for floppyfw devkit + (http://pong.no/floppyfw/muninlite/) + - post ini script (post-muninlite.ini) for floppyfw + (http://pong.no/floppyfw/muninlite/) + \ No newline at end of file diff --git a/Changelog b/Changelog new file mode 100644 index 0000000..af65301 --- /dev/null +++ b/Changelog @@ -0,0 +1,34 @@ +muninlite + +Changelog: + +0.9.14 - 0.9.15 + +Date: + + - Some documentations added + + +0.9.13 - 0.9.14 + +Date: 2007-06-10 + + - Plugins as separate files + - Makefile (make smaller munin-node for systems with less plugins) + +0.9.12 - 0.9.13 + +Date: 2007-06-10 + + - Fixed spikes (hopefully) in if_ and if_err_ + - Fixed missing output due to parsed $ in variables in multiple plugins + + +0 - 0.9.12 + +Date: 2007-06-08 + + - First Changelog + - Initial "release" + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..21b9363 --- /dev/null +++ b/LICENSE @@ -0,0 +1,341 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..10109d1 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ + + +#PLUGINS=df cpu if_ if_err_ load memory processes swap netstat uptime interrupts irqstats +PLUGINS=cpu if_ if_err_ load memory processes netstat uptime interrupts irqstats + +munin-node: + @VERSION=$$(cat VERSION); \ + echo "Making munin-node for muninlite version $$VERSION"; \ + PLSTR=""; \ + for PLGIN in $(PLUGINS); \ + do \ + echo "Adding plugin $$PLGIN"; \ + PLSTR=$$(echo "$$PLSTR"; grep -v '^#' plugins/$$PLGIN); \ + done; \ + PLSTR=$$(echo "$$PLSTR" | sed -e 's/\\/\\\\/g' \ + -e 's/\//\\\//g' \ + -e 's/\$$/\\$$/g'); \ + perl -p -e \ + "s/\@\@VERSION\@\@/$$VERSION/;s/\@\@PLUGINS\@\@/$(PLUGINS)/;s/\@\@PLSTR\@\@/$$PLSTR/;" \ + munin-node.in > munin-node + @chmod +x munin-node + + +all: munin-node + +clean-node: + @echo "Removing munin-node" + @rm -f munin-node + +clean-tgz: + @echo "Old releases" + @rm -rf releases + +clean: clean-node + +clean-all: clean-node clean-tgz + +tgz: clean-node + @VERSION=$$(cat VERSION); \ + echo "Building release/muninlite-$$VERSION.tar.gz"; \ + mkdir -p releases; \ + cp -ra . releases/muninlite-$$VERSION 2>/dev/null || true; \ + cd releases; \ + rm -rf muninlite-$$VERSION/releases; \ + tar zcvf muninlite-$$VERSION.tar.gz muninlite-$$VERSION >/dev/null; \ + rm -rf muninlite-$$VERSION; \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..63411c0 --- /dev/null +++ b/README @@ -0,0 +1,171 @@ +README for MuninLite +==================== + +MuninLite is a single Bourne Shell script that implements the Munin +protocoll as well as some Linux specific plugins. The motivation for +developing MuninLite was to provide a simple Munin Node, using inetd +on systems without a full featured Perl and/or bash or a busybox +system. + +MuninLite is Copyright (C) 2007 Rune Nordbøe Skillingstad + and released under GPLv2 (see LICENSE file) + +Features +-------- +MuninLite implements the following plugins: +* df +* cpu +* if_ +* if_err_ +* load +* memory +* processes +* swap +* netstat +* uptime +* interrupts +* irqstats + +Included files +-------------- +Changelog Changelog +CREDITS Credits to contributors +LICENSE GPLv2 License +Makefile Rules to make munin-node +README This file +TODO Things to do in future releases +VERSION Current version +munin-node.in The MuninLite script skeleton +examples/xinetd.d/munin Sample xinetd configuration +examples/inetd.conf Sample inetd.conf configuration +examples/inetd.busybox Sample inetd.conf configuration for busybox +examples/hosts.deny Sample hosts.deny configuration +examples/hosts.allow Sample hosts.allow configuration +plugins/cpu CPU usage plugin +plugins/df Filesystem usage plugin +plugins/if_ Network interface traffic plugin +plugins/if_err_ Network interface errors plugin +plugins/interrupts Interrupts & context switches plugin +plugins/irqstats Individual interrupts plugin +plugins/load Load average plugin +plugins/memory Memory usage plugin +plugins/netstat Netstat plugin +plugins/processes Number of Processes plugin +plugins/swap Swap in/out plugin +plugins/uptime Uptime plugin + +Build requirements +------------------ +Make (Not sure what requirements) +Perl (even very old versions should work) + +Requirements +------------ +Bourne Shell (ash or dash should be sufficient) +grep (simple grep in busybox is sufficient) +sed (simple sed in busybox is sufficient -- but a bit strange...) +cut (cut in busybox is sufficient) +wc (wc in busybox is sufficient) +xargs (xargs in busybox is sufficient) +inetd (inetd in busybox is sufficient) + +Installation +------------ +Download source and unpack it. +Edit Makefile to suit your choice of plugins + +Make munin-node by running "make" + # make + Making munin-node for muninlite version 0.9.14 + Adding plugin df + Adding plugin cpu + Adding plugin if_ + Adding plugin if_err_ + Adding plugin load + Adding plugin memory + Adding plugin processes + Adding plugin swap + Adding plugin netstat + Adding plugin uptime + Adding plugin interrupts + Adding plugin irqstats + +Copy munin-node to a suitable location (/usr/local/bin/) and make it +executable (there will be a "make install" at a later release) + + # cp munin-node /usr/local/bin + # chmod +x /usr/local/bin/munin-node + +Add munin port to /etc/services + + # echo "munin 4949/tcp lrrd # Munin" >>/etc/services + +Configure inetd or xinetd to fork this script for request on the +munin port (4949). + +Sample configuration for xinetd is located in examples/xinetd.d/munin + + # cp examples/xinetd.d/munin /etc/xinetd.d + # killall -HUP xinetd + +Sample configuration for inetd is located in examples/inetd.conf + + # cat examples/inetd.conf >> /etc/inetd.conf + # killall -HUP inetd + +Restrict access to munin port using hosts.allow and +hosts.deny or add a rule to your favorite firewall config. +Examples of hosts.allow/deny settings is provided in the examples +directory. + +Iptables might be set with something like this: + + # iptables -A INPUT -p tcp --dport munin --source 10.42.42.25 -j ACCEPT + +Test +---- +To test script, just run it (/usr/bin/local/munin-node): + + # /usr/local/bin/munin-node + # munin node at localhost.localdomain + help + # Unknown command. Try list, nodes, config, fetch, version or quit + list + df cpu if_eth0 if_eth1 if_err_eth0 if_err_eth1 load memory + version + munins node on mose.medisin.ntnu.no version: 0.0.5 (munin-lite) + quit + +For inetd-test, try to telnet to munin port from allowed host. + + # telnet localhost 4949 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + # munin node at localhost.localdomain + help + # Unknown command. Try list, nodes, config, fetch, version or quit + list + df cpu if_eth0 if_eth1 if_err_eth0 if_err_eth1 load memory + version + munins node on mose.medisin.ntnu.no version: 0.0.5 (munin-lite) + quit + Connection closed by foreign host. + + +Plugin configuration +------------------------ +To configure which plugins should be enabled, locate the PLUGINS +variable in munin-node and remove unwanted plugins. + +There is no specific configuration for plugins. + +Munin configuration +------------------- +Configure your /etc/munin/munin.conf as you would for a regular +munin-node. + +[some.host.tld] + address 10.42.42.25 + use_node_name yes + diff --git a/TODO b/TODO new file mode 100644 index 0000000..dc7fb8d --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ +* Homepage +* Documentation diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..5d11b14 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.9.15 diff --git a/doc/Working-distributions.txt b/doc/Working-distributions.txt new file mode 100644 index 0000000..61bb999 --- /dev/null +++ b/doc/Working-distributions.txt @@ -0,0 +1,12 @@ +These distributions are known to be working with muninlite: + +* Floppyfw 3.0 + - Needs a busybox with inetd + - See http://pong.no/floppyfw/muninlite/ + +* Endian Firewall Community 2.1 + - Needs some kind of inetd (xinetd RPM from Centos might work) + +* OpenSuSE 10.2 + - Just works + diff --git a/examples/hosts.allow b/examples/hosts.allow new file mode 100644 index 0000000..fdd1dbf --- /dev/null +++ b/examples/hosts.allow @@ -0,0 +1 @@ +munin-node : 10.42.42.25 diff --git a/examples/hosts.deny b/examples/hosts.deny new file mode 100644 index 0000000..6246f52 --- /dev/null +++ b/examples/hosts.deny @@ -0,0 +1 @@ +munin-node : ALL diff --git a/examples/inetd.busybox b/examples/inetd.busybox new file mode 100644 index 0000000..d0b5009 --- /dev/null +++ b/examples/inetd.busybox @@ -0,0 +1 @@ +munin stream tcp nowait root /usr/local/bin/munin-node diff --git a/examples/inetd.conf b/examples/inetd.conf new file mode 100644 index 0000000..a587d9b --- /dev/null +++ b/examples/inetd.conf @@ -0,0 +1 @@ +munin stream tcp nowait root /usr/sbin/tcpd /usr/local/bin/munin-node diff --git a/examples/xinetd.d/munin b/examples/xinetd.d/munin new file mode 100644 index 0000000..5913203 --- /dev/null +++ b/examples/xinetd.d/munin @@ -0,0 +1,11 @@ +service munin +{ + socket_type = stream + protocol = tcp + wait = no + user = root + group = root + only_from = 10.42.42.25 + server = /usr/local/bin/munin-node + disable = no +} diff --git a/munin-node.in b/munin-node.in new file mode 100755 index 0000000..ef0a3c0 --- /dev/null +++ b/munin-node.in @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Simple Bourne Shell script that implements Munin protocoll and +# some common Linux plugins. +# +# For latest version, see http://muninlite.sf.net/ +# +# Copyright (c) 2007 Rune Nordbøe Skillingstad +# +# Licensed under GPLv2 (see LICENSE file for full License) +# +# $Id: $ +# + +VERSION="@@VERSION@@" + +# Remove unwanted plugins from this list +PLUGINS="@@PLUGINS@@" + +# ===== PLUGINS CODE ===== +@@PLSTR@@ + +# ===== NODE CODE ===== +do_list() { + echo $PLUGINS +} + + +do_nodes() { + echo "$HOSTNAME" + echo "." +} + +do_config() { + if echo "$PLUGINS" | grep "\b$1\b" >/dev/null 2>&1; then + config_$1 + else + echo "# Unknown service" + fi + echo "." +} + +do_fetch() { + if echo "$PLUGINS" | grep "\b$1\b" >/dev/null 2>&1; then + fetch_$1 + else + echo "# Unknown service" + fi + echo "." +} + +do_version() { + echo "munins node on $HOSTNAME version: $VERSION (munin-lite)" +} + +do_quit() { + exit 0 +} + +# ===== Runtime config ===== +RES="" +for PLUG in $PLUGINS +do + if [ "$PLUG" = "if_" ]; then + for INTER in $(grep '^ *\(eth\|wlan\|ath\|ra\)[0-9]\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'); + do + RES="$RES if_$INTER" + eval "fetch_if_${INTER}() { fetch_if $INTER $@; };" + eval "config_if_${INTER}() { config_if $INTER $@; };" + done + elif [ "$PLUG" = "if_err_" ]; then + for INTER in $(grep '^ *\(eth\|wlan\|ath\|ra\)[0-9]\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'); + do + RES="$RES if_err_$INTER" + eval "fetch_if_err_${INTER}() { fetch_if_err $INTER $@; };" + eval "config_if_err_${INTER}() { config_if_err $INTER $@; };" + done + elif [ "$PLUG" = "netstat" ]; then + if netstat -s >/dev/null 2>&1; then + RES="$RES netstat" + fi + else + RES="$RES $PLUG"; + fi +done +PLUGINS=$RES + +# ===== MAIN LOOP ===== +FUNCTIONS="list nodes config fetch version quit" +HOSTNAME=$(hostname -f 2>/dev/null || hostname) +echo "# munin node at $HOSTNAME" +while read arg0 arg1 +do + arg0=$(echo "$arg0" | xargs) + arg1=$(echo "$arg1" | xargs) + if ! echo "$FUNCTIONS" | grep "\b$arg0\b" >/dev/null 2>&1 ; then + echo "# Unknown command. Try" $(echo "$FUNCTIONS" | sed -e 's/\( [[:alpha:]]\{1,\}\)/,\1/g' -e 's/,\( [[:alpha:]]\{1,\}\)$/ or\1/') + continue + fi + + do_$arg0 $arg1 +done + diff --git a/plugins/cpu b/plugins/cpu new file mode 100644 index 0000000..ba10bed --- /dev/null +++ b/plugins/cpu @@ -0,0 +1,83 @@ +config_cpu() { + extinfo="" + if grep '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat >/dev/null 2>&1; then + extinfo="iowait irq softirq" + fi + NCPU=$(($(grep '^cpu. ' /proc/stat | wc -l) - 1)) + PERCENT=$(($NCPU * 100)) + graphlimit=$PERCENT + SYSWARNING=$(($PERCENT * 30 / 100)) + SYSCRITICAL=$(($PERCENT * 50 / 100)) + USRWARNING=$(($PERCENT * 80 / 100)) + echo "graph_title CPU usage" + echo "graph_order system user nice idle" $extinfo + echo "graph_args --base 1000 -r --lower-limit 0 --upper-limit $graphlimit" + echo "graph_vlabel %" + echo "graph_scale no" + echo "graph_info This graph shows how CPU time is spent." + echo "graph_category system" + echo "graph_period second" + echo "system.label system" + echo "system.draw AREA" + echo "system.max 5000" + echo "system.min 0" + echo "system.type DERIVE" + echo "system.warning $SYSWARNING" + echo "system.critical $SYSCRITICAL" + echo "system.info CPU time spent by the kernel in system activities" + echo "user.label user" + echo "user.draw STACK" + echo "user.min 0" + echo "user.max 5000" + echo "user.warning $USRWARNING" + echo "user.type DERIVE" + echo "user.info CPU time spent by normal programs and daemons" + echo "nice.label nice" + echo "nice.draw STACK" + echo "nice.min 0" + echo "nice.max 5000" + echo "nice.type DERIVE" + echo "nice.info CPU time spent by nice(1)d programs" + echo "idle.label idle" + echo "idle.draw STACK" + echo "idle.min 0" + echo "idle.max 5000" + echo "idle.type DERIVE" + echo "idle.info Idle CPU time" + if [ ! -z "$extinfo" ]; then + echo "iowait.label iowait" + echo "iowait.draw STACK" + echo "iowait.min 0" + echo "iowait.max 5000" + echo "iowait.type DERIVE" + echo "iowait.info CPU time spent waiting for I/O operations to finish" + echo "irq.label irq" + echo "irq.draw STACK" + echo "irq.min 0" + echo "irq.max 5000" + echo "irq.type DERIVE" + echo "irq.info CPU time spent handling interrupts" + echo "softirq.label softirq" + echo "softirq.draw STACK" + echo "softirq.min 0" + echo "softirq.max 5000" + echo "softirq.type DERIVE" + echo "softirq.info CPU time spent handling "batched" interrupts" + fi +} +fetch_cpu() { + extinfo="" + if grep '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat >/dev/null 2>&1; then + extinfo="iowait irq softirq" + fi + CINFO=$(grep '^cpu ' /proc/stat | cut -c6-) + echo "user.value" $(echo "$CINFO" | cut -d\ -f1) + echo "nice.value" $(echo "$CINFO" | cut -d\ -f2) + echo "system.value" $(echo "$CINFO" | cut -d\ -f3) + echo "idle.value" $(echo "$CINFO" | cut -d\ -f4) + if [ ! -z "$extinfo" ]; then + echo "iowait.value" $(echo "$CINFO" | cut -d\ -f5) + echo "irq.value" $(echo "$CINFO" | cut -d\ -f6) + echo "softirq.value" $(echo "$CINFO" | cut -d\ -f7) + fi +} diff --git a/plugins/df b/plugins/df new file mode 100644 index 0000000..7839bf4 --- /dev/null +++ b/plugins/df @@ -0,0 +1,24 @@ +config_df() { + echo "graph_title Filesystem usage (in %) +graph_args --upper-limit 100 -l 0 +graph_vlabel % +graph_category disk +graph_info This graph shows disk usage on the machine." + for PART in $(df | grep '\/[a-z0-9]*$' | sed 's/ \{1,\}/ /g;' | cut -d\ -f6) + do + PINFO=$(df $PART | tail -1); + PNAME=$(echo $PINFO | cut -d\ -f1 | sed 's/\//_/g') + echo "$PNAME.label $PART" + echo "$PNAME.info $PNAME -> $PART" + echo "$PNAME.warning 92" + echo "$PNAME.critical 98" + done +} +fetch_df() { + for PART in $(df | grep '\/[a-z0-9]*$' | sed 's/ \{1,\}/ /g;' | cut -d\ -f6) + do + PINFO=$(df $PART | tail -1); + PNAME=$(echo $PINFO | cut -d\ -f1 | sed 's/\//_/g') + echo "$PNAME.value" $(echo $PINFO | cut -f5 -d\ | sed -e 's/\%//g') + done +} diff --git a/plugins/if_ b/plugins/if_ new file mode 100644 index 0000000..9c91c92 --- /dev/null +++ b/plugins/if_ @@ -0,0 +1,21 @@ +config_if() { + echo "graph_order down up" + echo "graph_title $1 traffic" + echo "graph_args --base 1000" + echo "graph_vlabel bits in (-) / out (+) per \${graph_period}" + echo "graph_category network" + echo "graph_info This graph shows the traffic of the $INTERFACE network interface. Please note that the traffic is shown in bits per second, not bytes. IMPORTANT: Since the data source for this plugin use 32bit counters, this plugin is really unreliable and unsuitable for most 100Mb (or faster) interfaces, where bursts are expected to exceed 50Mbps. This means that this plugin is usuitable for most production environments. To avoid this problem, use the ip_ plugin instead." + echo "down.label received" + echo "down.type COUNTER" + echo "down.graph no" + echo "down.cdef down,8,*" + echo "up.label bps" + echo "up.type COUNTER" + echo "up.negative down" + echo "up.cdef up,8,*" +} +fetch_if() { + IINFO=$(grep "$1:" /proc/net/dev | cut -d: -f2 | sed -e 's/ / /g') + echo "down.value" $(echo $IINFO | cut -d\ -f1) + echo "up.value" $(echo $IINFO | cut -d\ -f9) +} diff --git a/plugins/if_err_ b/plugins/if_err_ new file mode 100644 index 0000000..8f699f7 --- /dev/null +++ b/plugins/if_err_ @@ -0,0 +1,21 @@ +config_if_err() { + echo "graph_order rcvd trans" + echo "graph_title $1 errors" + echo "graph_args --base 1000" + echo "graph_vlabel packets in (-) / out (+) per \${graph_period}" + echo "graph_category network" + echo "graph_info This graph shows the amount of errors on the $1 network interface." + echo "rcvd.label packets" + echo "rcvd.type COUNTER" + echo "rcvd.graph no" + echo "rcvd.warning 1" + echo "trans.label packets" + echo "trans.type COUNTER" + echo "trans.negative rcvd" + echo "trans.warning 1" +} +fetch_if_err() { + IINFO=$(grep "$1:" /proc/net/dev | cut -d: -f2 | sed -e 's/ / /g') + echo "rcvd.value" $(echo $IINFO | cut -d\ -f3) + echo "trans.value" $(echo $IINFO | cut -d\ -f11) +} diff --git a/plugins/interrupts b/plugins/interrupts new file mode 100644 index 0000000..fb9bdcf --- /dev/null +++ b/plugins/interrupts @@ -0,0 +1,22 @@ +config_interrupts() { + echo "graph_title Interrupts & context switches" + echo "graph_args --base 1000 -l 0" + echo "graph_vlabel interrupts & ctx switches / \${graph_period}" + echo "graph_category system" + echo "graph_info This graph shows the number of interrupts and context switches on the system. These are typically high on a busy system." + echo "intr.info Interrupts are events that alter sequence of instructions executed by a processor. They can come from either hardware (exceptions, NMI, IRQ) or software." + echo "ctx.info A context switch occurs when a multitasking operatings system suspends the currently running process, and starts executing another." + echo "intr.label interrupts" + echo "ctx.label context switches" + echo "intr.type DERIVE" + echo "ctx.type DERIVE" + echo "intr.max 100000" + echo "ctx.max 100000" + echo "intr.min 0" + echo "ctx.min 0" +} +fetch_interrupts() { + IINFO=$(cat /proc/stat) + echo "ctx.value" $(echo "$IINFO" | grep "^ctxt" | cut -d\ -f2) + echo "intr.value" $(echo "$IINFO" | grep "^intr" | cut -d\ -f2) +} diff --git a/plugins/irqstats b/plugins/irqstats new file mode 100644 index 0000000..f9e4c44 --- /dev/null +++ b/plugins/irqstats @@ -0,0 +1,36 @@ +config_irqstats() { + echo "graph_title Individual interrupts +graph_args --base 1000 -l 0; +graph_vlabel interrupts / \${graph_period} +graph_category system" + CPUS=$(grep 'CPU[0-9]' /proc/interrupts | wc -w) + IINFO=$(sed -e 's/ \{1,\}/ /g' -e 's/^ //' /proc/interrupts | grep '.:') + for ID in $(echo "$IINFO" | cut -d: -f1) + do + IDL=$(echo "$IINFO" | grep "^$ID:") + INFO=$(eval "echo \"$IDL\" | cut -d\ -f$((3+$CPUS))-") + if [ "$INFO" = "" ]; then + echo "i$ID.label $ID" + else + echo "i$ID.label $INFO" + echo "i$ID.info Interrupt $ID, for device(s): $INFO" + fi + echo "i$ID.type DERIVE" + echo "i$ID.min 0" + done +} +fetch_irqstats() { + CPUS=$(grep 'CPU[0-9]' /proc/interrupts | wc -w) + IINFO=$(sed -e 's/ \{1,\}/ /g' -e 's/^ //' /proc/interrupts | grep '.:') + for ID in $(echo "$IINFO" | cut -d: -f1) + do + IDL=$(echo "$IINFO" | grep "^$ID:") + VALS=$(eval "echo \"$IDL\" | cut -d\ -f2-$((1+$CPUS))") + VALUE=0 + for VAL in $VALS; + do + VALUE=$(($VALUE + $VAL)) + done + echo "i$ID.value $VALUE" + done +} diff --git a/plugins/load b/plugins/load new file mode 100644 index 0000000..4f585b0 --- /dev/null +++ b/plugins/load @@ -0,0 +1,15 @@ +config_load() { + echo "graph_title Load average +graph_args --base 1000 -l 0 +graph_vlabel load +graph_scale no +graph_category system +load.label load +load.warning 10 +load.critical 120 +graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run \"immediately\"). +load.info Average load for the five minutes." +} +fetch_load() { + echo "load.value" $(cut -f2 -d\ /proc/loadavg) +} diff --git a/plugins/memory b/plugins/memory new file mode 100644 index 0000000..90f5666 --- /dev/null +++ b/plugins/memory @@ -0,0 +1,185 @@ +config_memory() { + MINFO=$(cat /proc/meminfo | sed 's/ \{1,\}/ /g;') + MEMTOTAL=$(echo "$MINFO" | grep "^MemTotal:" | cut -d\ -f2) + PAGETABLES=$(echo "$MINFO" | grep "^PageTables:" | cut -d\ -f2) + SWAPCACHED=$(echo "$MINFO" | grep "^SwapCached:" | cut -d\ -f2) + SWAPTOTAL=$(echo "$MINFO" | grep "^SwapTotal:" | cut -d\ -f2) + VMALLOCUSED=$(echo "$MINFO" | grep "^VmallocUsed:" | cut -d\ -f2) + SLAB=$(echo "$MINFO" | grep "^Slab:" | cut -d\ -f2) + MAPPED=$(echo "$MINFO" | grep "^Mapped:" | cut -d\ -f2) + COMMITTEDAS=$(echo "$MINFO" | grep "^Committed_AS:" | cut -d\ -f2) + ACTIVE=$(echo "$MINFO" | grep "^Active:" | cut -d\ -f2) + INACTIVE=$(echo "$MINFO" | grep "^Inactive:" | cut -d\ -f2) + ACTIVEANON=$(echo "$MINFO" | grep "^ActiveAnon:" | cut -d\ -f2) + ACTIVECACHE=$(echo "$MINFO" | grep "^ActiveCache:" | cut -d\ -f2) + INACTIVE=$(echo "$MINFO" | grep "^Inactive:" | cut -d\ -f2) + INACTDIRTY=$(echo "$MINFO" | grep "^Inact_dirty:" | cut -d\ -f2) + INACTLAUNDY=$(echo "$MINFO" | grep "^Inact_laundry:" | cut -d\ -f2) + INACTCLEAN=$(echo "$MINFO" | grep "^Inact_clean:" | cut -d\ -f2) + + GRAPH_ORDER="apps"; + test "$PAGETABLES" != "" && GRAPH_ORDER="$GRAPH_ORDER page_tables" + test "$SWAPCACHED" != "" && GRAPH_ORDER="$GRAPH_ORDER swap_cache" + test "$VMALLOCUSED" != "" && GRAPH_ORDER="$GRAPH_ORDER vmalloc_used" + test "$SLAB" != "" && GRAPH_ORDER="$GRAPH_ORDER slab" + GRAPH_ORDER="$GRAPH_ORDER cached buffers free swap" + + echo "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit $MEMTOTAL" + echo "graph_title Memory usage" + echo "graph_category system" + echo "graph_info This graph shows what the machine uses its memory for." + echo "graph_order $GRAPH_ORDER" + echo "apps.label apps" + echo "apps.draw AREA" + echo "apps.info Memory used by user-space applications." + echo "buffers.label buffers" + echo "buffers.draw STACK" + echo "buffers.info Block device (e.g. harddisk) cache. Also where \"dirty\" blocks are stored until written." + echo "swap.label swap" + echo "swap.draw STACK" + echo "swap.info Swap space used." + echo "cached.label cache" + echo "cached.draw STACK" + echo "cached.info Parked file data (file content) cache." + echo "free.label unused" + echo "free.draw STACK" + echo "free.info Wasted memory. Memory that is not used for anything at all." + if [ "$SLAB" != "" ]; then + echo "slab.label slab_cache" + echo "slab.draw STACK" + echo "slab.info Memory used by the kernel (major users are caches like inode, dentry, etc)." + fi + if [ "$SWAPCACHED" != "" ]; then + echo "swap_cache.label swap_cache" + echo "swap_cache.draw STACK" + echo "swap_cache.info A piece of memory that keeps track of pages that have been fetched from swap but not yet been modified." + fi + if [ "$PAGETABLES" != "" ]; then + echo "page_tables.label page_tables" + echo "page_tables.draw STACK" + echo "page_tables.info Memory used to map between virtual and physical memory addresses.\n" + fi + if [ "$VMALLOCUSED" != "" ]; then + echo "vmalloc_used.label vmalloc_used" + echo "vmalloc_used.draw STACK" + echo "vmalloc_used.info Virtual memory used by the kernel (used when the memory does not have to be physically contigious)." + fi + if [ "$COMMITTEDAS" != "" ]; then + echo "committed.label committed" + echo "committed.draw LINE2" + echo "committed.warn" $(($SWAPTOTAL + $MEMTOTAL)) + echo "committed.info The amount of memory that would be used if all the memory that's been allocated were to be used." + fi + if [ "$MAPPED" != "" ]; then + echo "mapped.label mapped" + echo "mapped.draw LINE2" + echo "mapped.info All mmap()ed pages." + fi + if [ "$ACTIVE" != "" ]; then + echo "active.label active" + echo "active.draw LINE2" + echo "active.info Memory recently used. Not reclaimed unless absolutely necessary." + fi + if [ "$ACTIVEANON" != "" ]; then + echo "active_anon.label active_anon" + echo "active_anon.draw LINE1" + fi + if [ "$ACTIVECACHE" != "" ]; then + echo "active_cache.label active_cache" + echo "active_cache.draw LINE1" + fi + if [ "$INACTIVE" != "" ]; then + echo "inactive.label inactive" + echo "inactive.draw LINE2" + echo "inactive.info Memory not currently used." + fi + if [ "$INACTDIRTY" != "" ]; then + echo "inact_dirty.label inactive_dirty" + echo "inact_dirty.draw LINE1" + echo "inact_dirty.info Memory not currently used, but in need of being written to disk." + fi + if [ "$INACTLAUNDRY" != "" ]; then + echo "inact_laundry.label inactive_laundry" + echo "inact_laundry.draw LINE1" + fi + if [ "$INACTCLEAN" != "" ]; then + echo "inact_clean.label inactive_clean" + echo "inact_clean.draw LINE1" + echo "inact_clean.info Memory not currently used." + fi +} +fetch_memory() { + MINFO=$(cat /proc/meminfo | sed 's/ \{1,\}/ /g;') + MEMTOTAL=$(echo "$MINFO" | grep "^MemTotal:" | cut -d\ -f2) + MEMFREE=$(echo "$MINFO" | grep "^MemFree:" | cut -d\ -f2) + BUFFERS=$(echo "$MINFO" | grep "^Buffers:" | cut -d\ -f2) + CACHED=$(echo "$MINFO" | grep "^Cached:" | cut -d\ -f2) + SWAP_TOTAL=$(echo "$MINFO" | grep "^SwapTotal:" | cut -d\ -f2) + SWAP_FREE=$(echo "$MINFO" | grep "^SwapFree:" | cut -d\ -f2) + MEMTOTAL=$(echo "$MINFO" | grep "^MemTotal:" | cut -d\ -f2) + PAGETABLES=$(echo "$MINFO" | grep "^PageTables:" | cut -d\ -f2) + SWAPCACHED=$(echo "$MINFO" | grep "^SwapCached:" | cut -d\ -f2) + VMALLOCUSED=$(echo "$MINFO" | grep "^VmallocUsed:" | cut -d\ -f2) + SLAB=$(echo "$MINFO" | grep "^Slab:" | cut -d\ -f2) + MAPPED=$(echo "$MINFO" | grep "^Mapped:" | cut -d\ -f2) + COMMITTEDAS=$(echo "$MINFO" | grep "^Committed_AS:" | cut -d\ -f2) + ACTIVE=$(echo "$MINFO" | grep "^Active:" | cut -d\ -f2) + INACTIVE=$(echo "$MINFO" | grep "^Inactive:" | cut -d\ -f2) + ACTIVEANON=$(echo "$MINFO" | grep "^ActiveAnon:" | cut -d\ -f2) + ACTIVECACHE=$(echo "$MINFO" | grep "^ActiveCache:" | cut -d\ -f2) + INACTIVE=$(echo "$MINFO" | grep "^Inactive:" | cut -d\ -f2) + INACTDIRTY=$(echo "$MINFO" | grep "^Inact_dirty:" | cut -d\ -f2) + INACTLAUNDY=$(echo "$MINFO" | grep "^Inact_laundry:" | cut -d\ -f2) + INACTCLEAN=$(echo "$MINFO" | grep "^Inact_clean:" | cut -d\ -f2) + APPS=$(($MEMTOTAL - $MEMFREE - $BUFFERS - $CACHED)) + SWAP=$(($SWAP_TOTAL - $SWAP_FREE)) + echo "buffers.value" $(($BUFFERS * 1024)) + echo "swap.value" $(($SWAP * 1024)) + echo "cached.value" $(($CACHED * 1024)) + echo "free.value" $(($MEMFREE * 1024)) + if [ "$SLAB" != "" ]; then + echo "slab.value" $(($SLAB * 1024)) + APPS=$(($APPS - $SLAB)) + fi + if [ "$SWAPCACHED" != "" ]; then + echo "swap_cache.value" $(($SWAPCACHED * 1024)) + APPS=$(($APPS - $SWAPCACHED)) + fi + if [ "$PAGETABLES" != "" ]; then + echo "page_tables.value" $(($PAGETABLES * 1024)) + APPS=$(($APPS - $PAGETABLES)) + fi + if [ "$VMALLOCUSED" != "" ]; then + echo "vmalloc_used.value" $(($VMALLOCUSED * 1024)) + APPS=$(($APPS - $VMALLOCUSED)) + fi + if [ "$COMMITTEDAS" != "" ]; then + echo "committed.value" $(($COMMITTEDAS * 1024)) + fi + if [ "$MAPPED" != "" ]; then + echo "mapped.value" $(($MAPPED * 1024)) + fi + if [ "$ACTIVE" != "" ]; then + echo "active.value" $(($ACTIVE * 1024)) + fi + if [ "$ACTIVEANON" != "" ]; then + echo "active_anon.value" $(($ACTIVEANON * 1024)) + fi + if [ "$ACTIVECACHE" != "" ]; then + echo "active_cache.value" $(($ACTIVECACHE * 1024)) + fi + if [ "$INACTIVE" != "" ]; then + echo "inactive.value" $(($INACTIVE * 1024)) + fi + if [ "$INACTDIRTY" != "" ]; then + echo "inact_dirty.value" $(($INACTDIRTY * 1024)) + fi + if [ "$INACTLAUNDRY" != "" ]; then + echo "inact_laundry.value" $(($INACTLAUNDRY * 1024)) + fi + if [ "$INACTCLEAN" != "" ]; then + echo "inact_clean.value" $(($INACTCLEAN * 1024)) + fi + + echo "apps.value" $(($APPS * 1024)) +} diff --git a/plugins/netstat b/plugins/netstat new file mode 100644 index 0000000..a76a274 --- /dev/null +++ b/plugins/netstat @@ -0,0 +1,41 @@ +config_netstat() { + echo "graph_title Netstat" + echo "graph_args -l 0 --base 1000" + echo "graph_vlabel active connections" + echo "graph_category network" + echo "graph_period second" + echo "graph_info This graph shows the TCP activity of all the network interfac +es combined." + echo "active.label active" + echo "active.type DERIVE" + echo "active.max 50000" + echo "active.min 0" + echo "active.info The number of active TCP openings per second." + echo "passive.label passive" + echo "passive.type DERIVE" + echo "passive.max 50000" + echo "passive.min 0" + echo "passive.info The number of passive TCP openings per second." + echo "failed.label failed" + echo "failed.type DERIVE" + echo "failed.max 50000" + echo "failed.min 0" + echo "failed.info The number of failed TCP connection attempts per second." + echo "resets.label resets" + echo "resets.type DERIVE" + echo "resets.max 50000" + echo "resets.min 0" + echo "resets.info The number of TCP connection resets." + echo "established.label established" + echo "established.type GAUGE" + echo "established.max 50000" + echo "established.info The number of currently open connections." +} +fetch_netstat() { + NINFO=$(netstat -s | sed 's/ \{1,\}/ /g') + echo "active.value" $(echo "$NINFO" | grep "active connections" | cut -d\ -f2) + echo "passive.value" $(echo "$NINFO" | grep "passive connection" | cut -d\ -f2) + echo "failed.value" $(echo "$NINFO" | grep "failed connection" | cut -d\ -f2) + echo "resets.value" $(echo "$NINFO" | grep "connection resets" | cut -d\ -f2) + echo "established.value" $(echo "$NINFO" | grep "connections established" | cut -d\ -f2) +} diff --git a/plugins/processes b/plugins/processes new file mode 100644 index 0000000..64d9095 --- /dev/null +++ b/plugins/processes @@ -0,0 +1,13 @@ +config_processes() { + echo "graph_title Number of Processes" + echo "graph_args --base 1000 -l 0 " + echo "graph_vlabel number of processes" + echo "graph_category processes" + echo "graph_info This graph shows the number of processes in the system." + echo "processes.label processes" + echo "processes.draw LINE2" + echo "processes.info The current number of processes." +} +fetch_processes() { + echo "processes.value" $(echo /proc/[0-9]* | wc -w) +} diff --git a/plugins/swap b/plugins/swap new file mode 100644 index 0000000..45b5181 --- /dev/null +++ b/plugins/swap @@ -0,0 +1,27 @@ +config_swap() { + echo "graph_title Swap in/out" + echo "graph_args -l 0 --base 1000" + echo "graph_vlabel pages per \${graph_period} in (-) / out (+)" + echo "graph_category system" + echo "swap_in.label swap" + echo "swap_in.type DERIVE" + echo "swap_in.max 100000" + echo "swap_in.min 0" + echo "swap_in.graph no" + echo "swap_out.label swap" + echo "swap_out.type DERIVE" + echo "swap_out.max 100000" + echo "swap_out.min 0" + echo "swap_out.negative swap_in" +} +fetch_swap() { + if [ -f /proc/vmstat ]; then + SINFO=$(cat /proc/vmstat) + echo "swap_in.value" $(echo "$SINFO" | grep "^pswpin" | cut -d\ -f2) + echo "swap_out.value" $(echo "$SINFO" | grep "^pswpout" | cut -d\ -f2) + else + SINFO=$(grep "^swap" /proc/stat) + echo "swap_in.value" $(echo "$SINFO" | cut -d\ -f2) + echo "swap_out.value" $(echo "$SINFO" | cut -d\ -f3) + fi +} diff --git a/plugins/uptime b/plugins/uptime new file mode 100644 index 0000000..7a387fd --- /dev/null +++ b/plugins/uptime @@ -0,0 +1,11 @@ +config_uptime() { + echo "graph_title Uptime" + echo "graph_args --base 1000 -l 0 " + echo "graph_vlabel uptime in days" + echo "uptime.label uptime" + echo "uptime.draw AREA" + echo "uptime.cdef uptime,86400,/" +} +fetch_uptime() { + echo "uptime.value" $(cut -d\ -f1 /proc/uptime) +}