Forum

problem with hiawatha montior

Wolf Johnson
27 April 2014, 18:21

I receive error when logging into hiawatha monitor fopen(../logfiles/actions.log): failed to open stream: Permission denied in /var/www/monitor/libraries/user.php on line 306.

I am running my hiawatha server behind a nginx reverse proxy server.

I run the hiawatha webserver as user hiawatha but I tried changing the group permission on the monitor directory under /var/www/monitor to root group to see if that would fix the permission denied problem. That has not solved the problem.

Hiawatha version: 8.7
Operating System: Centos 5.9 i386

Kind regards,
Wolf
Hugo Leisink
27 April 2014, 21:58
Make sure the files in the logfiles directory are writable for the webserver.
Wolf Johnson
27 April 2014, 23:16
Hi Hugo,

Thanks for the reply.
Here are the directory permissions for the files.
total 32
-rwxrwxr-x 1 hiawatha hiawatha 27058 Apr 27 17:29 access.log
-rwxrwxr-x 1 hiawatha hiawatha 0 Apr 23 20:15 actions.log
-rwxrwxr-x 1 hiawatha hiawatha 0 Apr 23 20:08 error.log
Hugo Leisink
27 April 2014, 23:18
Is PHP (FastCGI daemon) also running as user 'hiawatha'?
Wolf Johnson
27 April 2014, 23:20
I changed the permissions to 777 and the error disappeared. But I had 775 before and the webserver runs under user and group id hiawatha so I am a little confused as to why it needs 777??

Also what is the prowl key? I cannot find any information about it in the README..

Hugo Leisink
28 April 2014, 06:43
I doesn't need 777, o+w will be enough I guess. I don't know the situationat your server, but I'm sure there willbe a good explanation.

The prowl key is for notifications via the iPhone Prowl app.
Wolf Johnson
28 April 2014, 10:04
Hi Hugo,
Thanks for the information.
I have one other question and that is I am getting emails from the cron job. Cron <root@postur> /var/www/monitor/database/fetch_webserver_logs
PHP Notice: Undefined offset: 1 in /var/www/monitor/database/fetch_webserver_logs on line 94
Error retrieving webserver IP addresses.
How do I fix this?

Hugo Leisink
28 April 2014, 20:06
The PHP Notice can be fixed by swapping line 94 and 96.
The error by changing '==' at line 103 to '==='.

The last error will also go away by defining webservers via the CMS of the Monitor website.
Wolf Johnson
28 April 2014, 20:34
I have edited fetch_webserver_logs as instructed.

I cannot define the webserver in the CMS of the Monitor website because it logs me out everytime I select a tab ie. Dashboard, Events,...
I tried to enter MonitorSever = xxx.xxx.xxx.xxx into hiawatha.conf but the hiawatha service will not start if I add this string to the configuration file.
Hugo Leisink
28 April 2014, 20:43
Does Hiawatha have support for monitoring? What's the output of running Hiawatha with the '-v' option?

P.S.
I assume that MonitorSever is a typo only here at the forum and not in your configuration file.
Wolf Johnson
28 April 2014, 20:50
It is typo. MonitorServer = xxx.xxx.xxx.xxx

hiawatha -v
Hiawatha v8.7, cache, IPv6, reverse proxy, SSL, URL toolkit, XSLT
Copyright (C) by Hugo Leisink <hugo@leisink.net>
You have new mail in /var/spool/mail/root
Hugo Leisink
28 April 2014, 20:58
Your Hiawatha installation doesn't support monitoring. Recompile Hiawatha with -DENABLE_MONITOR=on. I also advice to update to the latest version of Hiawatha.
Wolf Johnson
28 April 2014, 21:25

I thought that might be the problem so I have started the process of creating a src rpm so that I can add -DENABLE_MONITOR=on flag. When I have finished updating to hiawatha 9.5 I will see what happens. I will add to this post the results of upgrading to hiawatha 9.5 with -DENABLE_MONITOR enabled. Hopefully, that will solve the problem.
Wolf Johnson
29 April 2014, 17:53
I have upgraded hiawatha to 9.5 and enabled -DENABLE_MONTIOR=on

# hiawatha -v
Hiawatha v9.5, cache, IPv6, Monitor, reverse proxy, SSL (1.3.6), URL toolkit, XSLT
Copyright (c) by Hugo Leisink <hugo@leisink.net>

I still have the same problem when logging into hiawatha monitor. That is I get redirected out of hiawatha monitor after intial login. I can log in but once I select Dashboard or any other tab I am logged out and redirected to the login web page for hiawatha monitor.
Hugo Leisink
30 April 2014, 15:13
Does it also occur when you uncheck the 'Bind session to IP' checkbox?
Wolf Johnson
30 April 2014, 22:15
Yes. I have also tried that. I have also checked the timezone settings in php and in /etc/localtime - they match. I have to login twice it never works on the first attempt and when I click on cms I am returned to the login window http://dns name/admin
I can never find a way to set the ip or hostname to monitor with hiawatha monitor which is in the README.
Hugo Leisink
30 April 2014, 22:20
Try the following: make sure DEBUG_MODE in settings/website.conf is set to 'yes'. Edit public/index.php and add the following line after the 'Load core modules' block at line 33:
print $_COOKIE[SESSION_NAME]."\n";

