mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 00:34:46 +02:00
2009-07-16 Ramon Novoa <rnovoa@artica.es>
* linux/plugins/pandora_ps, linux/plugins/pandora_df: Added to repository. New ps and df plugins. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1808 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f34630fc2c
commit
e0e2c0c9a7
@ -1,3 +1,8 @@
|
|||||||
|
2009-07-16 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* linux/plugins/pandora_ps, linux/plugins/pandora_df: Added to
|
||||||
|
repository. New ps and df plugins.
|
||||||
|
|
||||||
2009-07-02 Manuel Arostegui <marostegui@artica.es>
|
2009-07-02 Manuel Arostegui <marostegui@artica.es>
|
||||||
|
|
||||||
* linux/pandora_agent.spec: Fixed a typo.
|
* linux/pandora_agent.spec: Fixed a typo.
|
||||||
|
70
pandora_agents/linux/plugins/pandora_df
Executable file
70
pandora_agents/linux/plugins/pandora_df
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
# Copyright (c) 2009 Artica Soluciones Tecnologicas S.L.
|
||||||
|
#
|
||||||
|
# pandora_df Retrieve filesystem disk usage. By default information for all
|
||||||
|
# filesystems is returned, but one or more filesystems may be
|
||||||
|
# specified as command line parameters.
|
||||||
|
#
|
||||||
|
# Sample usage: ./pandora_df tmpfs /dev/sda1
|
||||||
|
#
|
||||||
|
# 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; version 2 of the License.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Retrieve information from all filesystems
|
||||||
|
my $all_filesystems = 0;
|
||||||
|
|
||||||
|
# Check command line parameters
|
||||||
|
if ($#ARGV < 0) {
|
||||||
|
$all_filesystems = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command line parameters
|
||||||
|
my %filesystems;
|
||||||
|
foreach my $fs (@ARGV) {
|
||||||
|
$filesystems{$fs} = '-1%';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Retrieve filesystem information
|
||||||
|
# -P use the POSIX output format for portability
|
||||||
|
my @df = `df -P`;
|
||||||
|
shift (@df);
|
||||||
|
|
||||||
|
# No filesystems? Something went wrong.
|
||||||
|
if ($#df < 0) {
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse filesystem usage
|
||||||
|
foreach my $row (@df) {
|
||||||
|
my @columns = split (' ', $row);
|
||||||
|
exit 1 if ($#columns < 4);
|
||||||
|
$filesystems{$columns[0]} = $columns[4] if (defined ($filesystems{$columns[0]}) || $all_filesystems == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (my ($filesystem, $use) = each (%filesystems)) {
|
||||||
|
|
||||||
|
# Remove the trailing %
|
||||||
|
chop ($use);
|
||||||
|
|
||||||
|
# Print module output
|
||||||
|
print "<module>\n";
|
||||||
|
print "<name><![CDATA[" . $filesystem . "]]></name>\n";
|
||||||
|
print "<type><![CDATA[generic_data]]></type>\n";
|
||||||
|
print "<data><value><![CDATA[" . $use . "]]></value></data>\n";
|
||||||
|
print "<module>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
56
pandora_agents/linux/plugins/pandora_ps
Executable file
56
pandora_agents/linux/plugins/pandora_ps
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
# Copyright (c) 2009 Artica Soluciones Tecnologicas S.L.
|
||||||
|
#
|
||||||
|
# pandora_ps Get the status of the given processes.
|
||||||
|
#
|
||||||
|
# Sample usage: ./pandora_ps init perl mysqld
|
||||||
|
#
|
||||||
|
# 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; version 2 of the License.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Check command line parameters
|
||||||
|
if ($#ARGV < 0) {
|
||||||
|
print "Usage: $0 <process_1> [process_2] ...\n\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command line parameters
|
||||||
|
my %processes;
|
||||||
|
my $module_name = $ARGV[0];
|
||||||
|
foreach my $process (@ARGV) {
|
||||||
|
$processes{$process} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Retrieve process information
|
||||||
|
my @df = `ps -eo ucmd`;
|
||||||
|
shift (@df);
|
||||||
|
|
||||||
|
# Parse filesystem usage
|
||||||
|
foreach my $row (@df) {
|
||||||
|
chomp ($row);
|
||||||
|
$processes{$row} = 1 if defined ($processes{$row});
|
||||||
|
}
|
||||||
|
|
||||||
|
while (my ($process, $status) = each (%processes)) {
|
||||||
|
# Print module output
|
||||||
|
print "<module>\n";
|
||||||
|
print " <name><![CDATA[" . $process . "]]></name>\n";
|
||||||
|
print " <type><![CDATA[generic_data]]></type>\n";
|
||||||
|
print " <data><value><![CDATA[" . $status . "]]></value></data>\n";
|
||||||
|
print "</module>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
Loading…
x
Reference in New Issue
Block a user