mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:20:12 +01:00
added indexer stat to health page
This commit is contained in:
parent
8d201ed50a
commit
2a8c13d774
149
src/hash.c
Normal file
149
src/hash.c
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* hash.c, SJ
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
void inithash(struct node *xhash[]){
|
||||
int i;
|
||||
|
||||
for(i=0;i<MAXHASH;i++){
|
||||
xhash[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clearhash(struct node *xhash[]){
|
||||
int i;
|
||||
struct node *p, *q;
|
||||
|
||||
for(i=0;i<MAXHASH;i++){
|
||||
q = xhash[i];
|
||||
while(q != NULL){
|
||||
p = q;
|
||||
|
||||
q = q->r;
|
||||
if(p){
|
||||
if(p->str){
|
||||
free(p->str);
|
||||
}
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
xhash[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct node *makenewnode(struct node *xhash[], char *s){
|
||||
struct node *h;
|
||||
int len;
|
||||
|
||||
if(s == NULL) return NULL;
|
||||
|
||||
len = strlen(s);
|
||||
|
||||
if((h = malloc(sizeof(struct node))) == NULL) return NULL;
|
||||
|
||||
memset(h, 0, sizeof(struct node));
|
||||
|
||||
h->str = malloc(len+2);
|
||||
|
||||
if(h->str == NULL){
|
||||
free(h);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(h->str, 0, len+2);
|
||||
|
||||
snprintf(h->str, len+1, "%s", s);
|
||||
|
||||
h->key = DJBHash(s, len);
|
||||
h->r = NULL;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
int addnode(struct node *xhash[], char *s){
|
||||
struct node *p=NULL, *q;
|
||||
unsigned int key = 0;
|
||||
int len;
|
||||
|
||||
if(s == NULL) return 0;
|
||||
|
||||
len = strlen(s);
|
||||
|
||||
key = DJBHash(s, len);
|
||||
|
||||
if(xhash[hash(key)] == NULL){
|
||||
xhash[hash(key)] = makenewnode(xhash, s);
|
||||
}
|
||||
else {
|
||||
q = xhash[hash(key)];
|
||||
while(q != NULL){
|
||||
p = q;
|
||||
if(p->key == key){
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
q = q->r;
|
||||
}
|
||||
}
|
||||
p->r = makenewnode(xhash, s);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct node *findnode(struct node *xhash[], char *s){
|
||||
struct node *q;
|
||||
unsigned int key;
|
||||
int len;
|
||||
|
||||
if(s == NULL) return NULL;
|
||||
|
||||
len = strlen(s);
|
||||
|
||||
key = DJBHash(s, len);
|
||||
|
||||
q = xhash[hash(key)];
|
||||
|
||||
if(q == NULL) return NULL;
|
||||
|
||||
while(q != NULL){
|
||||
|
||||
if(strcmp(q->str, s) == 0){
|
||||
return q;
|
||||
}
|
||||
else {
|
||||
q = q->r;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
inline int hash(unsigned int key){
|
||||
return key % MAXHASH;
|
||||
}
|
||||
|
||||
|
||||
unsigned int DJBHash(char* str, unsigned int len){
|
||||
unsigned int hash = 5381;
|
||||
unsigned int i = 0;
|
||||
|
||||
for(i=0; i < len; str++, i++){
|
||||
hash = ((hash << 5) + hash) + (*str);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
20
src/hash.h
Normal file
20
src/hash.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* hash.h, SJ
|
||||
*/
|
||||
|
||||
#ifndef _HASH_H
|
||||
#define _HASH_H
|
||||
|
||||
#include "cfg.h"
|
||||
#include "defs.h"
|
||||
|
||||
|
||||
void inithash(struct node *xhash[]);
|
||||
void clearhash(struct node *xhash[]);
|
||||
struct node *makenewnode(struct node *xhash[], char *s);
|
||||
int addnode(struct node *xhash[], char *s);
|
||||
struct node *findnode(struct node *xhash[], char *s);
|
||||
inline int hash(unsigned int key);
|
||||
unsigned int DJBHash(char* str, unsigned int len);
|
||||
|
||||
#endif /* _HASH_H */
|
@ -5,6 +5,7 @@ MAINTMPFILE=/var/run/piler/main.indexer.tmp
|
||||
DELTATMPFILE=/var/run/piler/delta.indexer.tmp
|
||||
INDEXER=indexer
|
||||
PRIORITY=mail.error
|
||||
TOUCHFILE=/var/piler/stat/indexer
|
||||
|
||||
if [ -f $MAINTMPFILE ]; then echo "INDEXER ERROR: indexer merging to main index is already running. It started at "`cat $MAINTMPFILE` | logger -p $PRIORITY ; exit 1; fi
|
||||
|
||||
@ -12,6 +13,8 @@ if [ -f $DELTATMPFILE ]; then echo "INDEXER ERROR: delta indexing and merging is
|
||||
|
||||
date > $DELTATMPFILE
|
||||
|
||||
touch $TOUCHFILE
|
||||
|
||||
function finish {
|
||||
rm -f $DELTATMPFILE
|
||||
}
|
||||
|
@ -4,11 +4,14 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
|
||||
MAINTMPFILE=/var/run/piler/main.indexer.tmp
|
||||
INDEXER=indexer
|
||||
PRIORITY=mail.error
|
||||
TOUCHFILE=/var/piler/stat/indexer
|
||||
|
||||
if [ -f $MAINTMPFILE ]; then echo "INDEXER ERROR: indexer merging to main index is already running. It started at "`cat $MAINTMPFILE` | logger -p $PRIORITY ; exit 1; fi
|
||||
|
||||
date > $MAINTMPFILE
|
||||
|
||||
touch $TOUCHFILE
|
||||
|
||||
function finish {
|
||||
rm -f $MAINTMPFILE
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ $config['PROVIDED_BY'] = 'www.mailpiler.org';
|
||||
$config['SITE_KEYWORDS'] = 'piler email archiver';
|
||||
$config['SITE_DESCRIPTION'] = 'piler email archiver';
|
||||
|
||||
$config['INDEXER_BEACON'] = '/var/piler/stat/indexer';
|
||||
|
||||
// authentication against an ldap directory (disabled by default)
|
||||
|
||||
|
@ -146,6 +146,10 @@ class ControllerHealthWorker extends Controller {
|
||||
$this->data['usagetrend'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$this->data['indexer_stat'] = $this->model_health_health->indexer_stat();
|
||||
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,7 @@ $_['text_import'] = "Import";
|
||||
$_['text_import_users'] = "Benutzer importieren";
|
||||
$_['text_import_users_from_LDAP'] = "Benutzer aus LDAP importieren";
|
||||
$_['text_inbound'] = "eingehend";
|
||||
$_['text_indexer_job'] = "Indexer job";
|
||||
$_['text_install_sudo_apply'] = "Add the following to /etc/sudoers: 'www-data ALL=NOPASSWD: /etc/init.d/rc.piler reload'";
|
||||
$_['text_internal'] = "intern";
|
||||
$_['text_invalid_data'] = "Ungültige Daten";
|
||||
|
@ -151,6 +151,7 @@ $_['text_import'] = "Import";
|
||||
$_['text_import_users'] = "Import users";
|
||||
$_['text_import_users_from_LDAP'] = "Import users from LDAP";
|
||||
$_['text_inbound'] = "inbound";
|
||||
$_['text_indexer_job'] = "Indexer job";
|
||||
$_['text_install_sudo_apply'] = "Add the following to /etc/sudoers: 'www-data ALL=NOPASSWD: /etc/init.d/rc.piler reload'";
|
||||
$_['text_internal'] = "internal";
|
||||
$_['text_invalid_data'] = "Invalid data";
|
||||
|
@ -151,6 +151,7 @@ $_['text_import'] = "Import";
|
||||
$_['text_import_users'] = "Felhasználók importálása";
|
||||
$_['text_import_users_from_LDAP'] = "Felhasználók importálása LDAP-ból";
|
||||
$_['text_inbound'] = "bejövõ";
|
||||
$_['text_indexer_job'] = "Indexer futás";
|
||||
$_['text_install_sudo_apply'] = "Adja az alábbi sort a /etc/sudoers file-hoz: 'www-data ALL=NOPASSWD: /etc/init.d/rc.piler reload'";
|
||||
$_['text_internal'] = "belsõ";
|
||||
$_['text_invalid_data'] = "Érvénytelen adat(ok)";
|
||||
|
@ -151,6 +151,7 @@ $_['text_import'] = "Import";
|
||||
$_['text_import_users'] = "Felhasználók importálása";
|
||||
$_['text_import_users_from_LDAP'] = "Felhasználók importálása LDAP-ból";
|
||||
$_['text_inbound'] = "bejövő";
|
||||
$_['text_indexer_job'] = "Indexer futás";
|
||||
$_['text_install_sudo_apply'] = "Adja az alábbi sort a /etc/sudoers file-hoz: 'www-data ALL=NOPASSWD: /etc/init.d/rc.piler reload'";
|
||||
$_['text_internal'] = "belső";
|
||||
$_['text_invalid_data'] = "Érvénytelen adat(ok)";
|
||||
|
@ -147,6 +147,7 @@ $_['text_import'] = "Importar";
|
||||
$_['text_import_users'] = "Importar usuários";
|
||||
$_['text_import_users_from_LDAP'] = "Importar usuários de LDAP";
|
||||
$_['text_inbound'] = "interno";
|
||||
$_['text_indexer_job'] = "Indexer job";
|
||||
$_['text_install_sudo_apply'] = "Add the following to /etc/sudoers: 'www-data ALL=NOPASSWD: /etc/init.d/rc.piler reload'";
|
||||
$_['text_internal'] = "interno";
|
||||
$_['text_invalid_data'] = "Dados inválidos";
|
||||
|
@ -198,6 +198,23 @@ class ModelHealthHealth extends Model {
|
||||
return $dirSize;
|
||||
}
|
||||
|
||||
|
||||
public function indexer_stat() {
|
||||
$data = array('', '');
|
||||
|
||||
if(file_exists(INDEXER_BEACON)) {
|
||||
|
||||
$st = stat(INDEXER_BEACON);
|
||||
$t1 = date(DATE_TEMPLATE . " H:i", $st['mtime']);
|
||||
$t2 = date(DATE_TEMPLATE . " H:i", $st['mtime']+30*60);
|
||||
|
||||
$data = array($t1, $t2);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,7 +118,7 @@ class ModelSaasCustomer extends Model
|
||||
$query = $this->db->query("INSERT INTO " . TABLE_ONLINE . " (username, ts, last_activity, ipaddr) VALUES(?,?,?,?)", array($username, NOW, NOW, $_SERVER['REMOTE_ADDR']));
|
||||
|
||||
if($this->db->countAffected() == 0) {
|
||||
$query = $this->db->query("UPDATE " . TABLE_ONLINE . " SET ts=?, last_activity=? WHERE username=? AND ipaddr=?", array(NOW, $username, $_SERVER['REMOTE_ADDR']));
|
||||
$query = $this->db->query("UPDATE " . TABLE_ONLINE . " SET ts=?, last_activity=? WHERE username=? AND ipaddr=?", array(NOW, NOW, $username, $_SERVER['REMOTE_ADDR']));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -130,7 +130,7 @@ class ModelUserAuth extends Model {
|
||||
if($ldap_auditor_member_dn == '') { return 0; }
|
||||
|
||||
foreach($e as $a) {
|
||||
foreach (array("memberof") as $memberattr) {
|
||||
foreach (array("memberof", "dn") as $memberattr) {
|
||||
if(isset($a[$memberattr])) {
|
||||
|
||||
if(isset($a[$memberattr]['count'])) {
|
||||
|
@ -67,6 +67,16 @@
|
||||
<th><?php print $text_periodic_purge; ?></th>
|
||||
<td><span class="<?php if($options['enable_purge'] == 1) { ?>ok<?php } else { ?>error<?php } ?>"><?php if($options['enable_purge'] == 1) { print $text_enabled; ?>. <a href="<?php print HEALTH_URL; ?>&toggle_enable_purge"><?php print $text_disable; ?></a><?php } else { print $text_disabled; ?>. <a href="<?php print HEALTH_URL; ?>&toggle_enable_purge"><?php print $text_enable; ?></a><?php } ?> </span></td>
|
||||
</tr>
|
||||
|
||||
<?php if($indexer_stat[0]) { ?>
|
||||
<tr>
|
||||
<th><?php print $text_indexer_job; ?></th>
|
||||
<td><?php print $text_last; ?>: <?php print $indexer_stat[0]; ?>, <?php print $text_next; ?>: <?php print $indexer_stat[1]; ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
@ -126,6 +126,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($indexer_stat[0]) { ?>
|
||||
<div class="row">
|
||||
<div class="cellhealthleft"><?php print $text_indexer_job; ?></div>
|
||||
<div class="cellhealthright"><?php print $text_last; ?>: <?php print $indexer_stat[0]; ?>, <?php print $text_next; ?>: <?php print $indexer_stat[1]; ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user