Skip to content

Commit

Permalink
initial commit, linux info
Browse files Browse the repository at this point in the history
  • Loading branch information
simultsop committed Aug 9, 2018
0 parents commit e59ebdd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
5 changes: 5 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
// Config values here
];
1 change: 1 addition & 0 deletions dhcp/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
30 changes: 30 additions & 0 deletions info/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

// Providing some Machine Info at a glance
$meminfo = file_exists("/proc/meminfo") ? file("/proc/meminfo") : 0;
$networkInfo = shell_exec("ifconfig -a");
$linuxInfo = array(
"os" => php_uname("s") . " " . php_uname("r"), //OS and version
"hostname" => php_uname("n"),
"totalDisk" => disk_total_space("/") / 1024, // Returns kilobytes
"freeDisk" => disk_free_space("/") / 1024, // Returns kilobytes
"totalMemory" => intval(preg_replace("/[^0-9]/", "", $meminfo[0])), // Returns kilobytes
"freeMemory" => intval(preg_replace("/[^0-9]/", "", $meminfo[1])), // Returns kilobytes
"ftp" => (getservbyport(21, "tcp")=="ftp") ? true : false, // Checking if port is default
"sftp" => (getservbyport(22, "tcp")=="ssh") ? true : false, // Checking if port is default
"telnet" => (getservbyport(23, "tcp")=="telnet") ? true : false, // Checking if port is default
"snmp" => (getservbyport(161, "udp")=="snmp") ? true : false, // Checking if port is default
"address" => mapNetworkInfo($networkInfo, "address"),
"subnet" => mapNetworkInfo($networkInfo, "subnet"),
"gateway" => mapNetworkInfo($networkInfo, "gateway"),
);

function mapNetworkInfo($networkInfo, $info) {
$map = array('address'=>'inet addr:', 'subnet'=>'Mask:', 'gateway'=>'Bcast:');
$result = explode($map[$info], $networkInfo);
$result = explode(" ", array_pop($result));
$result = array_shift($result);
return trim($result);
}

echo json_encode($linuxInfo);
1 change: 1 addition & 0 deletions snmp/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php

0 comments on commit e59ebdd

Please sign in to comment.