function cloud_init($php_version = "5.4") { if ($php_version == "5.4") { exec_script("sudo cloud-init php54atualizado"); } if ($php_version == "5.5") { exec_script(" sudo add-apt-repository ppa:ondrej/php5\n sudo apt-get update"); } //pacotes exec_script("\n sudo apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-mcrypt lynx lynx-cur php5-curl php5-dev php5-gd php5-mcrypt php5-memcache php5-memcached php5-mysql \n sudo a2enmod ssl\n sudo a2enmod rewrite\n sudo apt-get -y install apachetop\n sudo apt-get -y install firebird2.1-super subversion git-core php5-interbase \n sudo rm /etc/php5/conf.d/timezone.ini\n sudo mkdir /home/session;sudo chmod -R 777 /home/session"); time_zone(); // #################################################################################### // ###### COMENTADO POIS O XDEBUG NÃO FUNCIONA OS BREAKPOINTS ##################### // ###### ENTRANDO NAS FUNÇÕES COM ALGUMA EXTENSÃO DE CACHE ATIVA ##################### //eaccelerator //exec_script("sudo cloud-init eaccelerator"); // #################################################################################### //git clone //exec_script("cd /home; sudo git clone git@github.com:Superlogica/cloud.git"); //firewall exec_script("\n sudo ufw reset\n sudo ufw allow ssh\n sudo ufw allow http\n sudo ufw allow https\n sudo ufw enable"); //ativar app no apache if ($php_version == "5.5") { exec_script("sudo rm /etc/apache2/sites-enabled/*; sudo ln -s /home/cloud/conf/cloud.superlogica.com_php55 /etc/apache2/sites-enabled/001cloud.conf"); } else { exec_script("sudo rm /etc/apache2/sites-enabled/*; sudo ln -s /home/cloud/conf/cloud.superlogica.com /etc/apache2/sites-enabled/001cloud"); } exec_script("sudo rm -Rf /var/www\n sudo ln -s /home/cloud /var/www\n sudo cloud-init cloudini\n sudo cloud-init phpini\n sudo bash /home/cloud/conf/deploy.sh\n sudo chmod -R 777 /home/cloud/var\n sudo chmod -R 777 /home/cloud/public/scripts/min\n\t\t\tupdate-rc.d apache2 defaults\n "); //cloud.lock @unlink("/home/cloud/cloud.lock"); //deploy_action("cloud"); apache_tunning(); }
function fb21_init() { //http://www.slideshare.net/mindthebird/firebird-on-linux //http://www.ibphoenix.com/resources/documents/search/doc_26 $fb_ver = "2.1"; $classic = ""; // exec_script("sudo add-apt-repository ppa:mapopa // sudo apt-get update"); exec_script("\n sudo apt-get update\n sudo apt-get -f -y install\n\t\tsudo sysctl -w net.ipv4.tcp_keepalive_time=60 net.ipv4.tcp_keepalive_probes=3 net.ipv4.tcp_keepalive_intvl=10\n\t\tsudo apt-get -y -q install firebird{$fb_ver}-super{$classic} subversion git-core\n sudo dpkg-reconfigure firebird2.1-super\n\t\t"); time_zone(); // exec("sudo fdisk /dev/sdc << EOF\nn\np\n1\n\n\nw\nEOF"); //// exec_script("sudo mkfs -t ext3 /dev/sdc1 // // if (is_file("/dev/sdc1")){ // exec_script(" // sudo sed '/sdc/d' /etc/fstab > /tmp/fstab.tmp; sudo mv /tmp/fstab.tmp /etc/fstab // echo '/dev/sdc1 /home/cloud-db ext3 defaults 0 0' | sudo tee -a /etc/fstab"); // } // // if (is_file("/dev/xvda1")){ // exec_script(" // sudo sed '/xvd/d' /etc/fstab > /tmp/fstab.tmp; sudo mv /tmp/fstab.tmp /etc/fstab // echo '/dev/xvda1 /home/cloud-db ext3 defaults 0 0' | sudo tee -a /etc/fstab"); // } if (PHP_INT_SIZE == 8) { put_template("firebird/tbudf-64x.so", "/usr/lib/firebird/{$fb_ver}/UDF/tbudf.so"); } else { put_template("firebird/tbudf.so", "/usr/lib/firebird/{$fb_ver}/UDF/tbudf.so"); } exec_script(" \n sudo mkdir /home/cloud-db\n sudo mount /home/cloud-db\n\t\tsudo chmod 444 /etc/init.d/postfix\t\n\t\tsudo chown firebird.firebird /usr/lib/firebird/{$fb_ver}/UDF/*.so\n \n\t"); // sudo ln -s /usr/lib/libfbclient.so.2.5.0 /usr/lib/libfbclient.so exec_script("\n sudo ufw allow 3050\n"); firebird_tunning(true); firebird_restart(); }
function xdebug_init() { put_template("xdebug.ini", "/etc/php5/conf.d/xdebug.ini"); $diretorioExtensoes = ini_get('extension_dir'); $xdebugIni = 'zend_extension=' . rtrim($diretorioExtensoes, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xdebug.so'; exec_script("\n sed -i '1i" . $xdebugIni . "' /etc/php5/conf.d/xdebug.ini;\n cd /tmp; \n mkdir /tmp/xdebug; \n cd xdebug;\n wget -O /tmp/xdebug/xdebug.tar https://github.com/derickr/xdebug/tarball/master;\n tar --strip-components 1 -xf /tmp/xdebug/xdebug.tar; \n phpize; \n ./configure; \n sudo make; \n sudo make install;\n rm -rf /tmp/xdebug;\n sudo mkdir -p /var/log/xdebug;\n sudo mkdir -p /var/log/xdebug/profiler/;\n sudo chmod -R 777 /var/log/xdebug;\n sudo /etc/init.d/apache2 restart;\n "); }
<?php require_once 'lib.php'; require_once realpath(dirname(__FILE__)) . '/../actions.php'; require_once realpath(dirname(__FILE__)) . '/../conf.php'; global $conf; if (is_file("/home/ubuntu/fb25.lock")) { exec_script("sudo add-apt-repository ppa:ondrej/php5-oldstable\n sudo apt-get update"); $fb_ver = "2.5"; } else { $fb_ver = "2.1"; } //pacotes exec_script("\n sudo apt-get update\n sudo apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-mcrypt lynx lynx-cur php5-curl php5-dev php5-gd php5-mcrypt php5-memcache php5-memcached php5-mysql \n sudo a2enmod ssl\n sudo a2enmod rewrite\n sudo apt-get -y install apachetop\n sudo apt-get -y install firebird{$fb_ver}-super subversion git-core php5-interbase\n sudo dpkg-reconfigure -fff firebird2.1-super; \n sudo cp {$conf['basedir']}/firebird/*.so /usr/lib/firebird/{$fb_ver}/UDF\n sudo apt-get -y install tz-brasil\n sudo dpkg-reconfigure tzdata\n sudo chmod 444 /etc/init.d/postfix\n sudo rm /etc/php5/conf.d/timezone.ini"); //eaccelerator exec_script("sudo apt-get install make;\n\tcd /tmp; mkdir /tmp/eaccelerator; cd eaccelerator; wget -O /tmp/eaccelerator/eaccelerator.tar https://github.com/eaccelerator/eaccelerator/tarball/master;\n\tcd /tmp/eaccelerator; tar --strip-components 1 -xf /tmp/eaccelerator/eaccelerator.tar; phpize; ./configure; make; make install;\n rm -rf /tmp/eaccelerator;\n sudo mkdir -p /var/cache/eaccelerator;\n chmod 777 /var/cache/eaccelerator;\n sudo cp {$conf['basedir']}/templates/eaccelerator.ini /etc/php5/conf.d/;\n"); //git clone //exec_script("cd /home; sudo git clone git@github.com:Superlogica/cloud.git"); //firewall exec_script("\n sudo ufw reset\n sudo ufw allow ssh\n sudo ufw allow http\n sudo ufw allow https\n sudo ufw enable"); //cloud.lock @unlink("/home/cloud/cloud.lock"); //ativar app no apache exec_script("sudo rm /etc/apache2/sites-enabled/*; sudo ln -s /home/cloud/conf/cloud.superlogica.com /etc/apache2/sites-enabled/001cloud"); deploy_action("cloud"); atualizarCloudIni_action(); apachetunning_action(); phpiniupdate_action(); //_newrelic();
function zephir_init() { exec_script("\nsudo apt-get -y install git-core gcc make re2c php5 php5-dev libpcre3-dev\ncd /tmp\ncd /tmp; sudo git clone https://github.com/json-c/json-c.git\ncd /tmp/json-c; sh autogen.sh; ./configure; make && sudo make install\ncd /tmp; sudo git clone https://github.com/phalcon/zephir\ncd /tmp/zephir; ./install -c\nsudo apt-get -y install vim\ncd /home/cloud/todos-atual/library/zephir/superlogica; zephir fullclean; zephir build;\n"); firebird_restart(); }
function thold_check_threshold($rra_id, $data_id, $name, $currentval, $cdef) { global $config, $plugins, $debug; thold_debug("Checking Threshold: DS:{$name} RRA_ID:{$rra_id} DATA_ID:{$data_id} VALUE:{$currentval}"); $debug = false; // Do not proceed if we have chosen to globally disable all alerts if (read_config_option('thold_disable_all') == 'on') { thold_debug('Threshold checking is disabled globally'); return; } $alert_exempt = read_config_option('alert_exempt'); /* check for exemptions */ $weekday = date('l'); if (($weekday == 'Saturday' || $weekday == 'Sunday') && $alert_exempt == 'on') { thold_debug('Threshold checking is disabled by global weekend exemption'); return; } /* Get all the info about the item from the database */ $item = db_fetch_assoc("SELECT * FROM thold_data WHERE thold_enabled='on' AND data_id=" . $data_id); /* return if the item doesn't exist, which means its disabled */ if (!isset($item[0])) { thold_debug('Threshold is disabled'); return; } $item = $item[0]; /* check for the weekend exemption on the threshold level */ if (($weekday == 'Saturday' || $weekday == 'Sunday') && $item['exempt'] == 'on') { thold_debug('Threshold checking is disabled by global weekend exemption'); return; } /* don't alert for this host if it's selected for maintenance */ if (api_plugin_is_enabled('maint') || in_array('maint', $plugins)) { include_once $config["base_path"] . '/plugins/maint/functions.php'; if (plugin_maint_check_cacti_host($item['host_id'])) { thold_debug('Threshold checking is disabled by maintenance schedule'); return; } } $graph_id = $item['graph_id']; /* only alert if Host is in UP mode (not down, unknown, or recovering) */ $h = db_fetch_row('SELECT * FROM host WHERE id=' . $item['host_id']); if ($h['status'] != 3) { thold_debug('Threshold checking halted by Host Status (' . $h['status'] . ')'); return; } /* pull the cached name, if not present, it means that the graph hasn't polled yet */ $t = db_fetch_assoc('SELECT id, name, name_cache FROM data_template_data WHERE local_data_id = ' . $rra_id . ' ORDER BY id LIMIT 1'); /* pull a few default settings */ $global_alert_address = read_config_option('alert_email'); $global_notify_enabled = read_config_option('alert_notify_default') == 'on'; $logset = read_config_option('alert_syslog') == 'on'; $deadnotify = read_config_option('alert_deadnotify') == 'on'; $realert = read_config_option('alert_repeat'); $alert_trigger = read_config_option('alert_trigger'); $alert_bl_trigger = read_config_option('alert_bl_trigger'); $httpurl = read_config_option('alert_base_url'); $thold_show_datasource = read_config_option('thold_show_datasource'); $thold_send_text_only = read_config_option('thold_send_text_only'); $thold_alert_text = read_config_option('thold_alert_text'); $thold_warning_text = read_config_option('thold_warning_text'); /* remove this after adding an option for it */ $thold_show_datasource = true; $trigger = $item['thold_fail_trigger'] == '' ? $alert_trigger : $item['thold_fail_trigger']; $warning_trigger = $item['thold_warning_fail_trigger'] == '' ? $alert_trigger : $item['thold_warning_fail_trigger']; $alertstat = $item['thold_alert']; /* make sure the alert text has been set */ if (!isset($thold_alert_text) || $thold_alert_text == '') { $thold_alert_text = "<html><body>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></body></html>"; } /* make sure the warning text has been set */ if (!isset($thold_warning_text) || $thold_warning_text == '') { $thold_warning_text = "<html><body>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></body></html>"; } $hostname = db_fetch_row('SELECT description, hostname from host WHERE id = ' . $item['host_id']); $rows = db_fetch_assoc('SELECT plugin_thold_contacts.data FROM plugin_thold_contacts, plugin_thold_threshold_contact WHERE plugin_thold_contacts.id=plugin_thold_threshold_contact.contact_id AND plugin_thold_threshold_contact.thold_id = ' . $item['id']); $alert_emails = ''; if (read_config_option('thold_disable_legacy') != 'on') { $alert_emails = array(); if (count($rows)) { foreach ($rows as $row) { $alert_emails[] = $row['data']; } } $alert_emails = implode(',', $alert_emails); if ($alert_emails != '') { $alert_emails .= ',' . $item['notify_extra']; } else { $alert_emails = $item['notify_extra']; } } $alert_emails .= (strlen($alert_emails) ? "," : "") . get_thold_notification_emails($item['notify_alert']); $alert_phones = ''; if (read_config_option('thold_disable_legacy') != 'on') { // $alert_phones = array(); // if (count($rows)) { // foreach ($rows as $row) { // $alert_phones[] = $row['data']; // } // } // $alert_phones = implode(',', $alert_phones); if ($alert_phones != '') { $alert_phones .= ',' . $thold['alert_phones_extra']; } else { $alert_phones = $item['alert_phones_extra']; } } $alert_phones .= (strlen($alert_phones) ? "," : "") . get_thold_notification_phones($item['notify_alert']); $warning_emails = ''; if (read_config_option('thold_disable_legacy') != 'on') { $warning_emails = $item['notify_warning_extra']; } $warning_emails .= (strlen($warning_emails) ? "," : "") . get_thold_notification_emails($item['notify_warning']); $warning_phones = ''; if (read_config_option('thold_disable_legacy') != 'on') { $warning_phones = $item['warning_phones_extra']; } $alert_command = ''; $alert_command = $item['alert_command']; thold_debug('Alert Command: ' . $alert_command); $warning_command = $item['warning_command']; $types = array('High/Low', 'Baseline Deviation', 'Time Based'); // Do some replacement of variables $thold_alert_text = str_replace('<DESCRIPTION>', $hostname['description'], $thold_alert_text); $thold_alert_text = str_replace('<HOSTNAME>', $hostname['hostname'], $thold_alert_text); $thold_alert_text = str_replace('<TIME>', time(), $thold_alert_text); $thold_alert_text = str_replace('<GRAPHID>', $graph_id, $thold_alert_text); $thold_alert_text = str_replace('<URL>', "<a href='{$httpurl}/graph.php?local_graph_id={$graph_id}&rra_id=1'>{$httpurl}/graph.php?local_graph_id={$graph_id}&rra_id=1</a>", $thold_alert_text); $thold_alert_text = str_replace('<CURRENTVALUE>', $currentval, $thold_alert_text); $thold_alert_text = str_replace('<THRESHOLDNAME>', $item['name'], $thold_alert_text); $thold_alert_text = str_replace('<DSNAME>', $name, $thold_alert_text); $thold_alert_text = str_replace('<THOLDTYPE>', $types[$item['thold_type']], $thold_alert_text); $thold_alert_text = str_replace('<HI>', $item['thold_type'] == 0 ? $item['thold_hi'] : ($item['thold_type'] == 2 ? $item['time_hi'] : ''), $thold_alert_text); $thold_alert_text = str_replace('<LOW>', $item['thold_type'] == 0 ? $item['thold_low'] : ($item['thold_type'] == 2 ? $item['time_low'] : ''), $thold_alert_text); $thold_alert_text = str_replace('<TRIGGER>', $item['thold_type'] == 0 ? $item['thold_fail_trigger'] : ($item['thold_type'] == 2 ? $item['time_fail_trigger'] : ''), $thold_alert_text); $thold_alert_text = str_replace('<DURATION>', $item['thold_type'] == 2 ? plugin_thold_duration_convert($item['rra_id'], $item['time_fail_length'], 'time') : '', $thold_alert_text); $thold_alert_text = str_replace('<DATE_RFC822>', date(DATE_RFC822), $thold_alert_text); $thold_alert_text = str_replace('<DEVICENOTE>', $h['notes'], $thold_alert_text); // Do some replacement of variables $thold_warning_text = str_replace('<DESCRIPTION>', $hostname['description'], $thold_warning_text); $thold_warning_text = str_replace('<HOSTNAME>', $hostname['hostname'], $thold_warning_text); $thold_warning_text = str_replace('<TIME>', time(), $thold_warning_text); $thold_warning_text = str_replace('<GRAPHID>', $graph_id, $thold_warning_text); $thold_warning_text = str_replace('<URL>', "<a href='{$httpurl}/graph.php?local_graph_id={$graph_id}&rra_id=1'>{$httpurl}/graph.php?local_graph_id={$graph_id}&rra_id=1</a>", $thold_warning_text); $thold_warning_text = str_replace('<CURRENTVALUE>', $currentval, $thold_warning_text); $thold_warning_text = str_replace('<THRESHOLDNAME>', $item['name'], $thold_warning_text); $thold_warning_text = str_replace('<DSNAME>', $name, $thold_warning_text); $thold_warning_text = str_replace('<THOLDTYPE>', $types[$item['thold_type']], $thold_warning_text); $thold_warning_text = str_replace('<HI>', $item['thold_type'] == 0 ? $item['thold_hi'] : ($item['thold_type'] == 2 ? $item['time_warning_hi'] : ''), $thold_warning_text); $thold_warning_text = str_replace('<LOW>', $item['thold_type'] == 0 ? $item['thold_low'] : ($item['thold_type'] == 2 ? $item['time_warning_low'] : ''), $thold_warning_text); $thold_warning_text = str_replace('<TRIGGER>', $item['thold_type'] == 0 ? $item['thold_warning_fail_trigger'] : ($item['thold_type'] == 2 ? $item['time_warning_fail_trigger'] : ''), $thold_warning_text); $thold_warning_text = str_replace('<DURATION>', $item['thold_type'] == 2 ? plugin_thold_duration_convert($item['rra_id'], $item['time_warning_fail_length'], 'time') : '', $thold_warning_text); $thold_warning_text = str_replace('<DATE_RFC822>', date(DATE_RFC822), $thold_warning_text); $thold_warning_text = str_replace('<DEVICENOTE>', $h['notes'], $thold_warning_text); $msg = $thold_alert_text; $warn_msg = $thold_warning_text; if ($thold_send_text_only == 'on') { $file_array = ''; } else { $file_array = array(0 => array('local_graph_id' => $graph_id, 'rra_id' => 0, 'file' => "{$httpurl}/graph_image.php?local_graph_id={$graph_id}&rra_id=0&view_type=tree", 'mimetype' => 'image/png', 'filename' => $graph_id)); } $url = $httpurl . "/graph.php?local_graph_id=" . $graph_id . "&rra_id=all"; switch ($item['thold_type']) { case 0: /* hi/low */ if ($currentval != '') { $breach_up = $item['thold_hi'] != '' && $currentval > $item['thold_hi']; $breach_down = $item['thold_low'] != '' && $currentval < $item['thold_low']; $warning_breach_up = $item['thold_warning_hi'] != '' && $currentval > $item['thold_warning_hi']; $warning_breach_down = $item['thold_warning_low'] != '' && $currentval < $item['thold_warning_low']; } else { $breach_up = $breach_down = $warning_breach_up = $warning_breach_down = false; } /* is in alert status */ if ($breach_up || $breach_down) { $notify = false; thold_debug('Threshold HI / Low check breached HI:' . $item['thold_hi'] . ' LOW:' . $item['thold_low'] . ' VALUE:' . $currentval); $item['thold_fail_count']++; $item['thold_alert'] = $breach_up ? STAT_HI : STAT_LO; /* Re-Alert? */ $ra = $item['thold_fail_count'] > $trigger && $item['repeat_alert'] != 0 && $item['thold_fail_count'] % $item['repeat_alert'] == 0; if ($item['thold_fail_count'] == $trigger || $ra) { $notify = true; } $subject = "ALERT: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . ' ' . ($ra ? 'is still ' : 'went') . ' ' . ($breach_up ? 'above' : 'below') . ' threshold of ' . ($breach_up ? $item['thold_hi'] : $item['thold_low']) . " with {$currentval}"; if ($notify) { thold_debug('Alerting is necessary'); if ($logset == 1) { logger($item['name'], $ra ? 'realert' : 'alert', $breach_up ? $item['thold_hi'] : $item['thold_low'], $currentval, $trigger, $item['thold_fail_count'], $url); } if ($alert_command != '') { exec_script($alert_command); } if (trim($alert_phones) != '') { thold_sms($alert_phones, $subject); } if (trim($alert_emails) != '') { thold_mail($alert_emails, '', $subject, $msg, $file_array); } thold_log(array('type' => 0, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $breach_up ? $item['thold_hi'] : $item['thold_low'], 'current' => $currentval, 'status' => $ra ? ST_NOTIFYRA : ST_NOTIFYAL, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones, 'command' => $alert_command)); } db_execute("UPDATE thold_data\r\n\t\t\t\tSET thold_alert=" . $item['thold_alert'] . ",\r\n\t\t\t\tthold_fail_count=" . $item['thold_fail_count'] . ",\r\n\t\t\t\tthold_warning_fail_count=0\r\n\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } elseif ($warning_breach_up || $warning_breach_down) { $notify = false; thold_debug('Threshold HI / Low Warning check breached HI:' . $item['thold_warning_hi'] . ' LOW:' . $item['thold_warning_low'] . ' VALUE:' . $currentval); $item['thold_warning_fail_count']++; $item['thold_alert'] = $warning_breach_up ? STAT_HI : STAT_LO; /* re-alert? */ $ra = $item['thold_warning_fail_count'] > $warning_trigger && $item['repeat_alert'] != 0 && $item['thold_warning_fail_count'] % $item['repeat_alert'] == 0; if ($item['thold_warning_fail_count'] == $warning_trigger || $ra) { $notify = true; } $subject = ($notify ? "WARNING: " : "TRIGGER: ") . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . ' ' . ($ra ? 'is still' : 'went') . ' ' . ($warning_breach_up ? 'above' : 'below') . ' threshold of ' . ($warning_breach_up ? $item['thold_warning_hi'] : $item['thold_warning_low']) . " with {$currentval}"; if ($notify) { thold_debug('Alerting is necessary'); if ($logset == 1) { logger($item['name'], $ra ? 'rewarning' : 'warning', $warning_breach_up ? $item['thold_warning_hi'] : $item['thold_warning_low'], $currentval, $warning_trigger, $item['thold_warning_fail_count'], $url); } if ($warning_command != '') { exec_script($warning_command); } if (trim($warning_phones) != '') { thold_sms($warning_phones, $subject); } if (trim($warning_emails) != '') { thold_mail($warning_emails, '', $subject, $warn_msg, $file_array); } thold_log(array('type' => 0, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $warning_breach_up ? $item['thold_warning_hi'] : $item['thold_warning_low'], 'current' => $currentval, 'status' => $ra ? ST_NOTIFYRA : ST_NOTIFYWA, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $warning_phones, 'command' => $warning_command)); } elseif ($item['thold_warning_fail_count'] >= $warning_trigger && $item['thold_fail_count'] >= $trigger) { $subject = "ALERT -> WARNING: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . " Changed to Warning Threshold with Value {$currentval}"; if (trim($alert_emails) != '') { thold_mail($alert_emails, '', $subject, $warn_msg, $file_array); } if (trim($alert_phones) != '') { thold_sms($alert_phones, $subject); } thold_log(array('type' => 0, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $warning_breach_up ? $item['thold_warning_hi'] : $item['thold_warning_low'], 'current' => $currentval, 'status' => ST_NOTIFYAW, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones)); } db_execute("UPDATE thold_data\r\n\t\t\t\tSET thold_alert=" . $item['thold_alert'] . ",\r\n\t\t\t\tthold_warning_fail_count=" . $item['thold_warning_fail_count'] . ",\r\n\t\t\t\tthold_fail_count=0\r\n\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } else { thold_debug('Threshold HI / Low check is normal HI:' . $item['thold_hi'] . ' LOW:' . $item['thold_low'] . ' VALUE:' . $currentval); /* if we were at an alert status before */ if ($alertstat != 0) { $subject = "NORMAL: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . " Restored to Normal Threshold with Value {$currentval}"; db_execute("UPDATE thold_data\r\n\t\t\t\t\tSET thold_alert=0, thold_fail_count=0, thold_warning_fail_count=0\r\n\t\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); if ($item['thold_warning_fail_count'] >= $warning_trigger && $item['restored_alert'] != 'on') { if ($logset == 1) { logger($item['name'], 'ok', 0, $currentval, $warning_trigger, $item['thold_warning_fail_count'], $url); } if (trim($warning_emails) != '' && $item['restored_alert'] != 'on') { thold_mail($warning_emails, '', $subject, $warn_msg, $file_array); } if (trim($warning_phones) != '' && $item['restored_alert'] != 'on') { thold_sms($warning_phones, $subject); } thold_log(array('type' => 0, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => '', 'current' => $currentval, 'status' => ST_NOTIFYRS, 'description' => $subject, 'emails' => $warning_emails, 'phones' => $warning_phones)); } elseif ($item['thold_fail_count'] >= $trigger && $item['restored_alert'] != 'on') { if ($logset == 1) { logger($item['name'], 'ok', 0, $currentval, $trigger, $item['thold_fail_count'], $url); } if (trim($alert_emails) != '' && $item['restored_alert'] != 'on') { thold_mail($alert_emails, '', $subject, $msg, $file_array); } if (trim($alert_phones) != '' && $item['restored_alert'] != 'on') { thold_sms($alert_phones, $subject); } thold_log(array('type' => 0, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => '', 'current' => $currentval, 'status' => ST_NOTIFYRS, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones)); } } } break; case 1: /* baseline */ $bl_alert_prev = $item['bl_alert']; $bl_count_prev = $item['bl_fail_count']; $bl_fail_trigger = $item['bl_fail_trigger'] == '' ? $alert_bl_trigger : $item['bl_fail_trigger']; $item['bl_alert'] = thold_check_baseline($rra_id, $name, $currentval, $item); switch ($item['bl_alert']) { case -2: /* exception is active, Future Release 'todo' */ break; case -1: /* reference value not available, Future Release 'todo' */ break; case 0: /* all clear */ /* if we were at an alert status before */ if ($alertstat != 0) { thold_debug('Threshold Baseline check is normal'); if ($item['bl_fail_count'] >= $bl_fail_trigger && $item['restored_alert'] != 'on') { thold_debug('Threshold Baseline check returned to normal'); if ($logset == 1) { logger($item['name'], 'ok', 0, $currentval, $item['bl_fail_trigger'], $item['bl_fail_count'], $url); } $subject = "NORMAL: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . " restored to normal threshold with value {$currentval}"; if (trim($alert_emails) != '') { thold_mail($alert_emails, '', $subject, $msg, $file_array); } if (trim($alert_phones) != '') { thold_sms($alert_phones, $subject); } thold_log(array('type' => 1, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => '', 'current' => $currentval, 'status' => ST_NOTIFYRA, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones)); } } $item['bl_fail_count'] = 0; break; case 1: /* value is below calculated threshold */ /* value is below calculated threshold */ case 2: /* value is above calculated threshold */ $item['bl_fail_count']++; $breach_up = $item['bl_alert'] == STAT_HI; $breach_down = $item['bl_alert'] == STAT_LO; thold_debug('Threshold Baseline check breached'); /* re-alert? */ $ra = $item['bl_fail_count'] > $bl_fail_trigger && $item['bl_fail_count'] % ($item['repeat_alert'] == '' ? $realert : $item['repeat_alert']) == 0; if ($item['bl_fail_count'] == $bl_fail_trigger || $ra) { thold_debug('Alerting is necessary'); $subject = "ALERT: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . ' ' . ($ra ? 'is still' : 'went') . ' ' . ($breach_up ? 'above' : 'below') . " calculated baseline threshold " . ($breach_up ? $item['thold_hi'] : $item['thold_low']) . " with {$currentval}"; if ($logset == 1) { logger($item['name'], $ra ? 'realert' : 'alert', $breach_up ? $item['thold_hi'] : $item['thold_low'], $currentval, $item['bl_fail_trigger'], $item['bl_fail_count'], $url); } if ($alert_command != '') { exec_script($alert_command); } if (trim($alert_phones) != '') { thold_sms($alert_phones, $subject); } if (trim($alert_emails) != '') { thold_mail($alert_emails, '', $subject, $msg, $file_array); } thold_log(array('type' => 1, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $breach_up ? $item['thold_hi'] : $item['thold_low'], 'current' => $currentval, 'status' => $ra ? ST_NOTIFYRA : ST_NOTIFYAL, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones, 'command' => $alert_command)); } else { thold_log(array('type' => 1, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $breach_up ? $item['thold_hi'] : $item['thold_low'], 'current' => $currentval, 'status' => ST_TRIGGERA, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones)); } break; } db_execute("UPDATE thold_data SET thold_alert=0, thold_fail_count=0,\r\n\t\t\tbl_alert='" . $item['bl_alert'] . "',\r\n\t\t\tbl_fail_count='" . $item['bl_fail_count'] . "',\r\n\t\t\tthold_low='" . $item['thold_low'] . "',\r\n\t\t\tthold_hi='" . $item['thold_hi'] . "',\r\n\t\t\tbl_thold_valid='" . $item['bl_thold_valid'] . "'\r\n\t\t\tWHERE rra_id='{$rra_id}' AND data_id=" . $item['data_id']); break; case 2: /* time based */ if ($currentval != '') { $breach_up = $item['time_hi'] != '' && $currentval > $item['time_hi']; $breach_down = $item['time_low'] != '' && $currentval < $item['time_low']; $warning_breach_up = $item['time_warning_hi'] != '' && $currentval > $item['time_warning_hi']; $warning_breach_down = $item['time_warning_low'] != '' && $currentval < $item['time_warning_low']; } else { $breach_up = $breach_down = $warning_breach_up = $warning_breach_down = false; } $step = db_fetch_cell('SELECT rrd_step FROM data_template_data WHERE local_data_id = ' . $rra_id, FALSE); /* alerts */ $trigger = $item['time_fail_trigger']; $time = time() - $item['time_fail_length'] * $step; $failures = db_fetch_cell("SELECT count(id) FROM plugin_thold_log WHERE threshold_id=" . $item['id'] . " AND status IN (" . ST_TRIGGERA . "," . ST_NOTIFYRA . "," . ST_NOTIFYAL . ") AND time>" . $time); /* warnings */ $warning_trigger = $item['time_warning_fail_trigger']; $warning_time = time() - $item['time_warning_fail_length'] * $step; $warning_failures = db_fetch_cell("SELECT count(id) FROM plugin_thold_log WHERE threshold_id=" . $item['id'] . " AND status IN (" . ST_NOTIFYWA . "," . ST_TRIGGERW . ") AND time>" . $warning_time) + $failures; if ($breach_up || $breach_down) { $notify = false; thold_debug('Threshold Time Based check breached HI:' . $item['time_hi'] . ' LOW:' . $item['time_low'] . ' VALUE:' . $currentval); $item['thold_alert'] = $breach_up ? STAT_HI : STAT_LO; $item['thold_fail_count'] = $failures; /* we should only re-alert X minutes after last email, not every 5 pollings, etc... re-alert? */ $realerttime = ($item['repeat_alert'] - 1) * $step; $lastemailtime = db_fetch_cell("SELECT time\r\n\t\t\t\tFROM plugin_thold_log\r\n\t\t\t\tWHERE threshold_id=" . $item['id'] . "\r\n\t\t\t\tAND status IN (" . ST_NOTIFYRA . "," . ST_NOTIFYAL . ")\r\n\t\t\t\tORDER BY time DESC\r\n\t\t\t\tLIMIT 1", FALSE); $ra = $failures > $trigger && $item['repeat_alert'] && !empty($lastemailtime) && $lastemailtime + $realerttime <= time(); $failures++; thold_debug("Alert Time:'{$time}', Alert Trigger:'{$trigger}', Alert Failures:'{$failures}', RealertTime:'{$realerttime}', LastTime:'{$lastemailtime}', RA:'{$ra}', Diff:'" . ($realerttime + $lastemailtime) . "'<'" . time() . "'"); if ($failures == $trigger || $ra) { $notify = true; } $subject = ($notify ? "ALERT: " : "TRIGGER: ") . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . ' ' . ($failures > $trigger ? 'is still' : 'went') . ' ' . ($breach_up ? 'above' : 'below') . ' threshold of ' . ($breach_up ? $item['time_hi'] : $item['time_low']) . " with {$currentval}"; if ($notify) { thold_debug('Alerting is necessary'); if ($logset == 1) { logger($item['name'], $failures > $trigger ? 'realert' : 'alert', $breach_up ? $item['time_hi'] : $item['time_low'], $currentval, $trigger, $failures, $url); } if ($alert_command != '') { exec_script($alert_command); } if (trim($alert_phones) != '') { thold_sms($alert_phones, $subject); } if (trim($alert_emails) != '') { thold_mail($alert_emails, '', $subject, $msg, $file_array); } thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $breach_up ? $item['time_hi'] : $item['time_low'], 'current' => $currentval, 'status' => $failures > $trigger ? ST_NOTIFYAL : ST_NOTIFYRA, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones, 'command' => $alert_command)); } else { thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $breach_up ? $item['time_hi'] : $item['time_low'], 'current' => $currentval, 'status' => ST_TRIGGERA, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones)); } db_execute("UPDATE thold_data\r\n\t\t\t\tSET thold_alert=" . $item['thold_alert'] . ",\r\n\t\t\t\tthold_fail_count={$failures}\r\n\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } elseif ($warning_breach_up || $warning_breach_down) { $notify = false; $item['thold_alert'] = $warning_breach_up ? STAT_HI : STAT_LO; $item['thold_warning_fail_count'] = $warning_failures; /* we should only re-alert X minutes after last email, not every 5 pollings, etc... re-alert? */ $realerttime = ($item['time_warning_fail_length'] - 1) * $step; $lastemailtime = db_fetch_cell("SELECT time\r\n\t\t\t\tFROM plugin_thold_log\r\n\t\t\t\tWHERE threshold_id=" . $item['id'] . "\r\n\t\t\t\tAND status IN (" . ST_NOTIFYRA . "," . ST_NOTIFYWA . ")\r\n\t\t\t\tORDER BY time DESC\r\n\t\t\t\tLIMIT 1", FALSE); $ra = $warning_failures > $warning_trigger && $item['time_warning_fail_length'] && !empty($lastemailtime) && $lastemailtime + $realerttime <= time(); $warning_failures++; thold_debug("Warn Time:'{$warning_time}', Warn Trigger:'{$warning_trigger}', Warn Failures:'{$warning_failures}', RealertTime:'{$realerttime}', LastTime:'{$lastemailtime}', RA:'{$ra}', Diff:'" . ($realerttime + $lastemailtime) . "'<'" . time() . "'"); if ($warning_failures == $warning_trigger || $ra) { $notify = true; } $subject = ($notify ? "WARNING: " : "TRIGGER: ") . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . ' ' . ($warning_failures > $warning_trigger ? 'is still' : 'went') . ' ' . ($warning_breach_up ? 'above' : 'below') . ' threshold of ' . ($warning_breach_up ? $item['time_warning_hi'] : $item['time_warning_low']) . " with {$currentval}"; if ($notify) { if ($logset == 1) { logger($item['name'], $warning_failures > $warning_trigger ? 'rewarning' : 'warning', $warning_breach_up ? $item['time_warning_hi'] : $item['time_warning_low'], $currentval, $warning_trigger, $warning_failures, $url); } if ($warning_command != '') { exec_script($warning_command); } if (trim($warning_phones) != '') { thold_sms($warning_phones, $subject); } if (trim($alert_emails) != '') { thold_mail($warning_emails, '', $subject, $warn_msg, $file_array); } thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $breach_up ? $item['time_hi'] : $item['time_low'], 'current' => $currentval, 'status' => $warning_failures > $warning_trigger ? ST_NOTIFYRA : ST_NOTIFYWA, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $warning_phones, 'command' => $warning_command)); } elseif ($alertstat != 0 && $warning_failures < $warning_trigger && $failures < $trigger) { $subject = "ALERT -> WARNING: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . " restored to warning threshold with value {$currentval}"; thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $warning_breach_up ? $item['time_hi'] : $item['time_low'], 'current' => $currentval, 'status' => ST_NOTIFYAW, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $warning_phones)); } else { thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => $warning_breach_up ? $item['time_hi'] : $item['time_low'], 'current' => $currentval, 'status' => ST_TRIGGERW, 'description' => $subject, 'emails' => $warning_emails, 'phones' => $warning_phones)); } db_execute("UPDATE thold_data\r\n\t\t\t\tSET thold_alert=" . $item['thold_alert'] . ",\r\n\t\t\t\tthold_warning_fail_count={$warning_failures},\r\n\t\t\t\tthold_fail_count={$failures}\r\n\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } else { thold_debug('Threshold Time Based check is normal HI:' . $item['time_hi'] . ' LOW:' . $item['time_low'] . ' VALUE:' . $currentval); if ($alertstat != 0 && $warning_failures < $warning_trigger && $item['restored_alert'] != 'on') { if ($logset == 1) { logger($item['name'], 'ok', 0, $currentval, $warning_trigger, $item['thold_warning_fail_count'], $url); } $subject = "NORMAL: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . " restored to normal threshold with value {$currentval}"; if (trim($warning_emails) != '' && $item['restored_alert'] != 'on') { thold_mail($warning_emails, '', $subject, $msg, $file_array); } if (trim($warning_phones) != '' && $item['restored_alert'] != 'on') { thold_sms($warning_phones, $subject); } thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => '', 'current' => $currentval, 'status' => ST_NOTIFYRS, 'description' => $subject, 'emails' => $warning_emails, 'phones' => $warning_phones)); db_execute("UPDATE thold_data\r\n\t\t\t\t\tSET thold_alert=0, thold_warning_fail_count={$warning_failures}, thold_fail_count={$failures}\r\n\t\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } elseif ($alertstat != 0 && $failures < $trigger && $item['restored_alert'] != 'on') { if ($logset == 1) { logger($item['name'], 'ok', 0, $currentval, $trigger, $item['thold_fail_count'], $url); } $subject = "NORMAL: " . $item['name'] . ($thold_show_datasource ? " [{$name}]" : '') . " restored to warning threshold with value {$currentval}"; if (trim($alert_emails) != '' && $item['restored_alert'] != 'on') { thold_mail($alert_emails, '', $subject, $msg, $file_array); } if (trim($alert_phones) != '' && $item['restored_alert'] != 'on') { thold_sms($alert_phones, $subject); } thold_log(array('type' => 2, 'time' => time(), 'host_id' => $item['host_id'], 'graph_id' => $graph_id, 'threshold_id' => $item['id'], 'threshold_value' => '', 'current' => $currentval, 'status' => ST_NOTIFYRS, 'description' => $subject, 'emails' => $alert_emails, 'phones' => $alert_phones)); db_execute("UPDATE thold_data\r\n\t\t\t\t\tSET thold_alert=0, thold_warning_fail_count={$warning_failures}, thold_fail_count={$failures}\r\n\t\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } else { db_execute("UPDATE thold_data\r\n\t\t\t\t\tSET thold_fail_count={$failures},\r\n\t\t\t\t\tthold_warning_fail_count={$warning_failures}\r\n\t\t\t\t\tWHERE rra_id={$rra_id} AND data_id=" . $item['data_id']); } } break; } }
function hhvm_init($maq = "trusty") { exec_script("\ncloud-init cloud default\nwget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -\necho deb http://dl.hhvm.com/ubuntu {$maq} main | sudo tee /etc/apt/sources.list.d/hhvm.list\nsudo apt-get update\nsudo apt-get install hhvm\nsudo update-rc.d hhvm defaults\nsudo /usr/share/hhvm/install_fastcgi.sh\nsudo rm -Rf /var/www/html\nsudo ln -s /home/cloud/public /var/www/html\n"); put_template("hhvm_proxy_fcgi.conf", "/etc/apache2/mods-available/hhvm_proxy_fcgi.conf"); }
function php54atualizado_init() { exec_script("sudo apt-get install python-software-properties software-properties-common\n sudo add-apt-repository ppa:ondrej/php5-oldstable\n sudo apt-get update\n sudo apt-get install php5\n "); }
function eaccelerator_init() { exec_script("\n\tsudo apt-get install make;\n\tcd /tmp; mkdir /tmp/eaccelerator; cd eaccelerator; wget -O /tmp/eaccelerator/eaccelerator.tar https://github.com/eaccelerator/eaccelerator/tarball/master;\n\tcd /tmp/eaccelerator; tar --strip-components 1 -xf /tmp/eaccelerator/eaccelerator.tar; phpize; ./configure; make; make install;\n rm -rf /tmp/eaccelerator;\n sudo mkdir -p /var/cache/eaccelerator;\n sudo chmod -R 777 /var/cache/eaccelerator;\n"); put_template("eaccelerator.ini", "/etc/php5/conf.d/eaccelerator.ini"); }
function cloudteste_init() { exec_script("sudo cloud-init cloud\n sudo cloud-init fb21\n sudo cloud-init xdebug"); }
<?php require_once 'lib.php'; require_once realpath(dirname(__FILE__)) . '/../actions.php'; require_once realpath(dirname(__FILE__)) . '/../conf.php'; global $conf; exec_script("\n sudo apt-get update\n sudo apt-get -y install mysql-server-5.5;\n\tmysql -u root -p; \n\tset password for root@localhost=password(''); quit; \n"); //pacotes exec_script("\n sudo apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-mcrypt lynx lynx-cur php5-curl php5-dev php5-gd php5-mcrypt php5-memcache php5-memcached php5-mysql; \n sudo apt-get install phpmyadmin; \n\tsudo su;\n\tsudo echo 'Include /etc/phpmyadmin/apache.conf' >> /etc/apache2/apache2.conf;\t\n sudo a2enmod ssl;\n sudo a2enmod rewrite;\n sudo apt-get -y install apachetop;\n sudo apt-get -y /home/apps/sessioninstall git-core;\n sudo apt-get -y install tz-brasil;\n sudo dpkg-reconfigure tzdata;\n sudo chmod 444 /etc/init.d/postfix\n sudo cp {$conf['basedir']}/templates/superlogica.ini /etc/php5/apache2/conf.d/;\n cd /usr/local; sudo wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz; sudo tar xzf ioncube_loaders_lin_x86-64.tar.gz;\n sudo cp {$conf['basedir']}/templates/ioncube.ini /etc/php5/apache2/conf.d/; \n sudo rm /etc/php5/conf.d/timezone.ini\n\tsudo mkdir /home/apps/session; sudo chmod -R 777 /home/apps/session"); //eaccelerator exec_script("\n cd /tmp; mkdir /tmp/eaccelerator; cd eaccelerator; wget -O /tmp/eaccelerator/eaccelerator.tar https://github.com/eaccelerator/eaccelerator/tarball/master;\n cd /tmp/eaccelerator; tar --strip-components 1 -xf /tmp/eaccelerator/eaccelerator.tar; phpize; ./configure; make; make install;\n rm -rf /tmp/eaccelerator;\n sudo mkdir -p /var/cache/eaccelerator;\n chmod 777 /var/cache/eaccelerator;\n sudo cp {$conf['basedir']}/templates/eaccelerator.ini /etc/php5/conf.d/;\n"); // exec_script("sudo ln -s /home/plataforma/public /home/apps/public"); //firewall exec_script("\n sudo ufw reset\n sudo ufw allow ssh\n sudo ufw allow http\n sudo ufw allow https\n sudo ufw allow 3049\n sudo ufw enable"); //ativar app no apache exec_script("sudo rm /etc/apache2/sites-enabled/*; sudo ln -s /home/apps/conf/apps.superlogica.net /etc/apache2/sites-enabled/001apps"); deploy_action("apps"); //deploy_action("plataforma"); apachetunning_action(); //_newrelic();
function time_zone() { put_template("timezone", "/etc/timezone"); exec_script("sudo apt-get -y -q install tz-brasil" . "sudo chmod 444 /etc/init.d/postfix"); }