Exemplo n.º 1
0
function logMessage($type, $level, $message)
{
    global $debug;
    global $use_syslog;
    if ($use_syslog) {
        define_syslog_variables();
        if ($debug) {
        }
        if ($level == 0) {
            $s_level = LOG_ERR;
        } else {
            if ($level == 1) {
                $s_level = LOG_WARNING;
            } else {
                if ($level == 2) {
                    $s_level = LOG_INFO;
                } else {
                    if ($level == 3) {
                        $s_level = LOG_DEBUG;
                    } else {
                        $s_level = LOG_ERR;
                    }
                }
            }
        }
        $s_message = $type . " " . $message;
        openlog("restbot", LOG_PID, LOG_DAEMON);
        syslog($s_level, $s_message);
        closelog();
    }
}
Exemplo n.º 2
0
 function JabberAuth()
 {
     @define_syslog_variables();
     @openlog("pipe-auth", LOG_NDELAY, LOG_SYSLOG);
     if ($this->debug) {
         @error_reporting(E_ALL);
         @ini_set("log_errors", "1");
         @ini_set("error_log", $this->debugfile);
     }
     $this->logg("Starting pipe-auth ...");
     // We notice that it's starting ...
     $this->openstd();
 }
Exemplo n.º 3
0
 function alert_action_syslog($data)
 {
     global $NATS;
     $NATS->Event("Syslog AA Called for " . $data['name'], 10, "Syslog", "Start");
     if ($data['name'] != "_syslog") {
         return false;
     }
     $lvl = LOG_ERR;
     define_syslog_variables();
     openlog("FreeNATS", LOG_PID | LOG_PERROR, LOG_LOCAL0);
     if (syslog($lvl, $data['data']) === false) {
         $NATS->Event("Syslog Failed for " . $data['data'], 2, "Syslog", "Write");
     } else {
         $NATS->Event("Syslog Succeeded for " . $data['data'], 10, "Syslog", "Write");
     }
     closelog();
     return true;
 }
Exemplo n.º 4
0
 /**
  * Adds an entry to the log.
  *
  * Adds an entry to the log with Linux style log format.
  * Possible $level constants (can also be combined with "|"s)
  * SMARTIRC_DEBUG_NONE
  * SMARTIRC_DEBUG_NOTICE
  * SMARTIRC_DEBUG_CONNECTION
  * SMARTIRC_DEBUG_SOCKET
  * SMARTIRC_DEBUG_IRCMESSAGES
  * SMARTIRC_DEBUG_MESSAGETYPES
  * SMARTIRC_DEBUG_ACTIONHANDLER
  * SMARTIRC_DEBUG_TIMEHANDLER
  * SMARTIRC_DEBUG_MESSAGEHANDLER
  * SMARTIRC_DEBUG_CHANNELSYNCING
  * SMARTIRC_DEBUG_MODULES
  * SMARTIRC_DEBUG_USERSYNCING
  * SMARTIRC_DEBUG_ALL
  *
  * @see SMARTIRC_DEBUG_NOTICE
  * @param integer $level bit constants (SMARTIRC_DEBUG_*)
  * @param string $entry the new log entry
  * @return void
  * @access public
  */
 function log($level, $entry, $file = null, $line = null)
 {
     // prechecks
     if (!is_integer($level) || !($level & SMARTIRC_DEBUG_ALL)) {
         $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: invalid log level passed to log() (' . $level . ')', __FILE__, __LINE__);
         return;
     }
     if (!($level & $this->_debug) || $this->_logdestination == SMARTIRC_NONE) {
         return;
     }
     if (substr($entry, -1) != "\n") {
         $entry .= "\n";
     }
     if ($file !== null && $line !== null) {
         $file = basename($file);
         $entry = $file . '(' . $line . ') ' . $entry;
     } else {
         $entry = 'unknown(0) ' . $entry;
     }
     $formatedentry = date('M d H:i:s ') . $entry;
     switch ($this->_logdestination) {
         case SMARTIRC_STDOUT:
             echo $formatedentry;
             flush();
             break;
         case SMARTIRC_BROWSEROUT:
             echo '<pre>' . htmlentities($formatedentry) . '</pre>';
             break;
         case SMARTIRC_FILE:
             if (!is_resource($this->_logfilefp)) {
                 if ($this->_logfilefp === null) {
                     // we reconncted and don't want to destroy the old log entries
                     $this->_logfilefp = fopen($this->_logfile, 'a');
                 } else {
                     $this->_logfilefp = fopen($this->_logfile, 'w');
                 }
             }
             fwrite($this->_logfilefp, $formatedentry);
             fflush($this->_logfilefp);
             break;
         case SMARTIRC_SYSLOG:
             define_syslog_variables();
             if (!is_int($this->_logfilefp)) {
                 $this->_logfilefp = openlog('Net_SmartIRC', LOG_NDELAY, LOG_DAEMON);
             }
             syslog(LOG_INFO, $entry);
             break;
     }
 }
