Code Monkey home page Code Monkey logo

linfo's People

Contributors

ameliabradley avatar beaten-sect0r avatar chraac avatar daleffe avatar dbwiddis avatar doublehelix avatar evazzadeh avatar ewindfield avatar filisko avatar flieslikeabrick avatar froggdev avatar gemorroj avatar gpedro avatar gummibeer avatar hbokh avatar icyz avatar ilianiv avatar indrekhaav avatar jrgp avatar kaotic avatar kesselb avatar kj415j45 avatar ksandell avatar ktp95 avatar lyda avatar matriphe avatar matthiasstraka avatar mologie avatar readingsnail avatar shark-kun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linfo's Issues

Empty needle in Linux.php

Warning: strpos(): Empty needle in /linfo/src/Linfo/OS/Linux.php on line 1568

Generated by Linfo (2015-10-21) in 0.17 seconds.

Handle services when their executable paths are not availabe

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

Warnings: "continue" targeting switch is equivalent to "break".

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;

Division by zero in Linux.php line 1651

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?

Wrong Temperature Reported on CPU

linfo improperly reports on 1 out of 4 cores for my Intel CPU.
My CPU is running mostly at ~30 degrees Celsius when idle, linfo, however, reports one of the cores being at ~45. And each time I load the page it is a different core. Gotta fix that.
2018-08-06-005315_480x129_scrot
2018-08-06-005326_657x204_scrot

Which logs do you want to see?

Method getOS not present.

I installed Linfo to Windows 7 Pro. When I test, I've got error like: "Method getOS not present. "
Any idea?

Clean package

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.

Use internal css and js

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.

Undefined index: additional_paths on Mac OSX

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

ERR_CONTENT_DECODING_FAILED on windows

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.

OS\Linux wrong distro name

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,
                );
            }

Edit:

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,
                );
            }
        }

No Sass / Node build test

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?

.htacess on apache 2.4

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 !

Show the percentage of drive(s) used

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

Detect xhyve/bhyve guest

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.

RAM informations are wrong on Darwin OS

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 sysctlvelse I can make a merge request to put modification.

Network Activity

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

NTFS and HDDtemp

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

wrong CPU-Load under Windows Multi-Core

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.

[PULL} __CALL , auto-forward call to parser

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);
			
		}
		
	}

About “Service monitoring”

// 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]
);

2017-08-15 01 49 07
I want to get the red box service in Linfo.
Is it feasible?
What should I do with the above configuration?

Output line from /proc/stat as a solution to sleep()

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;
}

ob_start error in html output

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

More usage examples

Hi,

Is there any page where i can see more usage example?

for example:

  1. var_dump($parser->getTemps()); gives nothing with the following notice/error

Undefined index: temps

  1. var_dump($parser->determineCPUPercentage());
    gives null

  2. 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'

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

OS_Windows functions are all declared "private"

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.

Class 'COM' not found

Fatal error: Class 'COM' not found in linfo\src\Linfo\OS\Windows.php on line 52

using # v.3.0.1 8/24/2016

Unable to get CPU usage

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.

AutoRefesh

can you tell me were am i add autorefresh server cpu,memory ext. values with jquery timer?

Nice 500 error after updating linfo

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"

Output without echo

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
}

Release a new version

Hey,
I want to update the laravel wrapper to the v3.0version but get an exception in the Linux OS file, this error is fixed but not released yet. Can you pls release v3.1!?

Permission to change code license to MIT?

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?

Missing down services

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.

Undefined index

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!

Accessed IP

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.

PHP library usage

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.