当前位置: 建站>运营/SEO
本页文章导读:
▪[nagios监控] centos6.2安装配置nagios server 1> 安装软件包
yum install httpd gcc glibc glibc-common php gd gd-devel libpng libmng libjpeg zlib -y
yum install openssl openssl-devel -y
2> 配置php环境
&nbs.........
▪[nagios监控] 监控samba服务 监控samba服务
1> 监控端设置
a> 下载监控脚本
cd /usr/local/nagios/libexec/
wget ftp://192.168.68.254/monitor/nagios/scripts/ch.........
▪特殊按键--休眠键驱动 这是一个关于休眠和关机的按键驱动。板子:pxa31X系列 内核:2.6.25
这个驱动用到了内核文件操作,内核线程,等待队列,异步通知,并介绍了一种调试驱动的方法。
#include <linux/init.h&g.........
[1][nagios监控] centos6.2安装配置nagios server
来源: 互联网 发布时间: 2013-10-26
1> 安装软件包
yum install httpd gcc glibc glibc-common php gd gd-devel libpng libmng libjpeg zlib -y
yum install openssl openssl-devel -y
2> 配置php环境
vim /etc/httpd/conf/httpd.conf
276 ServerName localhost:80
3> 创建nagios帐号
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
4> 安装nagios-3.4.1
a> 下载软件包,解压编译
wget ftp://192.168.68.254/monitor/nagios/nagios-3.4.1.tar.gz
tar -zxvf nagios-3.4.1.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all && make install
make install-init && make install-config && make install-commandmode && make install-webconf
b> 创建用户用于Nagios的WEB接口登录,重启httpd使配置生效
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
5> 编译并安装Nagios插件
wget ftp://192.168.68.254/monitor/nagios/nagios-plugins-1.4.16.tar.gz
tar -zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make && make install
6> 验证nagios样例配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
7> 启动nagios服务
service nagios start
service httpd start
yum install httpd gcc glibc glibc-common php gd gd-devel libpng libmng libjpeg zlib -y
yum install openssl openssl-devel -y
2> 配置php环境
vim /etc/httpd/conf/httpd.conf
276 ServerName localhost:80
3> 创建nagios帐号
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
4> 安装nagios-3.4.1
a> 下载软件包,解压编译
wget ftp://192.168.68.254/monitor/nagios/nagios-3.4.1.tar.gz
tar -zxvf nagios-3.4.1.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all && make install
make install-init && make install-config && make install-commandmode && make install-webconf
b> 创建用户用于Nagios的WEB接口登录,重启httpd使配置生效
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
5> 编译并安装Nagios插件
wget ftp://192.168.68.254/monitor/nagios/nagios-plugins-1.4.16.tar.gz
tar -zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make && make install
6> 验证nagios样例配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
7> 启动nagios服务
service nagios start
service httpd start
作者:kakane 发表于2013-3-12 11:41:56 原文链接
阅读:69 评论:0 查看评论
[2][nagios监控] 监控samba服务
来源: 互联网 发布时间: 2013-10-26
监控samba服务
1> 监控端设置
a> 下载监控脚本
cd /usr/local/nagios/libexec/
wget ftp://192.168.68.254/monitor/nagios/scripts/check_smb
chmod +x check_smb
b> 添加服务命令
vim /usr/local/nagios/etc/objects/commands.cfg
# 'check_smb' command definition
define command{
command_name check_smb
command_line $USER1$/check_smb -H $HOSTADDRESS$
}
c> 添加监控主机
vim /usr/local/nagios/etc/objects/192.168.68.214.cfg
# Define a service to check SMB on the local machine.
define service{
use generic-service
host_name test-samba
service_description Samba
check_command check_smb
process_perf_data 1
}
1> 监控端设置
a> 下载监控脚本
cd /usr/local/nagios/libexec/
wget ftp://192.168.68.254/monitor/nagios/scripts/check_smb
chmod +x check_smb
b> 添加服务命令
vim /usr/local/nagios/etc/objects/commands.cfg
# 'check_smb' command definition
define command{
command_name check_smb
command_line $USER1$/check_smb -H $HOSTADDRESS$
}
c> 添加监控主机
vim /usr/local/nagios/etc/objects/192.168.68.214.cfg
# Define a service to check SMB on the local machine.
define service{
use generic-service
host_name test-samba
service_description Samba
check_command check_smb
process_perf_data 1
}
作者:kakane 发表于2013-3-12 13:44:55 原文链接
阅读:88 评论:0 查看评论
[3]特殊按键--休眠键驱动
来源: 互联网 发布时间: 2013-10-26
这是一个关于休眠和关机的按键驱动。板子:pxa31X系列 内核:2.6.25
这个驱动用到了内核文件操作,内核线程,等待队列,异步通知,并介绍了一种调试驱动的方法。
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/syscalls.h>
#include <linux/unistd.h>
#include <linux/miscdevice.h>
#include <linux/platform_device.h>
#include <linux/uaccess.h>
#include <linux/string.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/pxa3xx-regs.h>
#include <asm/arch/mfp-pxa300.h>
#include <asm/arch/gpio.h>
#include <asm/uaccess.h> //用于内核线程
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/errno.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/wait.h>
#include <asm/semaphore.h>
#include "pmb.h"
#define PB_DEVICE_NAME "william_pmb"
//#define DEBUG
#ifdef DEBUG
#define pr_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
#else
#define pr_debug(fmt, arg...) printk(KERN_INFO fmt, ##arg)
#endif
/*
用于调试驱动的一种方法。
其中printk函数中的参数,定义于<linux/kernel.h>。
#define KERN_EMERG "<0>" /* system is unusable紧急事件消息,系统崩溃前提示,表示系统不可用*/
#define KERN_ALERT "<1>" /* action must be taken immediately 报告消息,表示必须马上采取措施*/
#define KERN_CRIT "<2>" /* critical conditions临界情况,通常用于涉及严重的硬件或软件操作失败*/
#define KERN_ERR "<3>" /* error conditions错误情况,驱动程序常用来报告硬件错误*/
#define KERN_WARNING "<4>" /* warning conditions警告,对可能出现问题的情况进行警告*/
#define KERN_NOTICE "<5>" /* normal but significant condition正常但又重要的情况,常用于提醒与安全相关的消息*/
#define KERN_INFO "<6>" /* informational提示信息*/
#define KERN_DEBUG "<7>" /* debug-level messages调试级别消息*/
*/
/*硬件上的一些定义*/
#define PECR_E0IS (1 << 29) // EXT_WAKEUP<0> Interrupt Status
#define PECR_E0IE (1 << 28) // EXT_WAKEUP<0> Pin Interrupt Enable
#define PECR_DIR0(1 << 4) //Direction for EXT_WAKEUP<0>: 0/1= input/output
#define PECR_IVE0 (1 << 0) //Input Value for EXT_WAKEUP<0>
//Currently we have
#define IRQ_WAKEUP0 PXA_IRQ(49) /* EXT_WAKEUP0 */
#define IRQ_WAKEUP1 PXA_IRQ(50) /* EXT_WAKEUP1 */
//一个重要的全局结构体
static struct powerkey_t pwk;
/*
struct powerkey_t
{
int ifopen; //check if device is opened
unsigned int pressed; //current key state [0/1=release/press]
int event; //event: [0/1/2/3=narmal/sleep/deepsleep/wakeup]
wait_queue_head_t keywaitq; //powerkey queue
struct tast_struct *p_thread;
int checkforsleep; //check if which event for sleep
int ifhandshake; //check if need to handshake with app[]
int handshake;
struct fasync_struct *pwrkey_async_queue;
int ifreleasehandshakecnt; //0: you can release handshake. >0: can't release handshake
};
*/
static int pb_handshake(int sig,int mode);
static int wakeup_init(void)
{
PECR |= PECR_E0IE; //enable wakeup0 interrupt
PECR &= ~PECR_DIR0; //as input
return 0;
}
static int disable_wakeup(void)
{
PECR &= ~PECR_E0IE; //disable wakeup0 interrupt
return 0;
}
static int wakeup_ack_irq(void)
{
PECR |= PECR_E0IS; //interrupt state, write 1 to clear
return 0;
}
static int pb_sleep_exe(int sleep)
{
int ret;
struct file *fd;
mm_segment_t old_fs;
//printk("%s\n",__FUNCTION__);
fd = filp_open("sys/power/state",O_RDWR,0);
if(IS_ERR(fd))
{
printk("Open sys/power/state fail,ret = %ld \n",IS_ERR(fd));
return -1;
}
old_fs = get_fs();
set_fs(KERNEL_DS);
switch(sleep)
{
case SLEEP_EVENT:
printk("sleep!\n");
ret = fd->f_op->write(fd,"mem",3,&fd->f_pos);
if(ret != 3)
{
printk("Write to sleep fail!\n");
}
//printk("sleep write ok!\n");
break;
case DEEPSLEEP_EVENT:
ret = fd->f_op->write(fd,"deepsleep",9,&fd->f_pos);
if(ret != 9)
{
printk("Write to deepsleep fail!\n");
}
break;
default:
break;
}
set_fs(old_fs);
filp_close(fd ,NULL);
return 0;
}
/*
内核文件操作
strcut file* filp_open(const char* filename, int open_mode, int mode);
该函数返回strcut file*结构指针,供后继函数操作使用,该返回值用IS_ERR()来检验其有效性。
操作之前先要定位
void set_fs(mm_segment_t fs);
该函数的作用是改变kernel对内存地址检查的处理方式,其实该函数的参数fs只有两个取值:USER_DS,KERNEL_DS,分别代表用户空间和内核空间
get_fs(); 取得当前的设置
off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
offset是偏移量。
若origin是SEEK_SET(0),则将该文件的位移量设置为距文件开始处offset 个字节。
若origin是SEEK_CUR(1),则将该文件的位移量设置为其当前值加offset, offset可为正或负。
若origin是SEEK_END(2),则将该文件的位移量设置为文件长度加offset, offset可为正或负。
ret = fd->f_op->write(fd,"mem",3,&fd->f_pos); 文件读写函数
最后关闭文件 int filp_close(struct file*filp, fl_owner_t id);
*/
static int wait_wakeup_handshake(void)
{
int ret;
struct powerkey_t *ppwk = &pwk;
//printk("%s\n",__FUNCTION__);
ppwk->event = WAKEUP_EVENT;
if(ppwk->ifopen > NOOPENED)
{
if(ppwk->ifhandshake == REQUESTHANDSHAKE)
{
if(pb_handshake(SIGIO,POLL_IN))
{
printk("Posting Handshake fail\n");
return -1;
}
else
{
ppwk->handshake = NONEEDHANDSHAKE;
ret = wait_event_interruptible_timeout(ppwk->keywaitq, ppwk->handshake == HANDSHAKE_EVENT_OK, (20*HZ));
if( ret == 0)
{
printk("Wake up handshake timeout\n");
}
}
}
else
{
ppwk->handshake = NONEEDHANDSHAKE;
ret = wait_event_interruptible_timeout(ppwk->keywaitq, ppwk->handshake == HANDSHAKE_EVENT_OK, (20*HZ));
if( ret == 0)
{
printk("Wake up handshake timeout\n");
}
}
}
ppwk->handshake = NONEEDHANDSHAKE;
return 0;
}
static irqreturn_t extwakeup_handle(int irq, void *dev_id)
{
int readreg;
struct powerkey_t *ppwk = &pwk;
//printk("%s\n",__FUNCTION__);
wakeup_ack_irq();
readreg = PECR;
if(readreg & PECR_IVE0)
{
//printk("key is pressed !\n");
ppwk->checkforsleep = NEEDCHECKSLEEP;
ppwk->pressed = KEYPRESSED;
}
else
{
//printk("key released!\n");
ppwk->pressed = KEYRELEASE;
}
wake_up_interruptible(&ppwk->keywaitq);
wakeup_ack_irq();
return IRQ_HANDLED;
}
static int pb_irq_init(void)
{
int err;
//printk("%s\n",__FUNCTION__);
err = request_irq(IRQ_WAKEUP0, &extwakeup_handle,NULL,
"ext_wakeup0_detect", NULL);
return err;
}
static int preevent_sleep(const int sleepevent)
{
int ret;
struct powerkey_t *p = &pwk;
if(sleepevent == DEEPSLEEP_EVENT)
{
if(p->ifopen > NOOPENED)
ret = wait_event_interruptible_timeout(p->keywaitq, p->pressed == KEYRELEASE, (3*HZ));
disable_wakeup();
wakeup_ack_irq();
}
if(p->ifopen > NOOPENED)
{
p->handshake = NONEEDHANDSHAKE;
ret = wait_event_interruptible_timeout(p->keywaitq, p->handshake == HANDSHAKE_EVENT_OK, (20*HZ));
if( ret == 0)
{
printk("Handshake timeout\n");
}
p->handshake = NONEEDHANDSHAKE;
}
if(sleepevent == DEEPSLEEP_EVENT)
{
wakeup_init();
wakeup_ack_irq();
}
pb_sleep_exe(sleepevent);
wait_wakeup_handshake();
return 0;
}
static int wait_handshake_sleep(int sleepevent)
{
int ret;
struct powerkey_t *p = &pwk;
p->event = sleepevent;
if(p->ifhandshake == REQUESTHANDSHAKE)
{ //for signal mode
if(pb_handshake(SIGIO,POLL_IN))
{
printk("Posting Handshake fail\n");
return -1;
}
ret = preevent_sleep(sleepevent);
}
else //for polling mode
{
ret = preevent_sleep(sleepevent);
}
return 0;
}
/*
wait_event_interruptible_timeout(queue, condition, timeout)
使用例如:
(1)初始化等待队列
int flags = 0;
wait_queue_head_t select_wait;
init_waitqueue_head(&select_wait);
(2)等待事件的发生(条件满足)
{
...
wait_event_interruptible_timeout(select_wait, flags != 0, HZ/10);
...
}
(3)唤醒等待队列
{
...
if(waitqueue_active(&select_wait))
{
flags = 1;
wake_up_interruptible( &nd->select_in_wait );
}
...
}
*/
static int driver_data_init(void)
{
struct powerkey_t *ppwk = &pwk;
if(PECR & PECR_IVE0)
{
ppwk->pressed = KEYPRESSED;
}
else
{
ppwk->pressed = KEYRELEASE;
}
ppwk->ifopen = NOOPENED;
ppwk->event = NORMAL_EVENT;
ppwk->handshake = NONEEDHANDSHAKE;
ppwk->checkforsleep = NONEEDCHECKSLEEP;
ppwk->ifhandshake = FREEHANDSHAKE;
ppwk->ifreleasehandshakecnt = 0;
init_waitqueue_head(&ppwk->keywaitq);
return 0;
}
static int powerkey_thread(void *data)
{
struct powerkey_t *ppwk = &pwk;
long ret;
// unsigned long flags;
//printk("%s\n",__FUNCTION__);
while(!kthread_should_stop())
{
set_current_state(TASK_INTE
最新技术文章:
 
站内导航:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!