Exemplo n.º 5
0
function LOGLevel($msg, $level, $dodb = true)
{
    $msga = sanitizeText(str_replace("\n", " ", $msg));
    $msg = now() . ": ";
    if (!get_cfg_var('define_syslog_variables')) {
        if (function_exists('define_syslog_variables')) {
            define_syslog_variables();
        }
    }
    $prior = LOG_CRIT;
    switch ($level) {
        case 0:
            $msg .= "ERROR: ";
            $type = "error";
            $prior = LOG_ERR;
            break;
        case 1:
            $msg .= "WARN: ";
            $type = "warn";
            $prior = LOG_WARNING;
            break;
        case 2:
            $msg .= "INFO: ";
            $type = "info";
            $prior = LOG_INFO;
            break;
        case 3:
            $msg .= "DEBUG: ";
            $type = "debug";
            $prior = LOG_DEBUG;
            break;
    }
    $msg .= getIPHost() . ": " . $msga;
    openlog("BOCA", LOG_ODELAY, LOG_USER);
    syslog($prior, $msg);
    closelog();
    if ($dodb && isset($_SESSION["usertable"])) {
        DBNewLog($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"], $_SESSION["usertable"]["usernumber"], $type, getIP(), $msga, "");
    }
}
Exemplo n.º 6
0
function core_syslog($text)
{
    return;
    core_dbg('syslog', $text);
    if ($GLOBALS["dejaVu_syslog"][$text]++) {
        return;
    }
    define_syslog_variables();
    openlog($GLOBALS["core_syslogID"], LOG_PERROR, LOG_USER);
    syslog(LOG_ALERT, eregi_replace("  |\n|" . '\\\\n|<br>', " ", $text));
    closelog();
}
Exemplo n.º 7
0
 function activateOptions()
 {
     define_syslog_variables();
     $this->closed = false;
 }
Exemplo n.º 8
0
  foreach ($openlog_facilities as $facility) {
    openlog("PCC_TEST", $option, $facility);
    foreach ($syslog_priorities as $priority) {
      necho(380 + ($count / 1000), "option=$option, facility=$facility, priority=$priority, count=$count");
      syslog($priority, "$id: option=$option, facility=$facility, priority=$priority");
    }
    closelog();
  }
}
*/
necho(400, "log output: ");
if (posix_geteuid() == 0) {
    system("tail -5000 `find /var/log -type f` | grep -a {$id} | sed s/..:..:..//g | sed 's/PCC_TEST\\[.*\\]/PCC_TEST/' | sed 's/{$id}/PCC_TEST/' | sort");
}
// define_syslog_variables
necho(410, define_syslog_variables());
//} // winnt
// gethostbynamel
necho(520, gethostbynamel('www.roadsend.com'));
necho(530, gethostbynamel('tenkan.org'));
necho(540, gethostbynamel('localhost'));
// getmxrr
if (PHP_OS != 'WINNT') {
    $mxhosts = array();
    $weights = array();
    necho(550, getmxrr('roadsend.com', &$mxhosts, &$weights));
    sort($mxhosts);
    sort($weights);
    necho(560, "mxhosts: ");
    print_r($mxhosts);
    necho(570, "weights: ");
Exemplo n.º 9
0
function cacti_log($string, $output = false, $environ = "CMDPHP") {
	global $config;

	/* fill in the current date for printing in the log */
	$date = date("m/d/Y h:i:s A");

	/* determine how to log data */
	$logdestination = read_config_option("log_destination");
	$logfile        = read_config_option("path_cactilog");

	/* format the message */
	if (($environ != "SYSTEM") && ($environ != "EXPORT") && ($environ != "RECACHE")) {
		$message = "$date - " . $environ . ": Poller[0] " . $string . "\n";
	}else {
		$message = "$date - " . $environ . " " . $string . "\n";
	}

	/* Log to Logfile */
	if ((($logdestination == 1) || ($logdestination == 2)) && (read_config_option("log_verbosity") != POLLER_VERBOSITY_NONE)) {
		if ($logfile == "") {
			$logfile = $config["base_path"] . "/log/cacti.log";
		}

		/* echo the data to the log (append) */
		$fp = @fopen($logfile, "a");

		if ($fp) {
			@fwrite($fp, $message);
			fclose($fp);
		}
	}

	/* Log to Syslog/Eventlog */
	/* Syslog is currently Unstable in Win32 */
	if (($logdestination == 2) || ($logdestination == 3)) {
		$log_type = "";
		if (substr_count($string,"ERROR:"))
			$log_type = "err";
		else if (substr_count($string,"WARNING:"))
			$log_type = "warn";
		else if (substr_count($string,"STATS:"))
			$log_type = "stat";
		else if (substr_count($string,"NOTICE:"))
			$log_type = "note";

		if (strlen($log_type)) {
			define_syslog_variables();

			if ($config["cacti_server_os"] == "win32")
				openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_USER);
			else
				openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_SYSLOG);

			if (($log_type == "err") && (read_config_option("log_perror"))) {
				syslog(LOG_CRIT, $environ . ": " . $string);
			}

			if (($log_type == "warn") && (read_config_option("log_pwarn"))) {
				syslog(LOG_WARNING, $environ . ": " . $string);
			}

			if ((($log_type == "stat") || ($log_type == "note")) && (read_config_option("log_pstats"))) {
				syslog(LOG_INFO, $environ . ": " . $string);
			}

			closelog();
		}
   }

	/* print output to standard out if required */
	if (($output == true) && (isset($_SERVER["argv"][0]))){
		print $message;
	}
}
Exemplo n.º 10
0
 /**
  * Init system error log.
  *
  * @return	void
  * @see sysLog()
  */
 public static function initSysLog()
 {
     global $TYPO3_CONF_VARS;
     // for CLI logging name is <fqdn-hostname>:<TYPO3-path>
     if (defined('TYPO3_cliMode') && TYPO3_cliMode) {
         $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getHostname($requestHost = FALSE) . ':' . PATH_site;
     } else {
         $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     }
     // init custom logging
     if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
         $params = array('initLog' => TRUE);
         $fakeThis = FALSE;
         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
             t3lib_div::callUserFunction($hookMethod, $params, $fakeThis);
         }
     }
     // init TYPO3 logging
     foreach (explode(';', $TYPO3_CONF_VARS['SYS']['systemLog'], 2) as $log) {
         list($type, $destination) = explode(',', $log, 3);
         if ($type == 'syslog') {
             define_syslog_variables();
             if (TYPO3_OS == 'WIN') {
                 $facility = LOG_USER;
             } else {
                 $facility = constant('LOG_' . strtoupper($destination));
             }
             openlog($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'], LOG_ODELAY, $facility);
         }
     }
     $TYPO3_CONF_VARS['SYS']['systemLogLevel'] = t3lib_div::intInRange($TYPO3_CONF_VARS['SYS']['systemLogLevel'], 0, 4);
     $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
 }
