jrgp / linfo Goto Github PK
View Code? Open in Web Editor NEWLinfo PHP Server Health Status
License: MIT License
Linfo PHP Server Health Status
License: MIT License
$linfo = new \Linfo\Linfo; --> create problem without $setting vars,
Maybe possible do a defaults values and hard-include it in the class...
Warning: strpos(): Empty needle in /linfo/src/Linfo/OS/Linux.php on line 1568
Generated by Linfo (2015-10-21) in 0.17 seconds.
Hello,
I have some services I want to monitor but their executable paths are not available (they show up in 'ps' command as "[cmd]" with square brackets) and they don't have pid files..
One example is "[mega-cmd-server]" from MEGAcmd
https://github.com/meganz/MEGAcmd
Currently $settings['services']['executables'] array only takes full path of the executable:
// Format: Label => path to executable or array containing arguments to be checked
$settings['services']['executables'] = array(
// 'MySQLd' => '/usr/sbin/mysqld' // uncomment to enable
// 'BuildSlave' => array('/usr/bin/python', // executable
// 1 => '/usr/local/bin/buildslave') // argv[1]
);
Is it possible for settings array to handle services running as "[cmd]" in 'ps'?
see: https://unix.stackexchange.com/questions/22121/what-do-the-brackets-around-processes-mean
When accessing linfo, two warnings are spilled out:
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /srv/http/linfo/src/Linfo/OS/Linux.php on line 1034
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /srv/http/linfo/src/Linfo/OS/Linux.php on line 1351
The fix is simply to delete the "continue" from the switch-case.
UPDATE: considering the logic, it makes more sense to break out to the upper switch.
diff --git a/src/Linfo/OS/Linux.php b/src/Linfo/OS/Linux.php
index d77ef91..66a6447 100644
--- a/src/Linfo/OS/Linux.php
+++ b/src/Linfo/OS/Linux.php
@@ -1031,7 +1031,7 @@ class Linux extends Unixcommon
$charge_now = Common::getIntFromFile($b.'/charge_now');
break;
default:
- continue;
+ continue 2;
break;
}
@@ -1348,7 +1348,7 @@ class Linux extends Unixcommon
$state = 'Up (Stopped)';
break;
default:
- continue;
+ continue 3;
break;
}
break;
I have currently pulled in the dev-master build, as I will only really be using it for my admin panel.
I recently just updated to PHP7. Any recommendations?
I installed Linfo to Windows 7 Pro. When I test, I've got error like: "Method getOS not present. "
Any idea?
It would be good to clean this package to it's base - just PHP classes and bring them in a namespace. This supports the development of projects that extend this package and works better with composer (autoload PSR).
The usage examples can get an own repo (linfo/usage what ever).
The namespace also reduces possible conflicts with other classes.
This will be a great change that includes much of refactoring, renaming, moving and so on.
Suggested for 2.1 or even 3.0 cause this will be a big change that totaly changes the way this package is used/called.
Currently to load html output, linfo use 5 file contain 3 css, 1 js and 1 image as default and sometimes it being more for extra image or etc.
We can use internal css and js remove extra request. Someone maybe want to use linfo html preview as part of another service and they must customize location of media files. Because of that we can use internal css and js. For images i recommend to merge images into one file and convert it to base64 to use in css.
I get
exception 'ErrorException' with message 'Undefined index: additional_paths' in /Users/cedricverst/www/web/vendor/linfo/linfo/src/Linfo/Parsers/CallExt.php:67
Got PCRE installed and using PHP 5.6.10
You might want to @
silence the notices here, or perhaps check if it exists first.
Hi
Its better to add some documentation about running on windows!
I have ERR_CONTENT_DECODING_FAILED error and after some search found that is because force gzip on linfo.
By enable zlib.output_compression
in php.ini
its working. but maybe it's better to describe this or disable force gzip in request header.
Hello,
Running Fedora 30 (Thirty) Workstation, I was trying to call getDistro()
, I got:
array:2 [▼
"name" => "CentOS"
"version" => "Fedora release 30 (Thirty)"
]
The problem that Fedora
has redhat-release
file in /etc
and looking at src/Linfo/OS/Linux.php
line 1406 is considered the first match and at line 1471 gets returned as the first correct match.
The last condition is always true since all $contents_distros
have distro
index (except ones with closure
).
} elseif (isset($distro['distro'])) {
return array(
'name' => $distro['distro'],
'version' => $contents,
);
}
Adding isset($distro['distro']) && (strpos($distro['distro'], $contents) !== false)
to the last condition seems to solve the issue for me.
foreach ($contents_distros as $distro) {
if (!($contents = Common::getContents($distro['file'], false))) {
continue;
}
if (isset($distro['closure']) && ($info = $distro['closure']($contents))) {
return array(
'name' => ucfirst($info['distro']),
'version' => $info['version'].(isset($info['codename']) ? ' ('.ucfirst($info['codename']).')' : ''),
);
} elseif (isset($distro['regex']) && preg_match($distro['regex'], $contents, $info)) {
return array(
'name' => $distro['distro'],
'version' => $info['version'].(isset($info['codename']) ? ' ('.ucfirst($info['codename']).')' : ''),
);
} elseif (isset($distro['distro']) && (strpos($distro['distro'], $contents) !== false)) {
return array(
'name' => $distro['distro'],
'version' => $contents,
);
}
}
I've considered adding a Node build test to Linfo. For now it could just do a sanity check that the Sass and JavaScript compile correctly. Later it could do more complicated things (like running eslint or JS unit tests.)
But while TravisCI has excellent support for both PHP and Node, the way the .travis.yml
test matrix works we'd end up running the Node build test on every one of our PHP unit test platforms. This doesn't add much to our build time. It just seems unnecessary and inefficient.
We could use a different testing framework for the Node compilation. There's Semaphore. I don't consider it particularly ideal to have two CI platforms, but I guess GitHub supports it.
Ideally though, someone with more TravisCI experience can prove me wrong here!
Thoughts? Suggestions?
Hi,
on apache 2.4 i have the following error in apache logs:
/var/www/info/.htaccess: Regex could not be compiled
to solve the trouble i changed <FilesMatch ""> by <FilesMatch ".">, i don't have any apache2.2 to test if the fix work for both
if you can get an eye, thanks !
Warning: Division by zero in /linfo/lib/class.LinfoOutput.php on line 366
Swap 0 B 0 B 0 B 0%
Memory values in OS X are in Mebibytes.
Megabytes are only used for hard drives.
When calculating swap usage in Darwin.php you're multiplying the returned value by 1 million (Megabyte) rather than the correct 10242 (<< 20).
$return['swapTotal'] = $swap_total * 1000000;
$return['swapFree'] = $swap_free * 1000000;
Hi, I just installed linfo and I am happy with it. Many thanks for your efforts to provide a solution like linfo to the community.
One feature i am missing is a table showing the percentage of drive(s) capacity used to monitor possible drive lockouts!
regards, hitam4450
Linfo detects guest of xhyve and bhyve as being QEMU/KVM.
This seems to be a generic problem as I have found tickets for Salt and Puppet/facter that state the same also.
Hello,
I'm using Mac OS 10.15.6 (Catalina) and getRam function return incorrect result.
Here explained :
use Linfo\Linfo;
require 'vendor/autoload.php';
$linfo = (new Linfo())->getParser();
print_r($linfo->getRam());
Result :
Array
(
[type] => Physical
[total] => 17179869184
[free] => 17432133632
[swapTotal] => 0
[swapFree] => 0
[swapInfo] => Array
(
)
)
As you can see, free mem is greater than available. sysctl hw.usermem
return `hw.usermem: -216473600'. So I try to take only the absolute value (216473600) but it still wrong.
My current free RAM is about 3Gb.
A little trick allow me to get the free RAM in Dawin.php (I don't like to "unitPows trick but... it works)
$freeMemory = trim($this->exec->exec('top', '-l 1 | grep PhysMem | sed "s/.*, //" | sed "s/ .*//"'));
$unitPows = [
'K' => 1,
'M' => 2,
'G' => 3,
];
$unit = substr($freeMemory, -1);
$freeMemory = (int) $freeMemory;
$freeMemory = $freeMemory * pow(1024, $unitPows[$unit]);
Gives me 2008023040
(2Gb because my RAM available is about 2Gb ^^)
Hope you will find a fix with sysctl
velse I can make a merge request to put modification.
As the title suggests, the script doesn't monitor the inboud and outbound traffic of the current server.
I hope this gets added to this script, im sure many people would be interested of it being added since this script is actually pretty leightweight.
Thanks
It seems loading ntfs drives doesn't list specs just ? marks. I installed hddtemp and got a hdd parser error. Other than that awesome tool. Thank you
When trying to run the library on a PHP 7.1 installation it goes in an infinite loop. Not sure what's going wrong.
I watched the results from Linfo and from the Windows-Ressourcemonitor a while and there are great differences between them.
The Linfo Result is just the first Core (it's an 8 Core Intel) this Core is permanent between 50-70% - this is the Linfo result. But the whole CPU-Load in average is 30-40%. With an 8 times 3.7 GHz this is great difference and my live tracker for system health is nearly useless with these differences.
Would be nice if you can fix this and get the load for every Core in the CPU Array and the average load over all cores in the Load String.
MAGIC METHOD __CALL for \linfo\linfo for do auto-forward to parser
public function __call ( $name , $args ) {
if (method_exists($this->parser, $name) && is_callable ( array($this->parser, $name)) {
return call_user_func(array($this->parser,$name), $args);
}
}
// Format: Label => path to executable or array containing arguments to be checked
$settings['services']['executables'] = array(
// 'MySQLd' => '/usr/sbin/mysqld' // uncomment to enable
// 'BuildSlave' => array('/usr/bin/python', // executable
// 1 => '/usr/local/bin/buildslave') // argv[1]
);
I want to get the red box service in Linfo.
Is it feasible?
What should I do with the above configuration?
I was thinking about realtime cpu usage in percents and I think that Linfo should provide pure values from /proc/stat
instead of trying to make percents.
Linfo is fast, designed to be called once per second. So why don't move responsibility of making cpu usage in percentage to program that uses it? That program would have already values from last call so it would not need to wait. Moreover library sleeps one sec so when mentioned program is not synced then there will be gaps in results.
Since I didn't see configuration for this anywhere, I suspected that it's not possible, and hence writing issue.
Hackish solution is to change loop count to one and this function:
private function cpuPercent($key, $line) {
return $line;
}
I have this errors in windows
Warning: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression' in D:\xampp\htdocs\Projects\github\linfo\src\Linfo\Output\Html.php on line 150
Notice: ob_start(): failed to create buffer in D:\xampp\htdocs\Projects\github\linfo\src\Linfo\Output\Html.php on line 150
probably it's because don't clean last ob_start and start again. it try to fix this and send as pull request
Gemorroj#8
master...Gemorroj:master
I have a fork of this library.
There have been many changes in the fork. I want to change the license to LGPL. As far as I know, I have to ask permission from the author of the original GPL code.
Hi,
Is there any page where i can see more usage example?
for example:
var_dump($parser->getTemps());
gives nothing with the following notice/error
Undefined index: temps
var_dump($parser->determineCPUPercentage());
gives null
var_dump($parser->getMounts());
gives notice
Undefined index: show
I think i need to pass some more info to these method calls. Can you help.?
Thanks
Warning: usort() expects parameter 2 to be a valid callback, class 'OS_Windows' not found in C:*\src\Linfo\OS\Windows.php on line 278
Warning: usort() expects parameter 2 to be a valid callback, class 'OS_Windows' not found in C:*\src\Linfo\OS\Windows.php on line 382
Warning: usort() expects parameter 2 to be a valid callback, class 'OS_Windows' not found in C:*\src\Linfo\OS\Windows.php on line 422
After determining the operating system, Linfo creates a parser with the class name OS_[operatingsystem]
.
It then tries to execute all of the methods that are available for that OS parser by looping through the method names and calling method_exists()
to determine if the function is supported. if method_exists()
returns true, the method is called.
Unfortunately, method_exists()
returns true even if the method is not public/callable from an instance of the object.
All of the methods of the OS_Windows
class are declared private
and therefore, even though they are determined to exist, they throw an error when being called.
I've tried marking them all public
and this resolved the issue on my windows instance.
Fatal error: Class 'COM' not found in linfo\src\Linfo\OS\Windows.php on line 52
using # v.3.0.1 8/24/2016
Code
$linfo = new \Linfo\Linfo;
$parser = $linfo->getParser();
$cpu = $parser->getCPUUsage();
var_dump($cpu);
Output
/home/www/html/test.php:104:boolean false
RAM usage,Uptime etc works fine though.
System Info
PHP => PHP 7.2.8 (cli) (built: Jul 17 2018 09:50:46) ( NTS )
OS => CentOS Linux release 7.5.1804 (Core)
Kernel => Linux localhost 3.10.0-862.9.1.el7.x86_64
Its a local virtual machine, so nothing is restricted on PHP side. Please let me know if you need any further information.
Thank you.
can you tell me were am i add autorefresh server cpu,memory ext. values with jquery timer?
2015/08/31 14:35:32 [error] 17565#0: *116779 FastCGI sent in stderr: "PHP message: PHP Fatal error: Can't use function return value in write context in /home/touma/webserver/linfo/lib/class.OS_Linux.php on line 1513" while reading response header from upstream, client: ::ffff:0.0.0.0, server: stats.ilp.moe, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "stats.ilp.moe"
It would be really nice if you can add an output type that returns a php array and not echo everything. I would implement this in a Laravel5 package and found a workaround to get the data in php but it's not the nice way.
It would be better if I can call something like:
require_once __DIR__.'/init.php';
try {
$linfo = new Linfo;
$linfo->scan();
$data = $linfo->output('php');
// do something with the php array
// save in database, create graphics/charts, send email to admin and so on
} catch (LinfoFatalException $e) {
// handle the Exception
}
all of the core contents are disabled but the title still shown.
Warning: strpos(): Empty needle in /linfo/lib/class.OS_Linux.php on line 1513
Cant get the Value of "cpuUsage", its empty.
Hey,
I want to update the laravel wrapper to the v3.0
version but get an exception in the Linux OS file, this error is fixed but not released yet. Can you pls release v3.1
!?
I think it would be interesting (just as testing for if running inside VM) to see if Linfo is running inside a container.
Hey,
I'm working on a Laravel 5 wrapper for your package. If you have wishes or anything else pls tell me:
https://github.com/Gummibeer/laravel-linfo or via email.
It's work in progress yet but I want to provide this god peace of work for the big Laravel community. ;)
License "GPL" is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.
use
composer validate
to validate composer.json
Hi Everyone. I'm the author of this project, and would like to relicense all files from GPL to MIT, so the project becomes more permissive and more usable for everyone.
However, I need an explicit "YES" from each person who has contributed code. Is everyone okay with this?
Hello
In my setup I'm trying to monitor the service state (up/down) of some services,
i.e.:
// Format: Label => pid file path
$settings['services']['pidFiles'] = array(
'nginx' => '/run/nginx.pid',
'ssh' => '/run/sshd.pid'
);
The problem is that whenever a service stops, the corresponding row is removed from the services box.
Hello,
I've been using Linfo for a while now and it seems to be cluttering my server log with a little error (on every page load):
2015-01-19 03:40:04: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Notice: Undefined index: hw in /var/www/default/lib/class.HW_IDS.php on line 281
I'm using Lighttpd on a Raspberry Pi with FastCGI for PHP.
Thanks!
With local server on Windows with IIS (I use 7.5);
Accessed IP returns Unknown. Because of $_SERVER['SERVER_ADDR']
So I use
gethostbyname($_SERVER['SERVER_NAME'])
instead of
$_SERVER['SERVER_ADDR']
in class.LinfoOutput.php file.
Hi,
i followed your guide, so on my debian machine into a subdirectory i've download linfo project. I tested it and all work fine.
Now i created a new directory (outside linfo dir) i launched:
`
composer require linfo/linfo
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^3.0 for linfo/linfo
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing linfo/linfo (v3.0.0)
Downloading: 100%
linfo/linfo suggests installing ext-com (On Windows)
Writing lock file
Generating autoload files`
i created a new file api_linfo.php with this values:
getParser(); var_dump($parser->getCPU()); ?>But when i exec i've this error: PHP Fatal error: Class 'Linfo\Linfo' not found in
Where are my errors?
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.