$db_info ) { if( db_connect($db_name, "log") !== FALSE ) { // Get switching statistics of all SWITCH 3000 units $stats = db_fetch_lance_switch3000_switch_stats(); // collect data $switch_stats[$db_name] = array(); $t_set = FALSE; if( $stats ) foreach( $stats as $stat ) { // update time if( !$t_set || $stat['t_min'] < $switch_stats[$db_name]['t_min'] ) $switch_stats[$db_name]['t_min'] = $stat['t_min']; if( !$t_set || $stat['t_max'] > $switch_stats[$db_name]['t_max'] ) $switch_stats[$db_name]['t_max'] = $stat['t_max']; $t_set = TRUE; if( $stat['minor'] == MIN_SWITCH3000_ON ) { $sum['on'] += ($switch_stats[$db_name]['on'] = $stat['actions']); } else if( $stat['minor'] == MIN_SWITCH3000_OFF ) { $sum['off'] += ($switch_stats[$db_name]['off'] = $stat['actions']); } } // Debugging via syslog DBG(sprintf("Statistics SWITCH 3000: db %-10s: %s--%s, on: %7lu, off: %7lu", $db_name, iso8601($switch_stats[$db_name]['t_min']), iso8601($switch_stats[$db_name]['t_max']), $switch_stats[$db_name]['on'], $switch_stats[$db_name]['off'] )); } } // Restore default database connection db_connect(); // Send email with specific content $subject = _("MTinfo") . " " . _("statistics"); // Define content $content = ""; $content .= "

"; $content .= _("Dear MTinfo user") . ",

"; $content .= _("Hereby the MTinfo statistics") . " " ._("SWITCH 3000") . ": " . "

"; $content .= ""; $content .= ""; foreach( $_DATABASE as $db_name => $db_info ) { $content .= ""; $content .= ""; $content .= ""; $content .= ""; } $content .= ""; } $content .= ""; $content .= ""; $content .= "
" . ucfirst(_("database")) . "" . ucfirst(_("period")) . "" . ucfirst(_("switched on")) . "" . ucfirst(_("switched off")) . "
" . ucfirst(_($db_name)); if( $switch_stats[$db_name] ) { $content .= "" . date("Y-m-d H:i:s", $switch_stats[$db_name]['t_min']); $content .= "" . _("t/m"); $content .= "" . date("Y-m-d H:i:s", $switch_stats[$db_name]['t_max']); $content .= "" . $switch_stats[$db_name]['on']; $content .= "" . $switch_stats[$db_name]['off']; } else { $content .= "" . _("No data") . "
" . ucfirst(_("total number of switch actions")); $content .= "" . $sum['on']; $content .= "" . $sum['off']; $content .= "
"; $content .= "

"; $content .= "MTinfo"; $content .= "

"; // Send mail send_mail($_PAGE_INFO['ini']['comm']['statistics'], "", "", $_PAGE_INFO['ini']['report']['no-reply'], $subject, $content, $report, $_PAGE_INFO['file']); // Release mutex db_mutex_release(RemoveExtension(basename(__FILE__)) . "_" . $params['task_id']); // Set handled flag $handled = 1; } else { // Debug info DBG("Mutex not released: " . $params['task_id']); } ?>