Control Web Panel

WebPanel => CentOS-WebPanel GUI => Topic started by: ring_c on September 01, 2018, 08:54:37 PM

Title: Resources monitor per user/website
Post by: ring_c on September 01, 2018, 08:54:37 PM
Hi,


Is there a way for me as admin to see how many resources each user/site is using (RAM/CPU/etc...)?
Couldn't find a page with such info.


TIA.
Title: Re: Resources monitor per user/website
Post by: bullten on September 01, 2018, 10:44:27 PM
Well per site is not possible but all over you can see in GUi. You have to perform below installation

Code: [Select]
http://forum.centos-webpanel.com/how-to/(tutorial)-installing-netdata-on-centos-web-panel/
Check demo before installing it into your server

Code: [Select]
https://my-netdata.io/#demosites
Title: Re: Resources monitor per user/website
Post by: ring_c on September 02, 2018, 07:26:18 PM
Unfortunately, it resulted in an error, quite early.
Right after the command
Code: [Select]
pip install mysqlclient I was getting these errors:

Code: [Select]
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command /usr/bin/python2 -u -c "import setuptools, toke                                                                                                                                                             nize;__file__='/tmp/pip-install-WBKL5o/mysqlclient/setup.py';f=getattr(tokenize,                                                                                                                                                              'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(comp                                                                                                                                                             ile(code, __file__, 'exec'))" install --record /tmp/pip-record-G1r32T/install-re                                                                                                                                                             cord.txt --single-version-externally-managed --compile:
    /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distributio                                                                                                                                                             n option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
    creating build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/                                                                                                                                                             constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/co                                                                                                                                                             nstants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/consta                                                                                                                                                             nts
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/consta                                                                                                                                                             nts
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLd                                                                                                                                                             b/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/cons                                                                                                                                                             tants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/c                                                                                                                                                             onstants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-2.7
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2                                                                                                                                                              -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-sw                                                                                                                                                             itches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wa                                                                                                                                                             ll -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buf                                                                                                                                                             fer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv                                                                                                                                                              -fPIC -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/include/mys                                                                                                                                                             ql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
    _mysql.c:37:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1


    ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-                                                                                                                                                             install-WBKL5o/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__)                                                                                                                                                             ;code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exe                                                                                                                                                             c'))" install --record /tmp/pip-record-G1r32T/install-record.txt --single-versio                                                                                                                                                             n-externally-managed --compile" failed with error code 1 in /tmp/pip-install-WBK                                                                                                                                                             L5o/mysqlclient/


I guess I shouldn't continue the installation...
Any idea what's wrong?
Title: Re: Resources monitor per user/website
Post by: bullten on September 02, 2018, 10:23:10 PM
Does this helps

yum install python-devel -y
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 01:32:51 AM
Does this helps

yum install python-devel -y
Yes, it does. Thanks!
BUT... then I get this error:


Code: [Select]
[root@cwp netdata]# rpm -ivh https://github.com/firehol/packages/releases/download/2018-08-19-1732/firehol-3.1.6-1.el7.noarch.rpm
Retrieving https://github.com/firehol/packages/releases/download/2018-08-19-1732/firehol-3.1.6-1.el7.noarch.rpm
error: Failed dependencies:
        ipset is needed by firehol-3.1.6-1.el7.noarch


So I can't write the file /etc/firehol/fireqos.conf

Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 01:39:47 AM
Code: [Select]
Ok, figured it out after some search.
You first have to run this:
[codee]yum install ipset-service


Now it works. Thanks!
I'll go and check this. Looks great.
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 01:49:44 AM
Ok, this DOES look impressive and lots of data (too much? :) )...
Coming back to my original question - how can I see resources used by a specific site.
Let's say there's a huge increase in CPU usage - how can I tell which site is causing it and which process in this site?
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 01:53:59 AM
Oh, and one more thing - I see this system is open for all. How can I protect its access with a password so others won't use it?
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 05:57:03 AM
I got to work now, and am trying to access netdata from my workplace's PC, and get this:
Code: [Select]
Access to file is not permitted: /usr/local/apache/htdocs/netdata/usr/share/netdata/web//index.html

