[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 class Parser { 4 5 var $debug = false; 6 var $df_param; 7 8 function parse_lspci() { 9 10 $results = array(); 11 12 if ($_results = execute_program('lspci', '', $this->debug)) { 13 $lines = split("\n", $_results); 14 for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { 15 list($addr, $name) = explode(' ', trim($lines[$i]), 2); 16 //if (!preg_match('/bridge/i', $name) && !preg_match('/USB/i', $name)) { 17 // remove all the version strings 18 $name = preg_replace('/\(.*\)/', '', $name); 19 // is addr really usefull for this??? i think it's not 20 // $results[] = $addr . ' ' . $name; 21 $results[] = $name; 22 //} 23 } 24 } 25 26 if( empty( $results ) ) { 27 return false; 28 } else { 29 asort( $results ); 30 return $results; 31 } 32 } 33 34 function parse_pciconf() { 35 36 $results = array(); 37 38 if($buf = execute_program("pciconf", "-lv", $this->debug)) { 39 $buf = explode("\n", $buf); $s = 0; 40 foreach($buf as $line) { 41 if (preg_match("/(.*) = '(.*)'/", $line, $strings)) { 42 if (trim($strings[1]) == "vendor") { 43 $results[$s] = trim($strings[2]); 44 } elseif (trim($strings[1]) == "device") { 45 $results[$s] .= " - " . trim($strings[2]); 46 $s++; 47 } 48 } 49 } 50 } 51 52 if( empty( $results ) ) { 53 return false; 54 } else { 55 asort( $results ); 56 return $results; 57 } 58 } 59 60 function parse_filesystems() { 61 62 global $show_bind, $show_inodes; 63 64 $j = 0; 65 66 $df = execute_program('df', '-k' . $this->df_param ); 67 $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); 68 69 if( $show_inodes ) { 70 $df2 = execute_program('df', '-i' . $this->df_param ); 71 $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY); 72 } 73 74 $mount = execute_program('mount'); 75 $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); 76 77 foreach( $df as $df_line) { 78 $df_buf1 = preg_split("/(\%\s)/", $df_line, 2); 79 if( count($df_buf1) != 2) { 80 continue; 81 } 82 83 preg_match("/(.*)(\s+)(([0-9]+)(\s+)([0-9]+)(\s+)([0-9]+)(\s+)([0-9]+)$)/", $df_buf1[0], $df_buf2); 84 $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]); 85 86 if( $show_inodes ) { 87 preg_match_all("/([0-9]+)%/", $df2[$j + 1], $inode_buf, PREG_SET_ORDER); 88 } 89 90 if( count($df_buf) == 6 ) { 91 if( hide_mount( $df_buf[5] ) ) { 92 continue; 93 } 94 95 $df_buf[0] = trim( str_replace("\$", "\\$", $df_buf[0] ) ); 96 $df_buf[5] = trim( $df_buf[5] ); 97 98 $current = 0; 99 foreach( $mount as $mount_line ) { 100 $current++; 101 102 if ( preg_match("#" . $df_buf[0] . " on " . $df_buf[5] . " type (.*) \((.*)\)#", $mount_line, $mount_buf) ) { 103 $mount_buf[1] .= "," . $mount_buf[2]; 104 } elseif ( !preg_match("#" . $df_buf[0] . "(.*) on " . $df_buf[5] . " \((.*)\)#", $mount_line, $mount_buf) ) { 105 continue; 106 } 107 108 if ( $show_bind || !stristr($mount_buf[2], "bind")) { 109 $results[$j] = array(); 110 $results[$j]['disk'] = str_replace( "\\$", "\$", $df_buf[0] ); 111 $results[$j]['size'] = $df_buf[1]; 112 $results[$j]['used'] = $df_buf[2]; 113 $results[$j]['free'] = $df_buf[3]; 114 $results[$j]['percent'] = round(($results[$j]['used'] * 100) / $results[$j]['size']); 115 $results[$j]['mount'] = $df_buf[5]; 116 $results[$j]['fstype'] = substr( $mount_buf[1], 0, strpos( $mount_buf[1], "," ) ); 117 $results[$j]['options'] = substr( $mount_buf[1], strpos( $mount_buf[1], "," ) + 1, strlen( $mount_buf[1] ) ); 118 if( $show_inodes && isset($inode_buf[ count( $inode_buf ) - 1][1]) ) { 119 $results[$j]['inodes'] = $inode_buf[ count( $inode_buf ) - 1][1]; 120 } 121 $j++; 122 unset( $mount[$current - 1] ); 123 sort( $mount ); 124 break; 125 } 126 } 127 } 128 } 129 return $results; 130 } 131 132 } 133 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |