pax_global_header00006660000000000000000000000064134316563030014516gustar00rootroot0000000000000052 comment=aa431914381125bfa343272612cb8023e0f8e111 munin-c-0.0.13/000077500000000000000000000000001343165630300131455ustar00rootroot00000000000000munin-c-0.0.13/Makefile.am000066400000000000000000000015551343165630300152070ustar00rootroot00000000000000# # Copyright (C) 2013 Helmut Grohne - All rights reserved. # Copyright (C) 2013 Steve Schnepp - All rights reserved. # Copyright (C) 2013 Diego Elio Petteno - All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v.2 or v.3. # pkglibexecdir = $(libexecdir)/$(PACKAGE) ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src/node src/plugins t dist_doc_DATA = gpl-2.0.txt gpl-3.0.txt EXTRA_DIST = README.md all-local: $(pkglibexec_PROGRAMS) $(MKDIR_P) plugins for l in `./src/plugins/munin-plugins-c$(EXEEXT) listplugins`; do \ test -L plugins/$$l$(EXEEXT) || $(LN_S) ../src/plugins/munin-plugins-c$(EXEEXT) plugins/$$l$(EXEEXT); \ done clean-local: rm -rf plugins munin-c-0.0.13/README.rst000066400000000000000000000022551343165630300146400ustar00rootroot00000000000000munin-c ======= C rewrite of munin node components. It currently consists on a light-weight node, and some plugins. These are designed to be very light on resources, and compatible with the stock ones. Compatibility ------------- A main design feature is that munin-c components are drop-ins to stock ones. Therefore the munin-c node can run the stock plugins, and the plugins can be run by the stock node. There are still some missing parts in the node, mostly about the permission, and the environnements. The config file has also the same syntax. 3rd-party plugins should also work unmodified. Compiling ========= This project has been ported to autotools. You have to use:: autoreconf -i -I m4 && ./configure && make Contribute and coding style =========================== Contribute by open an issue or pull-request at https://github.com/munin-monitoring/munin-c When contributing code please follow the kernel coding style. Use GNU indent with the parameters to follow the Kernighan & Ritchie coding style and set the indention level to 8 spaces:: find . -iname "*.c" -exec indent -kr -i8 {} \; License ======= munin-c is licensed as gpl-2 or gpl-3 at your choice. munin-c-0.0.13/common.am000066400000000000000000000004301343165630300147510ustar00rootroot00000000000000MANCENTER="Munin C Documentation" RELEASE="$(shell $(top_srcdir)/getversion)" %.1:%.pod $(AM_V_GEN)pod2man --section=1 --release=$(RELEASE) --center=$(MANCENTER) $< > $@ sed -i.bak -e 's#@@pkglibexecdir@@#$(pkglibexecdir)#' -e 's#@@CONFDIR@@#$(sysconfdir)#' $@ # vim:ft=make munin-c-0.0.13/configure.ac000066400000000000000000000017611343165630300154400ustar00rootroot00000000000000# # Copyright (C) 2013 Helmut Grohne - All rights reserved. # Copyright (C) 2013 Steve Schnepp - All rights reserved. # Copyright (C) 2013 Diego Elio Petteno - All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v.2 or v.3. # AC_INIT([munin-c], [m4_esyscmd_s([./getversion])], [https://github.com/munin-monitoring/munin-c/issues], , [https://github.com/munin-monitoring/munin-c]) AC_CONFIG_AUX_DIR([build]) AM_INIT_AUTOMAKE([foreign subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE([enable]) AC_PROG_CC AC_PROG_CC_C_O AC_PROG_LN_S AC_FUNC_FORK CC_CHECK_CFLAGS_APPEND([-Wall -Wextra -Werror -pedantic -Wno-format]) AC_CHECK_HEADERS([mntent.h sys/vfs.h]) AC_CONFIG_FILES([Makefile src/node/Makefile src/plugins/Makefile t/Makefile]) AC_OUTPUT munin-c-0.0.13/getversion000077500000000000000000000014161343165630300152620ustar00rootroot00000000000000#!/bin/sh # # Generate a version string for use when building. # # * If in a git repository use "git describe" # * If building from tarball extract the version from the directory name or # try to get the version fronm the packaging. generate_version_string_from_dir() { basename $(pwd) | grep -e '^munin-c' | cut -c9- } generate_version_string_from_packaging() { if [ -d debian ]; then dpkg-parsechangelog -SVersion 2> /dev/null fi } if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then git describe --always elif [ ! -z "$(generate_version_string_from_dir)" ]; then generate_version_string_from_dir elif [ ! -z "$(generate_version_string_from_packaging)" ]; then generate_version_string_from_packaging else echo "unknown" fi munin-c-0.0.13/gpl-2.0.txt000066400000000000000000000432541343165630300147750ustar00rootroot00000000000000 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 Lesser 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) 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) year 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 Lesser General Public License instead of this License. munin-c-0.0.13/gpl-3.0.txt000066400000000000000000001045131343165630300147720ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state 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) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . munin-c-0.0.13/m4/000077500000000000000000000000001343165630300134655ustar00rootroot00000000000000munin-c-0.0.13/m4/attributes.m4000066400000000000000000000226661343165630300161310ustar00rootroot00000000000000dnl Macros to check the presence of generic (non-typed) symbols. dnl Copyright (c) 2006-2007 Diego Pettenò dnl Copyright (c) 2006-2007 xine project dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2, or (at your option) dnl any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA dnl 02110-1301, USA. dnl dnl As a special exception, the copyright owners of the dnl macro gives unlimited permission to copy, distribute and modify the dnl configure scripts that are the output of Autoconf when processing the dnl Macro. You need not follow the terms of the GNU General Public dnl License when using or distributing such scripts, even though portions dnl of the text of the Macro appear in them. The GNU General Public dnl License (GPL) does govern all other use of the material that dnl constitutes the Autoconf Macro. dnl dnl This special exception to the GPL applies to versions of the dnl Autoconf Macro released by this project. When you make and dnl distribute a modified version of the Autoconf Macro, you may extend dnl this special exception to the GPL to apply to your modified version as dnl well. dnl Check if the flag is supported by compiler dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $1" AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])], [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"], [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], [$2], [$3]) ]) dnl Check if the flag is supported by compiler (cacheable) dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_CFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_cflags_$1]), CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! ) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], [$2], [$3]) ]) dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) dnl Check for CFLAG and appends them to CFLAGS if supported AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_cflags_$1]), CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! ) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], [CFLAGS="$CFLAGS $1"; $2], [$3]) ]) dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [ for flag in $1; do CC_CHECK_CFLAG_APPEND($flag, [$2], [$3]) done ]) dnl Check if the flag is supported by linker (cacheable) dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_LDFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_ldflags_$1]), [ac_save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $1" AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])], [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"], [eval "AS_TR_SH([cc_cv_ldflags_$1])="]) LDFLAGS="$ac_save_LDFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], [$2], [$3]) ]) dnl Check for a -Werror flag or equivalent. -Werror is the GCC dnl and ICC flag that tells the compiler to treat all the warnings dnl as fatal. We usually need this option to make sure that some dnl constructs (like attributes) are not simply ignored. dnl dnl Other compilers don't support -Werror per se, but they support dnl an equivalent flag: dnl - Sun Studio compiler supports -errwarn=%all AC_DEFUN([CC_CHECK_WERROR], [ AC_CACHE_CHECK( [for $CC way to treat warnings as errors], [cc_cv_werror], [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror], [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])]) ]) ]) AC_DEFUN([CC_CHECK_ATTRIBUTE], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))], AS_TR_SH([cc_cv_attribute_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"], [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes], [AC_DEFINE( AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))] ) $4], [$5]) ]) AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ CC_CHECK_ATTRIBUTE( [constructor],, [extern void foo(); void __attribute__((constructor)) ctor() { foo(); }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_DESTRUCTOR], [ CC_CHECK_ATTRIBUTE( [destructor],, [extern void foo(); void __attribute__((destructor)) dtor() { foo(); }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ CC_CHECK_ATTRIBUTE( [format], [format(printf, n, n)], [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ CC_CHECK_ATTRIBUTE( [format_arg], [format_arg(printf)], [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ CC_CHECK_ATTRIBUTE( [visibility_$1], [visibility("$1")], [void __attribute__((visibility("$1"))) $1_function() { }], [$2], [$3]) ]) AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ CC_CHECK_ATTRIBUTE( [nonnull], [nonnull()], [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ CC_CHECK_ATTRIBUTE( [unused], , [void some_function(void *foo, __attribute__((unused)) void *bar);], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [ CC_CHECK_ATTRIBUTE( [sentinel], , [void some_function(void *foo, ...) __attribute__((sentinel));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [ CC_CHECK_ATTRIBUTE( [deprecated], , [void some_function(void *foo, ...) __attribute__((deprecated));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ CC_CHECK_ATTRIBUTE( [alias], [weak, alias], [void other_function(void *foo) { } void some_function(void *foo) __attribute__((weak, alias("other_function")));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ CC_CHECK_ATTRIBUTE( [malloc], , [void * __attribute__((malloc)) my_alloc(int n);], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_PACKED], [ CC_CHECK_ATTRIBUTE( [packed], , [struct astructure { char a; int b; long c; void *d; } __attribute__((packed)); char assert@<:@(sizeof(struct astructure) == (sizeof(char)+sizeof(int)+sizeof(long)+sizeof(void*)))-1@:>@;], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_CONST], [ CC_CHECK_ATTRIBUTE( [const], , [int __attribute__((const)) twopow(int n) { return 1 << n; } ], [$1], [$2]) ]) AC_DEFUN([CC_FLAG_VISIBILITY], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], [cc_cv_flag_visibility], [cc_flag_visibility_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], cc_cv_flag_visibility='yes', cc_cv_flag_visibility='no') CFLAGS="$cc_flag_visibility_save_CFLAGS"]) AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag]) $1], [$2]) ]) AC_DEFUN([CC_FUNC_EXPECT], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if compiler has __builtin_expect function], [cc_cv_func_expect], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" AC_COMPILE_IFELSE( [int some_function() { int a = 3; return (int)__builtin_expect(a, 3); }], [cc_cv_func_expect=yes], [cc_cv_func_expect=no]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([test "x$cc_cv_func_expect" = "xyes"], [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function]) $1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported], [cc_cv_attribute_aligned], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" for cc_attribute_align_try in 64 32 16 8 4 2; do AC_COMPILE_IFELSE([ int main() { static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0; return c; }], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) done CFLAGS="$ac_save_CFLAGS" ]) if test "x$cc_cv_attribute_aligned" != "x"; then AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned], [Define the highest alignment supported]) fi ]) munin-c-0.0.13/src/000077500000000000000000000000001343165630300137345ustar00rootroot00000000000000munin-c-0.0.13/src/node/000077500000000000000000000000001343165630300146615ustar00rootroot00000000000000munin-c-0.0.13/src/node/Makefile.am000066400000000000000000000014321343165630300167150ustar00rootroot00000000000000# # Copyright (C) 2013 Helmut Grohne - All rights reserved. # Copyright (C) 2013 Steve Schnepp - All rights reserved. # Copyright (C) 2013 Diego Elio Petteno - All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v.2 or v.3. # include $(top_srcdir)/common.am sbin_PROGRAMS = munin-node-c munin-inetd-c AM_CPPFLAGS = -DPLUGINDIR=\"$(sysconfdir)/munin/plugins\" \ -DPLUGINCONFDIR=\"$(sysconfdir)/munin/plugin-conf.d\" munin_node_c_SOURCES = node.c munin_inetd_c_SOURCES = inetd.c man_MANS = munin-node-c.1 CLEANFILES = $(man_MANS) EXTRA_DIST = munin-node-c.pod munin-c-0.0.13/src/node/README000066400000000000000000000010731343165630300155420ustar00rootroot00000000000000This is a rewrite of munin node in C. Pro: ---- The purpose is multiple: * reducing resource usage for embedded plateforms, specially when paired with the C rewrite of the core plugins. * no need for Perl * Everything runs from inetd. Cons: ----- * You lose flexibility It is compiled code, so you have to create binaries. Even one for each architecture. * Not all the features are implemented - root uid is not supported. All plugins are run with a single user, usually nobody. - no socket is opened. Everything runs from inetd. munin-c-0.0.13/src/node/inetd.c000066400000000000000000000053561343165630300161410ustar00rootroot00000000000000/* * Copyright (C) 2013 Steve Schnepp - All rights reserved. * Copyright (C) 2013 Helmut Grohne - All rights reserved. * Copyright (C) 2013 Diego Elio Petteno - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include #include #include #include #include #include #if !(defined(HAVE_WORKING_VFORK) || defined(S_SPLINT_S)) #define vfork fork #endif int main(int argc, char *argv[]) { static const int yes = 1; char *s; struct sockaddr_in server; unsigned int port; int sock_listen, sock_accept; pid_t pid; if (argc < 3) { fprintf(stderr, "usage: %s [ipaddr:]port program " "[argv0 argv1 ...]\n", argv[0]); return 1; } memset(&server, 0, sizeof(server)); server.sin_family = AF_INET; assert(argv[1] != NULL); s = strchr(argv[1], ':'); if (NULL == s) s = argv[1]; else { *s++ = '\0'; if (0 == inet_aton(argv[1], &server.sin_addr)) { fprintf(stderr, "not an ip address: %s\n", argv[1]); return 1; } } if ((1 != sscanf(s, "%u", &port)) || port != (unsigned int) (uint16_t) port) { fprintf(stderr, "not a valid port: %s\n", s); return 1; } server.sin_port = htons(port); if ((sock_listen = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket creation failed"); return 1; } if (setsockopt (sock_listen, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) { perror("failed to set SO_REUSEADDR on socket"); } if (bind(sock_listen, (struct sockaddr *) &server, sizeof(server)) < 0) { perror("failed to bind socket"); close(sock_listen); return 1; } if (listen(sock_listen, 5) != 0) { perror("failed to listen on the socket"); close(sock_listen); return 1; } /* We do *not* care about childs */ signal(SIGCHLD, SIG_IGN); while ((sock_accept = accept(sock_listen, NULL, NULL)) != -1) { posix_spawn_file_actions_t action; posix_spawn_file_actions_init(&action); posix_spawn_file_actions_addclose(&action, sock_listen); posix_spawn_file_actions_adddup2(&action, sock_accept, 0); posix_spawn_file_actions_adddup2(&action, sock_accept, 1); posix_spawn_file_actions_addclose(&action, sock_accept); if (0 == posix_spawnp(&pid, argv[2], &action, NULL, argv + 3, NULL)) { close(sock_accept); } else { perror("vfork failed in " __FILE__); close(sock_listen); return 1; } } perror("accept failed in " __FILE__); close(sock_listen); return 1; } munin-c-0.0.13/src/node/munin-node-c.pod000066400000000000000000000015741343165630300176650ustar00rootroot00000000000000=pod =head1 NAME munin-node-c - a single binary implementing the node functionality =head1 DESCRIPTION The munin-node-c binary can handle a single connection to a Munin node on stdin and stdout. It is usually run from an inetd like superserver. =head1 OPTIONS =over =item B<-d> I Specify the directory used to look up plugins. This directory usually contains symbolic links to installed plugins and executable scripts. The plugins are executed on request by the client to retrieve statistics about the system. =item B<-e> Enable extension stripping. When this option is given, filename extensions in plugins are ignored. This option is mainly useful on operating systems where extensions are relevant for execution. =item B<-H> I Specify the hostname with which the node should greet clients. =back =head1 AUTHORS Helmut Grohne, Steve Schnepp =cut munin-c-0.0.13/src/node/node.c000066400000000000000000000372771343165630300157720ustar00rootroot00000000000000/* * Copyright (C) 2013 Steve Schnepp - All rights reserved. * Copyright (C) 2013 Helmut Grohne - All rights reserved. * Copyright (C) 2013 Diego Elio Petteno - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef HOST_NAME_MAX #define HOST_NAME_MAX 256 #endif #ifndef LINE_MAX #define LINE_MAX 2048 #endif extern char **environ; static const int yes = 1; static const int no = 0; static int is_acquire = 0; static int verbose = 0; static bool extension_stripping = false; static char *host = ""; static char *plugin_dir = PLUGINDIR; static char *spoolfetch_dir = ""; static char *client_ip = "-"; static char *pluginconf_dir = PLUGINCONFDIR; static int handle_connection(); #define xisspace(x) isspace((int)(unsigned char) x) #define xisdigit(x) isdigit((int)(unsigned char) x) static /*@noreturn@ */ void oom_handler() { static const char *OOM_MSG = "Out of memory\n"; if (write(STDERR_FILENO, OOM_MSG, sizeof(OOM_MSG) - 1) < 0) { /* Do nothing on write failure, we are torched anyway */ } /* OOM triggers abort() since it's better to fail fast */ abort(); } /* an allocation bigger than MAX_ALLOC_SIZE is bogus */ #define MAX_ALLOC_SIZE (16 * 1024 * 1024) static /*@only@ */ /*@out@ */ void *xmalloc(size_t size) { void *ptr; assert(size < MAX_ALLOC_SIZE); ptr = malloc(size); if (ptr == NULL) oom_handler(); return ptr; } static /*@only@ */ char *xstrdup(const char *s) { char *new_str; assert(s != NULL); assert(strlen(s) < MAX_ALLOC_SIZE); new_str = strdup(s); if (new_str == NULL) oom_handler(); return new_str; } static int xsetenv(const char *envname, const char *envval, int overwrite) { if (verbose) printf("# Setting env %s = %s %s overwriting\n", envname, envval, overwrite ? "with" : "without"); return setenv(envname, envval, overwrite); } static int find_plugin_with_basename( /*@out@ */ char *cmdline, const char *plugin_dir, const char *plugin_basename) { DIR *dirp = opendir(plugin_dir); struct dirent *dp; int found = 0; size_t plugin_basename_len = strlen(plugin_basename); if (dirp == NULL) { perror("Cannot open plugin dir in " __FILE__); return (found); } /* Empty cmdline */ cmdline[0] = '\0'; while ((dp = readdir(dirp)) != NULL) { char *plugin_filename = dp->d_name; if (plugin_filename[0] == '.') { /* No dotted plugin */ continue; } if (strncmp (plugin_filename, plugin_basename, plugin_basename_len) != 0) { /* Does not start with base */ continue; } if (plugin_filename[plugin_basename_len] != '\0' && plugin_filename[plugin_basename_len] != '.') { /* Does not end the string or start an extension */ continue; } snprintf(cmdline, LINE_MAX, "%s/%s", plugin_dir, plugin_filename); if (access(cmdline, X_OK) == 0) { /* Found it */ found++; break; } } closedir(dirp); return found; } int acquire_all(); static void setenvvars_system(void); int main(int argc, char *argv[]) { int optch; char format[] = "aevd:D:H:s:"; struct sockaddr_in client; socklen_t client_len = sizeof(client); opterr = 1; while ((optch = getopt(argc, argv, format)) != -1) switch (optch) { case 'a': is_acquire = true; break; case 'e': extension_stripping = true; break; case 'v': verbose++; break; case 'd': plugin_dir = xstrdup(optarg); break; case 'D': pluginconf_dir = xstrdup(optarg); break; case 'H': host = xstrdup(optarg); break; case 's': spoolfetch_dir = xstrdup(optarg); break; } /* get default hostname if not precised */ if ('\0' == *host) { int idx; host = xmalloc(HOST_NAME_MAX + 1); gethostname(host, HOST_NAME_MAX); /* going to lowercase */ for (idx = 0; host[idx] != '\0'; idx++) { host[idx] = tolower((int) host[idx]); } } /* Prepare static plugin env vars once for all */ setenvvars_system(); /* Asked to acquire */ if (is_acquire) return acquire_all(); /* use a 1-shot stdin/stdout */ if (0 == getpeername(STDIN_FILENO, (struct sockaddr *) &client, &client_len)) if (client.sin_family == AF_INET) client_ip = inet_ntoa(client.sin_addr); return handle_connection(); } /* Setting munin specific vars */ static void setenvvars_system() { /* Some locales use "," as decimal separator. * This can mess up a lot of plugins. */ xsetenv("LC_ALL", "C", yes); /* LC_ALL should be enough, but some plugins don't * follow specs (#1014) */ xsetenv("LANG", "C", yes); /* PATH should be *very* sane by default. Can be * overrided via config file if needed * (Closes #863 and #1128). */ xsetenv("PATH", "/usr/sbin:/usr/bin:/sbin:/bin", yes); } /* Setting munin specific vars */ static void setenvvars_munin() { /* munin-node will override this with the IP of the * connecting master */ if (client_ip != NULL && client_ip[0] != '\0') { xsetenv("MUNIN_MASTER_IP", client_ip, no); } /* Tell plugins about supported capabilities */ xsetenv("MUNIN_CAP_MULTIGRAPH", "1", no); /* We only have one user, so using a fixed path */ xsetenv("MUNIN_PLUGSTATE", "/var/tmp", no); xsetenv("MUNIN_STATEFILE", "/dev/null", no); /* That's where plugins should live */ xsetenv("MUNIN_LIBDIR", "/usr/share/munin", no); } /* in-place */ static /*@null@ */ /*@exposed@ */ char *ltrim( /*@null@ */ char *s) { if (s == NULL || *s == '\0') { /* Empty string, returns unmodified */ return s; } while (xisspace(*s)) { s++; } return s; } /* in-place, but returns string for convenience */ static /*@null@ */ /*@exposed@ */ char *rtrim( /*@null@ */ char *s) { char *end; if (s == NULL || *s == '\0') { /* Empty string, returns unmodified */ return s; } end = s + strlen(s) - 1; while (end > s && xisspace(*end)) { /* Back from the end */ end--; } /* null-terminate new string */ end[1] = '\0'; return s; } /* in-place */ static /*@null@ */ /*@exposed@ */ char *trim( /*@null@ */ char *s) { s = ltrim(s); s = rtrim(s); return s; } #define MAX_ENV_BUF_SZ 256 struct s_env { /* buffer will hold a C string : "KEY=VALUE", use the key_len to know where the "=" is */ size_t key_len; char buffer[MAX_ENV_BUF_SZ]; }; #define MAX_ENV_NB 256 struct s_plugin_conf { uid_t uid; gid_t gid; size_t size; struct s_env env[MAX_ENV_NB]; }; static void set_value(struct s_plugin_conf *conf, const char *key, const char *value) { size_t i; size_t key_len = strlen(key); struct s_env *dst_env = NULL; /* Search for the corresponding env */ for (i = 0; i < conf->size; i++) { struct s_env *env = conf->env + i; if (key_len != env->key_len) continue; /* this cmp works since keys have the same length */ if (strncmp(key, env->buffer, env->key_len) != 0) continue; /* Found the key */ dst_env = env; } if (dst_env == NULL) { /* Allocate one */ if (conf->size == MAX_ENV_NB) { fprintf(stderr, "ran out of internal env space\n"); abort(); } /* ptr arithmetic is done with int, not with size_t */ dst_env = conf->env; dst_env += (int) conf->size; conf->size++; } /* Save the environment in setenv() format */ dst_env->key_len = key_len; snprintf(dst_env->buffer, MAX_ENV_BUF_SZ, "%s=%s", key, value); } static void end_before_first(char *s, char c) { s = strchr(s, c); if (s != NULL) *s = '\0'; } static struct s_plugin_conf *parse_plugin_conf(FILE * f, const char *plugin, struct s_plugin_conf *conf) { /* read from file */ char line[LINE_MAX]; bool is_relevant = false; while (fgets(line, LINE_MAX, f) != NULL) { char *line_trimmed = trim(line); assert(line_trimmed != NULL); if (line_trimmed[0] != '[' && !is_relevant) { /* Ignore the line */ continue; } if (line_trimmed[0] == '[') { line_trimmed++; end_before_first(line_trimmed, ']'); /* Try the key */ { int fnmatch_flags = FNM_NOESCAPE | FNM_PATHNAME; int res = fnmatch(line_trimmed, plugin, fnmatch_flags); if (res == 0) { is_relevant = true; } else if (res == FNM_NOMATCH) { is_relevant = false; } else { perror("fnmatch() error"); abort(); } } /* Next line */ continue; } { /* Parse the line, and add it to the current conf */ char *key = trim(strtok(line_trimmed, " ")); char *value; /* No key found, skip the line */ if (key == NULL) continue; /* Everything after the first " " is value */ value = trim(key + strlen(key) + 1); assert(value != NULL); if (0 == strcmp(key, "user")) { struct passwd *pswd = getpwnam(value); if (pswd == NULL) { perror("getpwnam() error"); abort(); } conf->uid = pswd->pw_uid; } else if (0 == strcmp(key, "group")) { struct group *grp = getgrnam(value); if (grp == NULL) { perror("getgrnam() error"); abort(); } conf->gid = grp->gr_gid; } else if (0 == strncmp(key, "env.", strlen("env."))) { char *env_key = key + strlen("env."); set_value(conf, env_key, value); } } } return conf; } /* Setting user configured vars */ static void setenvvars_conf(char *current_plugin_name) { /* TODO - add plugin conf parsing */ DIR *dirp = opendir(pluginconf_dir); if (dirp == NULL) { printf("# Cannot open plugin config dir '%s'\n", pluginconf_dir); return; } { struct s_plugin_conf pconf; pconf.size = 0; /* default is nobody:nobody */ { struct passwd *pswd = getpwnam("nobody"); if (pswd == NULL) { perror("getpwnam(\"nobody\") error"); abort(); } pconf.uid = pswd->pw_uid; } { struct group *grp = getgrnam("nogroup"); if (grp == NULL) { perror("getgrnam(\"nogroup\") error"); abort(); } pconf.gid = grp->gr_gid; } { struct dirent *dp; while ((dp = readdir(dirp)) != NULL) { char cmdline[LINE_MAX]; char *plugin_filename = dp->d_name;; if (plugin_filename[0] == '.') { /* No dotted plugin */ continue; } snprintf(cmdline, LINE_MAX, "%s/%s", pluginconf_dir, plugin_filename); { FILE *f = fopen(cmdline, "r"); if (f == NULL) { /* Ignore open failures */ continue; } parse_plugin_conf(f, current_plugin_name, &pconf); fclose(f); } } /* Set env after whole parsing */ { size_t i; for (i = 0; i < pconf.size; i++) { struct s_env *env = pconf.env + i; putenv(env->buffer); } } /* setuid/gid */ if (geteuid() == 0) { /* We *are* root */ int ret_val; ret_val = setgid(pconf.gid); if ((ret_val != 0) || (getgid() != pconf.gid)) { perror ("gid not changed by setgid"); abort(); } /* Change UID *after* GID, otherwise cannot change anymore */ ret_val = setuid(pconf.uid); if ((ret_val != 0) || (getuid() != pconf.uid)) { perror ("uid not changed by setuid"); abort(); } } } } closedir(dirp); } static int handle_connection() { char line[LINE_MAX]; /* Prepare per connection plugin env vars */ setenvvars_munin(); printf("# munin node at %s\n", host); while (fflush(stdout), fgets(line, LINE_MAX, stdin) != NULL) { char *cmd; char *arg; cmd = strtok(line, " \t\n\r"); if (cmd == NULL) arg = NULL; else arg = strtok(NULL, " \t\n\r"); if (!cmd || strlen(cmd) == 0) { printf("# empty cmd\n"); } else if (strcmp(cmd, "version") == 0) { printf("munin c node version: %s\n", VERSION); } else if (strcmp(cmd, "nodes") == 0) { printf("%s\n", host); printf(".\n"); } else if (strcmp(cmd, "quit") == 0) { return (0); } else if (strcmp(cmd, "list") == 0) { DIR *dirp = opendir(plugin_dir); if (dirp == NULL) { printf("# Cannot open plugin dir\n"); return (0); } { struct dirent *dp; while ((dp = readdir(dirp)) != NULL) { char cmdline[LINE_MAX]; char *plugin_filename = dp->d_name;; if (plugin_filename[0] == '.') { /* No dotted plugin */ continue; } snprintf(cmdline, LINE_MAX, "%s/%s", plugin_dir, plugin_filename); if (access(cmdline, X_OK) == 0) { if (extension_stripping) { /* Strip after the last . */ char *last_dot_idx = strrchr (plugin_filename, '.'); if (last_dot_idx != NULL) { *last_dot_idx = '\0'; } } printf("%s ", plugin_filename); } } closedir(dirp); } putchar('\n'); } else if (strcmp(cmd, "config") == 0 || strcmp(cmd, "fetch") == 0) { char cmdline[LINE_MAX]; pid_t pid; if (arg == NULL) { printf("# no plugin given\n"); continue; } if (arg[0] == '.' || strchr(arg, '/') != NULL) { printf("# invalid plugin character\n"); continue; } if (!extension_stripping || find_plugin_with_basename(cmdline, plugin_dir, arg) == 0) { /* extension_stripping failed, using the plain method */ snprintf(cmdline, LINE_MAX, "%s/%s", plugin_dir, arg); } if (access(cmdline, X_OK) == -1) { printf("# unknown plugin: %s\n", arg); continue; } /* Using posix_spawnp() here instead of fork() since we will * do a little more than a mere exec --> setenvvars_conf() */ pid = fork(); if (pid == -1) { printf("# fork failed\n"); continue; } else if (pid == 0) { /* Now is the time to set environnement */ setenvvars_conf(arg); execl(cmdline, arg, cmd, NULL); } waitpid(pid, NULL, 0); printf(".\n"); } else if (strcmp(cmd, "cap") == 0) { printf("cap "); if ('\0' != *spoolfetch_dir) { printf("spool "); } printf("\n"); } else if (strcmp(cmd, "spoolfetch") == 0) { printf("# not implem yet cmd: %s\n", cmd); } else { printf ("# Unknown cmd: %s. Try cap, list, nodes, config, fetch, version or quit\n", cmd); } } return 0; } pid_t acquire(char *plugin_name, char *plugin_filename); int acquire_all() { DIR *dirp = opendir(plugin_dir); if (dirp == NULL) { printf("# Cannot open plugin dir\n"); return (0); } { struct dirent *dp; while ((dp = readdir(dirp)) != NULL) { char cmdline[LINE_MAX]; char *plugin_filename = dp->d_name;; if (plugin_filename[0] == '.') { /* No dotted plugin */ continue; } snprintf(cmdline, LINE_MAX, "%s/%s", plugin_dir, plugin_filename); if (access(cmdline, X_OK) == 0) { if (extension_stripping) { /* Strip after the last . */ char *last_dot_idx = strrchr(plugin_filename, '.'); if (last_dot_idx != NULL) { *last_dot_idx = '\0'; } } /* run acquire on that */ printf("# acquire %s\n", plugin_filename); acquire(plugin_filename, cmdline); } } closedir(dirp); } /* wait for all childrens to end */ { pid_t waited_pid; while ((waited_pid = wait(NULL)) != -1); } return 0; } pid_t acquire(char *plugin_name, char *plugin_filename) { /* continue in background */ pid_t child = fork(); if (child) return child; setenvvars_munin(); setenvvars_conf(plugin_name); /* ask the plugin not to fork */ putenv("no_fork=1"); /* Go underwater */ close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); execl(plugin_filename, plugin_name, "acquire", NULL); /* should nevec come here */ exit(2); } munin-c-0.0.13/src/plugins/000077500000000000000000000000001343165630300154155ustar00rootroot00000000000000munin-c-0.0.13/src/plugins/Makefile.am000066400000000000000000000015641343165630300174570ustar00rootroot00000000000000# # Copyright (C) 2013 Helmut Grohne - All rights reserved. # Copyright (C) 2013 Steve Schnepp - All rights reserved. # Copyright (C) 2013 Diego Elio Petteno - All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v.2 or v.3. # include $(top_srcdir)/common.am pkglibexec_PROGRAMS = munin-plugins-c munin_plugins_c_SOURCES = \ common.c \ common.h \ plugins.h \ cpu.c \ df.c \ entropy.c \ external_.c \ forks.c \ fw_packets.c \ if_err_.c \ interrupts.c \ load.c \ open_files.c \ open_inodes.c \ processes.c \ swap.c \ threads.c \ memory.c \ uptime.c \ main.c man_MANS = munin-plugins-c.1 CLEANFILES = $(man_MANS) EXTRA_DIST = munin-plugins-c.pod munin-c-0.0.13/src/plugins/README000066400000000000000000000021251343165630300162750ustar00rootroot00000000000000What is this? ~~~~~~~~~~~~~ This is a rewrite of commonly used munin plugins in C as a single binary. The purpose is reducing resource usage: * disk space: the binary is smaller than the plugins together * more diskspace: it has no dependencies on other programs * less forks: it does not fork internally * faster startup: it doesn't start perl or shell * less memory: just a small C program * less file accesses: one binary for many plugins This can be useful for machines with restricted resources like embedded machines. What plugins are included? ~~~~~~~~~~~~~~~~~~~~~~~~~~ cpu entropy forks fw_packets interrupts load open_files open_inodes processes swap uptime Disadvantages? ~~~~~~~~~~~~~~ You lose flexibility. You can no longer just edit the plugin and if you try you have to be very careful not to break it. If you want to deploy this you have to create one binary for each architecture. How to use? ~~~~~~~~~~~ After compiling there will be binary munin-plugins-c. You can just replace symlinks in /etc/munin/plugins/ with symlinks to this binary. # vim7:spelllang=en # vim:textwidth=75 munin-c-0.0.13/src/plugins/common.c000066400000000000000000000033711343165630300170550ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include "common.h" extern char **environ; int writeyes(void) { puts("yes"); return 0; } int autoconf_check_readable(const char *path) { if (0 == access(path, R_OK)) return writeyes(); else { printf("no (%s is not readable, errno=%d)\n", path, errno); return 0; } } int getenvint(const char *name, int defvalue) { const char *value; value = getenv(name); if (value == NULL) return defvalue; return atoi(value); } static /*@null@ */ /*@observer@ */ const char *getenv_composed(const char *name1, const char *name2) { char **p; size_t len1 = strlen(name1), len2 = strlen(name2); for (p = environ; *p; ++p) { if (0 == strncmp(*p, name1, len1) && 0 == strncmp(len1 + *p, name2, len2) && (*p)[len1 + len2] == '=') return len1 + len2 + 1 + *p; } return NULL; } void print_warning(const char *name) { const char *p; p = getenv_composed(name, "_warning"); if (p == NULL) p = getenv("warning"); if (p == NULL) return; printf("%s.warning %s\n", name, p); } void print_critical(const char *name) { const char *p; p = getenv_composed(name, "_critical"); if (p == NULL) p = getenv("critical"); if (p == NULL) return; printf("%s.critical %s\n", name, p); } void print_warncrit(const char *name) { print_warning(name); print_critical(name); } int fail(const char *message) { fputs(message, stderr); fputc('\n', stderr); return 1; } munin-c-0.0.13/src/plugins/common.h000066400000000000000000000030141343165630300170540ustar00rootroot00000000000000/* * Copyright (C) 2008 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #ifndef COMMON_H #define COMMON_H #define PROC_STAT "/proc/stat" /** Write yes to stdout and return 0. The intended use is give an autoconf * response like "return writeyes();". * @returns a success state to be passed on as the return value from main */ int writeyes(void); /** Answer an autoconf request by checking the readability of the given file. */ int autoconf_check_readable(const char *); /** Obtain an integer value from the environment. In the absence of the * variable the given defaultvalue is returned. */ int getenvint(const char *, int defaultvalue); /** Print a name.warning line using the "name_warning" or "warning" environment * variables. */ void print_warning(const char *name); /** Print a name.critical line using the "name_critical" or "critical" * environment variables. */ void print_critical(const char *name); /** Print both name.warning and name.critical lines using environment * variables. */ void print_warncrit(const char *name); /** Fail by printing the given message and a newline to stderr. * @returns a failure state to be passed on as the return value from main */ int fail(const char *message); #define xisspace(x) isspace((int)(unsigned char) x) #define xisdigit(x) isdigit((int)(unsigned char) x) #endif munin-c-0.0.13/src/plugins/cpu.c000066400000000000000000000143101343165630300163470ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * Copyright (C) 2013 Steve Schnepp - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include #include #include #include "common.h" #include "plugins.h" #define SYSWARNING 30 #define SYSCRITICAL 50 #define USRWARNING 80 /* TODO: port support for env.foo_warning and env.foo_critical from mainline plugin */ static int print_stat_value(const char *field_name, const char *stat_value, int hz_) { uint64_t stat_value_ll = strtoull(stat_value, NULL, 0); if (hz_ != 0) { /* hz_ is not ZERO, narmalize the value */ stat_value_ll = stat_value_ll * 100 / hz_; } return printf("%s.value %" PRIu64 "\n", field_name, stat_value_ll); } static int parse_cpu_line(char *buff) { char *s; int hz_ = getenvint("HZ", 100); if (!(s = strtok(buff + 4, " \t"))) return -1; print_stat_value("user", s, hz_); if (!(s = strtok(NULL, " \t"))) return -1; print_stat_value("nice", s, hz_); if (!(s = strtok(NULL, " \t"))) return -1; print_stat_value("system", s, hz_); if (!(s = strtok(NULL, " \t"))) return -1; print_stat_value("idle", s, hz_); if (!(s = strtok(NULL, " \t"))) return 0; print_stat_value("iowait", s, hz_); if (!(s = strtok(NULL, " \t"))) return 0; print_stat_value("irq", s, hz_); if (!(s = strtok(NULL, " \t"))) return 0; print_stat_value("softirq", s, hz_); if (!(s = strtok(NULL, " \t"))) return 0; print_stat_value("steal", s, hz_); if (!(s = strtok(NULL, " \t"))) return 0; print_stat_value("guest", s, hz_); return 0; } int cpu(int argc, char **argv) { FILE *f; char buff[256]; int ncpu = 0, extinfo = 0, ret; bool scaleto100 = false; if (argc > 1) { if (!strcmp(argv[1], "config")) { char *s = getenv("scaleto100"); if (s && !strcmp(s, "yes")) scaleto100 = true; if (!(f = fopen(PROC_STAT, "r"))) return fail("cannot open " PROC_STAT); while (fgets(buff, 256, f)) { if (!strncmp(buff, "cpu", 3)) { if (xisdigit(buff[3])) ncpu++; if (buff[3] == ' ' && 0 == extinfo) { strtok(buff + 4, " \t"); for (extinfo = 1; strtok(NULL, " \t"); extinfo++); } } } fclose(f); if (ncpu < 1 || extinfo < 4) return fail("cannot parse " PROC_STAT); puts("graph_title CPU usage"); if (extinfo >= 7) puts("graph_order system user nice idle iowait irq softirq"); else puts("graph_order system user nice idle"); if (scaleto100) puts("graph_args --base 1000 -r --lower-limit 0 --upper-limit 100"); else printf ("graph_args --base 1000 -r --lower-limit 0 --upper-limit %d\n", 110 * ncpu); puts("graph_vlabel %\n" "graph_scale no\n" "graph_info This graph shows how CPU time is spent.\n" "graph_category system\n" "graph_period second\n" "system.label system\n" "system.draw AREA"); printf("system.max %d\n", 110 * ncpu); puts("system.min 0\n" "system.type DERIVE"); printf("system.warning %d\n", SYSWARNING * ncpu); printf("system.critical %d\n", SYSCRITICAL * ncpu); puts("system.info CPU time spent by the kernel in system activities\n" "user.label user\n" "user.draw STACK\n" "user.min 0"); printf("user.max %d\n", 110 * ncpu); printf("user.warning %d\n", USRWARNING * ncpu); puts("user.type DERIVE\n" "user.info CPU time spent by normal programs and daemons\n" "nice.label nice\n" "nice.draw STACK\n" "nice.min 0"); printf("nice.max %d\n", 110 * ncpu); puts("nice.type DERIVE\n" "nice.info CPU time spent by nice(1)d programs\n" "idle.label idle\n" "idle.draw STACK\n" "idle.min 0"); printf("idle.max %d\n", 110 * ncpu); puts("idle.type DERIVE\n" "idle.info Idle CPU time"); if (scaleto100) printf("system.cdef system,%d,/\n" "user.cdef user,%d,/\n" "nice.cdef nice,%d,/\n" "idle.cdef idle,%d,/\n", ncpu, ncpu, ncpu, ncpu); if (extinfo >= 7) { puts("iowait.label iowait\n" "iowait.draw STACK\n" "iowait.min 0"); printf("iowait.max %d\n", 110 * ncpu); puts("iowait.type DERIVE\n" "iowait.info CPU time spent waiting for I/O operations to finish\n" "irq.label irq\n" "irq.draw STACK\n" "irq.min 0"); printf("irq.max %d\n", 110 * ncpu); puts("irq.type DERIVE\n" "irq.info CPU time spent handling interrupts\n" "softirq.label softirq\n" "softirq.draw STACK\n" "softirq.min 0"); printf("softirq.max %d\n", 110 * ncpu); puts("softirq.type DERIVE\n" "softirq.info CPU time spent handling \"batched\" interrupts"); if (scaleto100) printf("iowait.cdef iowait,%d,/\n" "irq.cdef irq,%d,/\n" "softirq.cdef softirq,%d,/\n", ncpu, ncpu, ncpu); } if (extinfo >= 8) { puts("steal.label steal\n" "steal.draw STACK\n" "steal.min 0"); printf("steal.max %d\n", 110 * ncpu); puts("steal.type DERIVE\n" "steal.info The time that a virtual CPU had runnable tasks, but the virtual CPU itself was not running"); if (scaleto100) printf("steal.cdef steal,%d,/\n", ncpu); } if (extinfo >= 9) { puts("guest.label guest\n" "guest.draw STACK\n" "guest.min 0"); printf("guest.max %d\n", 110 * ncpu); puts("guest.type DERIVE\n" "guest.info The time spent running a virtual CPU for guest operating systems under the control of the Linux kernel."); if (scaleto100) printf("guest.cdef guest,%d,/\n", ncpu); } return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_STAT); } if (!(f = fopen(PROC_STAT, "r"))) return fail("cannot open " PROC_STAT); while (fgets(buff, 256, f)) { if (!strncmp(buff, "cpu ", 4)) { ret = parse_cpu_line(buff); goto OK; } } /* We didn't find anyting */ ret = fail("no cpu line found in " PROC_STAT); OK: fclose(f); return ret; } munin-c-0.0.13/src/plugins/df.c000066400000000000000000000063631343165630300161620ustar00rootroot00000000000000/* * Copyright (C) 2017 Bastiaan van Kesteren - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #ifdef HAVE_MNTENT_H #include /* for getmntent(), et al. */ #endif #include /* for getopt() */ #include #ifdef HAVE_SYS_VFS_H #include #endif #include "common.h" /* Defines taken from statfs(2) man page: */ #define ISOFS_SUPER_MAGIC 0x9660 #define SQUASHFS_MAGIC 0x73717368 #define UDF_SUPER_MAGIC 0x15013346 #define ROMFS_MAGIC 0x7275 #define RAMFS_MAGIC 0x858458f6 #define DEBUGFS_MAGIC 0x64626720 #define CGROUP_SUPER_MAGIC 0x27e0eb #define DEVPTS_SUPER_MAGIC 0x1cd1 #ifndef HAVE_MNTENT_H int df(int argc, char **argv) { if (argc && argv) { /* Do nothing, but silence the warnings */ } return fail("getmntent() is not supported on your system"); } #else static char *replace_slash(char *c) { char *p = c; while (*p) { if (*p == '/') { *p = '_'; } p++; } return c; } int df(int argc, char **argv) { FILE *fp; struct mntent *fs; struct statfs vfs; fp = setmntent("/etc/mtab", "r"); if (fp == NULL) { return fail("cannot open /etc/mtab"); } if (argc > 1) { if (strcmp(argv[1], "config") == 0) { printf("graph_title Disk usage in percent\n" "graph_args --upper-limit 100 -l 0\n" "graph_vlabel %%\n" "graph_scale no\n" "graph_category disk\n"); while ((fs = getmntent(fp)) != NULL) { if (fs->mnt_fsname[0] != '/') { continue; } if (statfs(fs->mnt_dir, &vfs) != 0) { continue; } if ((unsigned int) vfs.f_type == ISOFS_SUPER_MAGIC || (unsigned int) vfs.f_type == SQUASHFS_MAGIC || (unsigned int) vfs.f_type == UDF_SUPER_MAGIC || (unsigned int) vfs.f_type == ROMFS_MAGIC || (unsigned int) vfs.f_type == RAMFS_MAGIC || (unsigned int) vfs.f_type == DEBUGFS_MAGIC || (unsigned int) vfs.f_type == CGROUP_SUPER_MAGIC || (unsigned int) vfs.f_type == DEVPTS_SUPER_MAGIC) { continue; } printf("%s.label %s\n", replace_slash(fs->mnt_fsname), fs->mnt_dir); } endmntent(fp); return 0; } } /* Asking for a fetch */ while ((fs = getmntent(fp)) != NULL) { if (fs->mnt_fsname[0] != '/') { continue; } if (statfs(fs->mnt_dir, &vfs) != 0) { continue; } if ((unsigned int) vfs.f_type == ISOFS_SUPER_MAGIC || (unsigned int) vfs.f_type == SQUASHFS_MAGIC || (unsigned int) vfs.f_type == UDF_SUPER_MAGIC || (unsigned int) vfs.f_type == ROMFS_MAGIC || (unsigned int) vfs.f_type == RAMFS_MAGIC || (unsigned int) vfs.f_type == DEBUGFS_MAGIC || (unsigned int) vfs.f_type == CGROUP_SUPER_MAGIC || (unsigned int) vfs.f_type == DEVPTS_SUPER_MAGIC) { continue; } printf("%s.value %lf\n", replace_slash(fs->mnt_fsname), (100.0 / vfs.f_blocks) * (vfs.f_blocks - vfs.f_bfree)); } endmntent(fp); return 0; } #endif munin-c-0.0.13/src/plugins/entropy.c000066400000000000000000000025421343165630300172640ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include "common.h" #include "plugins.h" #define ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail" int entropy(int argc, char **argv) { FILE *f; int entropy; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Available entropy\n" "graph_args --base 1000 -l 0\n" "graph_vlabel entropy (bytes)\n" "graph_scale no\n" "graph_category system\n" "graph_info This graph shows the amount of entropy available in the system.\n" "entropy.label entropy\n" "entropy.info The number of random bytes available. This is typically used by cryptographic applications."); print_warncrit("entropy"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(ENTROPY_AVAIL); } if (!(f = fopen(ENTROPY_AVAIL, "r"))) return fail("cannot open " ENTROPY_AVAIL); if (1 != fscanf(f, "%d", &entropy)) { fclose(f); return fail("cannot read from " ENTROPY_AVAIL); } fclose(f); printf("entropy.value %d\n", entropy); return 0; } munin-c-0.0.13/src/plugins/external_.c000077500000000000000000000027161343165630300175530ustar00rootroot00000000000000/* * Copyright (C) 2013 Steve Schnepp - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include "common.h" #include "plugins.h" #ifndef LINE_MAX #define LINE_MAX 2048 #endif static int read_file_to_stdout(const char *filename) { FILE *f; int c; if (!(f = fopen(filename, "r"))) { fputs("cannot open ", stderr); /* filename is not a constant */ return fail(filename); } while ((c = fgetc(f)) != EOF) { fputc(c, stdout); } fclose(f); return 0; } static int set_filename(char *filename, const char *plugin_basename, const char *action) { if (getenv(action) == NULL) { /* Default */ return snprintf(filename, LINE_MAX, "%s/%s.%s", getenv("MUNIN_PLUGSTATE"), plugin_basename, action); } return snprintf(filename, LINE_MAX, "%s", getenv(action)); } int external_(int argc, char **argv) { char filename[LINE_MAX]; /* Default is "fetch" */ set_filename(filename, basename(argv[0]), "fetch"); if (argc > 1) { if (!strcmp(argv[1], "autoconf")) return puts("no (not yet implemented)"); if (!strcmp(argv[1], "config")) { set_filename(filename, basename(argv[0]), "config"); } } read_file_to_stdout(filename); return 0; } munin-c-0.0.13/src/plugins/forks.c000066400000000000000000000025771343165630300167200ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include #include "common.h" #include "plugins.h" int forks(int argc, char **argv) { FILE *f; char buff[256]; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Fork rate\n" "graph_args --base 1000 -l 0 \n" "graph_vlabel forks / ${graph_period}\n" "graph_category processes\n" "graph_info This graph shows the forking rate (new processes started).\n" "forks.label forks\n" "forks.type DERIVE\n" "forks.min 0\n" "forks.max 100000\n" "forks.info The number of forks per second."); print_warncrit("forks"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_STAT); } if (!(f = fopen(PROC_STAT, "r"))) return fail("cannot open " PROC_STAT); while (fgets(buff, 256, f)) { if (!strncmp(buff, "processes ", 10)) { fclose(f); printf("forks.value %s", buff + 10); return 0; } } fclose(f); return fail("no processes line found in " PROC_STAT); } munin-c-0.0.13/src/plugins/fw_packets.c000066400000000000000000000033331343165630300177110ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include "common.h" #include "plugins.h" #define PROC_NET_SNMP "/proc/net/snmp" int fw_packets(int argc, char **argv) { FILE *f; char buff[1024], *s; int ret; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Firewall Throughput\n" "graph_args --base 1000 -l 0\n" "graph_vlabel Packets/${graph_period}\n" "graph_category network\n" "received.label Received\n" "received.draw AREA\n" "received.type DERIVE\n" "received.min 0\n" "forwarded.label Forwarded\n" "forwarded.draw LINE2\n" "forwarded.type DERIVE\n" "forwarded.min 0"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_NET_SNMP); } if (!(f = fopen(PROC_NET_SNMP, "r"))) return fail("cannot open " PROC_NET_SNMP); while (fgets(buff, 1024, f)) { if (!strncmp(buff, "Ip: ", 4) && xisdigit(buff[4])) { if (!(s = strtok(buff + 4, " \t"))) break; if (!(s = strtok(NULL, " \t"))) break; if (!(s = strtok(NULL, " \t"))) break; printf("received.value %s\n", s); if (!(s = strtok(NULL, " \t"))) break; if (!(s = strtok(NULL, " \t"))) break; if (!(s = strtok(NULL, " \t"))) break; printf("forwarded.value %s\n", s); ret = 0; goto OK; } } ret = fail("no ip line found in " PROC_NET_SNMP); OK: fclose(f); return ret; } munin-c-0.0.13/src/plugins/if_err_.c000066400000000000000000000054161343165630300171740ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include "common.h" #include "plugins.h" #define PROC_NET_DEV "/proc/net/dev" int if_err_(int argc, char **argv) { char *interface; size_t interface_len; FILE *f; char buff[256], *s; int i; interface = basename(argv[0]); if (strncmp(interface, "if_err_", 7) != 0) return fail("if_err_ invoked with invalid basename"); interface += 7; interface_len = strlen(interface); if (argc > 1) { if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_NET_DEV); if (!strcmp(argv[1], "suggest")) { if (NULL == (f = fopen(PROC_NET_DEV, "r"))) return 1; while (fgets(buff, 256, f)) { for (s = buff; *s == ' '; ++s); i = 0; if (!strncmp(s, "lo:", 3)) continue; if (!strncmp(s, "sit", 3)) { for (i = 3; xisdigit(s[i]); ++i); if (s[i] == ':') continue; } while (s[i] != ':' && s[i] != '\0') ++i; if (s[i] != ':') continue; /* a header line */ s[i] = '\0'; puts(s); } fclose(f); return 0; } if (!strcmp(argv[1], "config")) { puts("graph_order rcvd trans"); printf("graph_title %s errors\n", interface); puts("graph_args --base 1000\n" "graph_vlabel packets in (-) / out (+) per " "${graph_period}\n" "graph_category network"); printf("graph_info This graph shows the amount of " "errors on the %s network interface.\n", interface); puts("rcvd.label packets\n" "rcvd.type COUNTER\n" "rcvd.graph no\n" "rcvd.warning 1\n" "trans.label packets\n" "trans.type COUNTER\n" "trans.negative rcvd\n" "trans.warning 1"); print_warncrit("rcvd"); print_warncrit("trans"); return 0; } } if (NULL == (f = fopen(PROC_NET_DEV, "r"))) return 1; while (fgets(buff, 256, f)) { for (s = buff; *s == ' '; ++s); if (0 != strncmp(s, interface, interface_len)) continue; s += interface_len; if (*s != ':') continue; ++s; while (*s == ' ') ++s; for (i = 1; i < 3; ++i) { while (xisdigit(*s)) ++s; while (xisspace(*s)) ++s; } for (i = 0; xisdigit(s[i]); ++i); printf("rcvd.value "); fwrite(s, 1, i, stdout); putchar('\n'); s += i; while (xisspace(*s)) ++s; for (i = 4; i < 11; ++i) { while (xisdigit(*s)) ++s; while (xisspace(*s)) ++s; } for (i = 0; xisdigit(s[i]); ++i); printf("trans.value "); fwrite(s, 1, i, stdout); putchar('\n'); } fclose(f); return 0; } munin-c-0.0.13/src/plugins/interrupts.c000066400000000000000000000036051343165630300200040ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include #include "common.h" #include "plugins.h" int interrupts(int argc, char **argv) { FILE *f; char buff[256]; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Interrupts and context switches\n" "graph_args --base 1000 -l 0\n" "graph_vlabel interrupts & ctx switches / ${graph_period}\n" "graph_category system\n" "graph_info This graph shows the number of interrupts and context switches on the system. These are typically high on a busy system.\n" "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."); puts("ctx.info A context switch occurs when a multitasking operatings system suspends the currently running process, and starts executing another.\n" "intr.label interrupts\n" "ctx.label context switches\n" "intr.type DERIVE\n" "ctx.type DERIVE\n" "intr.max 100000\n" "ctx.max 100000\n" "intr.min 0\n" "ctx.min 0"); print_warncrit("intr"); print_warncrit("ctx"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_STAT); } if (!(f = fopen(PROC_STAT, "r"))) return fail("cannot open " PROC_STAT); while (fgets(buff, 256, f)) { if (!strncmp(buff, "intr ", 5)) { buff[5 + strcspn(buff + 5, " \t\n")] = '\0'; printf("intr.value %s\n", buff + 5); } else if (!strncmp(buff, "ctxt ", 5)) { buff[5 + strcspn(buff + 5, " \t\n")] = '\0'; printf("ctx.value %s\n", buff + 5); } } fclose(f); return 0; } munin-c-0.0.13/src/plugins/load.c000066400000000000000000000024521343165630300165030ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include #include "common.h" #include "plugins.h" #define PROC_LOADAVG "/proc/loadavg" int load(int argc, char **argv) { FILE *f; float val; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Load average\n" "graph_args --base 1000 -l 0\n" "graph_vlabel load\n" "graph_scale no\n" "graph_category system\n" "load.label load"); print_warncrit("load"); puts("graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run \"immediately\").\n" "load.info 5 minute load average"); return 0; } if (!strcmp(argv[1], "autoconf")) return writeyes(); } if (!(f = fopen(PROC_LOADAVG, "r"))) return fail("cannot open " PROC_LOADAVG); if (1 != fscanf(f, "%*f %f", &val)) { fclose(f); return fail("cannot read from " PROC_LOADAVG); } fclose(f); printf("load.value %.2f\n", val); return 0; } munin-c-0.0.13/src/plugins/main.c000066400000000000000000000054651343165630300165170ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * Copyright (C) 2013 Steve Schnepp - All rights reserved. * Copyright (C) 2013 Diego Elio Petteno - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include "common.h" #include "plugins.h" static int busybox(int argc, char **argv) { if (argc < 2) return fail("missing parameter"); if (0 != strcmp(argv[1], "listplugins")) return fail("unknown parameter"); if (argc > 3 || (argc > 2 && 0 != strcmp(argv[2], "--include-experimental"))) return fail("unknown option"); /* The following is focused on readability over efficiency. */ puts("cpu"); puts("df"); puts("entropy"); puts("forks"); puts("fw_packets"); puts("interrupts"); puts("load"); puts("open_files"); puts("open_inodes"); puts("swap"); puts("threads"); puts("uptime"); if (argc > 2) { puts("memory"); puts("processes"); puts("external_"); } return 0; } int main(int argc, char **argv) { char *progname; char *ext; progname = basename(argv[0]); ext = strrchr(progname, '.'); if (ext != NULL) ext[0] = '\0'; switch (*progname) { case 'c': if (!strcmp(progname, "cpu")) return cpu(argc, argv); break; case 'd': if (!strcmp(progname, "df")) return df(argc, argv); break; case 'e': if (!strcmp(progname, "entropy")) return entropy(argc, argv); if (!strncmp(progname, "external_", strlen("external_"))) return external_(argc, argv); break; case 'f': if (!strcmp(progname, "forks")) return forks(argc, argv); if (!strcmp(progname, "fw_packets")) return fw_packets(argc, argv); break; case 'i': if (!strcmp(progname, "interrupts")) return interrupts(argc, argv); if (!strncmp(progname, "if_err_", strlen("if_err_"))) return if_err_(argc, argv); break; case 'l': if (!strcmp(progname, "load")) return load(argc, argv); break; case 'm': if (!strcmp(progname, "memory")) return memory(argc, argv); if (!strcmp(progname, "munin-plugins-c")) return busybox(argc, argv); break; case 'o': if (!strcmp(progname, "open_files")) return open_files(argc, argv); if (!strcmp(progname, "open_inodes")) return open_inodes(argc, argv); break; case 'p': if (!strcmp(progname, "processes")) return processes(argc, argv); break; case 's': if (!strcmp(progname, "swap")) return swap(argc, argv); break; case 't': if (!strcmp(progname, "threads")) return threads(argc, argv); break; case 'u': if (!strcmp(progname, "uptime")) return uptime(argc, argv); break; } return fail("unknown basename"); } munin-c-0.0.13/src/plugins/memory.c000066400000000000000000000075411343165630300171000ustar00rootroot00000000000000/* * Copyright (C) 2013 Steve Schnepp - All rights reserved. * Copyright (C) 2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include #include "common.h" #include "plugins.h" #define SYSWARNING 30 #define SYSCRITICAL 50 #define USRWARNING 80 #define PROC_MEMINFO "/proc/meminfo" /* Samples "/proc/meminfo" Linux 2.6.32: MemTotal: 121484 kB MemFree: 16036 kB Buffers: 13260 kB Cached: 35432 kB SwapCached: 13600 kB Active: 43160 kB Inactive: 43920 kB Active(anon): 12616 kB Inactive(anon): 26096 kB Active(file): 30544 kB Inactive(file): 17824 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 262136 kB SwapFree: 215608 kB Dirty: 92 kB Writeback: 0 kB AnonPages: 29468 kB Mapped: 6728 kB Shmem: 308 kB Slab: 12024 kB SReclaimable: 6708 kB SUnreclaim: 5316 kB KernelStack: 680 kB PageTables: 2116 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 322876 kB Committed_AS: 108564 kB VmallocTotal: 34359738367 kB VmallocUsed: 1196 kB VmallocChunk: 34359737024 kB HardwareCorrupted: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 131072 kB DirectMap2M: 0 kB Cygwin: MemTotal: 121484 kB MemFree: 16036 kB HighTotal: 0 kB HighFree: 0 kB LowFree: 16036 kB SwapTotal: 262136 kB SwapFree: 215608 kB } */ /* TODO - For now we only support Cygwin fields. */ int memory(int argc, char **argv) { FILE *f; char buff[256]; int_fast64_t mem_total = -1; int_fast64_t mem_free = -1; int_fast64_t swap_total = -1; int_fast64_t swap_free = -1; if (argc > 1) { if (!strcmp(argv[1], "config")) { printf("graph_args --base 1024 -l 0\n" "graph_vlabel Bytes\n" "graph_title Memory usage\n" "graph_category system\n" "graph_info This graph shows what the machine uses memory for.\n"); printf("apps.label apps\n"); printf("apps.draw AREA\n"); printf ("apps.info Memory used by user-space applications.\n"); printf("free.label free\n"); printf("free.draw STACK\n"); printf ("free.info Wasted memory. Memory that is not used for anything at all.\n"); printf("swap.label swap\n"); printf("swap.draw STACK\n"); printf("swap.info Swap space used.\n"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_MEMINFO); } /* Asking for a fetch */ if (!(f = fopen(PROC_MEMINFO, "r"))) return fail("cannot open " PROC_MEMINFO); while (fgets(buff, 256, f)) { char key[256]; int_fast64_t value; if (!sscanf(buff, "%s %" SCNdFAST64, key, &value)) { fclose(f); return fail("cannot parse " PROC_MEMINFO " line"); } if (!strcmp(key, "MemTotal:")) mem_total = value * 1024; else if (!strcmp(key, "MemFree:")) mem_free = value * 1024; else if (!strcmp(key, "SwapTotal:")) swap_total = value * 1024; else if (!strcmp(key, "SwapFree:")) swap_free = value * 1024; } fclose(f); if (mem_total < 0 || mem_free < 0 || swap_total < 0 || swap_free < 0) return fail("missing fileds in " PROC_MEMINFO); printf("apps.value %" PRIdFAST64 "\n", mem_total - mem_free); printf("free.value %" PRIdFAST64 "\n", mem_free); printf("swap.value %" PRIdFAST64 "\n", swap_total - swap_free); return 0; } munin-c-0.0.13/src/plugins/munin-plugins-c.pod000066400000000000000000000013221343165630300211440ustar00rootroot00000000000000=pod =head1 NAME munin-plugins-c - a single binary implementing a number of basic Munin plugins =head1 DESCRIPTION A Munin node runs plugins to gather statistics about the system. Most of the plugins were originally written in Perl or Shell for simplicity. The munin-plugins-c binary implements a number of the plugins as a single binary. It was written for reduced footprint in terms of system resources. Similar to the busybox utility, it evaluates the name it is called as. =head1 USAGE Discovering available plugins: @@pkglibexecdir@@/munin-plugins-c listplugins Enabling the I plugin: ln -s @@pkglibexecdir@@/munin-plugins-c @@CONFDIR@@/plugins/cpu =head1 AUTHORS Helmut Grohne, Steve Schnepp =cut munin-c-0.0.13/src/plugins/open_files.c000066400000000000000000000034451343165630300177120ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include "common.h" #include "plugins.h" #define FS_FILE_NR "/proc/sys/fs/file-nr" /* TODO: support env.warning and friends after the upstream plugin is fixed */ int open_files(int argc, char **argv) { FILE *f; int alloc, freeh, avail; if (argc > 1) { if (!strcmp(argv[1], "config")) { if (!(f = fopen(FS_FILE_NR, "r"))) return fail("cannot open " FS_FILE_NR); if (1 != fscanf(f, "%*d %*d %d", &avail)) { fclose(f); return fail("cannot read from " FS_FILE_NR); } fclose(f); puts("graph_title File table usage\n" "graph_args --base 1000 -l 0\n" "graph_vlabel number of open files\n" "graph_category system\n" "graph_info This graph monitors the Linux open files table.\n" "used.label open files\n" "used.info The number of currently open files.\n" "max.label max open files\n" "max.info The maximum supported number of open " "files. Tune by modifying " FS_FILE_NR "."); printf("used.warning %d\nused.critical %d\n", (int) (avail * 0.92), (int) (avail * 0.98)); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(FS_FILE_NR); } if (!(f = fopen(FS_FILE_NR, "r"))) return fail("cannot open " FS_FILE_NR); if (3 != fscanf(f, "%d %d %d", &alloc, &freeh, &avail)) { fclose(f); return fail("cannot read from " FS_FILE_NR); } fclose(f); printf("used.value %d\nmax.value %d\n", alloc - freeh, avail); return 0; } munin-c-0.0.13/src/plugins/open_inodes.c000066400000000000000000000027571343165630300200760ustar00rootroot00000000000000/* * Copyright (C) 2008-13 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include #include "common.h" #include "plugins.h" #define FS_INODE_NR "/proc/sys/fs/inode-nr" int open_inodes(int argc, char **argv) { FILE *f; int nr, freen; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Inode table usage\n" "graph_args --base 1000 -l 0\n" "graph_vlabel number of open inodes\n" "graph_category system\n" "graph_info This graph monitors the Linux open inode table.\n" "used.label open inodes\n" "used.info The number of currently open inodes.\n" "max.label inode table size\n" "max.info The size of the system inode table. This is dynamically adjusted by the kernel."); print_warncrit("used"); print_warncrit("max"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(FS_INODE_NR); } if (!(f = fopen(FS_INODE_NR, "r"))) return fail("cannot open " FS_INODE_NR); if (2 != fscanf(f, "%d %d", &nr, &freen)) { fclose(f); return fail("cannot read from " FS_INODE_NR); } fclose(f); printf("used.value %d\nmax.value %d\n", nr - freen, nr); return 0; } munin-c-0.0.13/src/plugins/plugins.h000066400000000000000000000016141343165630300172510ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #ifndef PLUGINS_H #define PLUGINS_H int cpu(int argc, char **argv); int df(int argc, char **argv); int entropy(int argc, char **argv); int external_(int argc, char **argv); int forks(int argc, char **argv); int fw_packets(int argc, char **argv); int if_err_(int argc, char **argv); int interrupts(int argc, char **argv); int load(int argc, char **argv); int memory(int argc, char **argv); int open_files(int argc, char **argv); int open_inodes(int argc, char **argv); int processes(int argc, char **argv); int swap(int argc, char **argv); int threads(int argc, char **argv); int uptime(int argc, char **argv); #endif munin-c-0.0.13/src/plugins/processes.c000066400000000000000000000031711343165630300175710ustar00rootroot00000000000000/* * Copyright (C) 2008-13 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ #include #include #include #include #include #include #include #include #include "common.h" #include "plugins.h" /* TODO: The upstream plugin does way more nowawdays. */ int processes(int argc, char **argv) { DIR *d; struct dirent *e; char *s; int n = 0; struct stat statbuf; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Number of Processes\n" "graph_args --base 1000 -l 0 \n" "graph_vlabel number of processes\n" "graph_category processes\n" "graph_info This graph shows the number of processes in the system.\n" "processes.label processes\n" "processes.draw LINE2\n" "processes.info The current number of processes."); return 0; } if (!strcmp(argv[1], "autoconf")) { if (0 != stat("/proc/1", &statbuf)) { printf ("no (cannot stat /proc/1, errno=%d)\n", errno); return 1; } if (!S_ISDIR(statbuf.st_mode)) { printf("no (/proc/1 is not a directory\n"); return 1; } return writeyes(); } } if (!(d = opendir("/proc"))) return fail("cannot open /proc"); while ((e = readdir(d))) { for (s = e->d_name; *s; ++s) if (!xisdigit(*s)) break; if (!*s) ++n; } closedir(d); printf("processes.value %d\n", n); return 0; } munin-c-0.0.13/src/plugins/swap.c000066400000000000000000000042331343165630300165350ustar00rootroot00000000000000/* * Copyright (C) 2008-13 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include #include #include "common.h" #include "plugins.h" #define PROC_VMSTAT "/proc/vmstat" int swap(int argc, char **argv) { FILE *f; char buff[256]; bool in, out; int inval, outval; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Swap in/out\n" "graph_args -l 0 --base 1000\n" "graph_vlabel pages per ${graph_period} in (-) / out (+)\n" "graph_category system\n" "swap_in.label swap\n" "swap_in.type DERIVE\n" "swap_in.max 100000\n" "swap_in.min 0\n" "swap_in.graph no\n" "swap_out.label swap\n" "swap_out.type DERIVE\n" "swap_out.max 100000\n" "swap_out.min 0\n" "swap_out.negative swap_in"); print_warncrit("swap_in"); print_warncrit("swap_out"); return 0; } if (!strcmp(argv[1], "autoconf")) return autoconf_check_readable(PROC_STAT); } if ((f = fopen(PROC_VMSTAT, "r"))) { in = out = false; while (fgets(buff, 256, f)) { if (!in && !strncmp(buff, "pswpin ", 7)) { in = true; printf("swap_in.value %s", buff + 7); } else if (!out && !strncmp(buff, "pswpout ", 8)) { out = true; printf("swap_out.value %s", buff + 8); } } fclose(f); if (!(in && out)) return fail("no usable data on " PROC_VMSTAT); return 0; } else { if (!(f = fopen(PROC_STAT, "r"))) return fail("cannot open " PROC_STAT); while (fgets(buff, 256, f)) { if (!strncmp(buff, "swap ", 5)) { fclose(f); if (2 != sscanf(buff + 5, "%d %d", &inval, &outval)) return fail("bad data on " PROC_STAT); printf ("swap_in.value %d\nswap_out.value %d\n", inval, outval); return 0; } } fclose(f); return fail("no swap line found in " PROC_STAT); } } munin-c-0.0.13/src/plugins/threads.c000066400000000000000000000037631343165630300172240ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include #include #include #include #include "common.h" #include "plugins.h" int threads(int argc, char **argv) { FILE *f; char buff[270]; const char *s; int i, sum; DIR *d; struct dirent *e; if (argc > 1) { if (!strcmp(argv[1], "autoconf")) { i = getpid(); snprintf(buff, sizeof(buff), "/proc/%d/status", i); if (NULL == (f = fopen(buff, "r"))) return fail("failed to open /proc/$$/status"); while (fgets(buff, 256, f)) if (!strncmp(buff, "Threads:", 8)) { fclose(f); return writeyes(); } fclose(f); puts("no"); return 0; } if (!strcmp(argv[1], "config")) { puts("graph_title Number of threads\n" "graph_vlabel number of threads\n" "graph_category processes\n" "graph_info This graph shows the number of threads.\n" "threads.label threads\n" "threads.info The current number of threads."); return 0; } } if (NULL == (d = opendir("/proc"))) return fail("cannot open /proc"); sum = 0; while ((e = readdir(d))) { for (s = e->d_name; *s; ++s) if (!xisdigit(*s)) break; if (*s) /* non-digit found */ continue; snprintf(buff, 270, "/proc/%s/status", e->d_name); if (!(f = fopen(buff, "r"))) continue; /* process has vanished */ while (fgets(buff, 256, f)) { if (strncmp(buff, "Threads:", 8)) continue; if (1 != sscanf(buff + 8, "%d", &i)) { fclose(f); closedir(d); return fail("failed to parse " "/proc/somepid/status"); } sum += i; } fclose(f); } closedir(d); printf("threads.value %d\n", sum); return 0; } munin-c-0.0.13/src/plugins/uptime.c000066400000000000000000000021761343165630300170720ustar00rootroot00000000000000/* * Copyright (C) 2008-2013 Helmut Grohne - All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2 or v.3. */ /* This plugin is compatible with munin-mainline version 2.0.17. */ #include #include #include "common.h" #include "plugins.h" #define PROC_UPTIME "/proc/uptime" int uptime(int argc, char **argv) { FILE *f; float uptime; if (argc > 1) { if (!strcmp(argv[1], "config")) { puts("graph_title Uptime\n" "graph_args --base 1000 -l 0 \n" "graph_vlabel uptime in days\n" "graph_category system\n" "uptime.label uptime\n" "uptime.draw AREA"); print_warncrit("uptime"); return 0; } if (!strcmp(argv[1], "autoconf")) return writeyes(); } if (!(f = fopen(PROC_UPTIME, "r"))) return fail("cannot open " PROC_UPTIME); if (1 != fscanf(f, "%f", &uptime)) { fclose(f); return fail("cannot read from " PROC_UPTIME); } fclose(f); printf("uptime.value %.2f\n", uptime / 86400); return 0; } munin-c-0.0.13/systemd/000077500000000000000000000000001343165630300146355ustar00rootroot00000000000000munin-c-0.0.13/systemd/munin-node-c.socket000066400000000000000000000001121343165630300203320ustar00rootroot00000000000000[Socket] ListenStream=4949 Accept=true [Install] WantedBy=sockets.target munin-c-0.0.13/systemd/munin-node-c@.service000066400000000000000000000002561343165630300206130ustar00rootroot00000000000000[Unit] JoinsNamespaceOf=munin-node-daemon.service [Service] ExecStart=/usr/local/sbin/munin-node-c PrivateTmp=yes ProtectHome=yes StandardInput=socket StandardOutput=socket munin-c-0.0.13/systemd/munin-node-daemon.service000066400000000000000000000002241343165630300215270ustar00rootroot00000000000000[Unit] [Service] ExecStart=/usr/local/sbin/munin-node-c -a PrivateTmp=yes PrivateNetwork=no ProtectHome=yes [Install] WantedBy=multi-user.target munin-c-0.0.13/t/000077500000000000000000000000001343165630300134105ustar00rootroot00000000000000munin-c-0.0.13/t/Makefile.am000066400000000000000000000006451343165630300154510ustar00rootroot00000000000000# Copyright (C) 2014 Steve Schnepp - All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v.2 or v.3. # include $(top_srcdir)/common.am sbin_PROGRAMS = ok_plugin nb_env ok_plugin_SOURCES = ok_plugin.c common.c nb_env_SOURCES = nb_env.c common.c munin-c-0.0.13/t/common.c000066400000000000000000000003471343165630300150500ustar00rootroot00000000000000/* Simmle plugin framework */ #include #include "common.h" int main(int argc, const char *argv[]) { int is_config = (argc == 2) && (strcmp(argv[1], "config") == 0); return is_config ? emit_config() : emit_fetch(); } munin-c-0.0.13/t/common.h000066400000000000000000000002501343165630300150460ustar00rootroot00000000000000/* This is the forward API of all test plugins */ int emit_config(); int emit_fetch(); /* This is the common main function */ int main(int argc, const char* argv[]); munin-c-0.0.13/t/nb_env.c000066400000000000000000000011101343165630300150140ustar00rootroot00000000000000#include #include #include "common.h" extern char **environ; int count_env_nb() { int env_nb = 0; char **cur_environ = environ; while (*cur_environ) { env_nb++; cur_environ++; } return env_nb; } int emit_config() { printf("graph_title " __FILE__ "\n"); printf("env_nb.label Number of env vars\n"); return 0; } int emit_fetch() { char **cur_environ = environ; printf("env_nb.value %d\n", count_env_nb()); printf("env_nb.ext_info "); while (*cur_environ) { printf("{%s},", *cur_environ); cur_environ++; } printf("\n"); return 0; } munin-c-0.0.13/t/ok_plugin.c000066400000000000000000000005221343165630300155420ustar00rootroot00000000000000#include #include "common.h" int emit_config() { printf("graph_title " __FILE__ "\n"); printf("first_f.label This is the first field\n"); printf("second_f.label This is the second field\n"); return 0; } int emit_fetch() { printf("first_f.value %f\n", 1234.567); printf("second_f.value %f\n", -2345.678); return 0; }