From bb4746d4d0b5508f5340402ae758ddf1443df5e9 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 31 Mar 2011 10:51:02 +0000 Subject: [PATCH] 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 --- html/includes/functions.inc.php | 30 +++--- html/includes/graphs/sensor/fanspeed.inc.php | 4 +- html/includes/graphs/sensor/humidity.inc.php | 3 +- .../graphs/sensor/temperature.inc.php | 7 +- html/pages/device/bgp.inc.php | 2 +- html/pages/device/edit/alerts.inc.php | 2 +- html/pages/device/edit/ipmi.inc.php | 6 +- html/pages/device/edit/snmp.inc.php | 6 +- includes/billing.php | 4 +- includes/defaults.inc.php | 3 +- includes/discovery/entity-physical.inc.php | 2 +- includes/discovery/ipv6-addresses.inc.php | 2 +- includes/discovery/ports.inc.php | 12 +-- .../temperatures/observernms-custom.inc.php | 2 +- includes/discovery/vmware-vminfo.inc.php | 2 +- includes/polling/current.inc.php | 4 +- includes/rewrites.php | 4 +- includes/rrdtool.inc.php | 8 +- includes/snmp.inc.php | 5 +- scripts/distro | 102 +++++++++--------- scripts/geshi-ios.php | 7 +- test-discovery.php | 69 ------------ test-poll.php | 65 ----------- 23 files changed, 108 insertions(+), 243 deletions(-) delete mode 100755 test-discovery.php delete mode 100755 test-poll.php diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 6e8e4bb5a..29dd78286 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -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 .= ""; - 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 ""; } - 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
'.$right_text.'
'; + 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'] = ""; - echo generate_port_link($args, $args['content']); + if (!$args['bg']) { $args['bg'] = "FFFFF"; } + $args['content'] = ""; + 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)
"); } - function print_optionbar_end() { echo('
diff --git a/html/includes/graphs/sensor/fanspeed.inc.php b/html/includes/graphs/sensor/fanspeed.inc.php index e1cb53605..c7c83859e 100644 --- a/html/includes/graphs/sensor/fanspeed.inc.php +++ b/html/includes/graphs/sensor/fanspeed.inc.php @@ -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"; diff --git a/html/includes/graphs/sensor/humidity.inc.php b/html/includes/graphs/sensor/humidity.inc.php index 74a97007c..08a51035f 100644 --- a/html/includes/graphs/sensor/humidity.inc.php +++ b/html/includes/graphs/sensor/humidity.inc.php @@ -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); diff --git a/html/includes/graphs/sensor/temperature.inc.php b/html/includes/graphs/sensor/temperature.inc.php index 3f81bdd63..baf687212 100644 --- a/html/includes/graphs/sensor/temperature.inc.php +++ b/html/includes/graphs/sensor/temperature.inc.php @@ -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"; diff --git a/html/pages/device/bgp.inc.php b/html/pages/device/bgp.inc.php index 4e3ae6802..4866f991d 100644 --- a/html/pages/device/bgp.inc.php +++ b/html/pages/device/bgp.inc.php @@ -1,5 +1,5 @@
-
Local AS :
+
Local AS :
/>
Override sysContact: - value="" /> + value="" />
/>
diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index 4cf760d95..f500468b7 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -36,16 +36,16 @@ if ($updated && $update_message) - + - + - + diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index e5c5c039e..51a529414 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -73,9 +73,9 @@ echo("
IPMI/BMC Hostname
IPMI/BMC Username
IPMI/BMC Password
foreach ($config['snmp']['transports'] as $transport) { - echo (""); + echo(""); } echo(" diff --git a/includes/billing.php b/includes/billing.php index 8dcf6f038..45577031f 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -188,6 +188,4 @@ function getTotal($bill_id,$datefrom,$dateto) return($mtot); } -$dayofmonth = date("j"); //FIXME is this used anywhere? - -?> +?> \ No newline at end of file diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 2ee6cedc3..0abd953f7 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -223,4 +223,5 @@ $config['astext'][65333] = "Cymru Bogon Feed"; ### What should we warn about? $config['warn']['ifdown'] = false; -?> + +?> \ No newline at end of file diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index ce2297573..0f5bf1ff0 100755 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -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("+"); diff --git a/includes/discovery/ipv6-addresses.inc.php b/includes/discovery/ipv6-addresses.inc.php index d5c150195..61e171647 100644 --- a/includes/discovery/ipv6-addresses.inc.php +++ b/includes/discovery/ipv6-addresses.inc.php @@ -79,6 +79,6 @@ while ($row = mysql_fetch_array($data)) unset($valid_v6); -echo "\n"; +echo("\n"); ?> \ No newline at end of file diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index ab934432b..04cf8f750 100755 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -21,13 +21,13 @@ foreach (explode("\n", $ports) as $entry) { $if = trim(strtolower($ifDescr)); $nullintf = 0; - foreach ($config['bad_if'] as $bi) - { - if (strstr($if, $bi)) - { - $nullintf = 1; + foreach ($config['bad_if'] as $bi) + { + if (strstr($if, $bi)) + { + $nullintf = 1; if($debug) { echo("ignored : $bi : $if"); } - } + } } if (is_array($config['bad_if_regexp'])) { diff --git a/includes/discovery/temperatures/observernms-custom.inc.php b/includes/discovery/temperatures/observernms-custom.inc.php index 2508e8e6e..b226bb228 100644 --- a/includes/discovery/temperatures/observernms-custom.inc.php +++ b/includes/discovery/temperatures/observernms-custom.inc.php @@ -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 "); diff --git a/includes/discovery/vmware-vminfo.inc.php b/includes/discovery/vmware-vminfo.inc.php index a59d0523e..a954d53d2 100755 --- a/includes/discovery/vmware-vminfo.inc.php +++ b/includes/discovery/vmware-vminfo.inc.php @@ -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("."); } /* diff --git a/includes/polling/current.inc.php b/includes/polling/current.inc.php index bbc8c9ee6..6f17725ab 100644 --- a/includes/polling/current.inc.php +++ b/includes/polling/current.inc.php @@ -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"); diff --git a/includes/rewrites.php b/includes/rewrites.php index 1a62edca0..45cfc043b 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -953,7 +953,7 @@ function array_preg_replace($array, $string) function rewrite_adslLineType($adslLineType) { $adslLineTypes = array ('noChannel' => 'No Channel', - 'fastOnly' => 'Fastpath', + 'fastOnly' => 'Fastpath', 'interleavedOnly' => 'Interleaved', 'fastOrInterleaved' => 'Fast/Interleaved', 'fastAndInterleaved' => 'Fast+Interleaved'); @@ -969,4 +969,4 @@ function rewrite_adslLineType($adslLineType) return($adslLineType); } -?> +?> \ No newline at end of file diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 1c37b7cf4..8b73d82cf 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -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,7 +47,8 @@ function rrdtool($command, $file, $options) } if ($debug) { echo($command."\n"); } + return shell_exec($command); } -?> +?> \ No newline at end of file diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index f17639549..fcf537f3b 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -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) diff --git a/scripts/distro b/scripts/distro index f4172acea..cce3f7c61 100755 --- a/scripts/distro +++ b/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} diff --git a/scripts/geshi-ios.php b/scripts/geshi-ios.php index 01ada56ba..ab587b511 100755 --- a/scripts/geshi-ios.php +++ b/scripts/geshi-ios.php @@ -1,6 +1,5 @@ 'IOS', @@ -9,7 +8,7 @@ $language_data = array ( 'OOLANG' => false, 'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX, 'KEYWORDS' => array( - 1 => array( + 1 => array( 'no', 'shutdown' ), # 2 => array( @@ -32,7 +31,7 @@ $language_data = array ( # 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl' # ), # 4 => array( - # 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide', + # 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide', # 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1', # 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent' # ), @@ -169,4 +168,4 @@ $language_data = array ( ); -?> +?> \ No newline at end of file diff --git a/test-discovery.php b/test-discovery.php deleted file mode 100755 index 8ae0ac2cd..000000000 --- a/test-discovery.php +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env php - Poll single device\n"); - echo("--os 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"); - - -?> diff --git a/test-poll.php b/test-poll.php deleted file mode 100755 index 99ecb67d2..000000000 --- a/test-poll.php +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env php - Poll single device\n"); - echo("--os 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"); - -?>