Exemplo n.º 11
0
function thold_config_settings()
{
    global $tabs, $settings, $item_rows, $config;
    if (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) != 'settings.php') {
        return;
    }
    include_once "./plugins/thold/thold_functions.php";
    define_syslog_variables();
    if ($config["cacti_server_os"] == "unix") {
        $syslog_facil_array = array(LOG_AUTH => 'Auth', LOG_AUTHPRIV => 'Auth Private', LOG_CRON => 'Cron', LOG_DAEMON => 'Daemon', LOG_KERN => 'Kernel', LOG_LOCAL0 => 'Local 0', LOG_LOCAL1 => 'Local 1', LOG_LOCAL2 => 'Local 2', LOG_LOCAL3 => 'Local 3', LOG_LOCAL4 => 'Local 4', LOG_LOCAL5 => 'Local 5', LOG_LOCAL6 => 'Local 6', LOG_LOCAL7 => 'Local 7', LOG_LPR => 'LPR', LOG_MAIL => 'Mail', LOG_NEWS => 'News', LOG_SYSLOG => 'Syslog', LOG_USER => 'User', LOG_UUCP => 'UUCP');
        $default_facility = LOG_DAEMON;
    } else {
        $syslog_facil_array = array(LOG_USER => 'User');
        $default_facility = LOG_USER;
    }
    $tabs['alerts'] = 'Thresholds';
    $settings['alerts'] = array('general_header' => array('friendly_name' => 'General', 'method' => 'spacer'), 'thold_disable_all' => array('friendly_name' => 'Disable All Thresholds', 'description' => 'Checking this box will disable Alerting on all Thresholds.  This can be used when it is necessary to perform maintenance on your network.', 'method' => 'checkbox', 'default' => 'off'), 'thold_disable_legacy' => array('friendly_name' => 'Disable Legacy Notifications', 'description' => 'Checking this box will disable Legacy Alerting on all Thresholds.  Legacy Alerting is defined as any Specific Email Alerts not associated with a Notification List.', 'method' => 'checkbox', 'default' => ''), 'thold_filter_default' => array('friendly_name' => 'Default Status', 'description' => 'Default Threshold Filter Status', 'method' => 'drop_array', 'array' => array("-1" => "Any", "0" => "Disabled", "2" => "Enabled", "1" => "Breached", "3" => "Triggered"), 'default' => 20), 'alert_base_url' => array('friendly_name' => 'Base URL', 'description' => 'Cacti base URL', 'method' => 'textbox', 'default' => isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) == 'settings.php' ? 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' : '', 'max_length' => 255), 'alert_num_rows' => array('friendly_name' => 'Thresholds Per Page', 'description' => 'Number of thresholds to display per page', 'method' => 'drop_array', 'array' => $item_rows, 'default' => 20), 'thold_log_cacti' => array('friendly_name' => 'Log Threshold Breaches', 'description' => 'Enable logging of all Threshold failures to the Cacti Log', 'method' => 'checkbox', 'default' => 'off'), 'thold_log_changes' => array('friendly_name' => 'Log Threshold Changes', 'description' => 'Enable logging of all Threshold changes to the Cacti Log', 'method' => 'checkbox', 'default' => 'off'), 'thold_log_debug' => array('friendly_name' => 'Debug Log', 'description' => 'Enable logging of debug messages with Thold', 'method' => 'checkbox', 'default' => 'off'), 'thold_alerting_header' => array('friendly_name' => 'Default Alerting Options', 'method' => 'spacer'), 'alert_exempt' => array('friendly_name' => 'Weekend exemptions', 'description' => 'If this is checked, thold will not run on weekends.', 'method' => 'checkbox'), 'alert_trigger' => array('friendly_name' => 'Default Trigger Count', 'description' => 'Default number of consecutive times the Data Source must be in breach of the Threshold for an Alert to be raised', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 1), 'alert_repeat' => array('friendly_name' => 'Re-Alerting', 'description' => 'Repeat Alert after specified number of poller cycles.', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 12), 'alert_syslog' => array('friendly_name' => 'Syslog Support', 'description' => 'These messages will be sent to your local syslog. If you would like these sent to a remote box, you must setup your local syslog to do so', 'method' => 'checkbox'), 'thold_syslog_level' => array('friendly_name' => 'Syslog Level', 'description' => 'This is the priority level that your syslog messages will be sent as.', 'method' => 'drop_array', 'default' => LOG_WARNING, 'array' => array(LOG_EMERG => 'Emergency', LOG_ALERT => 'Alert', LOG_CRIT => 'Critical', LOG_ERR => 'Error', LOG_WARNING => 'Warning', LOG_NOTICE => 'Notice', LOG_INFO => 'Info', LOG_DEBUG => 'Debug')), 'thold_syslog_facility' => array('friendly_name' => 'Syslog Facility', 'description' => 'This is the facility level that your syslog messages will be sent as.', 'method' => 'drop_array', 'default' => $default_facility, 'array' => $syslog_facil_array), 'thold_email_header' => array('friendly_name' => 'Emailing Options', 'method' => 'spacer'), 'thold_email_prio' => array('friendly_name' => 'Send Emails with Urgent Priority', 'description' => 'Allows you to set e-mails with urgent priority', 'method' => 'checkbox', 'default' => 'off'), 'alert_deadnotify' => array('friendly_name' => 'Dead Hosts Notifications', 'description' => 'Enable Dead/Recovering host notification', 'method' => 'checkbox', 'default' => 'on'), 'alert_email' => array('friendly_name' => 'Dead Host Notifications Email', 'description' => 'This is the Email Address that the Dead Host Notifications will be sent to if the Global Notification List is selected.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255), 'thold_down_subject' => array('friendly_name' => 'Down Host Subject', 'description' => 'This is the Email subject that will be used for Down Host Messages.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => 'Host Error: <DESCRIPTION> (<HOSTNAME>) is DOWN'), 'thold_down_text' => array('friendly_name' => 'Down Host Message', 'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060TOT_POLL&#062 &#060FAIL_POLL&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked DOWN : <LAST_FAIL><br>Host Previously UP for: <DOWNTIME><br>NOTE: <NOTES>'), 'thold_up_subject' => array('friendly_name' => 'Recovering Host Subject', 'description' => 'This is the Email subject that will be used for Recovering Host Messages.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => 'Host Notice: <DESCRIPTION> (<HOSTNAME>) returned from DOWN state'), 'thold_up_text' => array('friendly_name' => 'Recovering Host Message', 'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060TOT_POLL&#062 &#060FAIL_POLL&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => '<br>System <DESCRIPTION> (<HOSTNAME>) status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked UP: <LAST_FAIL><br>Host Previously DOWN for: <DOWNTIME><br><br>Snmp Info:<br>Name - <SNMP_HOSTNAME><br>Location - <SNMP_LOCATION><br>Uptime - <UPTIMETEXT> (<UPTIME> ms)<br>System - <SNMP_SYSTEM><br><br>NOTE: <NOTES>'), 'thold_from_email' => array('friendly_name' => 'From Email Address', 'description' => 'This is the Email address that the threshold will appear from.', 'method' => 'textbox', 'default' => read_config_option("settings_from_email"), 'max_length' => 255), 'thold_from_name' => array('friendly_name' => 'From Name', 'description' => 'This is the actual name that the threshold will appear from.', 'method' => 'textbox', 'default' => read_config_option("settings_from_name"), 'max_length' => 255), 'thold_alert_text' => array('friendly_name' => 'Threshold Alert Message', 'description' => 'This is the message that will be displayed at the top of all Threshold Alerts (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060DESCRIPTION&#062 &#060HOSTNAME&#062 &#060TIME&#062 &#060URL&#062 &#060GRAPHID&#062 &#060CURRENTVALUE&#062 &#060THRESHOLDNAME&#062  &#060DSNAME&#062 &#060SUBJECT&#062 &#060GRAPH&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'An Alert has been issued that requires your attention. <br><br><strong>Host</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>'), 'thold_warning_text' => array('friendly_name' => 'Threshold Warning Message', 'description' => 'This is the message that will be displayed at the top of all threshold warnings (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060DESCRIPTION&#062 &#060HOSTNAME&#062 &#060TIME&#062 &#060URL&#062 &#060GRAPHID&#062 &#060CURRENTVALUE&#062 &#060THRESHOLDNAME&#062  &#060DSNAME&#062 &#060SUBJECT&#062 &#060GRAPH&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'A warning has been issued that requires your attention. <br><br><strong>Host</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>'), 'thold_send_text_only' => array('friendly_name' => 'Send Alerts as Text', 'description' => 'If checked, this will cause all Alerts to be sent as plain text Emails with no graph.  The default is HTML Emails with the graph embedded in the Email.', 'method' => 'checkbox', 'default' => 'off'), 'thold_baseline_header' => array('friendly_name' => 'Default Baseline Settings', 'method' => 'spacer'), 'alert_bl_timerange_def' => array('friendly_name' => 'Baseline Time Range Default', 'description' => 'This is the default value used in creating thresholds or templates.', 'method' => 'drop_array', 'array' => get_reference_types(), 'size' => 12, 'max_length' => 12, 'default' => 86400), 'alert_bl_trigger' => array('friendly_name' => 'Baseline Trigger Count', 'description' => 'Default number of consecutive times the Data Source must be in breach of the calculated Baseline Threshold for an Alert to be raised', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 2), 'alert_bl_percent_def' => array('friendly_name' => 'Baseline Deviation Percentage', 'description' => 'This is the default value used in creating thresholds or templates.', 'method' => 'textbox', 'size' => 3, 'max_length' => 3, 'default' => 20));
}
Exemplo n.º 12
0
function make_nrc_file($username, $rand, $unique_list)
{
    if (!$username) {
        $filename = _NESSUS_STORE . '/' . $rand . ".nrc";
    } else {
        $filename = _NESSUS_STORE . '/' . $username . '-' . $rand . ".nrc";
    }
    $fh = fopen($filename, "w");
    // do an exclusive lock
    if (flock($fh, LOCK_EX)) {
        // Write a common header
        fwrite($fh, "# Nessus Client Preferences File\n");
        // This defines the start of the scanner list
        fwrite($fh, "begin(SCANNER_SET)\n");
        foreach ($unique_list as $key => $val) {
            fwrite($fh, $key . " = " . $val . "\n");
        }
        fwrite($fh, "end(SCANNER_SET)\n");
        // This defines the start of the plugin list
        fwrite($fh, "begin(PLUGIN_SET)\n");
        foreach ($unique_list as $key => $val) {
            fwrite($fh, $key . " = " . $val . "\n");
        }
        fwrite($fh, "end(PLUGIN_SET)\n");
        flock($fh, LOCK_UN);
        // release the lock
    } else {
        define_syslog_variables();
        syslog(LOG_WARNING, "Couldn't lock the nessusrc file !");
    }
    fclose($fh);
    chmod($filename, 0777);
    return $filename;
}
Exemplo n.º 13
0
function thold_cacti_log($string)
{
    global $config;
    $environ = 'THOLD';
    /* fill in the current date for printing in the log */
    $date = date("m/d/Y h:i:s A");
    /* determine how to log data */
    $logdestination = read_config_option("log_destination");
    $logfile = read_config_option("path_cactilog");
    /* format the message */
    $message = "{$date} - " . $environ . ": " . $string . "\n";
    /* Log to Logfile */
    if (($logdestination == 1 || $logdestination == 2) && read_config_option("log_verbosity") != POLLER_VERBOSITY_NONE) {
        if ($logfile == "") {
            $logfile = $config["base_path"] . "/log/cacti.log";
        }
        /* echo the data to the log (append) */
        $fp = @fopen($logfile, "a");
        if ($fp) {
            @fwrite($fp, $message);
            fclose($fp);
        }
    }
    /* Log to Syslog/Eventlog */
    /* Syslog is currently Unstable in Win32 */
    if ($logdestination == 2 || $logdestination == 3) {
        $string = strip_tags($string);
        $log_type = "";
        if (substr_count($string, "ERROR:")) {
            $log_type = "err";
        } else {
            if (substr_count($string, "WARNING:")) {
                $log_type = "warn";
            } else {
                if (substr_count($string, "STATS:")) {
                    $log_type = "stat";
                } else {
                    if (substr_count($string, "NOTICE:")) {
                        $log_type = "note";
                    }
                }
            }
        }
        if (strlen($log_type)) {
            define_syslog_variables();
            if ($config["cacti_server_os"] == "win32") {
                openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_USER);
            } else {
                openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_SYSLOG);
            }
            if ($log_type == "err" && read_config_option("log_perror")) {
                syslog(LOG_CRIT, $environ . ": " . $string);
            }
            if ($log_type == "warn" && read_config_option("log_pwarn")) {
                syslog(LOG_WARNING, $environ . ": " . $string);
            }
            if (($log_type == "stat" || $log_type == "note") && read_config_option("log_pstats")) {
                syslog(LOG_INFO, $environ . ": " . $string);
            }
            closelog();
        }
    }
}
Exemplo n.º 14
0
 function InitSession()
 {
     set_time_limit(1200);
     error_reporting(E_ALL ^ E_NOTICE);
     define_syslog_variables();
     openlog("smbwebclient", LOG_ODELAY | LOG_PID, $this->cfgFacility);
     if ($this->cfgSessionName != '') {
         session_name($this->cfgSessionName);
     }
     session_start();
 }
