寻觅生命中的那一片浅草......

文章属于类别 Cacti

spine的make错误:cannot find -lz

./configure时没有报错
/usr/bin/ld: cannot find -lz

vi config.log
搜索lz
可以看到如下错误

configure:19207: $? = 0
configure:19210: test -s conftest
configure:19213: $? = 0
configure:19226: result: yes
configure:19240: checking for deflate in -lz
configure:19270: gcc -o conftest -g -O2 conftest.c -lz -lpthread -lm >&5
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
configure:19276: $? = 1
configure: failed program was:
| /* confdefs.h. */

Google下checking for deflate in -lz,发现跟zlib有关
yum -y install zlib-devel

就可以正常make了

SysAdmin to SysAdmin: Making use of SNMP

“Simple Network Management Protocol” is a relative term. To the uninitiated, raw SNMP output, along with arcane technobabble like “MIB” and “ASN.1,” looks a little daunting. Developing some understanding of how to parse and filter SNMP information doesn’t take long, though, and can put you on a fast track to making SNMP bend to your whim.

The first thing to know about SNMP is that it is a service that is structured such that an SNMP agent sitting on a target host can be queried by remote hosts for various bits of information. Only the target host (the one you want information about) needs to be running an SNMP daemon. The client making the queries just needs some tool capable of making SNMP queries and parsing the output. Most Linux server and client tools are supplied by the Net-SNMP project. A quick poke around your system to locate snmpwalk or snmpget should let you know in short order if you have the client tools installed. The server daemon is called, predictably, snmpd.

The easiest way to get familiar with how SNMP works is to set it up on your own Linux system. Since this might be the piece of machinery with which you are also the most familiar, it’ll also be a great way to see the sheer power of SNMP. Since most Linux distributions come with a Net-SNMP daemon, I’m going to forgo discussing installation and head right to configuration.

Configuring snmpd

If you maintain a lot of services, you’re probably tired of having to remember which directive handles what in all of the differently formatted config files. Apache, BIND, Sendmail, LDAP, NIS, NFS, and SSH all have different formats — and that’s just the beginning. You’ll be relieved to know that SNMP has a really great configuration tool called snmpconf. Veteran sysadmins will be happy to know that this is a command-line tool. New admins will have to suck it up!

Seriously, though, if you just want to get a very quick configuration put together, try running snmpconf -g basic_setup, and you’ll be able to set up what you need in order to see what the daemon has to offer. For those who have more than three minutes on their hands and want more control over the configuration, simply running snmpconf will prompt you with menus to configure the different aspects of the running daemon. The questions are very easy and completely self-explanatory (I’d even venture to say elementary) for any Linux or Unix sysadmin. Once you finish, move the resulting snmpd.conf file into place, and start the snmpd daemon.

Once the daemon is started, try pasting this into your terminal and pressing Enter: snmpwalk -v2c -c public localhost tcp. Here’s some output from my laptop:

TCP-MIB::tcpConnState.0.0.0.0.22.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.111.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.199.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.32768.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.25.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.631.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.32769.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.32776.127.0.0.1.631 = INTEGER: closeWait(8)

This is just a chunk of output, and as you can probably discern, it’s telling me which ports I have open (they’re in state “listen”). For the record, recent Net-SNMP packages come with a command called snmpnetstat that does this and more for you. But the point is that SNMP can tell you just about anything you want to know about the running system, but this output doesn’t reveal very much about SNMP itself.

Let’s alter the command like this: snmpwalk -On -v2c -c public localhost tcp. The -On flag tells the client to return the numeric OID or object ID string instead of abbreviating it using the MIB used to parse said OID. What’s an OID? Glad you asked. Let’s look at the output:

.1.3.6.1.2.1.6.13.1.1.0.0.0.0.22.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.0.0.0.0.111.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.0.0.0.0.199.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.0.0.0.0.32768.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.127.0.0.1.25.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.127.0.0.1.631.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.127.0.0.1.32769.0.0.0.0.0 = INTEGER: listen(2)
.1.3.6.1.2.1.6.13.1.1.127.0.0.1.32776.127.0.0.1.631 = INTEGER: closeWait(8)

My favorite output flag, though, is -Of, which parses each of the numbers above into a human-readable (if very long) name.

The OID in the above output is everything before the equals-sign. It’s called an object ID because SNMP stores every piece of data as an object. Furthermore, those objects are identified internally as numbers, which get parsed into names on the client side, using a Management Information Base (MIB) file. A MIB is a human-readable text file which is actually extremely handy, since it contains all of the descriptions for the different pieces of data returned. If you’re not sure if a particular piece of data is what you’re looking for, heading for the MIB file that parsed it is usually a good way to find the answer.

For example, in the first output listing, you can see something called “tcpConnState.” At the very beginning of each line, you also see “TCP-MIB.” If you want to see a better description of what this value really means, you need to find a file on your system called TCP-MIB.txt; on my Fedora Core 2 machine, MIBs are in /usr/share/snmp/mibs. grep for “tcpConnState” in the file, and scroll down to the description to see what it says. NOTE: Descriptions aren’t always useful. Generally, though, the standard MIBs (i.e., not vendor-supplied ones) are good enough to get a clue.

