echo "\t{$size} kB of {$type} at {$mount}\n";
    }
    echo "\n";
}
function print_info($hostname, $ip, $dmi)
{
    echo "Host info:\n";
    echo "\t{$hostname} [IP: {$ip}]\n";
    $psk = "/proc/sys/kernel";
    if (file_exists("{$psk}/ostype")) {
        $type = trim(file_get_contents("{$psk}/ostype"));
        $rel = trim(file_get_contents("{$psk}/osrelease"));
        $ver = trim(file_get_contents("{$psk}/version"));
        echo "\t{$type} {$rel} {$ver}\n";
    }
    if (isset($dmi["product_name"])) {
        $product = $dmi["product_name"];
        $vendor = $dmi["vendor"];
        echo "\t{$product} by {$vendor}\n";
    }
    echo "\n";
}
$hostname = get_hostname();
$ip = get_ip($hostname);
$dmi = parse_dmi();
print_info($hostname, $ip, $dmi);
$cpu = parse_cpuinfo();
print_cpu($cpu, $dmi);
$mem = parse_meminfo();
$swap = parse_swaps();
print_memory($mem, $swap);
Example #2
0
function get_domain()
{
    $hostname = get_hostname();
    preg_match("/\\.([^\\/]+)/", $hostname, $domain);
    return $domain[1];
}
Example #3
0
     }
     // cmdline
     $p = $_SERVER['DOCUMENT_ROOT'];
     if (isset($_SERVER['PWD'])) {
         $p = $_SERVER['PWD'];
     }
     $a = explode('/', $p);
     // /home/pwnoogle/htdocs/emulive/htdocs
     // DEBUG
     //  print_r ($a);
     if (isset($a[count($a) - 2])) {
         return $a[count($a) - 2];
     }
     return '';
 }
 $config_domain = get_hostname();
 $config_subdomain = get_subdomain();
 // DEBUG
 //echo '$config_domain=='.$config_domain."<br>\n";
 //echo '$config_subdomain=='.$config_subdomain."<br>\n";
 /*
 // HACK
 if (in_array ($config_subdomain, array ('', 'www')))
   $config_subdomain = 'rsscache';
 
 if (isset ($_SERVER['PWD']))
   $pwd = $_SERVER['PWD'].'/../htdocs/'; 
 else  
   $pwd = $_SERVER['DOCUMENT_ROOT'];
 
 if (!file_exists ($pwd.'/'.$config_subdomain.'_config.php'))
    <td class='summaryValue'><span class='sleft'><?php 
echo uptime();
?>
</span> </td>
  </tr>
  <tr>
    <td class='summaryKey'> System Load </td>
    <td class='summaryValue'><span class='sleft'><?php 
echo get_system_load();
?>
</span> </td>
  </tr>
  <tr>
    <td class='summaryKey'> Hostname </td>
    <td class='summaryValue'><span class='sleft'><?php 
echo get_hostname();
?>
</span> </td>
  </tr>
  <tr>
    <td class='summaryKey'> Current Date </td>
    <td class='summaryValue'><span class='sleft'><?php 
echo get_datetime();
?>
</span> </td>
  </tr>
</table>


<?php 
echo "<h3>Memory Information</h3>";
Example #5
0
/**
 * Obtain list of system which are registerd in the wsus server, fetch their status for each  necessary update and write everything into the vmps db
 */
