initial commit of file from CVS for smeserver-sysmon on Sat Sep 7 21:06:49 AEST 2024
This commit is contained in:
parent
248b2e2a1b
commit
22691426e4
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.rpm
|
||||
*.log
|
||||
*spec-20*
|
||||
*.tar.gz
|
21
Makefile
Normal file
21
Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# Makefile for source rpm: smeserver-sysmon
|
||||
# $Id: Makefile,v 1.1 2020/10/29 17:41:54 brianr Exp $
|
||||
NAME := smeserver-sysmon
|
||||
SPECFILE = $(firstword $(wildcard *.spec))
|
||||
|
||||
define find-makefile-common
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(find-makefile-common))
|
||||
|
||||
ifeq ($(MAKEFILE_COMMON),)
|
||||
# attept a checkout
|
||||
define checkout-makefile-common
|
||||
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
|
||||
endif
|
||||
|
||||
include $(MAKEFILE_COMMON)
|
17
README.md
17
README.md
@ -1,3 +1,16 @@
|
||||
# smeserver-sysmon
|
||||
# <img src="https://www.koozali.org/images/koozali/Logo/Png/Koozali_logo_2016.png" width="25%" vertical="auto" style="vertical-align:bottom"> smeserver-sysmon
|
||||
|
||||
SMEServer Koozali developed git repo for smeserver-sysmon smecontribs
|
||||
SMEServer Koozali developed git repo for smeserver-sysmon smecontribs
|
||||
|
||||
## Wiki
|
||||
<br />https://wiki.koozali.org/Sysmon/fr
|
||||
<br />https://wiki.koozali.org/Sysmon
|
||||
|
||||
## Bugzilla
|
||||
Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-sysmon&product=SME%20Contribs&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
|
||||
|
||||
## Description
|
||||
|
||||
<br />*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.*
|
||||
*Once it has been checked, then this comment will be deleted*
|
||||
<br />
|
||||
|
340
additional/COPYING
Normal file
340
additional/COPYING
Normal file
@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
1
contriborbase
Normal file
1
contriborbase
Normal file
@ -0,0 +1 @@
|
||||
contribs10
|
28
createlinks
Normal file
28
createlinks
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use esmith::Build::CreateLinks qw(:all);
|
||||
use esmith::Build::Backup qw(:all);
|
||||
|
||||
panel_link("sysmon", "manager");
|
||||
# our event specific for updating with yum without reboot
|
||||
$event = 'smeserver-sysmon-update';
|
||||
#add here the path to your templates needed to expand
|
||||
#see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event
|
||||
|
||||
foreach my $file (qw(
|
||||
/etc/dar/DailyBackup.dcf
|
||||
/etc/systemd/system-preset/49-koozali.preset
|
||||
))
|
||||
{
|
||||
templates2events( $file, $event );
|
||||
};
|
||||
#action needed in case we have a systemd unit
|
||||
event_link('systemd-default', $event, '10');
|
||||
event_link('systemd-reload', $event, '50');
|
||||
#services we need to restart
|
||||
safe_symlink('restart',"root/etc/e-smith/events/$event/services2adjust/sysmon");
|
||||
|
||||
backup_includes("smeserver-sysmon", qw(
|
||||
/var/lib/rrd/
|
||||
));
|
||||
|
1
root/etc/e-smith/db/configuration/defaults/sysmon/status
Normal file
1
root/etc/e-smith/db/configuration/defaults/sysmon/status
Normal file
@ -0,0 +1 @@
|
||||
enabled
|
1
root/etc/e-smith/db/configuration/defaults/sysmon/type
Normal file
1
root/etc/e-smith/db/configuration/defaults/sysmon/type
Normal file
@ -0,0 +1 @@
|
||||
service
|
716
root/etc/e-smith/web/functions/sysmon
Normal file
716
root/etc/e-smith/web/functions/sysmon
Normal file
@ -0,0 +1,716 @@
|
||||
#!/usr/bin/perl -T
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Administration
|
||||
# description : System Monitor
|
||||
# navigation : 4000 4050
|
||||
#
|
||||
# copyright (C) 2002 Shad L. Lords <slords@mail.com>
|
||||
# copyright (C) 2001 Eneo Tecnologia SC. <jjptapia@eresmas.com>
|
||||
# Distributed under the GPL license.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
#use strict;
|
||||
use CGI ':all';
|
||||
use CGI::Carp qw(fatalsToBrowser);
|
||||
|
||||
use esmith::cgi;
|
||||
use esmith::config;
|
||||
use esmith::util;
|
||||
use esmith::db;
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$ENV {'PATH'} = '';
|
||||
$ENV {'SHELL'} = '/bin/bash';
|
||||
delete $ENV {'ENV'};
|
||||
}
|
||||
esmith::util::setRealToEffective ();
|
||||
|
||||
$scriptname = 'sysmon';
|
||||
|
||||
$RRDDIR = '/var/lib/rrd';
|
||||
$RRDFILE = 'sysmon';
|
||||
$HOSTFILE = 'host_';
|
||||
$IFACEFILE = 'iface_';
|
||||
$SENSORSFILE = 'sensors';
|
||||
$UPSFILE = 'ups';
|
||||
|
||||
my %conf;
|
||||
tie %conf, 'esmith::config';
|
||||
my $hosts = db_get_prop(\%conf, $RRDFILE, 'hosts') || "gateway";
|
||||
my $pingscale = db_get_prop(\%conf, $RRDFILE, 'pingscale') || "300";
|
||||
my $maxping = db_get_prop(\%conf, $RRDFILE, 'maxping') || "400";
|
||||
$maxping -= 0.01;
|
||||
|
||||
$sechour = 24000;
|
||||
$secday = 120000;
|
||||
$secweek = 720000;
|
||||
$secmonth = 2880000;
|
||||
$secyear = 34560000;
|
||||
|
||||
$graphwidth = 401;
|
||||
$graphheight = 160;
|
||||
|
||||
$TITLE = 'System Monitor';
|
||||
$MINUTE = 'Minute';
|
||||
$HOUR = 'Hour';
|
||||
$HOURLY = 'Hourly';
|
||||
$DAY = 'Day';
|
||||
$DAILY = 'Daily';
|
||||
$WEEKLY = 'Weekly';
|
||||
$MONTHLY = 'Monthly';
|
||||
$GRAPH = 'Graph';
|
||||
$YEARLY = 'Yearly';
|
||||
$MAXIMAL = 'Maximal';
|
||||
$AVERAGE = 'Average';
|
||||
$CURRENT = 'Current';
|
||||
|
||||
$CPU = "CPU";
|
||||
$LOADCPU = "Load/CPU";
|
||||
$MEM = "Memory";
|
||||
$TEMP = "Temp";
|
||||
$UPS = "UPS";
|
||||
$PROCQUE = "Proc/Que";
|
||||
$HD = "Drives";
|
||||
$VOLTAGE = "Volt";
|
||||
$FAN = "Fan";
|
||||
$UPTIME = "Uptime";
|
||||
|
||||
my $RRDCMD = "/usr/bin/rrdtool graph - -a 'PNG' -w '600' -h '250' --color 'SHADEA#ffffff' --color 'SHADEB#ffffff' --color 'BACK#ffffff' --color 'CANVAS#ffffff' -r -E -M ";
|
||||
|
||||
$CPU_GRAPH = "-b '1000' -l '0' ";
|
||||
$CPU_GRAPH .= "-t 'CPU<D> Utilitization' ";
|
||||
$CPU_GRAPH .= "-v 'CPU (%)' ";
|
||||
$CPU_GRAPH .= "'DEF:avgsystem=$RRDDIR/$RRDFILE.rrd:system<D>:AVERAGE' ";
|
||||
$CPU_GRAPH .= "'DEF:maxsystem=$RRDDIR/$RRDFILE.rrd:system<D>:MAX' ";
|
||||
$CPU_GRAPH .= "'DEF:avguser=$RRDDIR/$RRDFILE.rrd:user<D>:AVERAGE' ";
|
||||
$CPU_GRAPH .= "'DEF:maxuser=$RRDDIR/$RRDFILE.rrd:user<D>:MAX' ";
|
||||
$CPU_GRAPH .= "'DEF:avgiowait=$RRDDIR/$RRDFILE.rrd:iowait<D>:AVERAGE' ";
|
||||
$CPU_GRAPH .= "'DEF:maxiowait=$RRDDIR/$RRDFILE.rrd:iowait<D>:MAX' ";
|
||||
$CPU_GRAPH .= "'DEF:avgnice=$RRDDIR/$RRDFILE.rrd:nice<D>:AVERAGE' ";
|
||||
$CPU_GRAPH .= "'DEF:maxnice=$RRDDIR/$RRDFILE.rrd:nice<D>:MAX' ";
|
||||
$CPU_GRAPH .= "'CDEF:avgadjsystem=avgsystem,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:maxadjsystem=maxsystem,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:avgadjuser=avguser,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:maxadjuser=maxuser,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:avgadjiowait=avgiowait,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:maxadjiowait=maxiowait,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:avgadjnice=avgnice,100,*' ";
|
||||
$CPU_GRAPH .= "'CDEF:maxadjnice=maxnice,100,*' ";
|
||||
$CPU_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg\\n' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjuser:LAST:%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjuser:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:maxadjuser:MAX:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$CPU_GRAPH .= "'AREA:avgadjuser#009900:\\tUser (%)\\n' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjnice:LAST:%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjnice:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:maxadjnice:MAX:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$CPU_GRAPH .= "'AREA:avgadjnice#FFFF00:\\tNice (%)\\n:STACK' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjsystem:LAST:%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjsystem:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:maxadjsystem:MAX:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$CPU_GRAPH .= "'AREA:avgadjsystem#000080:\\tSystem (%)\\n:STACK' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjiowait:LAST:%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:avgadjiowait:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'GPRINT:maxadjiowait:MAX:\\t%6.2lf\\g' ";
|
||||
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$CPU_GRAPH .= "'AREA:avgadjiowait#FF0000:\\tIO Wait (%)\\n:STACK' ";
|
||||
|
||||
$LOADCPU_GRAPH = "-b '1000' -l '0' ";
|
||||
$LOADCPU_GRAPH .= "-t 'System Load / %CPU' ";
|
||||
$LOADCPU_GRAPH .= "-v 'Load*30 / %CPU' ";
|
||||
$LOADCPU_GRAPH .= "'DEF:avgload=$RRDDIR/$RRDFILE.rrd:ldavg-1:AVERAGE' ";
|
||||
$LOADCPU_GRAPH .= "'DEF:maxload=$RRDDIR/$RRDFILE.rrd:ldavg-1:MAX' ";
|
||||
$LOADCPU_GRAPH .= "'DEF:avgtotalcpu=$RRDDIR/$RRDFILE.rrd:total:AVERAGE' ";
|
||||
$LOADCPU_GRAPH .= "'DEF:maxtotalcpu=$RRDDIR/$RRDFILE.rrd:total:MAX' ";
|
||||
$LOADCPU_GRAPH .= "'CDEF:avgadjload=avgload,30,*' ";
|
||||
$LOADCPU_GRAPH .= "'CDEF:maxadjload=maxload,30,*' ";
|
||||
$LOADCPU_GRAPH .= "'CDEF:diffadjload=maxadjload,avgadjload,-' ";
|
||||
$LOADCPU_GRAPH .= "'CDEF:avgadjtotalcpu=avgtotalcpu,100,*' ";
|
||||
$LOADCPU_GRAPH .= "'CDEF:maxadjtotalcpu=maxtotalcpu,100,*' ";
|
||||
$LOADCPU_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg<\\tPeak>\\n' ";
|
||||
$LOADCPU_GRAPH .= "'GPRINT:avgload:LAST:%6.3lf\\g' ";
|
||||
$LOADCPU_GRAPH .= "'GPRINT:avgload:AVERAGE:\\t%6.3lf\\g' ";
|
||||
$LOADCPU_GRAPH .= "'GPRINT:maxload:MAX:\\t%6.3lf\\g' ";
|
||||
$LOADCPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$LOADCPU_GRAPH .= "'AREA:avgadjload#00FF00:\\t{Load\\n}<\\g>' ";
|
||||
$LOADCPU_GRAPH .= "<'AREA:diffadjload#006400:\\tLoad\\n:STACK'> ";
|
||||
$LOADCPU_GRAPH .= "'GPRINT:avgadjtotalcpu:LAST:%6.2lf\\g' ";
|
||||
$LOADCPU_GRAPH .= "'GPRINT:avgadjtotalcpu:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$LOADCPU_GRAPH .= "'GPRINT:maxadjtotalcpu:MAX:\\t%6.2lf\\g' ";
|
||||
$LOADCPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$LOADCPU_GRAPH .= "'LINE1:avgadjtotalcpu#1000FF:\\t{CPU (%)\\n}<\\g>' ";
|
||||
$LOADCPU_GRAPH .= "<'LINE1:maxadjtotalcpu#000080:\\tCPU (%)\\n'> ";
|
||||
$LOADCPU_MAX = 'week month year';
|
||||
|
||||
$PROCQUE_GRAPH = "-b '1000' -l '0' ";
|
||||
$PROCQUE_GRAPH .= "-t 'System Processes / Run Queue' ";
|
||||
$PROCQUE_GRAPH .= "-v 'Processes / Queue*10' ";
|
||||
$PROCQUE_GRAPH .= "'DEF:avgplist=$RRDDIR/$RRDFILE.rrd:plist-sz:AVERAGE' ";
|
||||
$PROCQUE_GRAPH .= "'DEF:maxplist=$RRDDIR/$RRDFILE.rrd:plist-sz:MAX' ";
|
||||
$PROCQUE_GRAPH .= "'DEF:avgrunq=$RRDDIR/$RRDFILE.rrd:runq-sz:AVERAGE' ";
|
||||
$PROCQUE_GRAPH .= "'DEF:maxrunq=$RRDDIR/$RRDFILE.rrd:runq-sz:MAX' ";
|
||||
$PROCQUE_GRAPH .= "'CDEF:avgadjrunq=avgrunq,10,*' ";
|
||||
$PROCQUE_GRAPH .= "'CDEF:maxadjrunq=maxrunq,10,*' ";
|
||||
$PROCQUE_GRAPH .= "'CDEF:diffplist=maxplist,avgplist,-' ";
|
||||
$PROCQUE_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg<\\tPeak>\\n' ";
|
||||
$PROCQUE_GRAPH .= "'GPRINT:avgplist:LAST:%6.1lf\\g' ";
|
||||
$PROCQUE_GRAPH .= "'GPRINT:avgplist:AVERAGE:\\t%6.1lf\\g' ";
|
||||
$PROCQUE_GRAPH .= "'GPRINT:maxplist:MAX:\\t%6.1lf\\g' ";
|
||||
$PROCQUE_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$PROCQUE_GRAPH .= "'AREA:avgplist#00FF00:\\t{Processes\\n}<\\g>' ";
|
||||
$PROCQUE_GRAPH .= "<'AREA:diffplist#006400:\\tProcesses\\n:STACK'> ";
|
||||
$PROCQUE_GRAPH .= "'GPRINT:avgrunq:LAST:%6.2lf\\g' ";
|
||||
$PROCQUE_GRAPH .= "'GPRINT:avgrunq:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$PROCQUE_GRAPH .= "'GPRINT:maxrunq:MAX:\\t%6.2lf\\g' ";
|
||||
$PROCQUE_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$PROCQUE_GRAPH .= "'LINE1:avgadjrunq#1000FF:\\t{Run Queue\\n}<\\g>' ";
|
||||
$PROCQUE_GRAPH .= "<'LINE1:maxadjrunq#000080:\\tRun Queue\\n'> ";
|
||||
$PROCQUE_MAX = 'week month year';
|
||||
|
||||
$MEM_GRAPH = "-b '1024' -l '0' ";
|
||||
$MEM_GRAPH .= "-t 'Memory Utilization' ";
|
||||
$MEM_GRAPH .= "-v 'Bytes' ";
|
||||
$MEM_GRAPH .= "'DEF:minmemused=$RRDDIR/$RRDFILE.rrd:memused:MIN' ";
|
||||
$MEM_GRAPH .= "'DEF:avgmemused=$RRDDIR/$RRDFILE.rrd:memused:AVERAGE' ";
|
||||
$MEM_GRAPH .= "'DEF:maxmemused=$RRDDIR/$RRDFILE.rrd:memused:MAX' ";
|
||||
$MEM_GRAPH .= "'DEF:minmembuffers=$RRDDIR/$RRDFILE.rrd:buffers:MIN' ";
|
||||
$MEM_GRAPH .= "'DEF:avgmembuffers=$RRDDIR/$RRDFILE.rrd:buffers:AVERAGE' ";
|
||||
$MEM_GRAPH .= "'DEF:maxmembuffers=$RRDDIR/$RRDFILE.rrd:buffers:MAX' ";
|
||||
$MEM_GRAPH .= "'DEF:minmemcached=$RRDDIR/$RRDFILE.rrd:cached:MIN' ";
|
||||
$MEM_GRAPH .= "'DEF:avgmemcached=$RRDDIR/$RRDFILE.rrd:cached:AVERAGE' ";
|
||||
$MEM_GRAPH .= "'DEF:maxmemcached=$RRDDIR/$RRDFILE.rrd:cached:MAX' ";
|
||||
$MEM_GRAPH .= "'DEF:minmemfree=$RRDDIR/$RRDFILE.rrd:memfree:MIN' ";
|
||||
$MEM_GRAPH .= "'DEF:avgmemfree=$RRDDIR/$RRDFILE.rrd:memfree:AVERAGE' ";
|
||||
$MEM_GRAPH .= "'DEF:maxmemfree=$RRDDIR/$RRDFILE.rrd:memfree:MAX' ";
|
||||
$MEM_GRAPH .= "'DEF:minswapused=$RRDDIR/$RRDFILE.rrd:swpused:MIN' ";
|
||||
$MEM_GRAPH .= "'DEF:avgswapused=$RRDDIR/$RRDFILE.rrd:swpused:AVERAGE' ";
|
||||
$MEM_GRAPH .= "'DEF:maxswapused=$RRDDIR/$RRDFILE.rrd:swpused:MAX' ";
|
||||
$MEM_GRAPH .= "'CDEF:minmemactualfree=minmemfree,minmembuffers,-,minmemcached,-' ";
|
||||
$MEM_GRAPH .= "'CDEF:avgmemactualfree=avgmemfree,avgmembuffers,-,avgmemcached,-' ";
|
||||
$MEM_GRAPH .= "'CDEF:maxmemactualfree=maxmemfree,maxmembuffers,-,maxmemcached,-' ";
|
||||
$MEM_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmemused:LAST:%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:minmemused:MIN:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmemused:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:maxmemused:MAX:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$MEM_GRAPH .= "'AREA:avgmemused#000080:\\tUsed (bytes)\\n' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmembuffers:LAST:%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:minmembuffers:MIN:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmembuffers:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:maxmembuffers:MAX:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$MEM_GRAPH .= "'AREA:avgmembuffers#1000FF:\\tBuffers (bytes)\\n:STACK' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmemcached:LAST:%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:minmemcached:MIN:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmemcached:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:maxmemcached:MAX:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$MEM_GRAPH .= "'AREA:avgmemcached#006600:\\tCache (bytes)\\n:STACK' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmemactualfree:LAST:%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:minmemactualfree:MIN:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgmemactualfree:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:maxmemactualfree:MAX:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$MEM_GRAPH .= "'AREA:avgmemactualfree#00FF00:\\tFree (bytes)\\n:STACK' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgswapused:LAST:%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:minswapused:MIN:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:avgswapused:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'GPRINT:maxswapused:MAX:\\t%5.0lf%S\\g' ";
|
||||
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$MEM_GRAPH .= "'LINE2:avgswapused#FF0000:\\tSwap (bytes)\\n' ";
|
||||
|
||||
$HD_GRAPH = "-b '1024' -l '0' ";
|
||||
$HD_GRAPH .= "-t 'Hard Drive Usage' ";
|
||||
$HD_GRAPH .= "-v 'Bytes' ";
|
||||
$HD_GRAPH .= "'DEF:minhdused=$RRDDIR/$RRDFILE.rrd:hdused:MIN' ";
|
||||
$HD_GRAPH .= "'DEF:avghdused=$RRDDIR/$RRDFILE.rrd:hdused:AVERAGE' ";
|
||||
$HD_GRAPH .= "'DEF:maxhdused=$RRDDIR/$RRDFILE.rrd:hdused:MAX' ";
|
||||
$HD_GRAPH .= "'DEF:minhdfree=$RRDDIR/$RRDFILE.rrd:hdfree:MIN' ";
|
||||
$HD_GRAPH .= "'DEF:avghdfree=$RRDDIR/$RRDFILE.rrd:hdfree:AVERAGE' ";
|
||||
$HD_GRAPH .= "'DEF:maxhdfree=$RRDDIR/$RRDFILE.rrd:hdfree:MAX' ";
|
||||
$HD_GRAPH .= "'CDEF:diffhdused=maxhdused,avghdused,-' ";
|
||||
$HD_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' ";
|
||||
$HD_GRAPH .= "'GPRINT:avghdused:LAST:%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'GPRINT:minhdused:MIN:\\t%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'GPRINT:avghdused:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'GPRINT:maxhdused:MAX:\\t%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$HD_GRAPH .= "'AREA:avghdused#000080:\\tUsed (bytes)\\n' ";
|
||||
$HD_GRAPH .= "'GPRINT:avghdfree:LAST:%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'GPRINT:minhdfree:MIN:\\t%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'GPRINT:avghdfree:AVERAGE:\\t%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'GPRINT:maxhdfree:MAX:\\t%5.0lf%S\\g' ";
|
||||
$HD_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$HD_GRAPH .= "'AREA:avghdfree#00FF00:\\tFree (bytes)\\n:STACK' ";
|
||||
|
||||
$UPTIME_GRAPH = "-b '1000' -l '0' ";
|
||||
$UPTIME_GRAPH .= "-t 'Uptime' ";
|
||||
$UPTIME_GRAPH .= "-v 'Days' ";
|
||||
$UPTIME_GRAPH .= "'DEF:avguptime=$RRDDIR/$RRDFILE.rrd:uptime:AVERAGE' ";
|
||||
$UPTIME_GRAPH .= "'DEF:maxuptime=$RRDDIR/$RRDFILE.rrd:uptime:MAX' ";
|
||||
$UPTIME_GRAPH .= "'CDEF:avgdays=avguptime,86400,/' ";
|
||||
$UPTIME_GRAPH .= "'CDEF:maxdays=maxuptime,86400,/' ";
|
||||
$UPTIME_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg\\n' ";
|
||||
$UPTIME_GRAPH .= "'GPRINT:avgdays:LAST:%6.1lf\\g' ";
|
||||
$UPTIME_GRAPH .= "'GPRINT:avgdays:AVERAGE:\\t%6.1lf\\g' ";
|
||||
$UPTIME_GRAPH .= "'GPRINT:maxdays:MAX:\\t%6.1lf\\g' ";
|
||||
$UPTIME_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPTIME_GRAPH .= "'AREA:avgdays#00FF00:\\tUptime (days)\\n' ";
|
||||
$UPTIME_GRAPH .= "'LINE1:avgdays#1000FF' ";
|
||||
|
||||
$LATENCY_GRAPH = "-b '1000' -l '0' ";
|
||||
$LATENCY_GRAPH = "-t 'Latency / Packet Loss (<D>)' ";
|
||||
$LATENCY_GRAPH .= "-v 'ms / % (${pingscale}ms = 100%)' ";
|
||||
$LATENCY_GRAPH .= "'DEF:minlatency=$RRDDIR/$HOSTFILE<D>.rrd:median:MIN' ";
|
||||
$LATENCY_GRAPH .= "'DEF:avglatency=$RRDDIR/$HOSTFILE<D>.rrd:median:AVERAGE' ";
|
||||
$LATENCY_GRAPH .= "'DEF:maxlatency=$RRDDIR/$HOSTFILE<D>.rrd:median:MAX' ";
|
||||
$LATENCY_GRAPH .= "'DEF:minloss=$RRDDIR/$HOSTFILE<D>.rrd:loss:MIN' ";
|
||||
$LATENCY_GRAPH .= "'DEF:avgloss=$RRDDIR/$HOSTFILE<D>.rrd:loss:AVERAGE' ";
|
||||
$LATENCY_GRAPH .= "'DEF:maxloss=$RRDDIR/$HOSTFILE<D>.rrd:loss:MAX' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:minmslatency=minlatency,1000,*' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:avgmslatency=avglatency,1000,*' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:maxmslatency=maxlatency,1000,*' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:avgadjlatency=avglatency,${maxping},1000,/,MIN' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:maxadjlatency=maxlatency,${maxping},1000,/,MIN' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:diffadjlatency=maxadjlatency,avgadjlatency,-' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:avgadjloss=avgloss,25000,/,${pingscale},*' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:maxadjloss=maxloss,25000,/,${pingscale},*' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:minrealloss=minloss,.25000,/,' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:avgrealloss=avgloss,.25000,/,' ";
|
||||
$LATENCY_GRAPH .= "'CDEF:maxrealloss=maxloss,.25000,/,' ";
|
||||
$LATENCY_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg<\\tPeak>\\n' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:avgmslatency:LAST:%6.1lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:minmslatency:MIN:\\t%6.1lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:avgmslatency:AVERAGE:\\t%6.1lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:maxmslatency:MAX:\\t%6.1lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$LATENCY_GRAPH .= "'AREA:avgadjlatency#00FF00:\\t{Latency (ms)\\n}<\\g>' ";
|
||||
$LATENCY_GRAPH .= "<'AREA:diffadjlatency#006400:\\tLatency (ms)\\n:STACK'> ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:avgrealloss:LAST:%6.2lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:minrealloss:MIN:\\t%6.2lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:avgrealloss:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'GPRINT:maxrealloss:MAX:\\t%6.2lf\\g' ";
|
||||
$LATENCY_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$LATENCY_GRAPH .= "'LINE1:avgadjloss#1000FF:\\t{Loss (%)\\n}<\\g>' ";
|
||||
$LATENCY_GRAPH .= "<'LINE1:maxadjloss#000080:\\tLoss (%)\\n'> ";
|
||||
$LATENCY_MAX = 'week month year';
|
||||
|
||||
$IFACE_GRAPH = "-b '1024' -l '0' ";
|
||||
$IFACE_GRAPH = "-t 'Ethernet Traffic (<D>)' ";
|
||||
$IFACE_GRAPH .= "-v 'kB/s' ";
|
||||
$IFACE_GRAPH .= "'DEF:minbin=$RRDDIR/$IFACEFILE<D>.rrd:rxkB:MIN' ";
|
||||
$IFACE_GRAPH .= "'DEF:avgbin=$RRDDIR/$IFACEFILE<D>.rrd:rxkB:AVERAGE' ";
|
||||
$IFACE_GRAPH .= "'DEF:maxbin=$RRDDIR/$IFACEFILE<D>.rrd:rxkB:MAX' ";
|
||||
$IFACE_GRAPH .= "'DEF:minbout=$RRDDIR/$IFACEFILE<D>.rrd:txkB:MIN' ";
|
||||
$IFACE_GRAPH .= "'DEF:avgbout=$RRDDIR/$IFACEFILE<D>.rrd:txkB:AVERAGE' ";
|
||||
$IFACE_GRAPH .= "'DEF:maxbout=$RRDDIR/$IFACEFILE<D>.rrd:txkB:MAX' ";
|
||||
$IFACE_GRAPH .= "'CDEF:diffbin=maxbin,avgbin,-' ";
|
||||
$IFACE_GRAPH .= "'COMMENT: ' ";
|
||||
$IFACE_GRAPH .= "'AREA:avgbin#00FF00:Inbound' ";
|
||||
$IFACE_GRAPH .= "<'STACK:diffbin#006400: '> ";
|
||||
$IFACE_GRAPH .= "{'COMMENT: '} ";
|
||||
$IFACE_GRAPH .= "'LINE1:avgbout#1000FF:Outbound' ";
|
||||
$IFACE_GRAPH .= "<'LINE1:maxbout#000080: '> ";
|
||||
$IFACE_GRAPH .= "'COMMENT:\\n' ";
|
||||
$IFACE_GRAPH .= "'COMMENT: Max\\: ' ";
|
||||
$IFACE_GRAPH .= "'GPRINT:maxbin:MAX:%6.2lf %skB/s' ";
|
||||
$IFACE_GRAPH .= "'GPRINT:maxbout:MAX:< > %6.2lf %skB/s' ";
|
||||
$IFACE_GRAPH .= "'COMMENT:\\n' ";
|
||||
$IFACE_GRAPH .= "'COMMENT: Avg\\: ' ";
|
||||
$IFACE_GRAPH .= "'GPRINT:avgbin:AVERAGE:%6.2lf %skB/s' ";
|
||||
$IFACE_GRAPH .= "'GPRINT:avgbout:AVERAGE:< > %6.2lf %skB/s' ";
|
||||
$IFACE_GRAPH .= "'COMMENT:\\n' ";
|
||||
$IFACE_GRAPH .= "'COMMENT:Last\\: ' ";
|
||||
$IFACE_GRAPH .= "'GPRINT:avgbin:LAST:%6.2lf %skB/s' ";
|
||||
$IFACE_GRAPH .= "'GPRINT:avgbout:LAST:< > %6.2lf %skB/s' ";
|
||||
$IFACE_MAX = 'week month year';
|
||||
|
||||
$VOLTAGE_GRAPH = "-b '1000' ";
|
||||
$VOLTAGE_GRAPH .= "-t 'System Sensors (Voltage)' ";
|
||||
$VOLTAGE_GRAPH .= "-v 'Volts' ";
|
||||
my @color = ('CC0099', 'FF99CC', '0000FF', '8B4513', 'DAA520', 'FF0000', 'FFFF00','0000FF', '999999', '000000');
|
||||
my $sensortest = `/usr/bin/rrdtool fetch $RRDDIR/$SENSORSFILE.rrd AVERAGE -s -0 |/usr/bin/head -n1| /usr/bin/tr -s ' '| /usr/bin/tr -d '\n'`;
|
||||
my @sensorarr = split / /, $sensortest;
|
||||
my %params = map { $_ => 1 } @sensorarr;
|
||||
my $isvolt = "";
|
||||
for (my $i=0; $i <= 8; $i++) {
|
||||
if(exists($params{"in$i"})) {
|
||||
$VOLTAGE_GRAPH .= "'DEF:minin$i=$RRDDIR/$SENSORSFILE.rrd:in$i:MIN' ";
|
||||
$VOLTAGE_GRAPH .= "'DEF:avgin$i=$RRDDIR/$SENSORSFILE.rrd:in$i:AVERAGE' ";
|
||||
$VOLTAGE_GRAPH .= "'DEF:maxin$i=$RRDDIR/$SENSORSFILE.rrd:in$i:MAX' ";
|
||||
$VOLTAGE_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' " if $i == 0;
|
||||
$VOLTAGE_GRAPH .= "'GPRINT:avgin$i:LAST:%6.2lf\\g' ";
|
||||
$VOLTAGE_GRAPH .= "'GPRINT:minin$i:MIN:\\t%6.2lf\\g' ";
|
||||
$VOLTAGE_GRAPH .= "'GPRINT:avgin$i:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$VOLTAGE_GRAPH .= "'GPRINT:maxin$i:MAX:\\t%6.2lf\\g' ";
|
||||
$VOLTAGE_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$VOLTAGE_GRAPH .= "'LINE2:avgin0#".$color[$i].":\\tVoltage $i (V)\\n' ";
|
||||
$isvolt=1;
|
||||
}
|
||||
}
|
||||
|
||||
$FAN_GRAPH = "-b '1000' ";
|
||||
$FAN_GRAPH .= "-t 'System Sensors (Fans)' ";
|
||||
$FAN_GRAPH .= "-v 'RPM' ";
|
||||
my $isfan = "";
|
||||
for (my $i=1; $i <= 3; $i++) {
|
||||
if(exists($params{"fan$i"})) {
|
||||
$FAN_GRAPH .= "'DEF:minfan$i=$RRDDIR/$SENSORSFILE.rrd:fan$i:MIN' ";
|
||||
$FAN_GRAPH .= "'DEF:avgfan$i=$RRDDIR/$SENSORSFILE.rrd:fan$i:AVERAGE' ";
|
||||
$FAN_GRAPH .= "'DEF:maxfan$i=$RRDDIR/$SENSORSFILE.rrd:fan$i:MAX' ";
|
||||
$FAN_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' " if $i == 1;
|
||||
$FAN_GRAPH .= "'GPRINT:avgfan$i:LAST:%6.2lf\\g' ";
|
||||
$FAN_GRAPH .= "'GPRINT:minfan$i:MIN:\\t%6.2lf\\g' ";
|
||||
$FAN_GRAPH .= "'GPRINT:avgfan$i:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$FAN_GRAPH .= "'GPRINT:maxfan$i:MAX:\\t%6.2lf\\g' ";
|
||||
$FAN_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$FAN_GRAPH .= "'LINE2:avgfan$i#".$color[$i].":\\tFan $i (rpm)\\n' ";
|
||||
$isfan=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$TEMP_GRAPH = "-b '1000' ";
|
||||
$TEMP_GRAPH .= "-t 'System Sensors (Temperature)' ";
|
||||
$TEMP_GRAPH .= "-v '°C' ";
|
||||
my $istemp = "";
|
||||
for (my $i=0; $i <= 8; $i++) {
|
||||
if(exists($params{"temp$i"})) {
|
||||
$TEMP_GRAPH .= "'DEF:mintemp$i=$RRDDIR/$SENSORSFILE.rrd:temp$i:MIN' ";
|
||||
$TEMP_GRAPH .= "'DEF:avgtemp$i=$RRDDIR/$SENSORSFILE.rrd:temp$i:AVERAGE' ";
|
||||
$TEMP_GRAPH .= "'DEF:maxtemp$i=$RRDDIR/$SENSORSFILE.rrd:temp$i:MAX' ";
|
||||
$TEMP_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' " if $i == 0;
|
||||
$TEMP_GRAPH .= "'GPRINT:avgtemp$i:LAST:%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:mintemp$i:MIN:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:avgtemp$i:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:maxtemp$i:MAX:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$TEMP_GRAPH .= "'LINE2:avgtemp$i#".$color[$i].":\\tTemp $i (°C)\\n' ";
|
||||
$istemp=1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( -e "$RRDDIR/${UPSFILE}1.rrd" )
|
||||
{
|
||||
$TEMP_GRAPH .= "'DEF:minups1temp=$RRDDIR/${UPSFILE}1.rrd:u_temperature:MIN' ";
|
||||
$TEMP_GRAPH .= "'DEF:avgups1temp=$RRDDIR/${UPSFILE}1.rrd:u_temperature:AVERAGE' ";
|
||||
$TEMP_GRAPH .= "'DEF:maxups1temp=$RRDDIR/${UPSFILE}1.rrd:u_temperature:MAX' ";
|
||||
}
|
||||
if ( -e "$RRDDIR/${UPSFILE}2.rrd" )
|
||||
{
|
||||
$TEMP_GRAPH .= "'DEF:minups2temp=$RRDDIR/${UPSFILE}2.rrd:u_temperature:MIN' ";
|
||||
$TEMP_GRAPH .= "'DEF:avgups2temp=$RRDDIR/${UPSFILE}2.rrd:u_temperature:AVERAGE' ";
|
||||
$TEMP_GRAPH .= "'DEF:maxups2temp=$RRDDIR/${UPSFILE}2.rrd:u_temperature:MAX' ";
|
||||
}
|
||||
|
||||
if ( -e "$RRDDIR/${UPSFILE}1.rrd" ) {
|
||||
$TEMP_GRAPH .= "'GPRINT:avgups1temp:LAST:%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:minups1temp:MIN:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:avgups1temp:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:maxups1temp:MAX:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$TEMP_GRAPH .= "'LINE2:avgups1temp#999999:\\tUPS 1 (°C)\\n' ";
|
||||
}
|
||||
|
||||
if ( -e "$RRDDIR/${UPSFILE}2.rrd" ) {
|
||||
$TEMP_GRAPH .= "'GPRINT:avgups2temp:LAST:%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:minups2temp:MIN:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:avgups2temp:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'GPRINT:maxups2temp:MAX:\\t%6.2lf\\g' ";
|
||||
$TEMP_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$TEMP_GRAPH .= "'LINE2:avgups2temp#333333:\\tUPS 2 (°C)\\n' ";
|
||||
}
|
||||
|
||||
$UPS_GRAPH = "-b '1000' -l '0' ";
|
||||
$UPS_GRAPH .= "-t 'UPS<D> Statistics' ";
|
||||
$UPS_GRAPH .= "-v 'V / % / Minutes / °C' ";
|
||||
$UPS_GRAPH .= "'DEF:minlinev=$RRDDIR/$UPSFILE<D>.rrd:i_voltage:MIN' ";
|
||||
$UPS_GRAPH .= "'DEF:avglinev=$RRDDIR/$UPSFILE<D>.rrd:i_voltage:AVERAGE' ";
|
||||
$UPS_GRAPH .= "'DEF:maxlinev=$RRDDIR/$UPSFILE<D>.rrd:i_voltage:MAX' ";
|
||||
$UPS_GRAPH .= "'DEF:minloadpct=$RRDDIR/$UPSFILE<D>.rrd:u_load:MIN' ";
|
||||
$UPS_GRAPH .= "'DEF:avgloadpct=$RRDDIR/$UPSFILE<D>.rrd:u_load:AVERAGE' ";
|
||||
$UPS_GRAPH .= "'DEF:maxloadpct=$RRDDIR/$UPSFILE<D>.rrd:u_load:MAX' ";
|
||||
$UPS_GRAPH .= "'DEF:minbcharge=$RRDDIR/$UPSFILE<D>.rrd:b_charge:MIN' ";
|
||||
$UPS_GRAPH .= "'DEF:avgbcharge=$RRDDIR/$UPSFILE<D>.rrd:b_charge:AVERAGE' ";
|
||||
$UPS_GRAPH .= "'DEF:maxbcharge=$RRDDIR/$UPSFILE<D>.rrd:b_charge:MAX' ";
|
||||
$UPS_GRAPH .= "'DEF:mintimeleft=$RRDDIR/$UPSFILE<D>.rrd:b_runtime:MIN' ";
|
||||
$UPS_GRAPH .= "'DEF:avgtimeleft=$RRDDIR/$UPSFILE<D>.rrd:b_runtime:AVERAGE' ";
|
||||
$UPS_GRAPH .= "'DEF:maxtimeleft=$RRDDIR/$UPSFILE<D>.rrd:b_runtime:MAX' ";
|
||||
$UPS_GRAPH .= "'DEF:minbattv=$RRDDIR/$UPSFILE<D>.rrd:b_voltage:MIN' ";
|
||||
$UPS_GRAPH .= "'DEF:avgbattv=$RRDDIR/$UPSFILE<D>.rrd:b_voltage:AVERAGE' ";
|
||||
$UPS_GRAPH .= "'DEF:maxbattv=$RRDDIR/$UPSFILE<D>.rrd:b_voltage:MAX' ";
|
||||
$UPS_GRAPH .= "'DEF:minitemp=$RRDDIR/$UPSFILE<D>.rrd:u_temperature:MIN' ";
|
||||
$UPS_GRAPH .= "'DEF:avgitemp=$RRDDIR/$UPSFILE<D>.rrd:u_temperature:AVERAGE' ";
|
||||
$UPS_GRAPH .= "'DEF:maxitemp=$RRDDIR/$UPSFILE<D>.rrd:u_temperature:MAX' ";
|
||||
$UPS_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avglinev:LAST:%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:minlinev:MIN:\\t%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avglinev:AVERAGE:\\t%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:maxlinev:MAX:\\t%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPS_GRAPH .= "'LINE2:avglinev#0000FF:\\tIncoming (V)\\n' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgbattv:LAST:%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:minbattv:MIN:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgbattv:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:maxbattv:MAX:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPS_GRAPH .= "'LINE2:avgbattv#DAA520:\\tBattery (V)\\n' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgbcharge:LAST:%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:minbcharge:MIN:\\t%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgbcharge:AVERAGE:\\t%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:maxbcharge:MAX:\\t%6.1lf\\g' ";
|
||||
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPS_GRAPH .= "'LINE2:avgbcharge#FF0000:\\tCharge (%)\\n' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgtimeleft:LAST:%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:mintimeleft:MIN:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgtimeleft:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:maxtimeleft:MAX:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPS_GRAPH .= "'LINE2:avgtimeleft#999999:\\tRuntime (min)\\n' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgloadpct:LAST:%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:minloadpct:MIN:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgloadpct:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:maxloadpct:MAX:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPS_GRAPH .= "'LINE2:avgloadpct#8B4513:\\tLoad (%)\\n' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgitemp:LAST:%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:minitemp:MIN:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:avgitemp:AVERAGE:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'GPRINT:maxitemp:MAX:\\t%6.2lf\\g' ";
|
||||
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||||
$UPS_GRAPH .= "'LINE2:avgitemp#333333:\\tTemp (°C)\\n' ";
|
||||
|
||||
$CGI::POST_MAX=1024 * 100;
|
||||
$CGI::DISABLE_UPLOADS = 1;
|
||||
|
||||
my $q = new CGI;
|
||||
|
||||
my @hosts = ();
|
||||
my @hostfiles = `/bin/ls $RRDDIR/$HOSTFILE*.rrd`;
|
||||
foreach(@hostfiles)
|
||||
{
|
||||
if (/$HOSTFILE([^\/]+).rrd$/)
|
||||
{
|
||||
push(@hosts,$1);
|
||||
}
|
||||
}
|
||||
|
||||
my @interfaces = ();
|
||||
my @ifacefiles = `/bin/ls $RRDDIR/$IFACEFILE*.rrd`;
|
||||
foreach(@ifacefiles)
|
||||
{
|
||||
if (/$IFACEFILE([^\/]+).rrd$/)
|
||||
{
|
||||
push(@interfaces,$1);
|
||||
}
|
||||
}
|
||||
|
||||
if (! grep (/^state$/, $q->param))
|
||||
{
|
||||
$q->param(-name=>"time",value=>"day");
|
||||
&showGeneral ($q);
|
||||
&generateFoot($q);
|
||||
}
|
||||
elsif ($q->param('state') eq "detailed")
|
||||
{
|
||||
&showDetailed ($q);
|
||||
&generateFoot($q);
|
||||
}
|
||||
elsif ($q->param('state') eq "general")
|
||||
{
|
||||
&showGeneral ($q);
|
||||
&generateFoot($q);
|
||||
}
|
||||
elsif ($q->param('state') eq "gif")
|
||||
{
|
||||
&showGif ($q);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
sub showGeneral ($)
|
||||
{
|
||||
my ($q) = @_;
|
||||
my ($typeGraph, $time);
|
||||
# untaint the parameters
|
||||
if ( $q->param("typegraph") =~ /^([\w]+)$/ ) { $typeGraph = $1; } else { $typeGraph = 'CPU'; }
|
||||
if ( $q->param("time") =~ /^([\w]+)$/ ) { $time = $1; } else { $time = 'day'; }
|
||||
|
||||
my $key;
|
||||
|
||||
if ($time eq "hour") { $header = "'$HOURLY' $GRAPH (1 $MINUTE $AVERAGE)<br>"; }
|
||||
elsif ($time eq "day") { $header = "'$DAILY' $GRAPH (5 $MINUTE $AVERAGE)<br>"; }
|
||||
elsif ($time eq "week") { $header = "'$WEEKLY' $GRAPH (30 $MINUTE $AVERAGE)<br>"; }
|
||||
elsif ($time eq "month") { $header = "'$MONTHLY' $GRAPH (2 $HOUR $AVERAGE)<br>"; }
|
||||
elsif ($time eq "year") { $header = "'$YEARLY' $GRAPH (1 $DAY $AVERAGE)<br>"; }
|
||||
|
||||
esmith::cgi::genHeaderNonCacheable ($q, \%conf, "$TITLE");
|
||||
print "<meta http-equiv=\"refresh\" content=\"300\">";
|
||||
|
||||
print "<table border=0 cellspacing=0 cellpadding=0>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=hour"}, "$HOURLY") . "</b></td><td width=20></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=day"}, "$DAILY") . "</b></td><td width=20></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=week"}, "$WEEKLY") . "</b></td><td width=20></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=month"}, "$MONTHLY") . "</b></td><td width=20></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=year"}, "$YEARLY") . "</b></td><td width=20></td>";
|
||||
print "</table>";
|
||||
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=CPU"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=CPU&time=$time\">"));
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=LOADCPU"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=LOADCPU&time=$time\">"));
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=MEM"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=MEM&time=$time\">"));
|
||||
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||||
{
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=TEMP"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=TEMP&time=$time\">")) if $istemp;
|
||||
}
|
||||
if ( -e "$RRDDIR/${UPSFILE}1.rrd")
|
||||
{
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=1"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=UPS&time=$time&data=1\">"));
|
||||
}
|
||||
if ( -e "$RRDDIR/${UPSFILE}2.rrd")
|
||||
{
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=2"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=UPS&time=$time&data=2\">"));
|
||||
}
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=PROCQUE"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=PROCQUE&time=$time\">"));
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=HD"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=HD&time=$time\">"));
|
||||
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||||
{
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=VOLTAGE"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=VOLTAGE&time=$time\">")) if $isvolt;
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=FAN"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=FAN&time=$time\">")) if $isfan;
|
||||
}
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=UPTIME"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=UPTIME&time=$time\">"));
|
||||
if ($hosts ne "none")
|
||||
{
|
||||
foreach $key (@hosts)
|
||||
{
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=LATENCY&data=$key"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=LATENCY&data=$key&time=$time\">"));
|
||||
}
|
||||
}
|
||||
foreach $key (@interfaces)
|
||||
{
|
||||
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=IFACE&data=$key"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=IFACE&data=$key&time=$time\">"));
|
||||
}
|
||||
}
|
||||
|
||||
sub showDetailed($)
|
||||
{
|
||||
my ($q) = @_;
|
||||
my ($typeGraph, $data);
|
||||
# untaint the parameters
|
||||
if ( $q->param("typegraph") =~ /^([\w]+)$/ ) { $typeGraph = $1; } else { $typeGraph = 'CPU'; }
|
||||
if ( $q->param("data") =~ /^([.-\w]+)$/ ) { $data = $1; } else { $data = ''; }
|
||||
|
||||
my ($key,$title);
|
||||
|
||||
esmith::cgi::genHeaderNonCacheable ($q, \%conf, "$TITLE");
|
||||
|
||||
print "<meta http-equiv=\"refresh\" content=\"300\">";
|
||||
|
||||
print "<table>";
|
||||
print "<tr><td align=right><b>System:</b></td><td><table border=0 cellspacing=0 cellpadding=0>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=CPU"}, $CPU) . "</b></td><td width=10></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=LOADCPU"}, $LOADCPU) . "</b></td><td width=10></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=MEM"}, $MEM) . "</b></td><td width=10></td>";
|
||||
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||||
{
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=TEMP"}, $TEMP) . "</b></td><td width=10></td>";
|
||||
}
|
||||
if ( -e "$RRDDIR/${UPSFILE}1.rrd")
|
||||
{
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=1"}, $UPS.'1') . "</b></td><td width=10></td>";
|
||||
}
|
||||
if ( -e "$RRDDIR/${UPSFILE}2.rrd")
|
||||
{
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=2"}, $UPS.'2') . "</b></td><td width=10></td>";
|
||||
}
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=PROCQUE"}, $PROCQUE) . "</b></td><td width=10></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=HD"}, $HD) . "</b></td><td width=10></td>";
|
||||
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||||
{
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=VOLTAGE"}, $VOLTAGE) . "</b></td><td width=10></td>";
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=FAN"}, $FAN) . "</b></td><td width=10></td>";
|
||||
}
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=UPTIME"}, $UPTIME) . "</b></td><td width=10></td>";
|
||||
print "</table></td></tr>";
|
||||
|
||||
if ($hosts ne "none")
|
||||
{
|
||||
print "<td align=right><b>Hosts:</b></td><td><table border=0 cellspacing=0 cellpadding=0>";
|
||||
foreach $key (@hosts)
|
||||
{
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=LATENCY&data=$key"}, "$key") . "</b></td><td width=10></td>";
|
||||
}
|
||||
print "</table></td></tr>";
|
||||
}
|
||||
if ($#interfaces >= 0)
|
||||
{
|
||||
print "<td align=right><b>Interfaces:</b></td><td><table border=0 cellspacing=0 cellpadding=0>";
|
||||
foreach $key (@interfaces)
|
||||
{
|
||||
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=IFACE&data=$key"}, $key) . "</b></td><td width=10></td>";
|
||||
}
|
||||
print "</table></td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print $q->p ($q->a ({href => "${scriptname}?state=general&time=hour"},"'$HOURLY' $GRAPH (1 $MINUTE $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=hour\">"));
|
||||
print $q->p ($q->a ({href => "${scriptname}?state=general&time=day"},"'$DAILY' $GRAPH (5 $MINUTE $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=day\">"));
|
||||
print $q->p ($q->a ({href => "${scriptname}?state=general&time=week"},"'$WEEKLY' $GRAPH (30 $MINUTE $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=week\">"));
|
||||
print $q->p ($q->a ({href => "${scriptname}?state=general&time=month"},"'$MONTHLY' $GRAPH (2 $HOUR $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=month\">"));
|
||||
print $q->p ($q->a ({href => "${scriptname}?state=general&time=year"},"'$YEARLY' $GRAPH (1 $DAY $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=year\">"));
|
||||
}
|
||||
|
||||
sub showGif($)
|
||||
{
|
||||
my ($q) = @_;
|
||||
my ($typeGraph, $data, $time);
|
||||
# untaint the parameters
|
||||
if ( $q->param("typegraph") =~ /^([\w]+)$/ ) { $typeGraph = $1; } else { $typeGraph = 'CPU'; }
|
||||
if ( $q->param("data") =~ /^([.-\w]+)$/ ) { $data = $1; } else { $data = ''; }
|
||||
if ( $q->param("time") =~ /^([\w]+)$/ ) { $time = $1; } else { $time = 'day'; }
|
||||
|
||||
$rrdtime = ${"sec".$time} || $time;
|
||||
|
||||
my $rrd = "$RRDCMD -s '-$rrdtime' ${$typeGraph.'_GRAPH'}";
|
||||
$rrd =~ s/\<D\>/$data/g;
|
||||
|
||||
if (${$typeGraph.'_MAX'} =~ /$time/)
|
||||
{
|
||||
$rrd =~ s/\{.*?\}//g;
|
||||
$rrd =~ s/[\<\>]//g;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rrd =~ s/\<.*?\>//g;
|
||||
$rrd =~ s/[\{\}]//g;
|
||||
}
|
||||
|
||||
if ($q->param("debug") eq "show")
|
||||
{
|
||||
esmith::cgi::genHeaderNonCacheable ($q, \%conf, "$TITLE");
|
||||
print "$rrd";
|
||||
exit;
|
||||
}
|
||||
|
||||
print $q->header(-type=>'image/gif',-expires=>"+60s");
|
||||
open(IMGIF,"$rrd |");
|
||||
binmode STDOUT;
|
||||
while(<IMGIF>)
|
||||
{print;}
|
||||
close(IMGIF);
|
||||
}
|
||||
|
||||
sub generateFoot($)
|
||||
{
|
||||
my ($q) = @_;
|
||||
esmith::cgi::genFooter ($q);
|
||||
print $q->end_html;
|
||||
}
|
15
root/usr/lib/systemd/system/sysmon.service
Normal file
15
root/usr/lib/systemd/system/sysmon.service
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
[Unit]
|
||||
Description=System Monitor
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStartPre=-/sbin/e-smith/service-status sysmon
|
||||
ExecStart=
|
||||
ExecStart=-/usr/sbin/sysmon
|
||||
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
||||
|
394
root/usr/sbin/sysmon
Executable file
394
root/usr/sbin/sysmon
Executable file
@ -0,0 +1,394 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use POSIX;
|
||||
use RRDs;
|
||||
use IPC::Open3;
|
||||
use Symbol;
|
||||
use Carp;
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
use sigtrap;
|
||||
use File::Slurp qw/ read_file /;
|
||||
use File::Find::Rule;
|
||||
|
||||
$ENV {'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/lib/sa';
|
||||
$ENV {'LANG'} = 'C';
|
||||
|
||||
croak "ERROR: Already running!" if (-e "/var/lock/sysmon");
|
||||
|
||||
my $pingfactor;
|
||||
my $return = `fping -C 1 localhost 2>&1`;
|
||||
croak "ERROR: FPing must be installed setuid root or it will not work\n" if $return =~ m/only.+root/;
|
||||
if ($return =~ m/bytes, ([0-9.]+)\sms\s+.*\n.*\n.*:\s+([0-9.]+)/) {
|
||||
$pingfactor = 1000 * $2/$1;
|
||||
} else {
|
||||
$pingfactor = 1000;
|
||||
}
|
||||
|
||||
my %conf;
|
||||
tie %conf, 'esmith::config';
|
||||
my $status = db_get_prop(\%conf, 'sysmon', 'status') || "disabled";
|
||||
croak "ERROR: sysmon is not enabled" if $status ne 'enabled';
|
||||
|
||||
my $upsstatus = db_get_prop(\%conf, 'nut', 'status') || "disabled";
|
||||
my $rrddir = '/var/lib/rrd';
|
||||
|
||||
unless (fork) {
|
||||
open (FILELOCK,">/var/lock/sysmon");
|
||||
print FILELOCK $$;
|
||||
close FILELOCK;
|
||||
&POSIX::setsid;
|
||||
|
||||
unlink("/var/log/sysmon.old") if -e "/var/log/sysmon.old";
|
||||
rename("/var/log/sysmon","/var/log/sysmon.old") if -e "/var/log/sysmon";
|
||||
open STDOUT,'>>/var/log/sysmon';
|
||||
open STDERR,'>>/var/log/sysmon';
|
||||
open STDIN, '</dev/null';
|
||||
|
||||
$SIG{QUIT} = sub { unlink("/var/lock/sysmon"); exit 0; };
|
||||
$SIG{TERM} = sub { unlink("/var/lock/sysmon"); exit 0; };
|
||||
|
||||
while(1) {
|
||||
mkdir($rrddir) unless (-e $rrddir);
|
||||
my $days = 365;
|
||||
my @files = File::Find::Rule->file("*.rrd")
|
||||
->maxdepth(1)
|
||||
->in($rrddir);
|
||||
for my $file (@files){
|
||||
if (-M $file > $days){
|
||||
print "deleting $file\n";
|
||||
unlink $file or warn $!;
|
||||
}
|
||||
}
|
||||
my $lastupdate = RRDs::last("/var/lib/rrd/sysmon.rrd") || 0;
|
||||
my $datahash = ();
|
||||
my $badifaces = `/sbin/ifconfig -a | /bin/sed -ne '/^\\w\\+[0-9]/{;x;n;/inet addr/bd;x;s/^\\(\\w\\+[0-9]\\+\\).*/\\1/p;:d;}'` || 'none';
|
||||
chomp($badifaces);
|
||||
|
||||
rename("/var/lib/rrd/sysmon.stats","/var/lib/rrd/sysmon.process");
|
||||
if ( -x '/usr/lib/sa/sadc' ) {
|
||||
`/usr/lib/sa/sadc 1 1 /var/lib/rrd/sysmon.process > /dev/null 2>&1; /usr/lib/sa/sadc 1 1 /var/lib/rrd/sysmon.stats > /dev/null 2>&1`;}
|
||||
else
|
||||
{
|
||||
`/usr/lib64/sa/sadc 1 1 /var/lib/rrd/sysmon.process > /dev/null 2>&1; /usr/lib64/sa/sadc 1 1 /var/lib/rrd/sysmon.stats > /dev/null 2>&1`;}
|
||||
my @sardata;
|
||||
if ( -x '/usr/bin/sadf' ) { @sardata=`/usr/bin/sadf -U -- -qrbuS -n DEV /var/lib/rrd/sysmon.process 2> /dev/null`; }# sadf
|
||||
else { @sardata = `/usr/bin/sar -hqruS -P ALL -n DEV -f /var/lib/rrd/sysmon.process 2> /dev/null`; }# old systat
|
||||
unlink("/var/lib/rrd/sysmon.process");
|
||||
|
||||
if($#sardata > 0 && $sardata[0] =~ /\s+(\d+)\s+(\d{10})/ && $1 >= 45 && $1 <= 135 && $2 > $lastupdate) {
|
||||
open(FILE,"</proc/uptime"); my @filedata = <FILE>; close(FILE);
|
||||
if ($filedata[0] =~ /^([0-9,.]+)/) { $datahash->{uptime} = $1; };
|
||||
|
||||
my @gethd = `/bin/df --block-size=1 --portability --local | grep '^/dev'`;
|
||||
foreach (@gethd) {
|
||||
if(/^\/dev\/(?:mapper\/)?(\S+)\s+\d+\s+(\d+)\s+(\d+)\s+\d+\%/) {
|
||||
$datahash->{hdtotal}->{$1} = $2 + $3;
|
||||
$datahash->{hdfree}->{$1} = $3;
|
||||
$datahash->{hdused}->{$1} = $2;
|
||||
$datahash->{hdtotal}->{all} += $2 + $3;
|
||||
$datahash->{hdfree}->{all} += $3;
|
||||
$datahash->{hdused}->{all} += $2;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(@sardata) {
|
||||
if(/(all|cpu\d+)\s+\%(user|nice|system|iowait|idle)\s+([0-9,.]+)/) { $datahash->{$2}->{$1}=$3/100; }
|
||||
if(/(runq-sz|plist-sz|ldavg-[15]+)\s+([0-9,.]+)/) { $datahash->{$1}=$2; }
|
||||
if(/kb(memfree|memused|buffers|cached|swpfree|swpused)\s+([0-9,.]+)/) { $datahash->{$1}=$2*1024; }
|
||||
if(/(\w+)\s+(rxkB|txkB|rxpck|txpck)\/s\s+([0-9,.]+)/) { $datahash->{$2}->{$1}=$3; }
|
||||
}
|
||||
|
||||
foreach (keys %{$datahash->{idle}}) {
|
||||
$datahash->{total}->{$_}=1-$datahash->{idle}->{$_};
|
||||
}
|
||||
$datahash->{memtotal} = $datahash->{memused} + $datahash->{memfree};
|
||||
$datahash->{memused} -= $datahash->{cached} + $datahash->{buffers};
|
||||
$datahash->{memfree} += $datahash->{cached} + $datahash->{buffers};
|
||||
$datahash->{swptotal} = $datahash->{swpused} + $datahash->{swpfree};
|
||||
|
||||
RRDs::create("/var/lib/rrd/sysmon.rrd","-s","60",
|
||||
"DS:total:GAUGE:120:0:150",
|
||||
"DS:user:GAUGE:120:0:150",
|
||||
"DS:nice:GAUGE:120:0:150",
|
||||
"DS:system:GAUGE:120:0:150",
|
||||
"DS:iowait:GAUGE:120:0:150",
|
||||
"DS:idle:GAUGE:120:0:150",
|
||||
"DS:runq-sz:GAUGE:120:0:100",
|
||||
"DS:plist-sz:GAUGE:120:0:1000",
|
||||
"DS:ldavg-1:GAUGE:120:0:100",
|
||||
"DS:ldavg-5:GAUGE:120:0:100",
|
||||
"DS:memtotal:GAUGE:120:0:U",
|
||||
"DS:memfree:GAUGE:120:0:U",
|
||||
"DS:memused:GAUGE:120:0:U",
|
||||
"DS:buffers:GAUGE:120:0:U",
|
||||
"DS:cached:GAUGE:120:0:U",
|
||||
"DS:swptotal:GAUGE:120:0:U",
|
||||
"DS:swpfree:GAUGE:120:0:U",
|
||||
"DS:swpused:GAUGE:120:0:U",
|
||||
"DS:hdtotal:GAUGE:120:0:U",
|
||||
"DS:hdfree:GAUGE:120:0:U",
|
||||
"DS:hdused:GAUGE:120:0:U",
|
||||
"DS:uptime:GAUGE:120:0:U",
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/sysmon.rrd";
|
||||
RRDs::update("/var/lib/rrd/sysmon.rrd",
|
||||
"N:$datahash->{total}->{all}:$datahash->{user}->{all}:$datahash->{nice}->{all}:" .
|
||||
"$datahash->{system}->{all}:$datahash->{iowait}->{all}:$datahash->{idle}->{all}:" .
|
||||
"$datahash->{'runq-sz'}:$datahash->{'plist-sz'}:$datahash->{'ldavg-1'}:" .
|
||||
"$datahash->{'ldavg-5'}:$datahash->{memtotal}:$datahash->{memfree}:" .
|
||||
"$datahash->{memused}:$datahash->{buffers}:$datahash->{cached}:$datahash->{swptotal}:" .
|
||||
"$datahash->{swpfree}:$datahash->{swpused}:$datahash->{hdtotal}->{all}:$datahash->{hdfree}->{all}:" .
|
||||
"$datahash->{hdused}->{all}:$datahash->{uptime}");
|
||||
rename("/var/lib/rrd/sysmon.rrd","/var/lib/rrd/sysmon.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
|
||||
foreach my $cpu (keys %{$datahash->{idle}}) {
|
||||
next if $cpu eq 'all';
|
||||
RRDs::create("/var/lib/rrd/$cpu.rrd","-s","60",
|
||||
"DS:total:GAUGE:120:0:150",
|
||||
"DS:user:GAUGE:120:0:150",
|
||||
"DS:nice:GAUGE:120:0:150",
|
||||
"DS:system:GAUGE:120:0:150",
|
||||
"DS:iowait:GAUGE:120:0:150",
|
||||
"DS:idle:GAUGE:120:0:150",
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/$cpu.rrd";
|
||||
RRDs::update("/var/lib/rrd/$cpu.rrd",
|
||||
"N:$datahash->{total}->{$cpu}:$datahash->{user}->{$cpu}:$datahash->{nice}->{$cpu}:" .
|
||||
"$datahash->{system}->{$cpu}:$datahash->{iowait}->{$cpu}:$datahash->{idle}->{$cpu}");
|
||||
rename("/var/lib/rrd/$cpu.rrd","/var/lib/rrd/$cpu.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
}
|
||||
|
||||
foreach my $drive (keys %{$datahash->{hdtotal}}) {
|
||||
next if $drive eq 'all';
|
||||
RRDs::create("/var/lib/rrd/drive_$drive.rrd","-s","60",
|
||||
"DS:hdtotal:GAUGE:120:0:U",
|
||||
"DS:hdfree:GAUGE:120:0:U",
|
||||
"DS:hdused:GAUGE:120:0:U",
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/drive_$drive.rrd";
|
||||
RRDs::update("/var/lib/rrd/drive_$drive.rrd",
|
||||
"N:$datahash->{hdtotal}->{$drive}:$datahash->{hdfree}->{$drive}:$datahash->{hdused}->{$drive}");
|
||||
rename("/var/lib/rrd/drive_$drive.rrd","/var/lib/rrd/drive_$drive.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
}
|
||||
|
||||
foreach my $iface (keys %{$datahash->{rxkB}}) {
|
||||
next if ($iface =~ /(lo|br\d+|imq\d+)$/);
|
||||
next if ($datahash->{rxkB}->{$iface} == 0);
|
||||
next if ($badifaces =~ /$iface/);
|
||||
RRDs::create("/var/lib/rrd/iface_$iface.rrd","-s","60",
|
||||
"DS:rxkB:" . ($iface =~ /^sw/ ? "COUNTER" : "GAUGE" ) . ":120:0:U",
|
||||
"DS:txkB:" . ($iface =~ /^sw/ ? "COUNTER" : "GAUGE" ) . ":120:0:U",
|
||||
"DS:rxpck:" . ($iface =~ /^sw/ ? "COUNTER" : "GAUGE" ) . ":120:0:U",
|
||||
"DS:txpck:" . ($iface =~ /^sw/ ? "COUNTER" : "GAUGE" ) . ":120:0:U",
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/iface_$iface.rrd";
|
||||
RRDs::update("/var/lib/rrd/iface_$iface.rrd",
|
||||
"N:$datahash->{rxkB}->{$iface}:$datahash->{txkB}->{$iface}:$datahash->{rxpck}->{$iface}:" .
|
||||
"$datahash->{txpck}->{$iface}");
|
||||
rename("/var/lib/rrd/iface_$iface.rrd","/var/lib/rrd/iface_$iface.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
}
|
||||
|
||||
my $cnt=0;
|
||||
if ( $upsstatus eq 'enabled') {
|
||||
my @upsentries = ('i_voltage', 'u_load', 'b_charge', 'b_runtime', 'b_voltage', 'u_temperature') ;
|
||||
#use File::Slurp qw/ read_file /;
|
||||
my $upslines = read_file('/etc/ups/ups.conf');
|
||||
my @upses = $upslines =~ m/\[(.*)\]\n/;
|
||||
foreach(@upses) {
|
||||
chomp;
|
||||
my $upsname="$_\@localhost";
|
||||
$cnt++;
|
||||
my @upsdata = `/usr/bin/upsc $upsname 2> /dev/null`;
|
||||
$upslines="ups $upsname: ";
|
||||
foreach(@upsdata) {
|
||||
if(/^([a-z])[^.]+\.(voltage|load|charge|runtime|temperature|humidity)\s*:\s*([0-9,.]+)/) {
|
||||
my $element = "$1_$2";
|
||||
$upslines .= "$element=$3, ";
|
||||
$datahash->{ups}->{$cnt}->{$element}=$3;
|
||||
if($element=~/time/i) { $datahash->{ups}->{$cnt}->{$element} /= 60; }
|
||||
}
|
||||
}
|
||||
foreach my $element (@upsentries){
|
||||
next if exists($datahash->{ups}->{$cnt}->{$element});
|
||||
$datahash->{ups}->{$cnt}->{$element}='';
|
||||
$upslines .= "$element=, ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $ups (keys %{$datahash->{ups}}) {
|
||||
RRDs::create("/var/lib/rrd/ups$ups.rrd","-s","60",
|
||||
(map {"DS:$_:GAUGE:120:0:U"} sort keys %{$datahash->{ups}->{$ups}}),
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/ups$ups.rrd";
|
||||
RRDs::update("/var/lib/rrd/ups$ups.rrd",
|
||||
"N:".(join ":", map { $datahash->{ups}->{$ups}->{$_} } sort keys %{$datahash->{ups}->{$ups}}));
|
||||
rename("/var/lib/rrd/ups$ups.rrd","/var/lib/rrd/ups$ups.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
}
|
||||
|
||||
if( -e '/usr/bin/sensors') {
|
||||
my $check = `/sbin/lsmod 2> /dev/null`;
|
||||
if( $check =~ /i2c_/ ) {
|
||||
my @sensordata = `/usr/bin/sensors -u 2> /dev/null`;
|
||||
foreach(@sensordata) {
|
||||
#pre SME9 if(/(-?[0-9,.]+) \(((?:in|fan|temp|vid|vrm)[0-9]*)\)/) { $datahash->{sensors}->{$2} = $1; print "$2=$1, "}
|
||||
if(/(in|fan|temp|vid|vrm)([0-9])_input: ?(-?[0-9,.]+)/) { $datahash->{sensors}->{"$1$2"} = $3;} #print "sensors:$1$2=$3\n"}
|
||||
}
|
||||
if(defined($datahash->{sensors})) {
|
||||
RRDs::create("/var/lib/rrd/sensors.rrd","-s","60",
|
||||
(map {"DS:$_:GAUGE:120:U:U"} sort keys %{$datahash->{sensors}}),
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/sensors.rrd";
|
||||
RRDs::update("/var/lib/rrd/sensors.rrd",
|
||||
"N:".(join ":", map { $datahash->{sensors}->{$_} } sort keys %{$datahash->{sensors}}));
|
||||
rename("/var/lib/rrd/sensors.rrd","/var/lib/rrd/sensors.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $inh = gensym;
|
||||
my $outh = gensym;
|
||||
my $errh = gensym;
|
||||
|
||||
my $gateway = `/sbin/route -n | /bin/egrep '^0\.' | /bin/awk '{ print \$2 }' | /bin/egrep '^[1-9]'` ||
|
||||
`/sbin/ifconfig | /bin/sed -ne '/P-t-P/p' | /bin/awk '{ print \$3 }' | /bin/cut -d: -f2` ||
|
||||
'down';
|
||||
chomp $gateway;
|
||||
|
||||
my $hosts = db_get_prop(\%conf, 'sysmon', 'hosts') || "gateway";
|
||||
$hosts =~ s/\bgateway\b/$gateway/g;
|
||||
$hosts =~ s/[,:; ]+/ /g;
|
||||
|
||||
my @pings = `fping -C 25 -q -B1 -t1000 -r1 -p 500 $hosts 2>&1`;
|
||||
foreach (@pings) {
|
||||
chomp;
|
||||
my @times = split /\s+/;
|
||||
my $ip = shift @times;
|
||||
$ip =~ s/\b$gateway\b/gateway/g;
|
||||
if (':' eq shift @times) {
|
||||
@times = map {sprintf "%.10e", $_ / $pingfactor} sort {$a <=> $b} grep /^\d/, @times;
|
||||
|
||||
my $median = $times[int($#times/2)] || 'U';
|
||||
my $loss = 25 - ($#times+1);
|
||||
if ($loss >= 25) {
|
||||
@times = map {'U'} 1..25;
|
||||
} else {
|
||||
splice @times, sprintf("%.0f", int(($#times+1)/2)),0,map {'U'} 1..$loss;
|
||||
}
|
||||
|
||||
RRDs::create("/var/lib/rrd/host_$ip.rrd","-s","60",
|
||||
"DS:loss:GAUGE:120:0:25",
|
||||
"DS:median:GAUGE:120:0:180",
|
||||
(map {"DS:ping${_}:GAUGE:120:0:180"} 1..25),
|
||||
"RRA:MIN:0.5:1:1500",
|
||||
"RRA:MIN:0.5:5:600",
|
||||
"RRA:MIN:0.5:30:700",
|
||||
"RRA:MIN:0.5:120:775",
|
||||
"RRA:MIN:0.5:1440:797",
|
||||
"RRA:AVERAGE:0.5:1:1500",
|
||||
"RRA:AVERAGE:0.5:5:600",
|
||||
"RRA:AVERAGE:0.5:30:700",
|
||||
"RRA:AVERAGE:0.5:120:775",
|
||||
"RRA:AVERAGE:0.5:1440:797",
|
||||
"RRA:MAX:0.5:1:1500",
|
||||
"RRA:MAX:0.5:5:600",
|
||||
"RRA:MAX:0.5:30:700",
|
||||
"RRA:MAX:0.5:120:775",
|
||||
"RRA:MAX:0.5:1440:797") unless -e "/var/lib/rrd/host_$ip.rrd";
|
||||
RRDs::update("/var/lib/rrd/host_$ip.rrd",
|
||||
"N:$loss:$median:".(join ':', @times));
|
||||
rename("/var/lib/rrd/host_$ip.rrd","/var/lib/rrd/host_$ip.bad") if(RRDs::error);
|
||||
print RRDs::error . "\n" if (RRDs::error);
|
||||
}
|
||||
}
|
||||
}
|
||||
sleep(60-time%60);
|
||||
}
|
||||
}
|
115
smeserver-sysmon.spec
Normal file
115
smeserver-sysmon.spec
Normal file
@ -0,0 +1,115 @@
|
||||
# $Id: smeserver-sysmon.spec,v 1.8 2022/09/21 08:05:30 trevorb Exp $
|
||||
# Authority: slords
|
||||
# Name: Shad L. Lords
|
||||
|
||||
Summary: sme server system monitor
|
||||
%define name smeserver-sysmon
|
||||
Name: %{name}
|
||||
%define version 6.5
|
||||
%define release 6
|
||||
Version: %{version}
|
||||
Release: %{release}%{?dist}
|
||||
License: Freely distributable
|
||||
Group: Service
|
||||
Source: %{name}-%{version}.tar.xz
|
||||
BuildRoot: /var/tmp/e-smith-buildroot
|
||||
BuildRequires: e-smith-devtools
|
||||
BuildArchitectures: noarch
|
||||
Requires: smeserver-release >= 10
|
||||
Requires: sysstat >= 5
|
||||
Requires: rrdtool >= 1.2
|
||||
Requires: perl(RRDs)
|
||||
Requires: fping
|
||||
Requires: perl(File::Find::Rule)
|
||||
Requires: perl(File::Slurp)
|
||||
AutoReqProv: no
|
||||
|
||||
%changelog
|
||||
* Sat Sep 07 2024 cvs2git.sh aka Brian Read <brianr@koozali.org> 6.5-6.sme
|
||||
- Roll up patches and move to git repo [SME: 12338]
|
||||
|
||||
* Sat Sep 07 2024 BogusDateBot
|
||||
- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday,
|
||||
by assuming the date is correct and changing the weekday.
|
||||
|
||||
* Wed Sep 21 2022 Trevor Batley <trevor@batley.id.au> 6.5-5.sme
|
||||
- redo patch to remove 50koozali.conf (as not added to cvs) [SME: 12191]
|
||||
|
||||
* Wed Sep 21 2022 Trevor Batley <trevor@batley.id.au> 6.5-4.sme
|
||||
- remove superflous and incorrect references to 50koozali.conf [SME: 12191]
|
||||
|
||||
* Mon Aug 15 2022 Trevor Batley <trevor@batley.id.au> 6.5-3.sme
|
||||
- add -U parameter to sadf call to enforce datetime type [SME: 11702]
|
||||
- alter sysmon service to use to use systemd [SME: 11072]
|
||||
- initial release to contribs10
|
||||
|
||||
* Sun Jul 31 2022 Trevor Batley <trevor@batley.id.au> 6.5-2.sme
|
||||
- add to backup [SME: 12024]
|
||||
|
||||
* Fri Dec 27 2019 Jean-Philipe Pialasse <tests@pialasse.com> 6.5-1.sme
|
||||
- fix utf8 error
|
||||
- fix ups not displaying [SME: 4449]
|
||||
- fix broken image when DS not all available for ups, fan, temperature and voltage graphs
|
||||
|
||||
* Thu Jan 18 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 6.4-6.sme
|
||||
- Fix database backups iunspec file [[SME: 7096]]
|
||||
|
||||
* Mon Jan 15 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 6.4-5.sme
|
||||
- Fix missing swap information [[SME: 10493]]
|
||||
- Remove unnecessary daemonising line
|
||||
|
||||
* Thu Sep 24 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 6.4-4.sme
|
||||
- Network labels have changed in rrdtools
|
||||
- Added smeserver-sysmon-6.4.change_rrd_network_label.patch
|
||||
|
||||
* Thu Sep 24 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 6.4-2.sme
|
||||
- Initial release to contribs9
|
||||
|
||||
* Wed Aug 15 2012 JP Pialasse <tests@pialasse.com> 6.2-2.sme
|
||||
- patch for sysstats 7 and for 64 bit systems
|
||||
|
||||
* Thu Aug 9 2012 Shad L. Lords <slords@mail.com> 6.2-1.sme
|
||||
- Initial version
|
||||
|
||||
%description
|
||||
System monitor for SME Server version 9
|
||||
|
||||
%prep
|
||||
%setup
|
||||
|
||||
%build
|
||||
perl createlinks
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT)
|
||||
rm -f %{name}-%{version}-filelist
|
||||
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist
|
||||
echo "%doc COPYING" >> %{name}-%{version}-filelist
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%pre
|
||||
if [ $1 -ge 1 ]; then
|
||||
/sbin/service sysmon stop &> /dev/null || :
|
||||
fi
|
||||
|
||||
%post
|
||||
if [ $1 -ge 2 ]; then
|
||||
/sbin/service sysmon restart &> /dev/null || :
|
||||
fi
|
||||
|
||||
|
||||
%preun
|
||||
if [ $1 -eq 0 ]; then
|
||||
/sbin/service sysmon stop &> /dev/null || :
|
||||
fi
|
||||
|
||||
%postun
|
||||
if [ $1 -ge 1 ]; then
|
||||
/sbin/service sysmon restart &> /dev/null || :
|
||||
fi
|
||||
|
||||
%files -f %{name}-%{version}-filelist
|
||||
%defattr(-,root,root)
|
Loading…
Reference in New Issue
Block a user