diff --git a/html/includes/graphs/munin/auth.inc.php b/html/includes/graphs/munin/auth.inc.php
new file mode 100755
index 0000000000..ad7008fd58
--- /dev/null
+++ b/html/includes/graphs/munin/auth.inc.php
@@ -0,0 +1,23 @@
+
diff --git a/html/includes/graphs/munin/graph.inc.php b/html/includes/graphs/munin/graph.inc.php
new file mode 100644
index 0000000000..a151f9b4cb
--- /dev/null
+++ b/html/includes/graphs/munin/graph.inc.php
@@ -0,0 +1,65 @@
+ "500")
+{
+ $descr_len=24;
+} else {
+ $descr_len=14;
+ $descr_len += round(($width - 230) / 8.2);
+}
+
+if($width > "500")
+{
+ $rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len),0,$descr_len)." Current Average Maximum\l'";
+ $rrd_options .= " COMMENT:'\l'";
+} else {
+ $rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len),0,$descr_len)." Current Average Maximum\l'";
+}
+
+
+$c_i = 0;
+$dbq = dbFetchRows("SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?", array($mplug['mplug_id']));
+foreach ($dbq as $ds)
+{
+ $ds_filename = $plugfile."_".$ds['ds_name'].".rrd";
+ $ds_name = $ds['ds_name'];
+
+ $cmd_def .= " DEF:".$ds['ds_name']."=".$ds_filename.":val:AVERAGE";
+
+ if(!empty($ds['ds_cdef']))
+ {
+ $cmd_cdef .= "";
+ $ds_name = $ds['ds_name']."_cdef";
+ }
+
+ if($ds['ds_graph'] == "yes")
+ {
+ if(empty($ds['colour']))
+ {
+ if (!$config['graph_colours']['mixed'][$c_i]) { $c_i = 0; }
+ $colour=$config['graph_colours']['mixed'][$c_i]; $c_i++;
+ } else {
+ $colour = $ds['colour'];
+ }
+
+ $descr = str_replace(":", "\:", substr(str_pad($ds['ds_label'], $descr_len),0,$descr_len));
+
+ $cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.':"'.$descr.'"';
+ $cmd_graph .= ' GPRINT:'.$ds_name.':LAST:"%6.2lf%s"';
+ $cmd_graph .= ' GPRINT:'.$ds_name.':AVERAGE:"%6.2lf%s"';
+ $cmd_graph .= ' GPRINT:'.$ds_name.':MAX:"%6.2lf%s\\n"';
+
+ }
+
+}
+
+$rrd_options .= $cmd_def . $cmd_cdef . $cmd_graph;
+
+?>
diff --git a/html/includes/print-device-graph.php b/html/includes/print-device-graph.php
index 2377194f95..52cf57fb83 100644
--- a/html/includes/print-device-graph.php
+++ b/html/includes/print-device-graph.php
@@ -1,7 +1,7 @@
Graphs » ");
$sep = "";
-foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ?", array($device['device_id'])) as $graph)
+foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug)
+{
+# if(strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { }
+ $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
+ $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
+}
+
+foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph)
{
$section = $config['graph_types']['device'][$graph['graph']]['section'];
$graph_enable[$section][$graph['graph']] = $graph['graph'];
}
-foreach ($config['graph_sections'] as $section)
+#foreach ($config['graph_sections'] as $section)
+foreach($graph_enable as $section => $nothing)
{
if (isset($graph_enable) && is_array($graph_enable[$section]))
{
@@ -34,9 +42,7 @@ foreach ($config['graph_sections'] as $section)
{
echo('");
@@ -50,13 +56,20 @@ print_optionbar_end();
$graph_enable = $graph_enable[$vars['group']];
-foreach ($config['graph_types']['device'] as $graph => $entry)
+#foreach ($config['graph_types']['device'] as $graph => $entry)
+foreach($graph_enable as $graph => $entry)
{
if ($graph_enable[$graph])
{
- $graph_title = $config['graph_types']['device'][$graph]['descr'];
- $graph_type = "device_" . $graph;
-
+ if(is_numeric($entry['id']))
+ {
+ $graph_title = $entry['title'];
+ $graph_array['type'] = "munin_graph";
+ $graph_array['id'] = $entry['id'];
+ } else {
+ $graph_title = $config['graph_types']['device'][$graph]['descr'];
+ $graph_array['type'] = "device_" . $graph;
+ }
include("includes/print-device-graph.php");
}
}
diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php
index 0e79366511..aa91eee221 100644
--- a/includes/defaults.inc.php
+++ b/includes/defaults.inc.php
@@ -423,6 +423,7 @@ $config['warn']['ifdown'] = TRUE; ## Show down interfaces
## List of poller modules. Need to be in the array to be
## considered for execution.
+$config['poller_modules']['unix-agent'] = 0;
$config['poller_modules']['system'] = 1;
$config['poller_modules']['os'] = 1;
$config['poller_modules']['ipmi'] = 1;
@@ -451,7 +452,6 @@ $config['poller_modules']['cisco-ace-loadbalancer'] = 1;
$config['poller_modules']['cisco-ace-serverfarms'] = 1;
$config['poller_modules']['netscaler-vsvr'] = 1;
$config['poller_modules']['entity-physical'] = 1;
-$config['poller_modules']['unix-agent'] = 0;
$config['poller_modules']['applications'] = 1;
## List of discovery modules. Need to be in this array to be
diff --git a/includes/discovery/cisco-vrf.inc.php b/includes/discovery/cisco-vrf.inc.php
index e21354d3d7..36113c4912 100755
--- a/includes/discovery/cisco-vrf.inc.php
+++ b/includes/discovery/cisco-vrf.inc.php
@@ -1,5 +1,7 @@
>>", $section);
- $agent_data[$section] = trim($data);
- }
-
- ## FIXME - split these into separate modules which are "autoloaded" when the section exists.
-
- ### RPM
- if (!empty($agent_data['rpm']))
- {
- echo("\nRPM Packages: ");
- ## Build array of existing packages
- $manager = "rpm";
-
- $pkgs_db_db = dbFetchRows("SELECT * FROM `packages` WHERE `device_id` = ?", array($device['device_id']));
- foreach ($pkgs_db_db as $pkg_db)
+ list($sa, $sb) = explode("-", $section, 2);
+ if(!empty($sa) && !empty($sb))
{
- $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['id'] = $pkg_db['pkg_id'];
- $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['status'] = $pkg_db['status'];
- $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['size'] = $pkg_db['size'];
- $pkgs_db_id[$pkg_db['pkg_id']]['text'] = $pkg_db['manager'] ."-".$pkg_db['name']."-".$pkg_db['arch']."-".$pkg_db['version']."-".$pkg_db['build'];
- $pkgs_db_id[$pkg_db['pkg_id']]['manager'] = $pkg_db['manager'];
- $pkgs_db_id[$pkg_db['pkg_id']]['name'] = $pkg_db['name'];
- $pkgs_db_id[$pkg_db['pkg_id']]['arch'] = $pkg_db['arch'];
- $pkgs_db_id[$pkg_db['pkg_id']]['version'] = $pkg_db['version'];
- $pkgs_db_id[$pkg_db['pkg_id']]['build'] = $pkg_db['build'];
- }
-
- foreach (explode("\n", $agent_data['rpm']) as $package)
- {
- list($name, $version, $build, $arch, $size) = explode(" ", $package);
- $pkgs[$manager][$name][$arch][$version][$build]['manager'] = $manager;
- $pkgs[$manager][$name][$arch][$version][$build]['name'] = $name;
- $pkgs[$manager][$name][$arch][$version][$build]['arch'] = $arch;
- $pkgs[$manager][$name][$arch][$version][$build]['version'] = $version;
- $pkgs[$manager][$name][$arch][$version][$build]['build'] = $build;
- $pkgs[$manager][$name][$arch][$version][$build]['size'] = $size;
- $pkgs[$manager][$name][$arch][$version][$build]['status'] = '1';
- $text = $manager."-".$name."-".$arch."-".$version."-".$build;
- $pkgs_id[] = $pkgs[$manager][$name][$arch][$version][$build];
- }
- }
-
- ### DPKG
- if (!empty($agent_data['dpkg']))
- {
- echo("\nDEB Packages: ");
- ## Build array of existing packages
- $manager = "deb";
-
- $pkgs_db_db = dbFetchRows("SELECT * FROM `packages` WHERE `device_id` = ?", array($device['device_id']));
- foreach ($pkgs_db_db as $pkg_db)
- {
- $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['id'] = $pkg_db['pkg_id'];
- $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['status'] = $pkg_db['status'];
- $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['size'] = $pkg_db['size'];
- $pkgs_db_id[$pkg_db['pkg_id']]['text'] = $pkg_db['manager'] ."-".$pkg_db['name']."-".$pkg_db['arch']."-".$pkg_db['version']."-".$pkg_db['build'];
- $pkgs_db_id[$pkg_db['pkg_id']]['manager'] = $pkg_db['manager'];
- $pkgs_db_id[$pkg_db['pkg_id']]['name'] = $pkg_db['name'];
- $pkgs_db_id[$pkg_db['pkg_id']]['arch'] = $pkg_db['arch'];
- $pkgs_db_id[$pkg_db['pkg_id']]['version'] = $pkg_db['version'];
- $pkgs_db_id[$pkg_db['pkg_id']]['build'] = $pkg_db['build'];
- }
-
- foreach (explode("\n", $agent_data['dpkg']) as $package)
- {
- list($name, $version, $arch, $size) = explode(" ", $package);
- $build = "";
- $pkgs[$manager][$name][$arch][$version][$build]['manager'] = $manager;
- $pkgs[$manager][$name][$arch][$version][$build]['name'] = $name;
- $pkgs[$manager][$name][$arch][$version][$build]['arch'] = $arch;
- $pkgs[$manager][$name][$arch][$version][$build]['version'] = $version;
- $pkgs[$manager][$name][$arch][$version][$build]['build'] = $build;
- $pkgs[$manager][$name][$arch][$version][$build]['size'] = $size * 1024;
- $pkgs[$manager][$name][$arch][$version][$build]['status'] = '1';
- $text = $manager."-".$name."-".$arch."-".$version."-".$build;
- $pkgs_id[] = $pkgs[$manager][$name][$arch][$version][$build];
- }
- }
-
- ## This is run for all "packages" and is common to RPM/DEB/etc
- foreach ($pkgs_id as $pkg)
- {
- $name = $pkg['name'];
- $version = $pkg['version'];
- $build = $pkg['build'];
- $arch = $pkg['arch'];
- $size = $pkg['size'];
-
- #echo(str_pad($name, 20)." ".str_pad($version, 10)." ".str_pad($build, 10)." ".$arch."\n");
- #echo($name." ");
-
- if (is_array($pkgs_db[$pkg['manager']][$pkg['name']][$pkg['arch']][$pkg['version']][$pkg['build']]))
- {
- ### FIXME - packages_history table
- $id = $pkgs_db[$pkg['manager']][$pkg['name']][$pkg['arch']][$pkg['version']][$pkg['build']]['id'];
- if ($pkgs_db[$pkg['manager']][$pkg['name']][$pkg['arch']][$pkg['version']][$pkg['build']]['status'] != '1')
- {
- $pkg_update['status'] = '1';
- }
- if ($pkgs_db[$pkg['manager']][$pkg['name']][$pkg['arch']][$pkg['version']][$pkg['build']]['size'] != $size)
- {
- $pkg_update['size'] = $size;
- }
- if (!empty($pkg_update))
- {
- dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', array($id));
- echo("u");
- } else {
- echo(".");
- }
- unset($pkgs_db_id[$id]);
+ $agent_data[$sa][$sb] = trim($data);
} else {
- if (count($pkgs[$manager][$name][$arch], 1) > "10" || count($pkgs_db[$manager][$name][$arch], 1) == '0')
- {
- dbInsert(array('device_id' => $device['device_id'], 'name' => $name, 'manager' => $manager,
- 'status' => 1, 'version' => $version, 'build' => $build, 'arch' => $arch, 'size' => $size), 'packages');
- if ($build != "") { $dbuild = '-' . $build; } else { $dbuild = ''; }
- echo("+".$name."-".$version.$dbuild."-".$arch);
- log_event('Package installed: '.$name.' ('.$arch.') version '.$version.$dbuild, $device, 'package');
- } elseif(count($pkgs_db[$manager][$name][$arch], 1)) {
- $pkg_c = dbFetchRow("SELECT * FROM `packages` WHERE `device_id` = ? AND `manager` = ? AND `name` = ? and `arch` = ? ORDER BY version DESC, build DESC", array($device['device_id'], $manager, $name, $arch));
- if ($pkg_c['build'] != "") { $pkg_c_dbuild = '-'.$pkg_c['build']; } else { $pkg_c_dbuild = ''; }
- echo("U(".$pkg_c['name']."-".$pkg_c['version'].$pkg_c_dbuild."|".$name."-".$version.$dbuild.")");
- $pkg_update = array('version' => $version, 'build' => $build, 'status' => '1', 'size' => $size);
- dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', array($pkg_c['pkg_id']));
- log_event('Package updated: '.$name.' ('.$arch.') from '.$pkg_c['version'].$pkg_c_dbuild .' to '.$version.$dbuild, $device, 'package');
- unset($pkgs_db_id[$pkg_c['pkg_id']]);
- }
+ $agent_data[$section] = trim($data);
}
- unset($pkg_update);
}
- ## Packages
- foreach ($pkgs_db_id as $id => $pkg)
- {
- dbDelete('packages', "`pkg_id` = ?", array($id));
- echo("-".$pkg['text']);
- log_event('Package removed: '.$pkg['name'].' '.$pkg['arch'].' '.$pkg['version'].'-'.$pkg['build'], $device, 'package');
- }
+ #print_r($agent_data);
+
+ include("unix-agent/packages.inc.php");
+ include("unix-agent/munin-plugins.inc.php");
### Processes
if (!empty($agent_data['ps']))
@@ -220,13 +95,6 @@ if($device['os_group'] == "unix")
}
}
- unset($pkg);
- unset($pkgs_db_id);
- unset($pkg_c);
- unset($pkgs);
- unset($pkgs_db);
- unset($pkgs_db_db);
-
echo("\n");
}
diff --git a/scripts/agent-local/README b/scripts/agent-local/README
new file mode 100644
index 0000000000..b9fba04937
--- /dev/null
+++ b/scripts/agent-local/README
@@ -0,0 +1,5 @@
+These are local plugin scripts for the Observium Unix Agent.
+
+*DO NOT* put all of these files into your local folder, only use the scripts you want.
+
+Make sure that you configure any scripts that require configuration. (MySQL!)
diff --git a/scripts/agent-local/apache b/scripts/agent-local/apache
index 0270dcce7f..48652257ae 100755
--- a/scripts/agent-local/apache
+++ b/scripts/agent-local/apache
@@ -14,7 +14,7 @@
use LWP::Simple;
$CACHETIME = 30;
-$CACHEFILE = '/tmp/snmp-cache-apache';
+$CACHEFILE = '/tmp/observium-agent-apache';
# check for cache file newer CACHETIME seconds ago
if ( -f $CACHEFILE && time - (stat( $CACHEFILE ))[9] < $CACHETIME) {
diff --git a/scripts/agent-local/munin b/scripts/agent-local/munin
new file mode 100755
index 0000000000..242086d246
--- /dev/null
+++ b/scripts/agent-local/munin
@@ -0,0 +1,14 @@
+# Lokale Einzelchecks
+if cd munin-scripts
+then
+ for skript in $(ls)
+ do
+ if [ -x "$skript" ] ; then
+ echo "<<>>"
+ ./$skript
+ ./$skript config
+ fi
+ done
+ cd ..
+fi
+
diff --git a/scripts/agent-local/mysql b/scripts/agent-local/mysql
index 72297c2390..a0ca1b5ec3 100755
--- a/scripts/agent-local/mysql
+++ b/scripts/agent-local/mysql
@@ -49,7 +49,7 @@ $mysql_port = 3306;
$mysql_ssl = FALSE; # Whether to use SSL to connect to MySQL.
$heartbeat = ''; # db.tbl in case you use mk-heartbeat from Maatkit.
-$cache_dir = '/tmp'; # If set, this uses caching to avoid multiple calls.
+$cache_dir = '/tmp'; # If set, this uses caching to avoid multiple calls.
$cache_time = 30; # How long to cache data.
$chk_options = array (
@@ -283,7 +283,7 @@ function ss_get_mysql_stats( $options ) {
}
$sanitized_host = str_replace(array(":", "/"), array("", "_"), $host);
- $cache_file = "$cache_dir/mysql_stats.txt";
+ $cache_file = "$cache_dir/observium-agent-mysql";
debug("Cache file is $cache_file");
# First, check the cache.
diff --git a/sql-schema/014.sql b/sql-schema/014.sql
new file mode 100644
index 0000000000..5c6b6dfd3a
--- /dev/null
+++ b/sql-schema/014.sql
@@ -0,0 +1,2 @@
+CREATE TABLE IF NOT EXISTS `munin_plugins` ( `mplug_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `mplug_type` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `mplug_instance` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `mplug_category` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `mplug_title` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `mplug_info` text CHARACTER SET utf8 COLLATE utf8_bin, `mplug_vlabel` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `mplug_args` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `mplug_total` binary(1) NOT NULL DEFAULT '0', `mplug_graph` binary(1) NOT NULL DEFAULT '1', PRIMARY KEY (`mplug_id`), UNIQUE KEY `UNIQUE` (`device_id`,`mplug_type`), KEY `device_id` (`device_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
+CREATE TABLE IF NOT EXISTS `munin_plugins_ds` ( `mplug_id` int(11) NOT NULL, `ds_name` varchar(32) COLLATE utf8_bin NOT NULL, `ds_type` enum('COUNTER','ABSOLUTE','DERIVE','GAUGE') COLLATE utf8_bin NOT NULL DEFAULT 'GAUGE', `ds_label` varchar(64) COLLATE utf8_bin NOT NULL, `ds_cdef` text COLLATE utf8_bin NOT NULL, `ds_draw` varchar(64) COLLATE utf8_bin NOT NULL, `ds_graph` enum('no','yes') COLLATE utf8_bin NOT NULL DEFAULT 'yes', `ds_info` varchar(255) COLLATE utf8_bin NOT NULL, `ds_extinfo` text COLLATE utf8_bin NOT NULL, `ds_max` varchar(32) COLLATE utf8_bin NOT NULL, `ds_min` varchar(32) COLLATE utf8_bin NOT NULL, `ds_negative` varchar(32) COLLATE utf8_bin NOT NULL, `ds_warning` varchar(32) COLLATE utf8_bin NOT NULL, `ds_critical` varchar(32) COLLATE utf8_bin NOT NULL, `ds_colour` varchar(32) COLLATE utf8_bin NOT NULL, `ds_sum` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `ds_stack` text COLLATE utf8_bin NOT NULL, `ds_line` varchar(64) COLLATE utf8_bin NOT NULL, UNIQUE KEY `splug_id` (`mplug_id`,`ds_name`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;