diff --git a/assets/html/a_index.twig b/assets/html/a_index.twig
index 2627a8b..360f608 100644
--- a/assets/html/a_index.twig
+++ b/assets/html/a_index.twig
@@ -74,11 +74,11 @@
{{server.Freeram}}
|
- 0 %} class="bg-danger" {% endif %}>
+ | 0 %} class="bg-danger" {% endif %}>
{{server.HDDFastStats | raw}}
|
- 0 %} class="bgcolor-warn" {%endif%}>
+ | 0 %} class="bgcolor-warn" {%endif%}>
Monitorizando: {{server.SEnabled}}
{% if server.SEnabled > 0 %} Funcionando: {{server.SActive}} {% endif %}
{% if server.SInactive > 0 %} Parados: {{server.SInactive}} {% endif %}
@@ -86,11 +86,11 @@
|
{{server.Uptime}} |
{% if server.Enabled == 1 %}
- -1 %}class="bgcolor-ok"{%else%}class="bgcolor-warn"{%endif%}>{{server.Ping}}ms |
+ -1 %} class="bgcolor-ok"{%else%} class="bgcolor-warn"{%endif%}>{{server.Ping}}ms |
{% else %}
|
{% endif %}
- Ver
+ | Ver
|
{% endfor %}
diff --git a/assets/html/a_newserver.twig b/assets/html/a_newserver.twig
index a2c6587..7d8c429 100644
--- a/assets/html/a_newserver.twig
+++ b/assets/html/a_newserver.twig
@@ -55,6 +55,9 @@
+
diff --git a/cron/cron.php b/cron/cron.php
index b571bbf..ddd5147 100644
--- a/cron/cron.php
+++ b/cron/cron.php
@@ -70,7 +70,10 @@ while ($pc = dbw_fetch_array($db_conn,$pcsenabled)){
cron_status($db_conn,$time,$pc);
}
-
+ //Get type of linux
+ if ($pc['SO'] == 'LINUX'){ //Only update if needs (Todo? Well, as is only checks if no SYSTEMD or SERVICE found)
+ detect_linux($pc);
+ }
//Services
$services = dbw_query($db_conn,"SELECT ID_SERV,`Name` FROM S_SERVICES WHERE ID_SERV='$pc[ID_SERV]' AND `Enabled`=1 AND `Type`='SERVICE'");
@@ -87,11 +90,6 @@ while ($pc = dbw_fetch_array($db_conn,$pcsenabled)){
cron_uptime($db_conn,$time,$pc); //Uptime
- //Get type of linux
- if ($pc['SO'] == 'LINUX'){ //Only update if needs (Todo?)
- detect_linux($pc);
- }
-
cron_getversion($db_conn,$pc); //Windows/Linux version name
}
diff --git a/cron/servers.php b/cron/servers.php
index 66fa712..7dbcf4b 100644
--- a/cron/servers.php
+++ b/cron/servers.php
@@ -49,11 +49,13 @@ function cron_service($db_conn,$time,$pc,$service){
$status = $lastline != 0 ? 0 : 1; //3 is stop, 4 is non exist
break;
case 'LINUX_SERVICE':
+ case 'BSD_SERVICE': //BSD Has too the service command, but I don't know if it's same as Linux
$lines = explode(PHP_EOL,commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pc['Password'],'service '.$service['Name'].' status;echo $?'));
$lastline = $lines[count($lines)-1];
$status = $lastline != 0 ? 0 : 1; //3 is stop (TODO see number)
break;
case 'LINUX': //Proceso
+ case 'BSD': //BSD Uses process too
$lines = explode(PHP_EOL,commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pc['Password'],'ps -A | grep '.$service['Name']));
//$lastline = $lines[count($lines)-1];
if (count($lines)){
@@ -114,31 +116,46 @@ function cron_status($db_conn,$time,$pc){
$pass =$pc['Password'];
//Get Free RAM and total RAM
- if ($pc['SO'] == "WINDOWS"){
- $wql = "select FreePhysicalMemory from Win32_OperatingSystem";
- $freeramwmic = shell_exec('wmic -U \''.$pc['User'].'%'.$pass.'\' //'.$pc['IP'].' "'.$wql.'"');
+ switch ($pc['SO']){
+ case 'WINDOWS':
+ $wql = "select FreePhysicalMemory from Win32_OperatingSystem";
+ $freeramwmic = shell_exec('wmic -U \''.$pc['User'].'%'.$pass.'\' //'.$pc['IP'].' "'.$wql.'"');
- //showdeb($freeramwmic);
+ //showdeb($freeramwmic);
- $freeramexp = explode(PHP_EOL,$freeramwmic);
- $freeram = explode('|',$freeramexp[2])[0]*1024; //Third line. Windows doesn't have tail -n+3 and cut. Also show in KB
-
- $wql = "select TotalPhysicalMemory from Win32_ComputerSystem";
- $totalramwmic = shell_exec('wmic -U '.$pc['User'].'%'.$pass.' //'.$pc['IP'].' "'.$wql.'"');
- $totalramexp = explode(PHP_EOL,$totalramwmic);
- $detram = explode('|',$totalramexp[2])[1]; //Third line. Windows doesn't have tail an cut. This is in KB directly
+ $freeramexp = explode(PHP_EOL,$freeramwmic);
+ $freeram = explode('|',$freeramexp[2])[0]*1024; //Third line. Windows doesn't have tail -n+3 and cut. Also show in KB
+
+ $wql = "select TotalPhysicalMemory from Win32_ComputerSystem";
+ $totalramwmic = shell_exec('wmic -U '.$pc['User'].'%'.$pass.' //'.$pc['IP'].' "'.$wql.'"');
+ $totalramexp = explode(PHP_EOL,$totalramwmic);
+ $detram = explode('|',$totalramexp[2])[1]; //Third line. Windows doesn't have tail an cut. This is in KB directly
+ break;
+ case 'LINUX_SYSTEMD':
+ case 'LINUX_SERVICE':
+ case 'LINUX': //Systemd and init goes same way
+ $resu = commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pass,'free -b | tail -n+2 | head -1');
+ $line = preg_replace("/[[:blank:]]+/",' ',$resu);
+ $part = explode(' ',$line);
+ //Mem: total used free shared buff/cache available
+ $detram = $part[1]; //Total RAM
+ if (isset($part[6])){
+ $freeram = $part[6];//Avaiable
+ }else{ //Some systems do not have avaiable col
+ $freeram = $part[4];//Free
+ }
+ break;
+ case 'BSD':
+ $resu = commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pass,'sysctl hw.physmem');
+ $line = preg_replace("/[[:blank:]]+/",' ',$resu);
+ $part = explode(' ',$line);
+ //Mem: total used free shared buff/cache available
+ $detram = $part[1]; //Total RAM
- }else{ //Systemd and init goes same way
- $resu = commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pass,'free -b | tail -n+2 | head -1');
- $line = preg_replace("/[[:blank:]]+/",' ',$resu);
- $part = explode(' ',$line);
- //Mem: total used free shared buff/cache available
- $detram = $part[1]; //Total RAM
- if (isset($part[6])){
- $freeram = $part[6];//Avaiable
- }else{ //Some systems do not have avaiable col
- $freeram = $part[4];//Free
- }
+ $resu = commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pass,'vmstat | grep -E \'([0-9]+\w+)+\' | awk \'{print $5}\'');
+ $line = preg_replace("/[[:blank:]]+/",' ',$resu);
+ $freeram = $line; //Free RAM
+ break;
}
dbw_query($db_conn,"INSERT INTO S_HISTRAM (ID_SERV,`Timestamp`,Freeram,Detram) VALUES ('$pc[ID_SERV]','$time','$freeram','$detram')");