- Saved searches
- Use saved searches to filter your results more quickly
- License
- alhdo/Server-Stats
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- mysql_get_server_info
- Описание
- Список параметров
- Возвращаемые значения
- Примеры
- Смотрите также
- User Contributed Notes 3 notes
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
PHP Tool to easily get information from a server (With or without auto refresh)
License
alhdo/Server-Stats
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
PHP Tool to easily get server information
Server Stats is a group of premade easy to use custom functions that can return various types of information about your server. It can be used as static information or can be set up to auto refresh data whatever is needed for your project.
In the «Server Stats» folder you will find the file you need to use server stats without live refreshing
In the «Server Stats (With live refreshing)» folder you will find the files you need to use server stats with live refreshing (3 in total)
Both are very easy to use, server stats requres no setup at all apart from including the file. Server stats with refreshing requires a little setup but is very simple and explaied below.
Server stats can also be used remotley useing auto refresh. But please note only functions added to the array in stats_json can be used remotley so if you want to use a function remotley thats not in there it will need to be added but this is very easy to do.
(Will be updateing with wiki guides and rewwriting this read me soon)
What information can i get with Server-Stats
With Server-stats you can get the folling information:
- Uptime — (Days, Hours, Mins, Secs)
- Total RAM — (Ammount in Kilobytes, MegaBytes, Gigabytes)
- Available RAM — (Ammount in Kilobytes, MegaBytes, Gigabytes)
- Free RAM — (Ammount in Kilobytes, MegaBytes, Gigabytes)
- Used RAM — (Ammount inKilobytes, MegaBytes, Gigabytes or %)
- CPU Useage — (As a %)
- CPU Info — (model, clock speed, cache ammount, cores)
- Total Disk — Space (Ammount in Kilobytes, MegaBytes, Gigabytes)
- Total Free Disk Space — (Ammount Kilobytes, MegaBytes, Gigabytes)
- Disk Space Used — (Ammount Kilobytes, MegaBytes, Gigabytes or %)
##How To Use (with auto refresh) To use Server Stats with auto refresh you will need the 3 files provided in the «Server Stats (With auto refresh)» folder.
You will also need jqery installed.
####Step 1 Configure the stats_json.php File To do this you will need to change the values in the args to what memory size you want to use. By defualt they are all st to MB but can be KB, MB or GB if you want to find out more about this look as the normal setup for Server Stats without auto refresh below. However for the most part this file does not need to be changed inless you want to change the values given out from KB, MB, GB.
Heres an example of all the values being GB:
$function_array = array('cpuusage' => get_cpu_usage(), 'usedram' => get_usedram(gb), //This value has been changed from mb to gb 'freeram' => get_freeram(gb), //This value has been changed from mb to gb 'usedram2' => get_usedram2(), //This function does not use any args 'diskfreespace' => get_diskfreespace(gb), //This value has been changed from mb to gb 'diskusedspace' => get_diskusedspace(gb), //This value has been changed from mb to gb 'diskusedspace2' => get_diskusedspace2(), //This function does not use any args 'uptimedays' => get_uptime(days), //This value sould not be changed at all 'uptimehours' => get_uptime(hours), //This value sould not be changed at all 'uptimemins' => get_uptime(mins), //This value sould not be changed at all 'uptimesecs' => get_uptime(secs), //This value sould not be changed at all );
You can also remove any of the above entreies into the array if you know you whont be useing them and want to make the file smaller. However this is not really nessary.
####Step 2 Configure the serverstats.js File This is the most inporant part first we need to set the location of the stats_json file. The example below shows the setup for my server please change this to the relavent link on your own server where the stats_json file is located
$.get( "https://server.tomrouse.me/inc/stats_json.php", function( data )
The next step is 100% optional and should only be done if you really care about useing less banwidth (even know this does not use much anyway) This is removeing the commands from the call to get the information. the example below shows the defualt file you can edit this and remove the var’s that you whont be useing.
var cpuusage = obj.cpuusage; var usedram = obj.usedram; var freeram = obj.freeram; var usedram2 = obj.usedram2; var diskfreespace = obj.diskfreespace; var diskusedspace = obj.diskusedspace; var diskusedspace2 = obj.diskusedspace2; var uptimedays = obj.uptimedays; var uptimehours = obj.uptimehours; var uptimemins = obj.uptimemins; var uptimesecs = obj.uptimesecs;
The final step is to set the element that will be used to show the data the example below shows i have set each value to show in a element with the class of ‘result0’ — ‘result10’:
$(".result1").html(usedram); // For this is will display the used ram value in the html elment with the class result1 $(".result2").html(freeram); // For this is will display the free ram value in the html elment with the class result2 $(".result3").html(usedram2); // For this is will display the used ram % value in the html elment with the class result3 $(".result4").html(diskfreespace); // For this is will display the disk free space value in the html elment with the class result4 $(".result5").html(diskusedspace); // For this is will display the disk used space value in the html elment with the class result5 $(".result6").html(diskusedspace2); // For this is will display the disk used space % value in the html elment with the class result6 $(".result7").html(uptimedays); // For this is will display the uptime in days value in the html elment with the class result7 $(".result8").html(uptimehours); // For this is will display the uptime in hours value in the html elment with the class result8 $(".result9").html(uptimemins); // For this is will display the uptime in mins value in the html elment with the class result9 $(".result10").html(uptimesecs); // For this is will display the uptime in secs value in the html elment with the class result10
Its very easy to change the ones i have added or add your own as all the var’s are already made you just need to pick where to use them.
If you want more information on how each function works look below!
##How To Use (Without auto refresh) To use Server Stats just use it as a php include on your project and then you can call in the functions.
include_once 'directory/from/file/you/want/to/use/it/on/Server-Stats.php' ?>
mysql_get_server_info
Данный модуль устарел, начиная с версии PHP 5.5.0, и удалён в PHP 7.0.0. Используйте вместо него MySQLi или PDO_MySQL. Смотрите также инструкцию MySQL: выбор API. Альтернативы для данной функции:
Описание
Возвращает версию сервера MySQL.
Список параметров
Соединение MySQL. Если идентификатор соединения не был указан, используется последнее соединение, открытое mysql_connect() . Если такое соединение не было найдено, функция попытается создать таковое, как если бы mysql_connect() была вызвана без параметров. Если соединение не было найдено и не смогло быть создано, генерируется ошибка уровня E_WARNING .
Возвращаемые значения
Возвращает версию сервера MySQL в случае успешного выполнения или false в случае возникновения ошибки.
Примеры
Пример #1 Пример использования mysql_get_server_info()
$link = mysql_connect ( ‘localhost’ , ‘mysql_user’ , ‘mysql_password’ );
if (! $link ) die( ‘Ошибка соединения: ‘ . mysql_error ());
>
printf ( «Версия сервера MySQL: %s\n» , mysql_get_server_info ());
?>?php
Результатом выполнения данного примера будет что-то подобное:
Версия сервера MySQL: 4.0.1-alpha
Смотрите также
- mysql_get_client_info() — Возвращает данные о MySQL-клиенте
- mysql_get_host_info() — Возвращает информацию о соединении с MySQL
- mysql_get_proto_info() — Возвращает информацию о протоколе MySQL
- phpversion() — Получает текущую версию PHP
User Contributed Notes 3 notes
An alternative to mysql_get_client_info() is to use the VERSION() function in MySQL language like:
$query = mysql_query ( «SELECT VERSION() as mysql_version» );
?>
The output is the same as mysql_get_client_info()
Here is something I put together because I needed a way to pull the MySQL version number from the server without actually having a connection. This was due to being part of a server info screen prior to installation of a cms. Users need to know if their MySQL is supported or not prior to installation right? 🙂
This will scrape the phpinfo page looking for the MySQL row that says Client API version and return the version number after it. This could also be used to scrape just about anything from the phpinfo page. 🙂
ob_start();
phpinfo(INFO_MODULES);
$info = ob_get_contents();
ob_end_clean();
$info = stristr($info, ‘Client API version’);
preg_match(‘/5.2.43/’, $info, $match);
$gd = $match[0];
echo ‘MySQL: ‘.$gd.’
‘;
This will output:
MySQL: 4.1.22 (which is the version on my server)
I know this is crude but it’s the only thing I could come up with and there isn’t anything like this info available online so here it is. I suck at preg_match and it would be helpful if someone could modify the string here to stand the test of time.
mysql_connect ( ‘localhost’ , ‘user’ , ‘password’ ) or
die( ‘Could not connect: ‘ . mysql_error ());
$a = mysql_get_server_info ();
$b = substr ( $a , 0 , strpos ( $a , «-» ));
echo $b ;
?>
- MySQL
- mysql_affected_rows
- mysql_client_encoding
- mysql_close
- mysql_connect
- mysql_create_db
- mysql_data_seek
- mysql_db_name
- mysql_db_query
- mysql_drop_db
- mysql_errno
- mysql_error
- mysql_escape_string
- mysql_fetch_array
- mysql_fetch_assoc
- mysql_fetch_field
- mysql_fetch_lengths
- mysql_fetch_object
- mysql_fetch_row
- mysql_field_flags
- mysql_field_len
- mysql_field_name
- mysql_field_seek
- mysql_field_table
- mysql_field_type
- mysql_free_result
- mysql_get_client_info
- mysql_get_host_info
- mysql_get_proto_info
- mysql_get_server_info
- mysql_info
- mysql_insert_id
- mysql_list_dbs
- mysql_list_fields
- mysql_list_processes
- mysql_list_tables
- mysql_num_fields
- mysql_num_rows
- mysql_pconnect
- mysql_ping
- mysql_query
- mysql_real_escape_string
- mysql_result
- mysql_select_db
- mysql_set_charset
- mysql_stat
- mysql_tablename
- mysql_thread_id
- mysql_unbuffered_query