Is it related at all to the fact I'm trying to access it from another PC?
I've also tried from my mobile, and got the same.


Any idea what's wrong?
Title: Re: Resources monitor per user/website
Post by: bullten on September 03, 2018, 11:28:47 AM
Well you cannot monitor per site basis. Its for those who who to see how their server is functioning and using resources based on GUI. This send notification too on desktop to let user know if something is wrong.

Well that error is related to permission I think

Did you try to run the following command for permission

chown -R netdata:netdata /usr/local/apache/htdocs/netdata
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 12:01:58 PM
Did you try to run the following command for permission

chown -R netdata:netdata /usr/local/apache/htdocs/netdata
Wow you're a savior! Thank you!
Wasn't it part of the tutorial, though? I can swear there was such a command in there...
Title: Re: Resources monitor per user/website
Post by: bullten on September 03, 2018, 12:29:00 PM
You can actually password protect it using /usr/local/apache/bin/htpasswd and adding it in vhost file.

Search online to know how.

Well there was command in tutorial but I don't know why it didn't execute.
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 12:34:25 PM
Sorry for so many questions...
What if I won't password protect it. Is there any vulnerability in leaving it open to all?
Do you protect yours?
Title: Re: Resources monitor per user/website
Post by: bullten on September 03, 2018, 12:36:26 PM
Yes we do password protect it. Obviously its not good to keep it open. anyone can come and change settings see things. Thats not a vulnerability but why would I allow someone to see my chart :)
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 12:41:08 PM
Correct. I will have to investigate how to do it. As a newbie, everything looks so difficult (throws me back to the MS-DOS days before the Windows era, but I haven't used command line ever since)...


Any chance you have a guide up your sleeve to share how to put this password protection in place?
Title: Re: Resources monitor per user/website
Post by: Rug3r on September 03, 2018, 01:16:48 PM

Did you try to run the following command for permission

chown -R netdata:netdata /usr/local/apache/htdocs/netdata

Thanks for the fix Bullten
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 01:50:38 PM
Thanks for the fix Bullten
So it's not only me...
Title: Re: Resources monitor per user/website
Post by: bullten on September 03, 2018, 02:13:17 PM
Well you can password protect it like below
Quote
nano  /usr/local/apache/htdocs/netdata/etc/netdata/netdata.conf

Find # bind to = under [web] and uncomment it and change it to bind to = localhost

Before

Quote
[web]
        # mode = static-threaded
        # listen backlog = 4096
        # default port = 19999
        # bind to =
        # web files owner = netdata
        # web files group = netdata

After   
   
Quote
[web]
        # mode = static-threaded
        # listen backlog = 4096
        # default port = 19999
        bind to = localhost
        # web files owner = netdata
        # web files group = netdata


Create Password

Code: [Select]
ln -s /usr/local/apache/bin/htpasswd /usr/sbin/htpasswd
htpasswd -bc /usr/local/apache/htdocs/netdata/usr/share/netdata/web/.htpasswd yourusername yourpassword

Copy and Paste all lines not one by one

Quote
cat > /usr/local/apache/conf.d/netdata-auth.conf << "EOF"
<VirtualHost *:80>

   RewriteEngine On
   ProxyRequests Off
   ProxyPreserveHost On

   <Proxy *>
      Require all granted
   </Proxy>

   # Local netdata server accessed with '/netdata/', at localhost:19999
   ProxyPass "/netdata/" "http://localhost:19999/" connectiontimeout=5 timeout=30 keepalive=on
   ProxyPassReverse "/netdata/" "http://localhost:19999/"

   # if the user did not give the trailing /, add it
   # for HTTP (if the virtualhost is HTTP, use this)
   RewriteRule ^/netdata$ http://%{HTTP_HOST}/netdata/ [L,R=301]
   # for HTTPS (if the virtualhost is HTTPS, use this)
   #RewriteRule ^/netdata$ https://%{HTTP_HOST}/netdata/ [L,R=301]

    <Location /netdata/>
       AuthType Basic
       AuthName "Protected site"
      AuthUserFile /usr/local/apache/htdocs/netdata/usr/share/netdata/web/.htpasswd
      Require valid-user
      Order deny,allow
      Allow from all
</Location>
   
</VirtualHost>
EOF

Restart Apache
Code: [Select]
service httpd restart
Note: Now you cant access netdata using port you need to access like http://yourserverip/netdata/
Title: Re: Resources monitor per user/website
Post by: ring_c on September 03, 2018, 06:21:15 PM
Create Password
Code: [Select]
ln -s /usr/local/apache/bin/htpasswd /usr/sbin/htpasswd
htpasswd -bc /usr/local/apache/htdocs/netdata/usr/share/netdata/web/.htpasswd yourusername yourpassword


First, thank you so much for all your help.
Second, I got the following error:


Code: [Select]
[root@cwp ~]# ln -s /usr/local/apache/bin/htpasswd /usr/sbin/htpasswd
ln: failed to create symbolic link ‘/usr/sbin/htpasswd’: File exists

Title: Re: Resources monitor per user/website
Post by: bullten on September 03, 2018, 09:23:32 PM
Its just a warning to let you know file already exist there. You dont need to worry about that. I would suggest you to follow this tutorial

https://blog.bullten.com/centos-web-panel/password-protect-netdata-and-disable-port-access-in-centos-web-panel-centos-6-7/
Title: Re: Resources monitor per user/website
Post by: Rug3r on September 05, 2018, 12:23:43 AM
Its just a warning to let you know file already exist there. You dont need to worry about that. I would suggest you to follow this tutorial

https://blog.bullten.com/centos-web-panel/password-protect-netdata-and-disable-port-access-in-centos-web-panel-centos-6-7/

Hey Bullten,

I followed all on your write up for adding password protection and it all worked fine except for some reason I had to use chown -R netdata:netdata /usr/local/apache/htdocs/netdata again to access it after filling in user and password. I had to use chown -R netdata:netdata /usr/local/apache/htdocs/netdata yesterday in order to access netdata. What would cause me to have to do it today?

Or is this fixed now that I added password protection?

Thanks, Rug3r
Title: Re: Resources monitor per user/website
Post by: bullten on September 05, 2018, 03:33:19 AM
Code: [Select]
nano /usr/local/apache/htdocs/netdata/etc/netdata/netdata.conf
Find

Quote
# run as user = netdata
# web files owner = netdata
# web files group = netdata

Uncomment them

Quote
run as user = netdata
web files owner = netdata
web files group = netdata

Save and restart netdata

Code: [Select]
service netdata restart
See if its happening now.
Title: Re: Resources monitor per user/website
Post by: Sandeep on September 05, 2018, 01:01:04 PM
Correct. I will have to investigate how to do it. As a newbie, everything looks so difficult (throws me back to the MS-DOS days before the Windows era, but I haven't used command line ever since)...


Any chance you have a guide up your sleeve to share how to put this password protection in place?
https://github.com/firehol/netdata/wiki/Running-behind-nginx#enable-authentication
Title: Re: Resources monitor per user/website
Post by: ring_c on September 20, 2018, 07:16:33 AM
https://github.com/firehol/netdata/wiki/Running-behind-nginx#enable-authentication (https://github.com/firehol/netdata/wiki/Running-behind-nginx#enable-authentication)
I only managed to break my nginx when adding things to nginx.conf :(
As I can't password protect it, I think I'll have to uninstall it unfortunately...