diff --git a/cron.sh b/cron.sh index 13048c287a..8865ed867f 100755 --- a/cron.sh +++ b/cron.sh @@ -11,3 +11,4 @@ wget -O /var/sites/network.vostron.net/rrd/dill.vostron.net-mail_virus.rrd http: wget -O /var/sites/network.vostron.net/rrd/dill.vostron.net-mail.rrd http://dill.vostron.net/rrd/mailgraph.rrd wget -O /var/sites/network.vostron.net/rrd/dill.vostron.net-courier.rrd http://dill.vostron.net/rrd/couriergraph.rrd +./poll-billing.php diff --git a/html/.htaccess b/html/.htaccess index 4f36fb6c93..d50cfe3ef0 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -10,3 +10,6 @@ RewriteCond %{REQUEST_URI} !^(.*)\.png$ RewriteRule ^([a-z]+)$ ?page=$1 +RewriteRule ^bills/([0-9]+) ?page=bills&bill=$1 +RewriteRule ^device/([0-9]+) ?page=device&id=$1 + diff --git a/html/css/styles.css b/html/css/styles.css index 223750395d..9a685da2f7 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -13,13 +13,16 @@ A.green:visited, A.green, .green {color: #008C00;} A.blue:visited, A.blue, .blue {color: #0000ff;} A.orange:visited, a.orange, .orange {color: #FF7400;} - .pinkbg { background-color: #ffbbbb; } .redbg { background-color: #ff8585; } .bluebg { background-color: #aaaaff; } .greenbg { background-color: #aaffaa; } .greybg { background-color: #dddddd; } +.selector { + width:275px; +} + .page-h2 { font-size: 14px; font-weight: bold; diff --git a/html/graph.php b/html/graph.php index 472e28418e..161ba12179 100644 --- a/html/graph.php +++ b/html/graph.php @@ -10,6 +10,11 @@ include("../includes/functions.php"); include("includes/authenticate.inc"); + if($_GET['params']) { + list($_GET['host'], $_GET['if'], $_GET['from'], $_GET['to'], $_GET['width'], $_GET['height'], $_GET['title'], $_GET['vertical'], $_GET['type'], $_GET['interfaces']) = explode("||", mcrypt_ecb(MCRYPT_DES, $key_value, $_GET['params'], MCRYPT_DECRYPT)); + } + + if($_GET['host']) { $device_id = $_GET['host']; } elseif($_GET['device']) { @@ -28,7 +33,6 @@ $height = $_GET['height']; $title = $_GET['title']; $vertical = $_GET['vertical']; - $type = $_GET['type']; $graphfile = strgen() . ".png"; diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 0ec8b4c4df..6554044327 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -108,6 +108,9 @@ if($_SESSION['userlevel'] >= '10') { if($_SESSION['userlevel'] >= '5') { echo("

  • "); if($show_if_customers) { echo("
  • Customers
  • "); $ifbreak = 1;} + + if($show_if_bills) { echo("
  • Traffic Bills
  • "); $ifbreak = 1;} + if($show_if_l2tp) { echo("
  • L2TP
  • "); $ifbreak = 1; } if($show_if_transit) { echo("
  • Transit
  • "); $ifbreak = 1; } diff --git a/html/index.php b/html/index.php index c84f7ba7da..07fef25f9e 100755 --- a/html/index.php +++ b/html/index.php @@ -28,6 +28,7 @@ if($_GET[debug]) { <?php echo("$page_title"); ?> + " /> diff --git a/html/pages/default.php b/html/pages/default.php index 109b6d1f50..253876c46e 100644 --- a/html/pages/default.php +++ b/html/pages/default.php @@ -23,7 +23,7 @@ while($device = mysql_fetch_array($sql)){ } -$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0'"); +$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); while($device = mysql_fetch_array($sql)){ unset($already); $i = 0; @@ -37,7 +37,7 @@ while($device = mysql_fetch_array($sql)){ if(!$already) { $nodes[] = $device['device_id']; } } -$sql = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up'"); +$sql = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while($device = mysql_fetch_array($sql)){ unset($already); $i = 0; @@ -51,7 +51,7 @@ while($device = mysql_fetch_array($sql)){ if(!$already) { $nodes[] = $device['device_id']; } } -$sql = mysql_query("SELECT D.device_id FROM `services` AS S, `devices` AS D WHERE S.service_host = D.device_id AND service_status = 'down'"); +$sql = mysql_query("SELECT D.device_id FROM `services` AS S, `devices` AS D WHERE S.service_host = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while($device = mysql_fetch_array($sql)){ unset($already); $i = 0; diff --git a/html/pages/device/dev-edit.inc b/html/pages/device/dev-edit.inc index 317b734838..19e09f2237 100644 --- a/html/pages/device/dev-edit.inc +++ b/html/pages/device/dev-edit.inc @@ -34,7 +34,7 @@ echo("
    - +
    Description
    $descr
    diff --git a/html/pages/logon.inc b/html/pages/logon.inc index d4d74061e9..6f15a700fa 100644 --- a/html/pages/logon.inc +++ b/html/pages/logon.inc @@ -6,7 +6,7 @@
    -
    +

    Please log in:

    diff --git a/includes/functions.php b/includes/functions.php index 95f6b8ce32..323db6ac3d 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -8,6 +8,8 @@ include("procurve.php"); include("snom.php"); include("graphing.php"); include("print-functions.php"); +include("billing-functions.php"); + function strgen ($length = 8) { @@ -27,13 +29,34 @@ function strgen ($length = 8) return $string; } -function interfacepermitted($interface_id) { +function billpermitted($bill_id) { - return devicepermitted(mysql_result(mysql_query("SELECT device_id FROM interface WHERE interface_id = '$interface_id'"),0)); + global $_SESSION; + if($_SESSION['userlevel'] >= "5") { + $allowed = TRUE; + } elseif (@mysql_result(mysql_query("SELECT count(*) FROM bill_perms WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND `bill_id` = $bill_id"), 0) > '0') { + $allowed = TRUE; + } else { + $allowed = FALSE; + } + return $allowed; } +function interfacepermitted($interface_id) { + + global $_SESSION; + if($_SESSION['userlevel'] >= "5") { + $allowed = true; + } elseif ( devicepermitted(mysql_result(mysql_query("SELECT device_id FROM interface WHERE interface_id = '$interface_id'"),0))) { + $allowed = true; + } elseif ( @mysql_result(mysql_query("SELECT count(*) FROM interface_perms WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND `interface_id` = $interface_id"), 0) > '0') { + $allowed = true; + } else { $allowed = FALSE; } + return $allowed; +} + function devicepermitted($device_id) { global $_SESSION; if($_SESSION['userlevel'] >= "5") { $allowed = true; @@ -287,9 +310,11 @@ function humanspeed($speed) { $speed = preg_replace("/^0$/", "-", $speed); $speed = preg_replace("/^9000$/", "9Kbps", $speed); $speed = preg_replace("/^48000$/", "48Kbps", $speed); + $speed = preg_replace("/^56000$/", "56Kbps", $speed); $speed = preg_replace("/^64000$/", "64Kbps", $speed); $speed = preg_replace("/^128000$/", "128Kbps", $speed); $speed = preg_replace("/^256000$/", "256Kbps", $speed); + $speed = preg_replace("/^448000$/", "448Kbps", $speed); $speed = preg_replace("/^512000$/", "512Kbps", $speed); $speed = preg_replace("/^768000$/", "768Kbps", $speed); $speed = preg_replace("/^1024000$/", "1Mbps", $speed); @@ -297,6 +322,8 @@ function humanspeed($speed) { $speed = preg_replace("/^4192000$/", "4Mbps", $speed); $speed = preg_replace("/^10000000$/", "10Mbps", $speed); $speed = preg_replace("/^34000000$/", "34Mbps", $speed); + $speed = preg_replace("/^45000000$/", "45Mbps", $speed); + $speed = preg_replace("/^54000000$/", "54Mbps", $speed); $speed = preg_replace("/^100000000$/", "100Mbps", $speed); $speed = preg_replace("/^155000000$/", "155Mbps", $speed); $speed = preg_replace("/^622000000$/", "622Mbps", $speed); @@ -428,6 +455,7 @@ function fixifName ($inf) { $inf = str_replace("gig", "Gig", $inf); $inf = str_replace("fast", "Fast", $inf); $inf = str_replace("ten", "Ten", $inf); + $inf = str_replace("bvi", "BVI", $inf); $inf = str_replace("vlan", "Vlan", $inf); $inf = str_replace("ether", "Ether", $inf); $inf = str_replace("-802.1q Vlan subif", "", $inf); @@ -446,6 +474,8 @@ function fixifName ($inf) { function fixIOSFeatures($features){ + $features = str_replace("LANBASEK9", "Lan Base Crypto", $features); + $features = str_replace("LANBASE", "Lan Base", $features); $features = str_replace("ADVSECURITYK9", "Advanced Security Crypto", $features); $features = str_replace("K91P", "Provider Crypto", $features); $features = str_replace("K4P", "Provider Crypto", $features); @@ -483,6 +513,7 @@ function fixIOSHardware($hardware){ $hardware = str_replace("C3550", "Cisco Catalyst 3550", $hardware); $hardware = str_replace("C2950", "Cisco Catalyst 2950", $hardware); $hardware = str_replace("C7301", "Cisco 7301", $hardware); + $hardware = str_replace("CE500", "Catalyst Express 500", $hardware); return $hardware; } diff --git a/includes/polling/device-unix.inc.php b/includes/polling/device-unix.inc.php index 6bdf21673b..e7b48b473c 100755 --- a/includes/polling/device-unix.inc.php +++ b/includes/polling/device-unix.inc.php @@ -58,14 +58,27 @@ $oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0"; $oid_ssCpuRawNice = ".1.3.6.1.4.1.2021.11.51.0"; $oid_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.52.0"; $oid_ssCpuRawIdle = ".1.3.6.1.4.1.2021.11.53.0"; + $oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.0"; $oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0"; +$oid_ssCpuUser = ".1.3.6.1.4.1.2021.11.9.0"; +$oid_ssCpuSystem = ".1.3.6.1.4.1.2021.11.10.0"; + + $cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses"; -$cpu_cmd .= " $oid_hrSystemNumUsers .1.3.6.1.4.1.2021.1.101.1"; +$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem .1.3.6.1.4.1.2021.1.101.1"; $cpu = `$cpu_cmd`; -list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $cputemp) = explode("\n", $cpu); +list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem, $cputemp) = explode("\n", $cpu); + +$cpuUsage = $usageUser + $usageSystem; + +$update_usage = mysql_query("UPDATE devices_attribs SET attrib_value = '$cpuUsage' WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'"); + +if(mysql_affected_rows() == '0') { + $insert_usage = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'cpuusage', '$cpuUsage')"); +} ## Create CPU RRD if it doesn't already exist if (!is_file($cpurrd)) {