我正在使用PHPExcel将一些数据导出到excel文件中的用户.我希望脚本在创建后立即将excel文件发送给用户.这是我的测试代码:
try{
/* Some test data */
$data = array(
array(1, 10 , 2 ,),
array(3, 'qqq', 'some string' ,),
);
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
/* Fill the excel sheet with the data */
$rowI = 0;
foreach($data as $row){
$colI = 0;
foreach($row as $v){
$colChar = PHPExcel_Cell::stringFromColumnIndex($colI++);
$cellId = $colChar.($rowI+1);
$objPHPExcel->getActiveSheet()->SetCellValue($cellId, $v);
}
$rowI++;
}
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="export.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
}catch(Exception $e){
echo $e->__toString();
}
Run Code Online (Sandbox Code Playgroud)
在我的本地服务器上,(Windows 7 x64, Php 5.3.8, …
我想设置 nagios 来发送电子邮件通知。我可以在 nagios Web 界面中单击“发送自定义服务通知”手动发送电子邮件通知。正在创建通知,并且正在成功发送和传递电子邮件。但 nagios 不会自动发送通知。我已经测试过关闭机器上的 PING 服务(echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all)。Nagios 将 PING 服务设置为 CRITICAL 状态,但不发送通知电子邮件。
这些是我的配置文件:
templates.cfg 的一部分
define contact{
name generic-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands …Run Code Online (Sandbox Code Playgroud)