Does the error message change after every page (re)load? It should show the same string every time.
Wolf Johnson
30 April 2014, 22:30
The string changes every time. What does that mean?
Hugo Leisink
30 April 2014, 22:34
That means that for some reason your browser is blocking cookies. That's the cause of your problem.
Wolf Johnson
30 April 2014, 22:58
No its not cookies. I have tried it on 3 different browsers and two different computers. It might be the nginx reverse proxy in front but I have nothing in the logs to indicate that.
Hugo Leisink
30 April 2014, 23:41
Try it without the reverse proxy.
Wolf Johnson
1 May 2014, 19:17
I have tried both with and without proxy. I have now enabled the nginx reverse proxy and I have been looking at the log file. Nothing that stands out. What I notice is that the authentication seems not to work properly. What I mean is I have to login twice. The first time I use admin and the password I get login incorrect and then I use the same password again and I get logged in. When I click on any of the tabs ie. Dashboard or CMS I go back to the login screen. The authentication token does not get passed between sessions.
Hugo Leisink
1 May 2014, 19:53
This all doesn't change anything. For some reason, the cookies are forgotten by the browser or not accepted by PHP. It's hard for me to tell the cause of this all without being able to look at your server.
Wolf Johnson
1 May 2014, 20:08
What information do you need to diagnose and I will provide it. config files? log files? even access to the server if necessary!
Hugo Leisink
1 May 2014, 20:16
Can you tell me the URL of your Monitor website? If you don't want to post it here, send it to hugo@hiawatha-webserver.org.
Wolf Johnson
1 May 2014, 21:10
I sent the url. Thank you
Hugo Leisink
1 May 2014, 21:16
My browser also shows a different cookie for every request. Is the directory (/var/lib/php5 ?) where PHP stores cookies writable for PHP? I'm almost sure a misconfigured PHP is the cause of your problem.
Wolf Johnson
1 May 2014, 21:27
I can send my php.ini file that the hiawatha server is using.
Hugo Leisink
1 May 2014, 21:31
That won't help me. You need to check the access rights for the directory where PHP writes cookies.
Wolf Johnson
1 May 2014, 21:53
Where does the PHP write cookies?
Hugo Leisink
1 May 2014, 22:07
It's in the session.save_path setting, so for you it's in /var/lib/php/session
Wolf Johnson
1 May 2014, 22:13
permissions are drwxrwx root apache
I need to change group to hiawatha
Wolf Johnson
1 May 2014, 22:15
Changed permissions to /var/lib/php/session

drwxrwx--- 2 root hiawatha 4096 Mar 5 22:39 session
Wolf Johnson
1 May 2014, 22:16
Problem not resolved.
Hugo Leisink
1 May 2014, 23:30
Do you use FastCGI? If so, what user id do you use for PHP?
Wolf Johnson
2 May 2014, 10:53
I am using php-fpm for fastcgi.
Here is my fastcgi config in hiawatha
FastCGIserver {
FastCGIid = PHP5
# ConnectTo = /var/run/php-fpm
ConnectTo = 127.0.0.1:9000
# ConnectTo = 127.0.0.1:2005
# ConnectTo = 10.0.0.100:2005, 10.0.0.101:2005
Extension = php, php5
SessionTimeout = 30
}
User is hiawatha
hiawatha 15926 15925 0 May01 ? 00:00:00 php-fpm: pool www
hiawatha 15927 15925 0 May01 ? 00:00:00 php-fpm: pool www
hiawatha 15928 15925 0 May01 ? 00:00:00 php-fpm: pool www
hiawatha 15929 15925 0 May01 ? 00:00:01 php-fpm: pool www
hiawatha 15930 15925 0 May01 ? 00:00:00 php-fpm: pool www
hiawatha 15933 15925 0 May01 ? 00:00:00 php-fpm: pool www

Hugo Leisink
2 May 2014, 14:53
Make the directory /var/lib/php/session owned by root:root and give it the access rights drwx-wx-wt.
Wolf Johnson
2 May 2014, 17:35
Changed.
drwx-wx-wt 2 root root 4096 May 1 22:14 session

But problem is still not resolved.
Hugo Leisink
2 May 2014, 17:38
Then I am out of options. The problem lies somewhere in the cookies that are not handled by PHP correctly. But I have no idea why....
Wolf Johnson
2 May 2014, 18:38
Well that is strange, but you are the expert and I can only say thank you for your help. I don't understand myself why this would be so difficult.
Thousand thanks for the help.
Wolf Johnson
2 May 2014, 19:02
I am not running a reverse proxy and the same issues. Could the fact that I have word press on the same server be affecting this?
Hugo Leisink
2 May 2014, 22:50
In an earlier post you mentioned 'access to the server'. If that is still an option for you, just let me know. After all this trouble, I want to know what the cause is and I also want to get this solved.
Wolf Johnson
2 May 2014, 23:49
Yes that is an option. I can create an account for you. Is a normal user account enough or do you need sudo access as well?
Hugo Leisink
3 May 2014, 01:11
sudo access will be required for some testing and fixing. Hope that's ok...
Wolf Johnson
4 May 2014, 22:32
Hi Hugo
It is funny but I was creating a user for you on the server and I had problems configuring audit and pam_tty_audit.so. I realised then that the kernel and kernel headers were not installed so I installed them and rebooted the system. I checked and saw that audit service still did not start but this is probably a problem with openvz. I was checking the hiawatha webserver pages and now hiawatha monitor is working properly. I have no idea why except the restart might have cleared some memory buffers but not really sure. I am happy with it except I don't see how to get the host to appear in the drop down window.
Hugo Leisink
4 May 2014, 22:37
That's good news! Hosts will appear automatically when the Monitor downloads statistics information from the webservers. Follow the instructions in the README file and the Monitor HOWTO page at the Hiawatha website.
This topic has been closed.