So what’s with the long numbers as OIDs? That’s ASN.1 notation. Abstract Syntax Notation provides a standard way of describing data independent of any language or application. Agents are written to provide data using ASN.1, and client applications are written to handle that data in any language and in any way the developers see fit. The goal is generalization, and it would appear that it works. LDAP and SNMP both use ASN.1 notation, and the tools built around these two protocols (snmpwalk, ldapsearch, etc.) handle the task of making the output readable by humans. In LDAP parlance, a MIB is called a “schema.” The rest is very similar from a data representation perspective.

For SNMP data (as well as LDAP), the ASN.1 numbers actually represent a hierarchical structure — similar to the way the directory on your system is hierarchical in nature. In fact, you could look at the numeric output above, and think of .1 as the / or root directory. The fact that it’s followed by a 3 would seem to imply that there are at least two other nodes under that top-level node, and you’d be right in assuming that. The same goes for all of the numbers all the way down the line. In fact, you could think of the command snmpwalk -Of -v2c -c public localhost tcp as simply running ls -lR on the tcp directory within the hierarchy.

What SNMP can do for you

Here are some quick one-liners that illustrate some cool stuff about your system. These were tested on my FC2 laptop, as well as a SUSE 9.1 workstation:

* snmpwalk -Ov -OQ -v2c -c public localhost .1.3.6.1.2.1.25.6.3.1.2

This lists the names of every installed package on the machine. It essentially does the same thing as rpm -qa on an RPM-based distro, but it’s slightly easier to grab the information from a remote location using SNMP. There are lots of those -O flags available. The O stands for “output,” and you can stack them as I’ve done here in order to strip out everything but the actual value. For more on this, see the snmpcmd manpage.
* snmpwalk -Of -v2c -c public localhost interfaces | grep “.2 =”

This walks the interfaces directory and grabs anything pertaining to what amounts to “interface 2.” The interfaces are indexed numerically, and interface 1 is generally the loopback. For each interface, a host of values is displayed, so if you run something like this on a huge switch and aggregate and parse the data, you can create some extremely useful data.
* snmpwalk -OQ -Ov -v2c -c public localhost .1.3.6.1.2.1.25.4.2.1.2

This gets you a quick list of the programs running on a remote (or in this case, a local) host. The processes are also indexed, and you can get other information about them if you want to do a little scripting.

Plenty more where this came from

This is the tip of the iceberg. For avid scripters, I’ve used both the Perl and PHP SNMP interfaces, and both are immensely useful. Also, don’t think that SNMP is limited in use to Linux boxen; SNMP agents have been written for everything from large UPS units to tiny humidity sensors that’ll send a trap if your machine room starts to resemble a swampland. If there’s something in your environment with an Ethernet jack on it, there’s probably an SNMP agent for it.

I haven’t even mentioned the notion of actually making configuration changes via the snmpset command, but I urge you to investigate it for yourself. There’s a whole SNMP world out there waiting for you, and taking advantage of it can make your life as an administrator infinitely easier.

转载自:http://www.linux.com/archive/articles/113774

CentOS_4.6_Cacti短信报警设置

首先
参考安装Cacti的插件
http://www.php-oa.com/2009/06/04/plugin-architecture.html
参考设置邮件报警,并确认邮件报警是生效的,否则短信报警不会生效
http://www.hiadmin.com/cacti%E9%85%8D%E7%BD%AEe-mail%E6%8A%A5%E8%AD%A6/

然后,安装飞信
mkdir /root/downloadsss/fetion
cd /root/downloadsss/fetion
下载飞信主程序
wget http://www.it-adv.net/fetion/downng/fetion20090406003-linux.tar.gz
下载飞信用到的库
wget http://www.it-adv.net/fetion/downng/library_linux.tar.gz

mkdir -p /usr/local/tools/fetion/
cd /usr/local/tools/fetion/
tar xzf /root/downloadsss/fetion/fetion20090406003-linux.tar.gz
mv install/ fetion_src
mkdir /usr/local/tools/fetion/lib

释放fetion会用到的库
tar -xzvf /root/downloadsss/fetion/library_linux.tar.gz -C /usr/local/tools/fetion/lib
cd /usr/local/tools/fetion/lib
ln -s libcrypto.so.0.9.8 libcrypto.so.4
ln -s libssl.so.0.9.8 libssl.so.4

###################如果你是CentOS5以上版本(例如CactiEZ9.0),则无需做以下操作#################
由于是在CentOS4.6上安装fetion,所以需要拷贝CentOS5上的一些库文件,幸好网上有人找出来打包好了,下载来用就可以了
下载CentOS4会用到的库
cd /root/downloadsss/fetion
wget http://xok.la/file/2009/04/fetion_lib_rhel4_xok.zip
cd /usr/local/tools/fetion/
unzip /root/downloadsss/fetion/fetion_lib_rhel4_xok.zip
这个fetion_lib_rhel4_xok.zip包里的库文件也不是很全,启动飞信时,提示少一个libgcc_s.so.1,我们去我们自己的CentOS 5.2上scp一个过来
scp 192.168.0.110:/lib/libgcc_s.so.1 /usr/local/tools/fetion/lib
########################如果你是CentOS5以上版本,则无需做以上操作#################