Exemplo n.º 15
0
$_REQUEST["logtohtml"]=1;

// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu.
if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
{
	$_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
}


// Definition des constantes syslog
if (function_exists("define_syslog_variables"))
{
	if (version_compare(PHP_VERSION, '5.3.0', '<'))
	{
		define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
	}
}
else
{
	// Pour PHP sans syslog (comme sous Windows)
	define('LOG_EMERG',0);
	define('LOG_ALERT',1);
	define('LOG_CRIT',2);
	define('LOG_ERR',3);
	define('LOG_WARNING',4);
	define('LOG_NOTICE',5);
	define('LOG_INFO',6);
	define('LOG_DEBUG',7);
}
Exemplo n.º 16
0
function syslog_write($msg)
{
    global $phpenv, $win32;
    $msg = 'Client ' . $phpenv['remote'] . ' ' . $phpenv['useragent'] . ' ' . $msg;
    if (!$win32) {
        if (function_exists('define_syslog_variables')) {
            define_syslog_variables();
        }
        openlog('kplaylist', LOG_PID | LOG_PERROR, LOG_LOCAL0);
        syslog(LOG_INFO, $msg);
        closelog();
    } else {
        user_error($msg);
    }
}
Exemplo n.º 17
0
 function _init()
 {
     define_syslog_variables();
     openlog($this->_name, LOG_PID | LOG_PERROR, LOG_USER);
 }
