Skip to content
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

Create Webhook Logger #102

Closed
jc-vogel opened this issue Jul 5, 2017 · 6 comments
Closed

Create Webhook Logger #102

jc-vogel opened this issue Jul 5, 2017 · 6 comments
Assignees
Milestone

Comments

@jc-vogel
Copy link

@jc-vogel jc-vogel commented Jul 5, 2017

It would be nice to be able to Log to a webhook, eg Zabbix etc.

A Webhook Logger should at least be able to do the following:

  • call any specified URL
  • use GET or POST method
  • use different content types with POST method (xml / json / form)
  • build custom POST output using some kind of variables. This enables the user to use their own endpoint in their own format

I took the liberty of creating a PR with my proposal for such a Webhook (will be pushed in a minute). Maybe it's not all you guys want, so feel free to criticize.

@sebastianfeldmann sebastianfeldmann self-assigned this Jul 11, 2017
@sebastianfeldmann sebastianfeldmann added this to the Version 5.0.0 milestone Jul 11, 2017
sebastianfeldmann added a commit that referenced this issue Jul 11, 2017
@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Jul 11, 2017

You can now use log configuration like this

<log type="webhook">
  <option name="uri" value="https://some.host.com/webhook" />
  <option name="username" value="misterX" />
  <option name="password" value="secret" />
  <option name="method" value="POST" />
  <option name="contentType" value="application/json" />
</log>

This will trigger the configured webhook with a json body like this.

{
    "status": 0,
    "timestamp": 31726381641,
    "duration": 234,32
    "backupCount": 1,
    "backupFailed": 0,
    "errorCount": 0,
    "errors": [],
    "backups": [
        {
            "name": "MySQL code DB",
            "status": 0,
            "checks": {
                "executed": 1,
                "failed": 0
            },
            "crypt": {
                "executed": 0,
                "skipped": 0,
                "failed": 0
            },
            "syncs": {
                "executed": 1,
                "skipped": 0,
                "failed": 0
            }
            "cleanup": {
                "executed": 1
                "skipped": 0
                "failed": 0
            }
        }
    ]
}
@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Jul 11, 2017

Right now this os only available in dev-master, but I hope I can release version 5 early next week.

@andrelopez
Copy link

@andrelopez andrelopez commented Jul 11, 2017

Nice feature! hey @sebastianfeldmann this will be called at the end of the process?

@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Jul 11, 2017

Yes the phpbuEndEvent will trigger the web hook execution.

@andrelopez
Copy link

@andrelopez andrelopez commented Jul 11, 2017

Awesome! @sebastianfeldmann one final question, is there any way to avoid the wait when I call the cmd class?

 $cmd = new Cmd();

 $response = $cmd->run([
	'--configuration=PATH/config.json'
	]);

So the webhook will be notified when the process end? I read something about that here:

I just worried about big files, did you test this framework with large amount of data? I mean if the upload connection is bad, the timeout of php could be a problem.

Thanks in advance Sebastian!

@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Jul 12, 2017

If I understand you correctly you are calling phpbu not via the CLI but rather via a web request.
In this case, yes you have to worry about the max_execution ini setting.

You could either use ini_set to set the max_execution value to 0 or call phpbu in the background via system call.

shell_exec('phpbu --configuration=my/config.xml &');

If you use this approach there will be no delay/wait what so ever, but you won't be able to get any feedback on how phpbu is doing within the script you execute it in.

Only the log/webhook will tell you what happened.

Hope that helps ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.