编写飞信的启动脚本
vi /usr/local/tools/fetion/fetion
添加以下内容
#!/bin/bash
prefix=/usr/local/tools/fetion/
LD_LIBRARY_PATH=”$prefix/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}”
export LD_LIBRARY_PATH
$prefix/lib/ld-linux.so.2 /usr/local/tools/fetion/fetion_src/fetion “$@”

保存退出
chmod 755 /usr/local/tools/fetion/fetion

至此,飞信就安装好了。

最后,编辑cacti/plugins/thold/thold-functions.php
在thold–functions.php查找function thold_mail($to, $from, $subject, $message, $filename, $headers = ”)行在此行下面加入:
file_put_contents(’/var/www/cacti/plugins/thold/alert.log’, $subject);  # 用file_put_contents函数将$subject写入alert.log文件
exec(’echo $subject  >> /var/www/cacti/plugins/thold/alert.log’);  # 换行
exec(’date +%D/%T  >> /var/www/cacti/plugins/thold/alert.log’); #加入时间标签
exec(’sh /var/www/cacti/plugins/thold/sendsms.sh’);  #执行飞信机器人脚步

编写脚本sendsms.sh自动调用飞信机器人发送报警

#!/bin/sh
#send sms by fetion
#Write by Ethan.Pan
if [ ! -e “/var/www/cacti/plugins/thold/alert.log” ]; then
echo “Usage:alert.log does not exist”
elif [ -n “`cat /var/www/cacti/plugins/thold/alert.log`” ]; then
echo `cat /var/www/cacti/plugins/thold/alert.log`
/usr/local/tools/fetion/fetion –mobile=18888888888 –pwd=123456 –to=1888888882 –msg-type=1 –file-utf8=/var/www/cacti/plugins/thold/alert.log
echo “`cat /var/www/cacti/plugins/thold/alert.log`” >> /var/www/cacti/plugins/thold/sms.txt
echo “exit” >> /var/www/cacti/plugins/thold/sms.txt
echo “Usage:all sms sends”
fi

主要参考文章:
http://hi.baidu.com/ethanpan/blog/item/0c6d0bf0d1ce0ba7a50f5237.html
http://xok.la/2009/03/fetion_2009_to_rhel4_linux4.html
http://www.hiadmin.com/cacti%E9%85%8D%E7%BD%AEe-mail%E6%8A%A5%E8%AD%A6/
http://www.php-oa.com/2009/06/04/plugin-architecture.html

thold设置报警无法获取所有数据源

解决方法:将thold_add.php的第490-523行替换成
if ($graph != ”) {
$dt = db_fetch_assoc(‘SELECT DISTINCT data_template_rrd.local_data_id
FROM data_template_rrd
LEFT JOIN graph_templates_item ON graph_templates_item.task_item_id = data_template_rrd.id
LEFT JOIN graph_local ON graph_local.id=graph_templates_item.local_graph_id
WHERE graph_local.id = ‘ . $graph);
/* show the data source options */
?>
<tr>
<td width=’70’ style=’white-space:nowrap;’>
&nbsp;<b>Data Source:</b>
</td>
<td>
<select name=dsid onChange=”applyTholdFilterChange(document.tholdform, ‘ds’)”>
<option value=””></option><?php
foreach ($dt as $row1) {
$dss = db_fetch_assoc(‘SELECT DISTINCT id, data_source_name
FROM data_template_rrd
WHERE local_data_id = ‘ . $row1[‘local_data_id’] . ‘ ORDER BY data_source_name’);
foreach ($dss as $row) {
echo “<option value='” . $row[‘id’] . “‘” . ($row[‘id’] == $ds ? ‘ selected’ : ”) . ‘>’ . $row[‘data_source_name’] . ‘</option>’;
}}?>
<input type=hidden name=dt value=”<?php print $row1[‘local_data_id’];?>”>
</select>
</td>
</tr><?php
} else {
?>
<tr>
<td>
<input type=hidden name=dsid value=””>
</td>
</tr><?php
}

来自over大神

Cacti无法登陆故障解决一例

Cacti0.87b,今天发现不能登陆。

具体表现为:

用户名/密码输入正确、数据库的user_log表中正确记录了登录信息,并且result为1(验证成功),但是页面始终停留在index.php,不能进入

查资料得知,这个现象大多时候是因为php的session异常。

经检查发现,在这台机器上,由于另一服务的日志突然暴增,导致/分区的磁盘容量用尽,session无地方可写。删除异常的日志文件后,问题得到了解决。

另:

cacti的密码是MD5加密的,可以在登录mysql后,用这种方式重置密码

UPDATE user_auth SET password=MD5(“yourpassword”) WHERE username=’admin’

session.save_handler = files

session.save_path = “/tmp”

转载自:http://www.dbalife.com/archives/146.html

2024年十月
« 5月    
 123456
78910111213
14151617181920
21222324252627
28293031