diff --git a/includes/billing.php b/includes/billing.php index 27b20dafd..52ac54c0d 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -3,16 +3,17 @@ function format_bytes_billing($value) { global $config; + return format_number($value, $config['billing']['base'])."B"; } function format_bytes_billing_short($value) { global $config; + return format_number($value, $config['billing']['base'], 2, 3); } - function getDates($dayofmonth, $months=0) { $dayofmonth = zeropad($dayofmonth); @@ -30,13 +31,12 @@ function getDates($dayofmonth, $months=0) date_sub($date_start, date_interval_create_from_date_string('1 month')); } - if($months > 0) + if ($months > 0) { date_sub($date_start, date_interval_create_from_date_string($months.' month')); date_sub($date_end, date_interval_create_from_date_string($months.' month')); } - # date_sub($date_start, date_interval_create_from_date_string('1 month')); date_sub($date_end, date_interval_create_from_date_string('1 day')); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 8393a99b3..796e2db17 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -37,15 +37,13 @@ $config['unflatten'] = "/usr/bin/unflatten"; $config['neato'] = "/usr/bin/neato"; $config['sfdp'] = "/usr/bin/sfdp"; - ### Memcached - Keep immediate statistics -$config['memcached']['enable'] = FALSE; +$config['memcached']['enable'] = FALSE; $config['memcached']['host'] = "localhost"; $config['memcached']['port'] = 11211; -$config['slow_statistics'] = TRUE; ### THIS WILL CHANGE TO FALSE IN FUTURE - +$config['slow_statistics'] = TRUE; ### THIS WILL CHANGE TO FALSE IN FUTURE ### RRDCacheD - Make sure it can write to your RRD dir! @@ -57,7 +55,7 @@ if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"])) { if (strpos($_SERVER["SERVER_NAME"] , ":")) { - # Litteral IPv6 + # Literal IPv6 $config['base_url'] = "http://[" . $_SERVER["SERVER_NAME"] ."]:".$_SERVER["SERVER_PORT"]."/"; } else @@ -98,12 +96,12 @@ $config['snmp']['transports'] = array('udp', 'udp6', 'tcp', 'tcp6'); ### Autodiscovery Settings -$config['autodiscovery']['xdp'] = true; ## Autodiscover hosts via discovery protocols -$config['autodiscovery']['ospf'] = true; ## Autodiscover hosts via OSPF -$config['autodiscovery']['bgp'] = true; ## Autodiscover hosts via BGP -$config['autodiscovery']['snmpscan'] = true; ## autodiscover hosts via SNMP scanning +$config['autodiscovery']['xdp'] = TRUE; ## Autodiscover hosts via discovery protocols +$config['autodiscovery']['ospf'] = TRUE; ## Autodiscover hosts via OSPF +$config['autodiscovery']['bgp'] = TRUE; ## Autodiscover hosts via BGP +$config['autodiscovery']['snmpscan'] = TRUE; ## autodiscover hosts via SNMP scanning -$config['discover_services'] = false; ## Autodiscover services via SNMP on devices of type "server" +$config['discover_services'] = FALSE; ## Autodiscover services via SNMP on devices of type "server" ### Alerting Settings @@ -111,7 +109,7 @@ $config['alerts']['email']['default'] = NULL; ## Default alert recipient $config['alerts']['email']['default_only'] = FALSE; ## Only use default recipient $config['alerts']['email']['enable'] = TRUE; ## Enable email alerts $config['alerts']['bgp']['whitelist'] = NULL; ## Populate as an array() with ASNs to alert on. -$config['alerts']['port']['ifdown'] = FALSE; ## Generate alerts for ports that go down +$config['alerts']['port']['ifdown'] = FALSE; ## Generate alerts for ports that go down ### Port bandwidth threshold percentage %age utilisation above this will cause an alert @@ -160,11 +158,11 @@ $config['graph_colours']['default'] = $config['graph_colours']['blues']; ### Device page options -$config['show_overview_tab'] = true; +$config['show_overview_tab'] = TRUE; ### The device overview page options -$config['overview_show_sysDescr'] = true; +$config['overview_show_sysDescr'] = TRUE; ### Enable version checker & stats @@ -296,9 +294,9 @@ $config['irc_chan'][] = "#observium"; ### Authentication -$config['allow_unauth_graphs'] = 0; ## Allow graphs to be viewed by anyone +$config['allow_unauth_graphs'] = 0; # Allow graphs to be viewed by anyone $config['allow_unauth_graphs_cidr'] = array(); # Allow graphs to be viewed without authorisation from certain IP ranges -$config['auth_mechanism'] = "mysql"; # Available mechanisms: mysql (default), ldap, http-auth +$config['auth_mechanism'] = "mysql"; # Available mechanisms: mysql (default), ldap, http-auth ### Sensors @@ -372,7 +370,6 @@ $config['astext'][65333] = "Cymru Bogon Feed"; ### Warnings on front page $config['warn']['ifdown'] = TRUE; ## Show down interfaces - ## List of poller modules. Need to be in the array to be ## considered for execution. @@ -401,7 +398,7 @@ $config['poller_modules']['cisco-cef'] = 1; $config['poller_modules']['cisco-mac-accounting'] = 1; $config['poller_modules']['cipsec-tunnels'] = 1; $config['poller_modules']['cisco-ace-loadbalancer'] = 1; -$config['poller_modules']['cisco-ace-serverfarms'] = 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; @@ -434,7 +431,6 @@ $config['discovery_modules']['toner'] = 1; $config['discovery_modules']['ucd-diskio'] = 1; $config['discovery_modules']['services'] = 1; - $config['modules_compat']['rfc1628']['liebert'] = 1; $config['modules_compat']['rfc1628']['netmanplus'] = 1; $config['modules_compat']['rfc1628']['deltaups'] = 1; diff --git a/includes/functions.php b/includes/functions.php index 42bc637ff..832d5c758 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -575,6 +575,7 @@ function include_dir($dir, $regex = "") if (filetype($config['install_dir'] . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file)) { if ($debug) { echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n"); } + include($config['install_dir'] . '/' . $dir . '/' . $file); } } diff --git a/includes/include-dir.inc.php b/includes/include-dir.inc.php index f4e15214d..98d5ab252 100644 --- a/includes/include-dir.inc.php +++ b/includes/include-dir.inc.php @@ -14,6 +14,7 @@ if (filetype($config['install_dir'] . '/' . $include_dir . '/' . $file) == 'file' && preg_match($include_dir_regexp, $file)) { if ($debug) { echo("Including: " . $config['install_dir'] . '/' . $include_dir . '/' . $file . "\n"); } + include($config['install_dir'] . '/' . $include_dir . '/' . $file); } } diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index a9da1fdc2..10245aac5 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -68,8 +68,8 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) function rrdtool_pipe_close(&$rrd_process, &$rrd_pipes) { - global $debug; + if ($debug) { echo stream_get_contents($rrd_pipes[1]); diff --git a/includes/static-config.php b/includes/static-config.php index dc55cf0a0..ae621dc23 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -33,7 +33,6 @@ $config['os'][$os]['over'][1]['text'] = "Processor Usage"; $config['os'][$os]['over'][2]['graph'] = "device_mempool"; $config['os'][$os]['over'][2]['text'] = "Memory Usage"; - ### Linux-based OSes here please. $os = "linux"; @@ -288,11 +287,11 @@ $config['os'][$os]['over'][2]['text'] = "Memory Usage"; $os = "ciscosb"; $config['os'][$os]['group'] = "cisco"; -$config['os'][$os]['text'] = "Cisco Small Business"; +$config['os'][$os]['text'] = "Cisco Small Business"; $config['os'][$os]['ifname'] = 1; $config['os'][$os]['type'] = "network"; $config['os'][$os]['icon'] = "linksys"; -$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; $config['os'][$os]['over'][0]['text'] = "Device Traffic"; ## Huawei @@ -389,7 +388,6 @@ $config['os'][$os]['icon'] = "brocade"; $config['os'][$os]['over'][0]['graph'] = "device_bits"; $config['os'][$os]['over'][0]['text'] = "Device Traffic"; - $os = "extremeware"; $config['os'][$os]['text'] = "Extremeware"; $config['os'][$os]['type'] = "network"; @@ -457,7 +455,6 @@ $config['os'][$os]['over'][0]['text'] = "Device Traffic"; $config['os'][$os]['over'][1]['graph'] = "device_processor"; $config['os'][$os]['over'][1]['text'] = "CPU Usage"; - $os = "proxim"; $config['os'][$os]['text'] = "Proxim"; $config['os'][$os]['type'] = "network"; @@ -1126,11 +1123,11 @@ if (!$observium_link) } $observium_db = mysql_select_db($config['db_name'], $observium_link); -if($config['memcached']['enable']) +if($config['memcached']['enable']) { $memcache = new Memcached(); $memcache->addServer($config['memcached']['host'], $config['memcached']['port']); - if($debug) { print_r($memcache->getStats()); } + if ($debug) { print_r($memcache->getStats()); } } # Set some times needed by loads of scripts (it's dynamic, so we do it here!) diff --git a/includes/syslog.php b/includes/syslog.php index 1146fe1c0..adf50ac09 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -6,16 +6,20 @@ # $device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id"); -function get_cache($host, $value) { +function get_cache($host, $value) +{ global $dev_cache; - if (!isset($dev_cache[$host][$value])) { - switch($value) { + if (!isset($dev_cache[$host][$value])) + { + switch($value) + { case 'device_id': - //Try by hostname + // Try by hostname $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host)); - //If failed, try by IP - if (!is_numeric($dev_cache[$host]['device_id'])) { + // If failed, try by IP + if (!is_numeric($dev_cache[$host]['device_id'])) + { $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `ipv4_addresses` AS A, `ports` AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id', array($host)); } break; @@ -32,9 +36,9 @@ function get_cache($host, $value) { return $dev_cache[$host][$value]; } -function process_syslog ($entry, $update) { - global $config; - global $dev_cache; +function process_syslog($entry, $update) +{ + global $config, $dev_cache; foreach ($config['syslog_filter'] as $bi) { @@ -47,10 +51,12 @@ function process_syslog ($entry, $update) { } $entry['device_id'] = get_cache($entry['host'], 'device_id'); - if ($entry['device_id']) { + if ($entry['device_id']) + { $os = get_cache($entry['host'], 'os'); - if (in_array($os, array('ios', 'iosxe', 'catos'))) { + if (in_array($os, array('ios', 'iosxe', 'catos'))) + { $matches = array(); # if (preg_match('#%(?P.*):( ?)(?P.*)#', $entry['msg'], $matches)) { # $entry['msg'] = $matches['msg']; @@ -87,7 +93,7 @@ function process_syslog ($entry, $update) { if (!$entry['msg']) { $entry['msg'] = $entry['program']; unset ($entry['program']); } } elseif($os == 'linux' and get_cache($entry['host'], 'version') == 'Point') { - //Cisco WAP200 and similar + // Cisco WAP200 and similar $matches = array(); if (preg_match('#Log: \[(?P.*)\] - (?P.*)#', $entry['msg'], $matches)) { $entry['msg'] = $matches['msg']; @@ -97,41 +103,47 @@ function process_syslog ($entry, $update) { } elseif($os == 'linux') { $matches = array(); - //User_CommonName/123.213.132.231:39872 VERIFY OK: depth=1, /C=PL/ST=Malopolska/O=VLO/CN=v-lo.krakow.pl/emailAddress=root@v-lo.krakow.pl - if ($entry['facility'] == 'daemon' and preg_match('#/([0-9]{1,3}\.) {3}[0-9]{1,3}:[0-9]{4,} ([A-Z]([A-Za-z])+( ?)) {2,}:#', $entry['msg'])) { + // User_CommonName/123.213.132.231:39872 VERIFY OK: depth=1, /C=PL/ST=Malopolska/O=VLO/CN=v-lo.krakow.pl/emailAddress=root@v-lo.krakow.pl + if ($entry['facility'] == 'daemon' and preg_match('#/([0-9]{1,3}\.) {3}[0-9]{1,3}:[0-9]{4,} ([A-Z]([A-Za-z])+( ?)) {2,}:#', $entry['msg'])) + { $entry['program'] = 'OpenVPN'; } - //pop3-login: Login: user=, method=PLAIN, rip=123.213.132.231, lip=123.213.132.231, TLS - //POP3(username): Disconnected: Logged out top=0/0, retr=0/0, del=0/1, size=2802 - elseif($entry['facility'] == 'mail' and preg_match('#^(((pop3|imap)\-login)|((POP3|IMAP)\(.*\))):', $entry['msg'])) { + // pop3-login: Login: user=, method=PLAIN, rip=123.213.132.231, lip=123.213.132.231, TLS + // POP3(username): Disconnected: Logged out top=0/0, retr=0/0, del=0/1, size=2802 + elseif($entry['facility'] == 'mail' and preg_match('#^(((pop3|imap)\-login)|((POP3|IMAP)\(.*\))):', $entry['msg'])) + { $entry['program'] = 'Dovecot'; } - //pam_krb5(sshd:auth): authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 - //pam_krb5[sshd:auth]: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 - elseif(preg_match('#^(?P(.*((\(|\[).*(\)|\])))):(?P.*)$#', $entry['msg'], $matches)) { + // pam_krb5(sshd:auth): authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 + // pam_krb5[sshd:auth]: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 + elseif(preg_match('#^(?P(.*((\(|\[).*(\)|\])))):(?P.*)$#', $entry['msg'], $matches)) + { $entry['msg'] = $matches['msg']; $entry['program'] = $matches['program']; } - //SYSLOG CONNECTION BROKEN; FD='6', SERVER='AF_INET(123.213.132.231:514)', time_reopen='60' - //pam_krb5: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 + // SYSLOG CONNECTION BROKEN; FD='6', SERVER='AF_INET(123.213.132.231:514)', time_reopen='60' + // pam_krb5: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 ## Disabled because broke this: - //diskio.c: don't know how to handle 10 request + // diskio.c: don't know how to handle 10 request #elseif($pos = strpos($entry['msg'], ';') or $pos = strpos($entry['msg'], ':')) { # $entry['program'] = substr($entry['msg'], 0, $pos); # $entry['msg'] = substr($entry['msg'], $pos+1); #} - //fallback, better than nothing... - elseif(empty($entry['program']) and !empty($entry['facility'])) { + // fallback, better than nothing... + elseif(empty($entry['program']) and !empty($entry['facility'])) + { $entry['program'] = $entry['facility']; } unset($matches); } - if (!isset($entry['program'])) { + if (!isset($entry['program'])) + { $entry['program'] = $entry['msg']; unset($entry['msg']); } + $entry['program'] = strtoupper($entry['program']); array_walk($entry, 'trim');