-
Notifications
You must be signed in to change notification settings - Fork 13
First script execution #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ruby version: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu] |
It looks like it can't find the csv header. Also, the script expects that it will have to append
Here's an example: |
Thank you for your help. I tried to add the self-signed certificate in /usr/local/share/ca-certificates/ and run the command "update-ca-certificates". |
I disabled the https while I was doing the tests. My haproxy is a package installed on pfsense, could this be a problem? |
To correct the error: |
Hi @Yazur-admin, can you try running this version of check_haproxy.rb with the --debug flag: https://raw.githubusercontent.com/benprew/nagios-checks/personal/bprew/debug-output/check_haproxy.rb It should print out the lines it is receiving from haproxy, that should give you some insight into what is causing the issue. I suspect that it's an authentication issue, that is working in your browser, but is not work when using check_haproxy. Also, this version has the insecure_ssl fix you mention above. Thanks |
The username and password that check_haproxy uses is used for basic auth, I suspect that pfsense doesn't use basic auth, do you know how authentication works in pfsense? Is it session/cookie based, or can you provide some kind of login token? |
Thank you for your response. We can use a RADIUS / LDAP server to connect but we always have to enter both "Username" and "Password" information. |
Hi @Yazur-admin, thanks for replying. Sorry about the confusion, Basic Auth is a specific type of authentication, I should've clarified what I meant by that. In this case it sounds like there is some of kind of session/cookie/etc that pfSense is storing after you login. I don't have pfSense set up anywhere, so I can't test it, but if you can provide the requests and responses that are needed, I could add them to check_haproxy |
I would love to help you add this feature, but I have no idea how I can help you. I've done some research on the internet regarding authentication on the pfsense webui page but I can't find any useful documentation. Maybe I can find directly on the pfsense server the script that displays the pfsense authentication page and send you this script in .txt format. |
Is this the right script? Because I have a pretty big script list in reality: |
After thinking about it, I don't think that the script sent is the login script but rather the home page once logged in. |
Hey @Yazur-admin, I was hoping that would be enough info to replicate the auth process, but it doesn't look like it. I'll probably need to test against a running version of pfsense. It looks like it runs on FreeBSD, is there a linux version I could run in docker or something similar? If not, do you have a test instance I could test against? Thanks |
Or, if you have a simple command-line tool that logs into pfsense and I could look at the source code, I could probably replicate it here. |
I took a look at the pfSense "Netgate" forum and one of the developers says I try to set up a pfsense in the afternoon with public ip and SSH access. I'll keep you informed! |
@benprew I just sent you the accesses for the test server. Thanks :) ! |
Thanks @Yazur-admin, I was able to script logging in, I'm trying to figure out a good way to incorporate it into the check_haproxy script |
That's great, thank you. |
Ok @Yazur-admin I created a script and put it in this repo: https://github.com/benprew/pfsense-login You'll need to download it and the Gemfile and the run Then, you can use it with check_haproxy in a bash script like this:
Where you fill in the values for $URL, $USERNAME, $PASSWORD and $HAPROXY_URL |
Thank you very much ! That is to say we should be able to write in clear text the authentication credentials in the code, because on pfsense we can create a user who can only see the haproxy stat page. And use only check_haproxy commands without having to authenticate. In other words, you would have to be able to put together the "pfsense authentication" code snippet with the "check_haproxy" one to be able to use this in a monitoring server like librenms. Thank you very much for everything you've already done! |
Hi @Yazur-admin , I'm not sure I understand what you mean? Are you not able to use the 2 scripts together? |
/usr/lib/ruby/2.5.0/net/protocol.rb:44:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain) (OpenSSL::SSL::SSLError) Problem with the certificate as it is self-signed. |
To return to my previous message: With the simple command ./check_haproxy.rb --cookie "$COOKIE" -u "$HAPROXY_URL", I should be able to retrieve the haproxy information to supervise them in my LibreNMS server. I can't execute other commands before, it would have to be automatic. |
I don't know how to write in Ruby, I have only bash and powershell notions. Or much simpler : Add a line in the script "login.rb" which executes a bash file and in this bash file I would put this:
|
Here I have succeeded with the help of my fellow developer. You can see the changes made to the script with: https://text-compare.com/fr/ Here is the final code: https://code.empreintesduweb.com/14540.html |
@Yazur-admin That's great! I'm glad you were able to get it working! |
Here is the error message I get with the command:
./check_haproxy.rb -u http://172.16.100.254/haproxy/haproxy_stats.php?haproxystats=1 -U *** -P ***
Traceback (most recent call last):
-- 2: from ./check_haproxy.rb:148:in `<\main>'
-- 1: from ./check_haproxy.rb:148:in `\each'
./check_haproxy.rb:158:in
block in <\main>': undefined method
zip' for nil:NilClass (NoMethodError)The text was updated successfully, but these errors were encountered: