ArmLUG Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Search
Calendar
Login
Register
News
:
September 09, 2010, 08:25:03 PM
ArmLUG Forum
GNU/Linux
Web Programming
(Moderators:
Mesrop
,
kernel
)
PHP Script, to get linux info.
« previous
next »
Topic Tools
Search this topic
Pages
1
Author
Topic: PHP Script, to get linux info. (Read 2989 times)
«
on:
August 21, 2008, 04:04:22 PM »
kernel
Moderator
Newbie
kernel
Posts: 39
PHP Script, to get linux info.
Հարգելի բարեկամներ, Linux - ի եւ PHP - ի սիրահարներ.
Այսօր ձեզ եմ ներկայացնում ծրագիր, որի միջոցով կարելի է ստանալ տվյալներ, Linux օպ. համակարգի մասին.
Ստանում ենք ինֆորմացիա օպրացիոն համակարգի մասին, պրոցեսսորի մասին, հիշողության մասին.
Զգուշացում: լինում են դեպքեր, երբ նշվածներից վերջին երեքը չեն աշխատում.
<?
echo "Get main info<br>";
$a = array();
exec("uname -a ",$a);
$i=0;
$c=count($a);
while($i<$c) {
echo "<br>".$a[$i];
$i++;
}
/////////////////////////////////////////////////////
echo "<br>Get CPU Info<br>";
$ldir = "/proc";
$p = parsefile($ldir."/cpuinfo");
$c = count($p);
$i=0;
echo '<table cellpadding="3" cellspacing="0">';
while ($i < $c ) {
echo "<tr><td><b>".key($p).':</b></td><td> '.$p[key($p)].'</td></tr>';
next($p);
$i++;
} // end while
echo "</table>";
////////////////////////////////////////////////////////
echo "Get MEMORY info<br>";
unset($p);
$p = parsefile($ldir."/meminfo");
$c = count($p);
$i=0;
echo '<table cellpadding="3" cellspacing="0">';
while ($i < $c ) {
echo "<tr><td><b>".key($p).':</b></td><td> '.$p[key($p)].'</td></tr>';
next($p);
$i++;
} // end while
echo "</table>";
///////////////////////////////////////////////////////////
function parsefile($file) {
@$content = file_get_contents($file);
$info=array();
foreach( explode("\n",$content) as $line) {
$pos = strpos($line,":");
$key = trim( substr($line,0,$pos) );
$val = trim( substr($line,$pos+1) );
if ( $key=="") continue;
$info[$key] = $val;
}
return $info;
}
?>
Ընդունում եմ առաջարկներ եւ նկատողություններ...
Logged
Reply #1
«
on:
August 21, 2008, 06:00:46 PM »
xalyavshik
Sr. Member
Linux Registred User #472973
Posts: 385
Re: PHP Script, to get linux info.
սա իմ կոմպը
Quote
Get main info
Linux localhost 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux
Get CPU Info
processor: 0
vendor_id: GenuineIntel
cpu family: 6
model: 7
model name: Pentium III (Katmai)
stepping: 3
cpu MHz: 497.846
cache size: 512 KB
fdiv_bug: no
hlt_bug: no
f00f_bug: no
coma_bug: no
fpu: yes
fpu_exception: yes
cpuid level: 2
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 mtrr pge mca cmov pat pse36 mmx fxsr sse up
bogomips: 996.81
clflush size: 32
Get MEMORY info
MemTotal: 319976 kB
MemFree: 240480 kB
Buffers: 5452 kB
Cached: 52728 kB
SwapCached: 0 kB
Active: 33124 kB
Inactive: 36104 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 319976 kB
LowFree: 240480 kB
SwapTotal: 655352 kB
SwapFree: 655352 kB
Dirty: 32 kB
Writeback: 0 kB
AnonPages: 11048 kB
Mapped: 11968 kB
Slab: 6004 kB
SReclaimable: 2320 kB
SUnreclaim: 3684 kB
PageTables: 1256 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 815340 kB
Committed_AS: 69028 kB
VmallocTotal: 700408 kB
VmallocUsed: 1820 kB
VmallocChunk: 698212 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 4096 kB
Դավ ջան դուրս եկավ
Logged
# killall -9 "win PC"
Reply #2
«
on:
August 21, 2008, 06:05:52 PM »
kernel
Moderator
Newbie
kernel
Posts: 39
Re: PHP Script, to get linux info.
Շատ շնորհակալ եմ.
Ցավոք սրտի, որոշ ինտերնետ սերվերներում չի աշխատեւմ.
Logged
Reply #3
«
on:
August 21, 2008, 11:07:24 PM »
seryoga
Newbie
Posts: 43
Re: PHP Script, to get linux info.
Տենաս բա խի չի աշխատում?
Logged
Reply #4
«
on:
August 21, 2008, 11:10:24 PM »
kernel
Moderator
Newbie
kernel
Posts: 39
Re: PHP Script, to get linux info.
Երկու հայտնի պատճառներով
1) permission denied
2) file not exists
Logged
Reply #5
«
on:
August 22, 2008, 01:18:49 AM »
xalyavshik
Sr. Member
Linux Registred User #472973
Posts: 385
Re: PHP Script, to get linux info.
ես կասեի pretmission denied
կամ ել հիմնականում chroot-ով են դնում սեռվեռները դրա համար ել այդ ֆայլը մեր համար հասանելի չի լինում
Logged
# killall -9 "win PC"
Pages
1
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> Rules
=> News
=> Open Source in Armenia
=> Anything
=> Site updates
=> Projects
=> Forum updates
=> Job
=> UNIX FAQ
-----------------------------
GNU/Linux
-----------------------------
=> Networking
=> Billing Systems
=> Projects
=> Programming
=> Web Programming
=> Scripts
=> Sources and RPMs
=> Databases
=> Kernel
=> FTP
=> Proxy
=> DNS
=> Super Servers
=> Mail
=> Web
=> Security
=> Games
=> Multimedia
=> Hardware
=> Drivers
=> Graphic interfaces
-----------------------------
Distributives
-----------------------------
=> Slackware Linux
=> Red Hat Linux, Fedora Core, ASP Linux
=> ALTLinux
=> Mandriva Linux, Mandrake Linux
=> Debian GNU/Linux
=> Gentoo Linux
=> Arch Linux
=> Novell SUSE Linux
=> BSD*
=> Live-CD
=> NUR Linux
=> Others UNIX Systems
-----------------------------
Offtop
-----------------------------
=> Sex & Drugs & Rock'N'Roll
=> Photos
-----------------------------
News
-----------------------------
=> Hardware
Print
Advanced search
Powered by SMF 1.1.8
|
SMF © 2006-2008, Simple Machines LLC
Pn-Pn Theme by koni.