运维监控利器Zabbix
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供柔软的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux, Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X等平台上。
zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。zabbix agent可以运行在Linux,Solaris,HP-UX,AIX,FreeBSD,Open BSD, OS X, Tru64/OSF1, Windows NT4.0, Windows 2000/2003/XP/Vista)等系统之上。
zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(agent方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。
另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。
1.安装必要的软件和库
安装mysql的头文件及库文件、net-snmp、curl、gcc、make
1 2 3 4 5 | yum install mysql-devel.x86_64 yum install net-snmp.x86_64 net-snmp-devel.x86_64 net-snmp-utils.x86_64 yum install curl.x86_64 curl-devel.x86_64 yum install gcc.x86_64 libgcc.i386 libgcc.x86_64 yum install make |
2.编译安装zabbix
从zabbix的官网下载源代码,进行解压缩(略)
编译安装zabbix,注意:连同agent一起编译
1 2 | #./configure -prefix=/app/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl |
创建zabbix用户
1QT中自定义控件的布局问题 阅读原文» 用户名:kingfly0302 文章数:5 评论数:0 对于普通的QWidget控件,我们可以很容易的通过QLayout, QBoxLayout, QHBoxLayout之间的嵌套完成对众多系统控件的很漂亮的布局,但是对于自定义控件,我们会感觉很纠结,因为QGraphicsLayoutItem, QGraphicsLayout都不能够添加自定义控件,只有QGraphicsLinearLayout的addItem可以添加QGraphicsLayoutItem类型的元素(可能是布局,也可能是控件),我们发现存在如下的继承关系 这样我们就可以通过QGraphicsWidget在场景中间接地添加控件,使用这种方法之后不需要再向scene中添加控件,只需要一次将含有layout的控件widget直接加到布局中scene中即可。 QGraphicsLinearLayout *linearLayout = new QGraphicsLinearLayout(Qt::Vertical); QGraphicsWidget *widget = new QGraphicsWidget; linearLayout->addItem(linkLabel); linearLayout->addItem(appLabel); widget->setLayout(linearLayout); scene->addItem(widget); 这里的linkLabel和appLabel是我们自定义的两个控件,scene就是场景了,但是这种方式添加的控件会存在一定的问题,这里为了说明方便,给出主函数的全部代码 #include <QtGui> #include <QGraphicsLayoutItem> #include "showlabel.h" #include "clickhandler.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QGraphicsScene *scene = new QGraphicsScene; QGraphicsView *view = new QGraphicsView(scene); ShowLabel *linkLabel = new ShowLabel("www.hao123.com"); //设置字体 QFont linkFont("Arial", 20, QFont::Bold, true); linkLabel->setFont(linkFont); //设置下划线 linkLabel->setUnderline(true); //设置颜色 QColor linkColor(255, 0, 0); linkLabel->setColor(linkColor); ShowLabel *appLabel = new ShowLabel("open app"); //设置字体 QFont appFont("times", 20, QFont::Bold, true); appLabel->setFont(appFont); //设置下划线 appLabel->setUnderline(true); //设置颜色 QColor appColor(0, 255, 0); appLabel->setColor(appColor); //设置控件的大小 linkLabel->setPreferredSize(rectLink.width(), rectLink.height()); ClickHandler *clickHandler = new ClickHandler(view); QObject::connect(linkLabel, SIGNAL(clicked()), clickHandler, SLOT(on_linkOpen())); QObject::connect(appLabel, SIGNAL(clicked()), clickHandler, SLOT(on_messageBox())); QRectF rectApp = appLabel->getRect(); //appLabel->setMaximumSize(rectApp.width(), rectApp.height()); //设置场景的大小 scene->setSceneRect(0, 0, 300, 300); QGraphicsLinearLayout *linearLayout = new QGraphicsLinearLayout(Qt::Vertical); QGraphicsWidget *widget = new QGraphicsWidget; linearLayout->addItem(linkLabel); linearLayout->addItem(appLabel); widget->setLayout(linearLayout); scene->addItem(widget); QRect rt = linkLabel->getRect(); QRect lt = appLabel->getRect(); //设置视口的大小 view->resize(300, 300); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setWindowTitle(QObject::tr("My hao123 Label")); view->show(); return app.exec(); } 如果这样做将会产生如下的错误 大家可能看到了,下面的一行虽然控件只有字符"open app"宽度的大小,但是却被拉伸了,原因是在使用Qt::Vertical方式布局的时候,系统会自动只关注组件的高度,而组件的宽度将会对齐上一个控件,我想水平方式布局情况也应该是类似的,因此需要增加如下的代码来控制下面的控件的大小 appLabel->setMaximumSize(rectApp.width(), rectApp.height()); 这样就正确了, 这里给出其他的代码 ShowLabel.h #pragma once #ifndef SHOWLABEL_H #define SHOWLABEL_H #include <QGraphicsWidget> class QGraphicsSceneMouseEvent; class QGraphicsSceneHoverEvent; class ShowLabel: public QGraphicsWidget { Q_OBJECT public: ShowLabel(const QString &string); void setText(const QString &string); QString text(); void setFont(const QFont& font); void setColor(const QColor& color); void setUnderline(bool isUnderLine); QRect getRect(); signals: void clicked(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *e); void mouseReleaseEvent(QGraphicsSceneMouseEvent *e); void hoverEnterEvent(QGraphicsSceneHoverEvent *e); void hoverLeaveEvent(); protected: virtual QRectF boundingRect(); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); private: QString m_text; bool m_isPressed; bool m_isUnderLine; QFont m_font; QColor m_penstyle; };
订阅:
博文评论 (Atom)
|
没有评论:
发表评论