mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
cleanups, small fixes and remove test-*php from the root
git-svn-id: http://www.observium.org/svn/observer/trunk@1998 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0)
|
||||
{
|
||||
global $twoday; global $day; global $now; global $config;
|
||||
global $twoday, $day, $now, $config;
|
||||
|
||||
if (!$start) { $start = $day; }
|
||||
if (!$end) { $end = $now; }
|
||||
@@ -56,7 +56,6 @@ function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0
|
||||
return $device['hostname'];
|
||||
}
|
||||
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
@@ -92,8 +91,8 @@ function generate_graph_popup($graph_array)
|
||||
$graph_array['from'] = $config['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
return overlib_link($graph_array['link'], $graph, $content, NULL);
|
||||
|
||||
return overlib_link($graph_array['link'], $graph, $content, NULL);
|
||||
}
|
||||
|
||||
function print_graph_popup($graph_array)
|
||||
@@ -101,8 +100,6 @@ function print_graph_popup($graph_array)
|
||||
echo(generate_graph_popup($graph_array));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function permissions_cache($user_id)
|
||||
{
|
||||
$permissions = array();
|
||||
@@ -121,12 +118,13 @@ function permissions_cache($user_id)
|
||||
{
|
||||
$permissions['bill'][$bill['bill_id']] = 1;
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
function bill_permitted($bill_id)
|
||||
{
|
||||
global $_SESSION; global $permissions;
|
||||
global $_SESSION, $permissions;
|
||||
|
||||
if ($_SESSION['userlevel'] >= "5") {
|
||||
$allowed = TRUE;
|
||||
@@ -141,7 +139,7 @@ function bill_permitted($bill_id)
|
||||
|
||||
function port_permitted($interface_id, $device_id = NULL)
|
||||
{
|
||||
global $_SESSION; global $permissions;
|
||||
global $_SESSION, $permissions;
|
||||
|
||||
if (!is_numeric($device_id)) { $device_id = get_device_id_by_interface_id($interface_id); }
|
||||
|
||||
@@ -161,7 +159,7 @@ function port_permitted($interface_id, $device_id = NULL)
|
||||
|
||||
function application_permitted($app_id, $device_id = NULL)
|
||||
{
|
||||
global $_SESSION; global $permissions;
|
||||
global $_SESSION, $permissions;
|
||||
if (is_numeric($app_id))
|
||||
{
|
||||
if (!$device_id) { $device_id = device_by_id_cache ($app_id); }
|
||||
@@ -177,12 +175,13 @@ function application_permitted($app_id, $device_id = NULL)
|
||||
} else {
|
||||
$allowed = FALSE;
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
}
|
||||
|
||||
function device_permitted($device_id)
|
||||
{
|
||||
global $_SESSION; global $permissions;
|
||||
global $_SESSION, $permissions;
|
||||
|
||||
if ($_SESSION['userlevel'] >= "5")
|
||||
{
|
||||
@@ -212,10 +211,10 @@ function generate_graph_tag ($args)
|
||||
$url .= $sep.$key."=".$arg;
|
||||
$sep="&";
|
||||
}
|
||||
|
||||
return "<img src=\"".$url."\" border=0>";
|
||||
}
|
||||
|
||||
|
||||
function print_percentage_bar ($width, $height, $percent, $left_text, $left_colour, $left_background, $right_text, $right_colour, $right_background)
|
||||
{
|
||||
$output = '
|
||||
@@ -226,12 +225,14 @@ function print_percentage_bar ($width, $height, $percent, $left_text, $left_colo
|
||||
<div style="vertical-align: middle;height: '.$height.'px;margin-top:-'.($height).'px; color:#'.$right_colour.'; padding-right:4px;text-align:right;"><b>'.$right_text.'</b></div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
{
|
||||
global $twoday; global $now; global $config; global $day; global $month;
|
||||
global $twoday, $now, $config, $day, $month;
|
||||
|
||||
$args = ifNameDescr($args);
|
||||
if (!$text) { $text = fixIfName($args['label']); }
|
||||
if ($type) { $args['graph_type'] = $type; }
|
||||
@@ -270,9 +271,9 @@ function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
|
||||
function generate_port_thumbnail($args)
|
||||
{
|
||||
if (!$args['bg']) { $args['bg'] = "FFFFF"; }
|
||||
$args['content'] = "<img src='graph.php?type=".$args['graph_type']."&id=".$args['interface_id']."&from=".$args['from']."&to=".$args['to']."&width=".$args['width']."&height=".$args['height']."&legend=no&bg=".$args['bg']."'>";
|
||||
echo generate_port_link($args, $args['content']);
|
||||
if (!$args['bg']) { $args['bg'] = "FFFFF"; }
|
||||
$args['content'] = "<img src='graph.php?type=".$args['graph_type']."&id=".$args['interface_id']."&from=".$args['from']."&to=".$args['to']."&width=".$args['width']."&height=".$args['height']."&legend=no&bg=".$args['bg']."'>";
|
||||
echo(generate_port_link($args, $args['content']));
|
||||
}
|
||||
|
||||
function print_optionbar_start ($height = 20, $width = 0, $marginbottom = 5)
|
||||
@@ -289,7 +290,6 @@ function print_optionbar_start ($height = 20, $width = 0, $marginbottom = 5)
|
||||
<div style='margin: auto; text-align: left; padding: 2px 5px; padding-left: 11px; clear: both; display:block; " . ($height ? 'height:' . $height . 'px;' : '') . "'>");
|
||||
}
|
||||
|
||||
|
||||
function print_optionbar_end()
|
||||
{
|
||||
echo(' </div>
|
||||
|
@@ -4,10 +4,10 @@ $scale_min = "0";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fanspeed-" . $sensor['sensor_type'] .'-'. $sensor['sensor_index'] . ".rrd");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 20),0,20);
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE";
|
||||
|
@@ -5,10 +5,9 @@ $scale_max = "40";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("humidity-" . $sensor['sensor_descr'] . ".rrd");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28);
|
||||
|
||||
|
@@ -5,11 +5,10 @@ $scale_max = "60";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
|
||||
### FIXME: Overwrite default because it won't work here yet
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temperature-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 21),0,21);
|
||||
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
|
||||
|
||||
@@ -28,8 +27,8 @@ $rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . $sensor['sensor_descr_fixed']."'";
|
||||
# $rrd_options .= " LINE1.5:sensorwarm#660000";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%4.1lfC";
|
||||
$rrd_options .= " GPRINT:sensor_min:MIN:%4.1lfC";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%4.1lfC";
|
||||
$rrd_options .= " GPRINT:sensor_max:MAX:%4.1lfC\\\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<div style='padding: 10px; height: 20px; clear: both; display: block;'>
|
||||
<div style='float: left; font-size: 22px; font-weight: bold;'>Local AS : <?php echo $device['bgpLocalAs'] ?></div>
|
||||
<div style='float: left; font-size: 22px; font-weight: bold;'>Local AS : <?php echo($device['bgpLocalAs']); ?></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
@@ -40,7 +40,7 @@ $disable_notify = get_dev_attrib($device,'disable_notify');
|
||||
<tr>
|
||||
<td width="50"><div style="padding-right: 5px; text-align: right"><input onclick="edit.sysContact.disabled=!edit.override_sysContact.checked" type="checkbox" name="override_sysContact"<?php if ($override_sysContact_bool) { echo(' checked="1"'); } ?> /></div></td>
|
||||
<td width="150">Override sysContact:</td>
|
||||
<td><input name="sysContact" size="32"<?php if (!$override_sysContact_bool) { echo(' disabled="1"'); } ?> value="<?php echo $override_sysContact_string; ?>" /></td>
|
||||
<td><input name="sysContact" size="32"<?php if (!$override_sysContact_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysContact_string); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50"><div style="padding-right: 5px; text-align: right"><input type="checkbox" name="disable_notify"<?php if ($disable_notify) { echo(' checked="1"'); } ?> /></div></td>
|
||||
|
@@ -36,16 +36,16 @@ if ($updated && $update_message)
|
||||
<table width="500" border="0">
|
||||
<tr>
|
||||
<td width="150"><div align="right">IPMI/BMC Hostname</div></td>
|
||||
<td colspan="3"><input name="ipmi_hostname" size="32" value="<?php echo get_dev_attrib($device,'ipmi_hostname'); ?>" /></td>
|
||||
<td colspan="3"><input name="ipmi_hostname" size="32" value="<?php echo(get_dev_attrib($device,'ipmi_hostname')); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right">IPMI/BMC Username</div></td>
|
||||
<td colspan="3"><input name="ipmi_username" size="32" value="<?php echo get_dev_attrib($device,'ipmi_username'); ?>" /></td>
|
||||
<td colspan="3"><input name="ipmi_username" size="32" value="<?php echo(get_dev_attrib($device,'ipmi_username')); ?>" /></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right">IPMI/BMC Password</div></td>
|
||||
<td colspan="3"><input name="ipmi_password" type="password" size="32" value="<?php echo get_dev_attrib($device,'ipmi_password'); ?>" /></td>
|
||||
<td colspan="3"><input name="ipmi_password" type="password" size="32" value="<?php echo(get_dev_attrib($device,'ipmi_password')); ?>" /></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@@ -73,9 +73,9 @@ echo("<table cellpadding=0 cellspacing=0><tr><td>
|
||||
|
||||
foreach ($config['snmp']['transports'] as $transport)
|
||||
{
|
||||
echo ("<option value='".$transport."'");
|
||||
if ($transport == $device['transport']) { echo (" selected='selected'"); }
|
||||
echo (">".$transport."</option>");
|
||||
echo("<option value='".$transport."'");
|
||||
if ($transport == $device['transport']) { echo(" selected='selected'"); }
|
||||
echo(">".$transport."</option>");
|
||||
}
|
||||
|
||||
echo(" </select>
|
||||
|
@@ -188,6 +188,4 @@ function getTotal($bill_id,$datefrom,$dateto)
|
||||
return($mtot);
|
||||
}
|
||||
|
||||
$dayofmonth = date("j"); //FIXME is this used anywhere?
|
||||
|
||||
?>
|
@@ -223,4 +223,5 @@ $config['astext'][65333] = "Cymru Bogon Feed";
|
||||
|
||||
### What should we warn about?
|
||||
$config['warn']['ifdown'] = false;
|
||||
|
||||
?>
|
@@ -64,7 +64,7 @@
|
||||
mysql_query($sql);
|
||||
echo(".");
|
||||
} else {
|
||||
$sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `entPhysicalHardwareRev`,`entPhysicalFirmwareRev`,`entPhysicalSoftwareRev`,`entPhysicalIsFRU`,`entPhysicalAlias`,`entPhysicalAssetID`, `ifIndex` ) ";
|
||||
$sql = "INSERT INTO `entPhysical` (`device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `entPhysicalHardwareRev`,`entPhysicalFirmwareRev`,`entPhysicalSoftwareRev`,`entPhysicalIsFRU`,`entPhysicalAlias`,`entPhysicalAssetID`, `ifIndex`) ";
|
||||
$sql .= "VALUES ( '" . $device['device_id'] . "', '$entPhysicalIndex', '$entPhysicalDescr', '$entPhysicalClass', '$entPhysicalName', '$entPhysicalModelName', '$entPhysicalSerialNum', '$entPhysicalContainedIn', '$entPhysicalMfgName','$entPhysicalParentRelPos' , '$entPhysicalVendorType', '$entPhysicalHardwareRev', '$entPhysicalFirmwareRev', '$entPhysicalSoftwareRev', '$entPhysicalIsFRU', '$entPhysicalAlias', '$entPhysicalAssetID', '$ifIndex')";
|
||||
mysql_query($sql);
|
||||
echo("+");
|
||||
|
@@ -79,6 +79,6 @@ while ($row = mysql_fetch_array($data))
|
||||
|
||||
unset($valid_v6);
|
||||
|
||||
echo "\n";
|
||||
echo("\n");
|
||||
|
||||
?>
|
@@ -7,7 +7,7 @@ if ($device['os_group'] == "unix")
|
||||
# FIXME snmp_walk
|
||||
# ObserverNMS-style temperature
|
||||
$cmd = $config['snmpwalk'] . " -M " . $config['mibdir'] . " -M " . $config['mibdir'] . " -".$device['snmpver']." -m SNMPv2-SMI -Osqn -CI -c ".$device['community']." ".$device['transport'].":".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1";
|
||||
if ($debug) { echo "$cmd\n"; }
|
||||
if ($debug) { echo("$cmd\n"); }
|
||||
$oids = shell_exec($cmd);
|
||||
$oids = trim($oids);
|
||||
if ($oids) echo("Observer-Style ");
|
||||
|
@@ -73,7 +73,7 @@ if ($device['os'] == "vmware")
|
||||
mysql_query("INSERT INTO vmware_vminfo (device_id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState) VALUES (" . $device["device_id"] . ", " . $oid . ", '" . mres($vmwVmDisplayName) . "', '" . mres($vmwVmGuestOS) . "', " . $vmwVmMemSize . ", " . $vmwVmCpus . ", '" . mres($vmwVmState) . "')");
|
||||
echo("+");
|
||||
} else {
|
||||
echo ".";
|
||||
echo(".");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -30,7 +30,7 @@ while ($dbcurrent = mysql_fetch_array($current_data))
|
||||
# FIXME also warn when crossing WARN level!!
|
||||
if ($dbcurrent['sensor_current'] > $dbcurrent['sensor_limit_low'] && $current <= $dbcurrent['sensor_limit_low'])
|
||||
{
|
||||
$msg = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is " . $current . "A (Limit " . $dbcurrent['sensor_limit'];
|
||||
$msg = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is under threshold: " . $current . "A (< " . $dbcurrent['sensor_limit'];
|
||||
$msg .= "A) at " . date($config['timestamp_format']);
|
||||
notify($device, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n");
|
||||
@@ -38,7 +38,7 @@ while ($dbcurrent = mysql_fetch_array($current_data))
|
||||
}
|
||||
else if ($dbcurrent['sensor_current'] < $dbcurrent['sensor_limit'] && $current >= $dbcurrent['sensor_limit'])
|
||||
{
|
||||
$msg = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is " . $current . "A (Limit " . $dbcurrent['sensor_limit'];
|
||||
$msg = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is over threshold: " . $current . "A (> " . $dbcurrent['sensor_limit'];
|
||||
$msg .= "A) at " . date($config['timestamp_format']);
|
||||
notify($device, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n");
|
||||
|
@@ -7,14 +7,13 @@ function rrdtool_update($rrdfile, $rrdupdate)
|
||||
|
||||
function rrdtool_create($rrdfile, $rrdupdate)
|
||||
{
|
||||
global $config; global $debug;
|
||||
global $config, $debug;
|
||||
|
||||
$command = $config['rrdtool'] . " create $rrdfile $rrdupdate";
|
||||
|
||||
if ($debug) { echo($command."\n"); }
|
||||
|
||||
return shell_exec($command);
|
||||
|
||||
}
|
||||
|
||||
function rrdtool_fetch($rrdfile, $rrdupdate)
|
||||
@@ -39,7 +38,7 @@ function rrdtool_lastupdate($rrdfile, $rrdupdate)
|
||||
|
||||
function rrdtool($command, $file, $options)
|
||||
{
|
||||
global $config; global $debug;
|
||||
global $config, $debug;
|
||||
|
||||
$command = $config['rrdtool'] . " $command $file $options";
|
||||
if ($config['rrdcached'])
|
||||
@@ -48,6 +47,7 @@ function rrdtool($command, $file, $options)
|
||||
}
|
||||
|
||||
if ($debug) { echo($command."\n"); }
|
||||
|
||||
return shell_exec($command);
|
||||
}
|
||||
|
||||
|
@@ -105,11 +105,10 @@ function snmp_get($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
$device['transport'] = "udp";
|
||||
}
|
||||
|
||||
|
||||
if (strstr($oid,' '))
|
||||
{
|
||||
echo "BUG: snmp_get called for multiple OIDs: $oid\n";
|
||||
echo "Please report this to the Observium team.";
|
||||
echo("BUG: snmp_get called for multiple OIDs: $oid\n");
|
||||
echo("Please report this to the Observium team.");
|
||||
}
|
||||
|
||||
if ($config['snmp']['internal'] == true)
|
||||
|
102
scripts/distro
102
scripts/distro
@@ -7,54 +7,58 @@ MACH=`uname -m`
|
||||
|
||||
GetVersionFromFile()
|
||||
{
|
||||
VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
|
||||
}
|
||||
VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
|
||||
}
|
||||
|
||||
if [ "${OS}" = "SunOS" ] ; then
|
||||
OS=Solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
elif [ "${OS}" = "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
elif [ "${OS}" = "Linux" ] ; then
|
||||
KERNEL=`uname -r`
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
DIST=$(cat /etc/redhat-release | awk '{print $1}')
|
||||
if [ "${DIST}" = "CentOS" ]; then
|
||||
DIST="CentOS"
|
||||
else
|
||||
DIST="RedHat"
|
||||
fi
|
||||
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
elif [ -f /etc/SuSE-release ] ; then
|
||||
DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
|
||||
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
|
||||
elif [ -f /etc/mandrake-release ] ; then
|
||||
DIST='Mandrake'
|
||||
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
elif [ -f /etc/debian_version ] ; then
|
||||
DIST="Debian `cat /etc/debian_version`"
|
||||
REV=""
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
fi
|
||||
if [ -f /etc/lsb-release ] ; then
|
||||
LSB_DIST="`cat /etc/lsb-release | grep DISTRIB_ID | cut -d "=" -f2`"
|
||||
LSB_REV="`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2`"
|
||||
if [ "$LSB_DIST" != "" ] ; then
|
||||
DIST=$LSB_DIST
|
||||
REV=$LSB_REV
|
||||
fi
|
||||
fi
|
||||
# OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
|
||||
OSSTR="${DIST} ${REV}"
|
||||
elif [ "${OS}" = "Darwin" ] ; then
|
||||
if [ -f /usr/bin/sw_vers ] ; then
|
||||
OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
|
||||
fi
|
||||
fi
|
||||
echo ${OSSTR}
|
||||
if [ "${OS}" = "SunOS" ] ; then
|
||||
OS=Solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
elif [ "${OS}" = "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
elif [ "${OS}" = "Linux" ] ; then
|
||||
KERNEL=`uname -r`
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
DIST=$(cat /etc/redhat-release | awk '{print $1}')
|
||||
if [ "${DIST}" = "CentOS" ]; then
|
||||
DIST="CentOS"
|
||||
else
|
||||
DIST="RedHat"
|
||||
fi
|
||||
|
||||
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
elif [ -f /etc/SuSE-release ] ; then
|
||||
DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
|
||||
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
|
||||
elif [ -f /etc/mandrake-release ] ; then
|
||||
DIST='Mandrake'
|
||||
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
elif [ -f /etc/debian_version ] ; then
|
||||
DIST="Debian `cat /etc/debian_version`"
|
||||
REV=""
|
||||
fi
|
||||
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
fi
|
||||
|
||||
if [ -f /etc/lsb-release ] ; then
|
||||
LSB_DIST="`cat /etc/lsb-release | grep DISTRIB_ID | cut -d "=" -f2`"
|
||||
LSB_REV="`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2`"
|
||||
if [ "$LSB_DIST" != "" ] ; then
|
||||
DIST=$LSB_DIST
|
||||
REV=$LSB_REV
|
||||
fi
|
||||
fi
|
||||
|
||||
# OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
|
||||
OSSTR="${DIST} ${REV}"
|
||||
elif [ "${OS}" = "Darwin" ] ; then
|
||||
if [ -f /usr/bin/sw_vers ] ; then
|
||||
OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ${OSSTR}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
$language_data = array (
|
||||
|
||||
'LANG_NAME' => 'IOS',
|
||||
|
@@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
|
||||
include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
include("includes/discovery/functions.inc.php");
|
||||
|
||||
$start = utime();
|
||||
|
||||
### Observium Device Discovery
|
||||
|
||||
echo("Observium v".$config['version']." Discovery\n\n");
|
||||
|
||||
if($argv[1] == "--device" && $argv[2]) {
|
||||
$where = "AND `device_id` = '".$argv[2]."'";
|
||||
} elseif ($argv[1] == "--os") {
|
||||
$where = "AND `os` = '".$argv[2]."'";
|
||||
} elseif ($argv[1] == "--odd") {
|
||||
$where = "AND MOD(device_id,2) = 1";
|
||||
} elseif ($argv[1] == "--even") {
|
||||
$where = "AND MOD(device_id,2) = 0";
|
||||
} elseif ($argv[1] == "--all") {
|
||||
$where = "";
|
||||
} else {
|
||||
echo("--device <device id> Poll single device\n");
|
||||
echo("--os <os string> Poll all devices of a given OS\n");
|
||||
echo("--all Poll all devices\n\n");
|
||||
echo("No polling type specified!\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
$debug = 1;
|
||||
|
||||
if ($argv[2] == "--type" && $argv[3]) {
|
||||
$discovery_type = $argv[3];
|
||||
} elseif ($argv[3] == "--type" && $argv[4]) {
|
||||
$discovery_type = $argv[4];
|
||||
} else {
|
||||
echo("Require valid discovery type.\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
$devices_polled = 0;
|
||||
|
||||
echo("includes/discovery/".$discovery_type.".php \n");
|
||||
|
||||
#$debug = 1;
|
||||
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id ASC");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
echo($device['hostname'] . "(".$device['sysName']."|".$device['device_id'].")\n");
|
||||
if($config['os'][$device['os']]['group']) {$device['os_group'] = $config['os'][$device['os']]['group']; echo "(".$device['os_group'].")";}
|
||||
|
||||
include("includes/discovery/".$discovery_type);
|
||||
|
||||
echo("\n"); $devices_polled++;
|
||||
}
|
||||
|
||||
$end = utime(); $run = $end - $start;
|
||||
$proctime = substr($run, 0, 5);
|
||||
|
||||
echo("$devices_polled devices polled in $proctime secs\n $mysql SQL");
|
||||
|
||||
|
||||
?>
|
@@ -1,65 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$debug =1;
|
||||
|
||||
$poller_start = utime();
|
||||
|
||||
### Observium Device Polling Test
|
||||
|
||||
echo("Observium v".$config['version']." Discovery\n\n");
|
||||
|
||||
if($argv[1] == "--device" && $argv[2]) {
|
||||
$where = "AND `device_id` = '".$argv[2]."'";
|
||||
} elseif ($argv[1] == "--os") {
|
||||
$where = "AND `os` = '".$argv[2]."'";
|
||||
} elseif ($argv[1] == "--odd") {
|
||||
$where = "AND MOD(device_id,2) = 1";
|
||||
} elseif ($argv[1] == "--even") {
|
||||
$where = "AND MOD(device_id,2) = 0";
|
||||
} elseif ($argv[1] == "--all") {
|
||||
$where = "";
|
||||
} else {
|
||||
echo("--device <device id> Poll single device\n");
|
||||
echo("--os <os string> Poll all devices of a given OS\n");
|
||||
echo("--all Poll all devices\n\n");
|
||||
echo("No polling type specified!\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($argv[2] == "--type" && $argv[3]) {
|
||||
$type = $argv[3];
|
||||
} elseif ($argv[3] == "--type" && $argv[4]) {
|
||||
$type = $argv[4];
|
||||
} else {
|
||||
echo("Require valid polling type.\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
$devices_polled = 0;
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id DESC");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
echo("\n" . $device['hostname'] ."\n");
|
||||
$host_rrd = $config['rrd_dir'] . "/" . $device['hostname'];
|
||||
$where = "WHERE device_id = '" . $device['device_id'] . "' AND deleted = '0'";
|
||||
include("includes/polling/".$type.".inc.php");
|
||||
|
||||
echo("\n"); $devices_polled++;
|
||||
|
||||
unset($array);
|
||||
|
||||
}
|
||||
|
||||
$poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5);
|
||||
|
||||
$string = $argv[0] . " " . date("F j, Y, G:i") . " - $i devices polled in $poller_time secs";
|
||||
echo("$string\n");
|
||||
shell_exec("echo '".$string."' >> /tmp/observer.log");
|
||||
|
||||
?>
|
Reference in New Issue
Block a user