mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
remove the last usage of config variables outside of the $config array ($rrd_file) + fixed adduser script
git-svn-id: http://www.observium.org/svn/observer/trunk@354 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@ -10,11 +10,9 @@ $config['db_name'] = "observer";
|
|||||||
$config['install_dir'] = "/opt/observer/";
|
$config['install_dir'] = "/opt/observer/";
|
||||||
$config['html_dir'] = $config['install_dir'] . "html";
|
$config['html_dir'] = $config['install_dir'] . "html";
|
||||||
$config['rrd_dir'] = $config['install_dir'] . "rrd";
|
$config['rrd_dir'] = $config['install_dir'] . "rrd";
|
||||||
$rrd_dir = $config['rrd_dir'];
|
|
||||||
|
|
||||||
### Default community
|
### Default community
|
||||||
$config['community'] = "observer";
|
$config['community'] = "observer";
|
||||||
$community = $config['community'];
|
|
||||||
|
|
||||||
$config['base_url'] = "http://observer";
|
$config['base_url'] = "http://observer";
|
||||||
|
|
||||||
@ -39,16 +37,15 @@ $config['rrdgraph_defaults'] = array("-c", "BACK#FFFFFF", "-c", "SHADEA#E5E5E5",
|
|||||||
$config['overlib_defaults'] = ",FGCOLOR,'#e5e5e5', BGCOLOR, '#e5e5e5'";
|
$config['overlib_defaults'] = ",FGCOLOR,'#e5e5e5', BGCOLOR, '#e5e5e5'";
|
||||||
|
|
||||||
|
|
||||||
### List of networks to allow scanning-based discovery.
|
## List of networks to allow scanning-based discovery.
|
||||||
$config['nets'] = array ("10.0.0.0/8", "172.22.0.0/16");
|
$config['nets'] = array ("10.0.0.0/8", "172.22.0.0/16");
|
||||||
|
|
||||||
### Your company domain name and specifics
|
## Your company domain name and specifics
|
||||||
$config['mydomain'] = "observernms.net";
|
$config['mydomain'] = "observernms.net";
|
||||||
$config['page_title'] = "Project Observer";
|
$config['page_title'] = "Project Observer";
|
||||||
$config['title_image'] = "images/observer-logo.jpg";
|
$config['title_image'] = "images/observer-logo.jpg";
|
||||||
$config['stylesheet'] = "css/styles.css";
|
$config['stylesheet'] = "css/styles.css";
|
||||||
$config['mono_font'] = $config['install_dir'] . "/fonts/DejaVuSansMono.ttf";
|
$config['mono_font'] = $config['install_dir'] . "/fonts/DejaVuSansMono.ttf";
|
||||||
$mono_font = $config['mono_font'];
|
|
||||||
$config['favicon'] = "favicon.ico";
|
$config['favicon'] = "favicon.ico";
|
||||||
$config['header_color'] = "#1F334E";
|
$config['header_color'] = "#1F334E";
|
||||||
|
|
||||||
@ -78,6 +75,8 @@ $config['enable_inventory'] = 1; # Enable Inventory
|
|||||||
|
|
||||||
## Uncomment this to enable display of rancid-collected configs
|
## Uncomment this to enable display of rancid-collected configs
|
||||||
#$config['rancid_configs'] = '/var/lib/rancid/network/configs/';
|
#$config['rancid_configs'] = '/var/lib/rancid/network/configs/';
|
||||||
|
$config['cdp_autocreate'] = false; # Should we autocreate hosts we see via CDP?
|
||||||
|
$config['snmp_autodiscovery'] = false;
|
||||||
|
|
||||||
## If a syslog entry contails these strings it is deleted from the database
|
## If a syslog entry contails these strings it is deleted from the database
|
||||||
$config['syslog_filter'] = array("last message repeated", "Connection from UDP: [127.0.0.1]:");
|
$config['syslog_filter'] = array("last message repeated", "Connection from UDP: [127.0.0.1]:");
|
||||||
|
@ -34,7 +34,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
|
|
||||||
$cdp_links = trim($cdp_links);
|
$cdp_links = trim($cdp_links);
|
||||||
|
|
||||||
echo("\n$cdp_links\n\n");
|
# echo("\n$cdp_links\n\n");
|
||||||
|
|
||||||
foreach ( explode("\n" ,$cdp_links) as $link ) {
|
foreach ( explode("\n" ,$cdp_links) as $link ) {
|
||||||
if ($link == "") { break; }
|
if ($link == "") { break; }
|
||||||
@ -49,8 +49,10 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
$ip = gethostbyname($dst_host);
|
$ip = gethostbyname($dst_host);
|
||||||
if ( match_network($config['nets'], $ip) ) {
|
if ( match_network($config['nets'], $ip) ) {
|
||||||
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `sysName` = '$dst_host'"), 0) == '0' ) {
|
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `sysName` = '$dst_host'"), 0) == '0' ) {
|
||||||
echo("++ Creating: $dst_host \n");
|
if($config['cdp_autocreate']) {
|
||||||
#createHost ($dst_host, $community, "v2c");
|
echo("++ Creating: $dst_host \n");
|
||||||
|
createHost ($dst_host, $community, "v2c");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
echo(".. Already got host $dst_host\n");
|
echo(".. Already got host $dst_host\n");
|
||||||
}
|
}
|
||||||
@ -96,9 +98,9 @@ while($entry = mysql_fetch_array($query)) {
|
|||||||
}
|
}
|
||||||
if (!$alive) {
|
if (!$alive) {
|
||||||
mysql_query("DELETE FROM `links` WHERE `src_if` = '$entry[src_if]' AND `dst_if` = '$entry[dst_if]'");
|
mysql_query("DELETE FROM `links` WHERE `src_if` = '$entry[src_if]' AND `dst_if` = '$entry[dst_if]'");
|
||||||
echo("$src_if_id -> $dst_if_id REMOVED \n");
|
# echo("$src_if_id -> $dst_if_id REMOVED \n");
|
||||||
} else {
|
} else {
|
||||||
echo("$src_if_id -> $dst_if_id VALID \n");
|
# echo("$src_if_id -> $dst_if_id VALID \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ echo("</td>");
|
|||||||
echo("</td></tr>");
|
echo("</td></tr>");
|
||||||
|
|
||||||
// If we're showing graphs, generate the graph and print the img tags
|
// If we're showing graphs, generate the graph and print the img tags
|
||||||
if($dographs && is_file($rrd_dir . "/" . $hostname . "/". $ifIndex . ".rrd")) {
|
if($dographs && is_file($config['rrd_dir'] . "/" . $hostname . "/". $ifIndex . ".rrd")) {
|
||||||
|
|
||||||
$type = $_GET['type'];
|
$type = $_GET['type'];
|
||||||
|
|
||||||
|
@ -7,22 +7,31 @@ if($_SESSION['userlevel'] != '10') { echo("<span class=alert>You do not have the
|
|||||||
echo("<h3>Add User</h3>");
|
echo("<h3>Add User</h3>");
|
||||||
|
|
||||||
if($_POST['action'] == "add") {
|
if($_POST['action'] == "add") {
|
||||||
|
if($_POST['new_username'] && $_POST['new_password'] && !mysql_result(mysql_query("SELECT * FROM users WHERE username = '".$_POST['new_username']."'"),0) ) {
|
||||||
mysql_query("INSERT INTO `users` (`username`, `realname`, `password`, `level`) VALUES ('" . mres($_POST['new_username']) . "', '" . mres($_POST['new_realname']) . "', MD5('" . mres($_POST['new_password']) . "'), '" . mres($_POST['new_level']) . "')");
|
mysql_query("INSERT INTO `users` (`username`, `realname`, `password`, `level`) VALUES ('" . mres($_POST['new_username']) . "', '" . mres($_POST['new_realname']) . "', MD5('" . mres($_POST['new_password']) . "'), '" . mres($_POST['new_level']) . "')");
|
||||||
|
if(mysql_affected_rows()) { echo("<span class=info>User " . $_POST['username'] . " added!</span>"); }
|
||||||
if(mysql_affected_rows()) { echo("<span class=info>User " . $_GET['username'] . " added!</span>"); }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo("<form method='post' action='?page=adduser'>
|
echo("<form method='post' action='?page=adduser'>
|
||||||
<input type='hidden' value='add' name='action'>");
|
<input type='hidden' value='add' name='action'>");
|
||||||
|
|
||||||
echo("Username <input name='new_username'></input><br />");
|
echo("Username <input style='margin: 1px;' name='new_username'></input><br />");
|
||||||
echo("Password <input name='new_password'></input><br />");
|
if($_POST['action'] == "add" && !$_POST['new_username']) {
|
||||||
|
echo("<div class=red>Please enter a username!</div>");
|
||||||
echo("Realname <input name='new_realname'></input><br /><br />");
|
} elseif( mysql_result(mysql_query("SELECT * FROM users WHERE username = '".$_POST['new_username']."'"),0)) {
|
||||||
|
echo("<span class=red>User with this name already exists!</span><br />");
|
||||||
echo("<select name='new_level'>
|
}
|
||||||
|
?>
|
||||||
|
Password <input style='margin: 1px;' name='new_password' id='new_password' type=password /><br />
|
||||||
|
<?php
|
||||||
|
if($_POST['action'] == "add" && !$_POST['new_password']) {
|
||||||
|
echo("<span class=red>Please enter a password!</span><br />");
|
||||||
|
}
|
||||||
|
echo("Realname <input style='margin: 1px;' name='new_realname'></input><br />");
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
echo("Level <select style='margin: 5px;' name='new_level'>
|
||||||
<option value='1'>Normal User</option>
|
<option value='1'>Normal User</option>
|
||||||
<option value='5'>Global Read</option>
|
<option value='5'>Global Read</option>
|
||||||
<option value='10'>Administrator</option>
|
<option value='10'>Administrator</option>
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
include("includes/geshi/geshi.php");
|
||||||
|
|
||||||
if($_SESSION[userlevel] >= "5" && is_file($config['rancid_configs'] . $device['hostname'])) {
|
if($_SESSION[userlevel] >= "5" && is_file($config['rancid_configs'] . $device['hostname'])) {
|
||||||
$file = $config['rancid_configs'] . $device['hostname'];
|
$file = $config['rancid_configs'] . $device['hostname'];
|
||||||
|
# $file = "/testconfig.txt";
|
||||||
$fh = fopen($file, 'r') or die("Can't open file");
|
$fh = fopen($file, 'r') or die("Can't open file");
|
||||||
$text = fread($fh, filesize($file));
|
$text = fread($fh, filesize($file));
|
||||||
echo(highlight_string($text));
|
$language = "ios";
|
||||||
|
$geshi = new GeSHi($text, $language);
|
||||||
|
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
|
||||||
|
$geshi->set_overall_style('color: black;');
|
||||||
|
# $geshi->set_line_style('color: #999999');
|
||||||
|
|
||||||
|
# echo("<div style='width:1175px;height:540px;overflow-x:hidden;overflow-y:auto;'>");
|
||||||
|
echo $geshi->parse_code();
|
||||||
|
# echo("</div>");
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
} else {
|
} else {
|
||||||
print_error("Error : Insufficient access.");
|
print_error("Error : Insufficient access.");
|
||||||
|
@ -24,7 +24,7 @@ if($_GET['type']) {
|
|||||||
|
|
||||||
echo("</td></tr><tr bgcolor='$bg'><td>");
|
echo("</td></tr><tr bgcolor='$bg'><td>");
|
||||||
|
|
||||||
if(file_exists($rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd")) {
|
if(file_exists($config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd")) {
|
||||||
|
|
||||||
$graph_type = "bits";
|
$graph_type = "bits";
|
||||||
include("includes/print-interface-graphs.php");
|
include("includes/print-interface-graphs.php");
|
||||||
|
@ -216,8 +216,8 @@ function truncate($substring, $max = 50, $rep = '...')
|
|||||||
|
|
||||||
function interface_rates ($interface)
|
function interface_rates ($interface)
|
||||||
{
|
{
|
||||||
global $config, $rrd_dir;
|
global $config;
|
||||||
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||||
$cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e";
|
$cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e";
|
||||||
$data = trim(`$cmd`);
|
$data = trim(`$cmd`);
|
||||||
foreach( explode("\n", $data) as $entry) {
|
foreach( explode("\n", $data) as $entry) {
|
||||||
@ -231,8 +231,8 @@ function interface_rates ($interface)
|
|||||||
|
|
||||||
function interface_errors ($interface)
|
function interface_errors ($interface)
|
||||||
{
|
{
|
||||||
global $config, $rrd_dir;
|
global $config;
|
||||||
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||||
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5";
|
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5";
|
||||||
$data = trim(`$cmd`);
|
$data = trim(`$cmd`);
|
||||||
foreach( explode("\n", $data) as $entry) {
|
foreach( explode("\n", $data) as $entry) {
|
||||||
@ -356,9 +356,8 @@ function delHost($id)
|
|||||||
mysql_query("DELETE FROM `interfaces` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `interfaces` WHERE `device_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `services` WHERE `service_host` = '$id'");
|
mysql_query("DELETE FROM `services` WHERE `service_host` = '$id'");
|
||||||
mysql_query("DELETE FROM `alerts` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `alerts` WHERE `device_id` = '$id'");
|
||||||
$rrd_dir = $config['rrd_dir'];
|
shell_exec("rm -f ".$config['rrd_dir'] . "/$host-*.rrd");
|
||||||
`rm -f $rrd_dir/$host-*.rrd`;
|
shell_exec("rm -rf ".$config['rrd_dir']."/$host");
|
||||||
`rm -rf $rrd_dir/$host`;
|
|
||||||
echo("Removed device $host<br />");
|
echo("Removed device $host<br />");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ while($peer = mysql_fetch_array($peers)) {
|
|||||||
|
|
||||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||||
|
|
||||||
$peerrrd = $rrd_dir . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
|
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
|
||||||
|
|
||||||
if(!is_file($peerrrd)) {
|
if(!is_file($peerrrd)) {
|
||||||
$woo = `rrdtool create $peerrrd \
|
$woo = `rrdtool create $peerrrd \
|
||||||
|
@ -8,9 +8,9 @@ $serial = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c
|
|||||||
$version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion);
|
$version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion);
|
||||||
list($hardware,$version,$features) = explode("||", $version);
|
list($hardware,$version,$features) = explode("||", $version);
|
||||||
|
|
||||||
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-cpu.rrd";
|
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-cpu.rrd";
|
||||||
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-memory.rrd";
|
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-memory.rrd";
|
||||||
$sessrrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-sessions.rrd";
|
$sessrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-sessions.rrd";
|
||||||
|
|
||||||
$cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
$cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||||
$cmd .= " fnSysCpuUsage.0 fnSysMemUsage.0 fnSysSesCount.0 fnSysMemCapacity.0";
|
$cmd .= " fnSysCpuUsage.0 fnSysMemUsage.0 fnSysSesCount.0 fnSysMemCapacity.0";
|
||||||
|
@ -5,17 +5,9 @@
|
|||||||
$hostname = $device['hostname'];
|
$hostname = $device['hostname'];
|
||||||
$port = $device['port'];
|
$port = $device['port'];
|
||||||
|
|
||||||
$Otemprrd = "rrd/" . $hostname . "-temp.rrd";
|
$temprrd = $config['rrd_dir'] . "/" . $hostname . "/temp.rrd";
|
||||||
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd";
|
||||||
$Omemrrd = "rrd/" . $hostname . "-mem.rrd";
|
$memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
|
||||||
|
|
||||||
$temprrd = $rrd_dir . "/" . $hostname . "/temp.rrd";
|
|
||||||
$cpurrd = $rrd_dir . "/" . $hostname . "/cpu.rrd";
|
|
||||||
$memrrd = $rrd_dir . "/" . $hostname . "/mem.rrd";
|
|
||||||
|
|
||||||
if(is_file($Otemprrd) && !is_file($temprrd)) { rename($Otemprrd, $temprrd); echo("Moving $Otemprrd to $temprrd"); }
|
|
||||||
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
|
|
||||||
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
|
|
||||||
|
|
||||||
$version = str_replace("Cisco IOS Software,", "", $sysDescr);
|
$version = str_replace("Cisco IOS Software,", "", $sysDescr);
|
||||||
$version = str_replace("IOS (tm) ", "", $version);
|
$version = str_replace("IOS (tm) ", "", $version);
|
||||||
|
@ -11,7 +11,7 @@ $features = preg_replace("/.+\ \((.+)\)$/", "\\1", $jun_ver);
|
|||||||
|
|
||||||
echo("$hardware - $version - $features - $serial\n");
|
echo("$hardware - $version - $features - $serial\n");
|
||||||
|
|
||||||
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/junos-cpu.rrd";
|
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/junos-cpu.rrd";
|
||||||
|
|
||||||
$cpu_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
$cpu_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||||
$cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0";
|
$cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0";
|
||||||
|
@ -12,10 +12,7 @@ if($device[os] != "Snom") {
|
|||||||
'tcpEstabResets','tcpInSegs','tcpOutSegs','tcpRetransSegs','udpInDatagrams','udpOutDatagrams','udpInErrors',
|
'tcpEstabResets','tcpInSegs','tcpOutSegs','tcpRetransSegs','udpInDatagrams','udpOutDatagrams','udpInErrors',
|
||||||
'udpNoPorts');
|
'udpNoPorts');
|
||||||
|
|
||||||
$rrdfile = $rrd_dir . "/" . $device['hostname'] . "/netinfo.rrd";
|
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/netinfo.rrd";
|
||||||
|
|
||||||
$Orrdfile = "rrd/" . $device['hostname'] . "-netinfo.rrd";
|
|
||||||
if(is_file($Orrdfile) && !is_file($rrdfile)) { rename($Orrdfile, $rrdfile); echo("Moving $Orrdfile to $rrdfile"); }
|
|
||||||
|
|
||||||
$rrd_create = "rrdtool create $rrdfile ";
|
$rrd_create = "rrdtool create $rrdfile ";
|
||||||
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd";
|
||||||
$Omemrrd = "rrd/" . $hostname . "-mem.rrd";
|
$memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
|
||||||
|
|
||||||
$cpurrd = $rrd_dir . "/" . $hostname . "/cpu.rrd";
|
|
||||||
$memrrd = $rrd_dir . "/" . $hostname . "/mem.rrd";
|
|
||||||
|
|
||||||
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
|
|
||||||
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
|
|
||||||
|
|
||||||
|
|
||||||
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0";
|
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0";
|
||||||
$cpu = `$cpu_cmd`;
|
$cpu = `$cpu_cmd`;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
$rxbytes = 0 - $rxbytes * 8;
|
$rxbytes = 0 - $rxbytes * 8;
|
||||||
echo("$rxbytes, $rxpkts, $txbytes, $txpkts, $calls, $registrations");
|
echo("$rxbytes, $rxpkts, $txbytes, $txpkts, $calls, $registrations");
|
||||||
|
|
||||||
$rrdfile = $rrd_dir . "/" . $device['hostname'] . "/data.rrd";
|
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/data.rrd";
|
||||||
if(!is_file($rrdfile)) {
|
if(!is_file($rrdfile)) {
|
||||||
$woo = `rrdtool create $rrdfile \
|
$woo = `rrdtool create $rrdfile \
|
||||||
DS:INOCTETS:COUNTER:600:U:100000000000 \
|
DS:INOCTETS:COUNTER:600:U:100000000000 \
|
||||||
|
@ -1,21 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd";
|
||||||
|
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd";
|
||||||
$Oloadrrd = "rrd/" . $device['hostname'] . "-load.rrd";
|
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd";
|
||||||
$Ocpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
|
$sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd";
|
||||||
$Omemrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
|
|
||||||
$Osysrrd = "rrd/" . $device['hostname'] . "-sys.rrd";
|
|
||||||
|
|
||||||
$loadrrd = $rrd_dir . "/" . $device['hostname'] . "/load.rrd";
|
|
||||||
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/cpu.rrd";
|
|
||||||
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/mem.rrd";
|
|
||||||
$sysrrd = $rrd_dir . "/" . $device['hostname'] . "/sys.rrd";
|
|
||||||
|
|
||||||
if(is_file($Oloadrrd) && !is_file($loadrrd)) { rename($Oloadrrd, $loadrrd); echo("Moving $Oloadrrd to $loadrrd"); }
|
|
||||||
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
|
|
||||||
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
|
|
||||||
if(is_file($Osysrrd) && !is_file($sysrrd)) { rename($Osysrrd, $sysrrd); echo("Moving $Osysrrd to $sysrrd"); }
|
|
||||||
|
|
||||||
if ($device['os'] == "FreeBSD") {
|
if ($device['os'] == "FreeBSD") {
|
||||||
$sysDescr = str_replace(" 0 ", " ", $sysDescr);
|
$sysDescr = str_replace(" 0 ", " ", $sysDescr);
|
||||||
@ -67,11 +55,7 @@ while ($dr = mysql_fetch_array($dq)) {
|
|||||||
|
|
||||||
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
||||||
|
|
||||||
$storage_rrd = $rrd_dir . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
|
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
|
||||||
$ostorage_rrd = "rrd/" . $device['hostname'] . "-storage-" . $filedesc . ".rrd";
|
|
||||||
|
|
||||||
if(is_file($ostorage_rrd) && !is_file($storage_rrd)) { rename($ostorage_rrd, $storage_rrd); echo("Moving $ostorage_rrd to $storage_rrd"); }
|
|
||||||
|
|
||||||
|
|
||||||
if (!is_file($storage_rrd)) {
|
if (!is_file($storage_rrd)) {
|
||||||
shell_exec($config['rrdtool'] . " create $storage_rrd \
|
shell_exec($config['rrdtool'] . " create $storage_rrd \
|
||||||
|
@ -13,12 +13,6 @@ while($temperature = mysql_fetch_array($temp_data)) {
|
|||||||
$temprrd = str_replace(")", "_", $temprrd);
|
$temprrd = str_replace(")", "_", $temprrd);
|
||||||
$temprrd = str_replace("(", "_", $temprrd);
|
$temprrd = str_replace("(", "_", $temprrd);
|
||||||
|
|
||||||
$otemprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
|
|
||||||
$otemprrd = str_replace(")", "_", $otemprrd);
|
|
||||||
$otemprrd = str_replace("(", "_", $otemprrd);
|
|
||||||
|
|
||||||
if(is_file($otemprrd) && !is_file($temprrd)) { rename($otemprrd, $temprrd); echo("Moving $otemprrd to $temprrd"); }
|
|
||||||
|
|
||||||
if (!is_file($temprrd)) {
|
if (!is_file($temprrd)) {
|
||||||
`rrdtool create $temprrd \
|
`rrdtool create $temprrd \
|
||||||
--step 300 \
|
--step 300 \
|
||||||
|
@ -33,7 +33,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
|
|
||||||
$pingable = isPingable($device['hostname']);
|
$pingable = isPingable($device['hostname']);
|
||||||
|
|
||||||
$host_rrd = $rrd_dir . "/" . $device['hostname'];
|
$host_rrd = $config['rrd_dir'] . "/" . $device['hostname'];
|
||||||
|
|
||||||
if(!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); }
|
if(!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); }
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
mail($notify_email, "Device Rebooted: " . $device['hostname'], "Device Rebooted :" . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']);
|
mail($notify_email, "Device Rebooted: " . $device['hostname'], "Device Rebooted :" . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$uptimerrd = $rrd_dir . "/" . $device['hostname'] . "/uptime.rrd";
|
$uptimerrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd";
|
||||||
|
|
||||||
$old_uptimerrd = "rrd/" . $device['hostname'] . "-uptime.rrd";
|
$old_uptimerrd = "rrd/" . $device['hostname'] . "-uptime.rrd";
|
||||||
if(is_file($old_uptimerrd) && !is_file($uptimerrd)) { rename($old_uptimerrd, $uptimerrd); echo("Moving $old_uptimerrd to $uptimerrd"); }
|
if(is_file($old_uptimerrd) && !is_file($uptimerrd)) { rename($old_uptimerrd, $uptimerrd); echo("Moving $old_uptimerrd to $uptimerrd"); }
|
||||||
|
@ -6,10 +6,13 @@ include("includes/functions.php");
|
|||||||
|
|
||||||
$search = $argv[1] . "$";
|
$search = $argv[1] . "$";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data = trim(`cat ips-scanned.txt | grep alive | cut -d" " -f 1 | egrep $search`);
|
$data = trim(`cat ips-scanned.txt | grep alive | cut -d" " -f 1 | egrep $search`);
|
||||||
|
|
||||||
foreach( explode("\n", $data) as $ip) {
|
foreach( explode("\n", $data) as $ip) {
|
||||||
$snmp = `snmpget -t 0.2 -v2c -c $community $ip sysName.0`;
|
$snmp = shell_exec("snmpget -t 0.2 -v2c -c ".$config['community']." $ip sysName.0");
|
||||||
if(strstr($snmp, "STRING")) {
|
if(strstr($snmp, "STRING")) {
|
||||||
$hostname = trim(str_replace("SNMPv2-MIB::sysName.0 = STRING: ","", $snmp));
|
$hostname = trim(str_replace("SNMPv2-MIB::sysName.0 = STRING: ","", $snmp));
|
||||||
if(mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE hostname = '$hostname'"),0) == '0') {
|
if(mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE hostname = '$hostname'"),0) == '0') {
|
||||||
|
Reference in New Issue
Block a user