🔗 Integration Examples
Here are examples of integrating Monitron heartbeats with various languages and frameworks.
🐘 PHP / Laravel
Laravel Scheduled Command
// app/Console/Kernel.php
$schedule->command('reports:generate')
->daily()
->after(function () {
Http::get('https://your-monitron.com/heartbeat/TOKEN');
})
->onFailure(function () {
Http::post('https://your-monitron.com/heartbeat/TOKEN/fail');
});
Plain PHP
<?php
// Your script logic
$success = do_backup();
if ($success) {
file_get_contents('https://your-monitron.com/heartbeat/TOKEN');
} else {
$ctx = stream_context_create(['http' => ['method' => 'POST']]);
file_get_contents('https://your-monitron.com/heartbeat/TOKEN/fail', false, $ctx);
}
🟢 Node.js
const https = require('https');
async function myJob() {
try {
await doSomething();
// Report success
https.get('https://your-monitron.com/heartbeat/TOKEN');
} catch (err) {
// Report failure
https.request('https://your-monitron.com/heartbeat/TOKEN/fail', { method: 'POST' }).end();
throw err;
}
}