Exemplo n.º 18
0
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
/**
 *	\file       htdocs/filefunc.inc.php
 * 	\ingroup	core
 *  \brief      File that include conf.php file and functions.lib.php
 *  \version    $Id: filefunc.inc.php,v 1.22 2011/08/04 12:07:29 eldy Exp $
 */
define('DOL_VERSION', '3.1.1');
// Also defined in htdocs/install/inc.php (Ex: x.y.z-alpha, x.y.z)
define('EURO', chr(128));
// Definition des constantes syslog
if (function_exists("define_syslog_variables")) {
    if (version_compare(PHP_VERSION, '5.3.0', '<')) {
        define_syslog_variables();
        // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
    }
} else {
    // Pour PHP sans syslog (comme sous Windows)
    define('LOG_EMERG', 0);
    define('LOG_ALERT', 1);
    define('LOG_CRIT', 2);
    define('LOG_ERR', 3);
    define('LOG_WARNING', 4);
    define('LOG_NOTICE', 5);
    define('LOG_INFO', 6);
    define('LOG_DEBUG', 7);
}
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
error_reporting(E_ALL ^ E_NOTICE);
Exemplo n.º 19
0
 /**
  * @param priority int
  * @param name string
  * @param messages string
  */
 protected function log()
 {
     $num = func_num_args();
     if ($num <= 1) {
         return false;
     }
     $args = func_get_args();
     $priority = $args[0];
     $name = $args[1];
     if (isset($this->priorities[$name])) {
         $allow_priority = $this->priorities[$name];
     } else {
         $allow_priority = $this->priority;
         $prefixes = @APF::get_instance()->get_config(self::CONFIG_N_PREFIX, self::CONFIG_F_LOGGER);
         if ($prefixes) {
             foreach ($prefixes as $key => $value) {
                 if (strncmp($key, $name, strlen($key)) == 0) {
                     $allow_priority = $value;
                     $this->priorities[$name] = $allow_priority;
                     break;
                 }
             }
         }
     }
     if ($priority > $allow_priority) {
         return false;
     }
     $message = "[{$priority}] [{$name}] ";
     for ($i = 2; $i < $num; $i++) {
         $message .= $args[$i];
     }
     //大部分系统允许写入的单条最大日志是1024,所以对大日志进行分割。
     //add by wbsong
     $message_array = str_split($message, 900);
     $error_level = error_reporting(0);
     define_syslog_variables();
     error_reporting($error_level);
     openlog("APF", LOG_PID, LOG_USER);
     foreach ($message_array as $key => $msg) {
         //安居客论坛出了一次问题,require 一个不存在的类,导致输出了很多日志,
         //进而导致网站服务器相应不过来,现在改为输出9次,基本上错误信息就全了
         if ($key > 8) {
             syslog($priority, "===too many messages No necessary to output===");
             break;
         }
         syslog($priority, $msg);
     }
     closelog();
     return true;
 }