function get_systems()
{
    global $logger, $timestamp;
    $query = "select t.targetid, t.fulldomainname, t.ipaddress, t.lastreportedstatustime, s.notinstalled, s.downloaded, s.installedpendingreboot, s.failed, d.computermake, d.computermodel, o.oslongname from dbo.tbcomputertarget t left join dbo.tbcomputersummaryformicrosoftupdates s on t.targetid = s.targetid left join dbo.tbcomputertargetdetail d on t.targetid = d.targetid left join dbo.tbosmap o on (d.osminorversion = o.osminorversion and d.osmajorversion = o.osmajorversion and d.osservicepackmajornumber = o.osservicepackmajornumber) where (o.processorarchitecture is null or o.processorarchitecture = 1)";
    $logger->debug("Executing: {$query}", 3);
    $result = mssql_query($query);
    if (!$result) {
        $logger->logit("Failed to obtain systems from wsus, " . mssql_get_last_message(), LOG_ERR);
        return false;
    }
    while ($sys_row = mssql_fetch_assoc($result)) {
        $hostname = get_hostname($sys_row['fulldomainname']);
        $id = get_vmps_id($hostname);
        if (!$id) {
            continue;
        }
        $query = sprintf("select us.localupdateid from dbo.tbupdatestatuspercomputer us where (us.summarizationstate <> 4) and (us.summarizationstate <> 1) and us.targetid = '%s'", $sys_row['targetid']);
        $logger->debug("Executing: {$query}", 3);
        $result_update = mssql_query($query);
        if (!$result) {
            // whenever there occurs an error we skip the current system and continue with the next one
            $logger->logit("Could not fetch update details for " . $sys_row['fulldomainname'] . ", skipping this system", LOG_WARNING);
            continue;
        }
        // insert system into wsus_systems
        $query = sprintf("insert into wsus_systems values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", $id, $hostname, validate($sys_row['ipaddress']), convert_date($sys_row['lastreportedstatustime']), validate($sys_row['oslongname']), validate($sys_row['computermake']), validate($sys_row['computermodel']), validate($sys_row['notinstalled']), validate($sys_row['downloaded']), validate($sys_row['installedpendingreboot']), validate($sys_row['failed']), $timestamp);
        $logger->debug("Executing: {$query}", 3);
        if (!mysql_query($query)) {
            $logger->logit("Could not insert system {$hostname}, " . mysql_error(), LOG_WARNING);
            continue;
        }
        // insert mapping to needed updates
        while ($update_row = mssql_fetch_assoc($result_update)) {
            $query = sprintf("insert into wsus_systemToUpdates(sid, localupdateid, lastsync) values('%s', '%s', '%s');", $id, validate($update_row['localupdateid']), $timestamp);
            $logger->debug("Executing {$query}", 3);
            if (!mysql_query($query)) {
                $logger->logit("Could not insert update relation {$id}, " . $update_row['localupdateid'], LOG_WARNING);
            }
        }
    }
    return true;
}
Example #6
0
along with Facelift Image Replacement.  If not, see <http://www.gnu.org/licenses/>.
*/
define('DEBUG', false);
define('ENABLE_FONTSIZE_BUG', false);
define('FLIR_VERSION', '1.2');
define('IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
require 'config-flir.php';
require 'inc-flir.php';
if (version_compare(PHP_VERSION, '4.3.0', '<')) {
    err('PHP_TOO_OLD');
}
if (version_compare(PHP_VERSION, '6.0.0', '>=')) {
    err('PHP_UNSUPPORTED');
}
if (false !== ALLOWED_DOMAIN && $_SERVER['HTTP_REFERER'] != '') {
    $refhost = get_hostname($_SERVER['HTTP_REFERER']);
    if (substr(ALLOWED_DOMAIN, 0, 1) == '.') {
        if (false === strpos($refhost, substr(ALLOWED_DOMAIN, 1))) {
            err('DISALLOWED_DOMAIN');
        }
    } else {
        if ($refhost != ALLOWED_DOMAIN) {
            err('DISALLOWED_DOMAIN');
        }
    }
}
$fonts_dir = str_replace('\\', '/', realpath(FONTS_DIR . '/'));
if (substr($fonts_dir, -1) != '/') {
    $fonts_dir .= '/';
}
$FLIR = array();
Example #7
0
 /**
  * performs a latency test for $endpoint. returns either an array of numeric 
  * metrics, or a hash with a 'metrics' key (and may include other meta 
  * attributes to be included in results for this test). returns NULL if the
  * test failed
  * @param string $endpoint test endpoint
  * @return array
  */
 private function testLatency($endpoint)
 {
     $metrics = NULL;
     if ($endpoint = get_hostname($endpoint)) {
         $interval = $this->options['latency_interval'];
         $samples = $this->options['latency_samples'];
         $timeout = $this->options['latency_timeout'];
         $cmd = sprintf('ping -i %s -c %d -W %d %s 2>/dev/null; echo $?', $interval, $samples, $timeout, $endpoint);
         print_msg(sprintf('Testing latency using ping command: %s', $cmd), $this->verbose, __FILE__, __LINE__);
         if ($buffer = shell_exec($cmd)) {
             $pieces = explode("\n", trim($buffer));
             $ecode = $pieces[count($pieces) - 1];
             // ping successful
             if ($ecode == 0 && preg_match_all('/time\\s*=\\s*([0-9\\.]+)\\s+/msU', $buffer, $m)) {
                 $metrics = array('metrics' => array());
                 foreach ($m[1] as $metric) {
                     $metrics['metrics'][] = $metric * 1;
                 }
                 $metrics['tests_failed'] = $samples - count($metrics['metrics']);
                 $metrics['tests_success'] = count($metrics['metrics']);
                 print_msg(sprintf('ping exited successfully with %d successful, %d failed. Metrics: %s', $metrics['tests_success'], $metrics['tests_failed'], implode(', ', $metrics['metrics'])), $this->verbose, __FILE__, __LINE__);
             } else {
                 if ($ecode == 0) {
                     print_msg(sprintf('ping exited successfully, but did not produce valid output: %s', $buffer), $this->verbose, __FILE__, __LINE__, TRUE);
                 } else {
                     print_msg(sprintf('ping failed with exit code %d - %s', $ecode, $ecode == 1 ? 'host is down or does not accept ICMP' : 'unknown error'), $this->verbose, __FILE__, __LINE__, TRUE);
                 }
             }
         } else {
             print_msg(sprintf('ping failed because no output was produced'), $this->verbose, __FILE__, __LINE__, TRUE);
         }
     }
     return $metrics;
 }