Commit 37928e06 authored by dmorley's avatar dmorley

Let podmin pick score to send alert

parent b58b667f
...@@ -5,7 +5,7 @@ ALTER TABLE pods RENAME COLUMN pingdomurl TO stats_apikey; ...@@ -5,7 +5,7 @@ ALTER TABLE pods RENAME COLUMN pingdomurl TO stats_apikey;
ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp; ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp;
ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime; ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime;
ALTER TABLE pods RENAME COLUMN responsetimelast7 TO latency; ALTER TABLE pods RENAME COLUMN responsetimelast7 TO latency;
=
ALTER TABLE pods RENAME COLUMN dateUpdated TO date_updated; ALTER TABLE pods RENAME COLUMN dateUpdated TO date_updated;
ALTER TABLE pods RENAME COLUMN dateLaststats TO date_laststats; ALTER TABLE pods RENAME COLUMN dateLaststats TO date_laststats;
ALTER TABLE pods RENAME COLUMN dateCreated TO date_created; ALTER TABLE pods RENAME COLUMN dateCreated TO date_created;
......
ALTER TABLE pods ADD podmin_notify_level int; ALTER TABLE pods ADD podmin_notify_level int DEFAULT 50;
...@@ -40,7 +40,7 @@ try { ...@@ -40,7 +40,7 @@ try {
$reader = new Reader(c('geoip2db')); $reader = new Reader(c('geoip2db'));
$sql = ' $sql = '
SELECT domain, score, date_created, weight, podmin_notify, email, masterversion, shortversion, status, detectedlanguage SELECT domain, score, date_created, weight, podmin_notify, podmin_notify_level, email, masterversion, shortversion, status, detectedlanguage
FROM pods FROM pods
'; ';
...@@ -63,17 +63,18 @@ try { ...@@ -63,17 +63,18 @@ try {
} }
foreach ($pods as $pod) { foreach ($pods as $pod) {
$domain = $pod['domain']; $domain = $pod['domain'];
$score = (int) $pod['score']; $score = (int) $pod['score'];
$dbscore = $score; $dbscore = $score;
$dateadded = $pod['date_created']; $dateadded = $pod['date_created'];
$weight = $pod['weight']; $weight = $pod['weight'];
$email = $pod['email']; $email = $pod['email'];
$notify = $pod['podmin_notify']; $notify = $pod['podmin_notify'];
$masterv = $pod['masterversion']; $notify_level = $pod['podmin_notify_level'];
$shortv = $pod['shortversion']; $masterv = $pod['masterversion'];
$dbstatus = $pod['status']; $shortv = $pod['shortversion'];
$language = $pod['detectedlanguage']; $dbstatus = $pod['status'];
$language = $pod['detectedlanguage'];
try { try {
$ratings = R::getAll(' $ratings = R::getAll('
...@@ -340,7 +341,7 @@ foreach ($pods as $pod) { ...@@ -340,7 +341,7 @@ foreach ($pods as $pod) {
_debug('Uptime', $uptime); _debug('Uptime', $uptime);
if ($score == 49 && $notify && !$develop && $dbscore == 50) { if ($score == ($notify_level - 1) && $notify && !$develop && $dbscore == $notify_level) {
$to = $email; $to = $email;
$headers = ['From: ' . c('adminemail'), 'Bcc: ' . c('adminemail')]; $headers = ['From: ' . c('adminemail'), 'Bcc: ' . c('adminemail')];
$subject = 'Monitoring notice from poduptime'; $subject = 'Monitoring notice from poduptime';
......
...@@ -40,7 +40,7 @@ CREATE TABLE pods ( ...@@ -40,7 +40,7 @@ CREATE TABLE pods (
tokenexpire timestamp, tokenexpire timestamp,
podmin_statement text, podmin_statement text,
podmin_notify boolean, podmin_notify boolean,
podmin_notify_level int, podmin_notify_level int DEFAULT 50,
sslexpire timestamp, sslexpire timestamp,
dnssec boolean, dnssec boolean,
comment_counts int, comment_counts int,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment