This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
simple_snmp [2007/08/28 23:40] adam created |
simple_snmp [2016/11/25 22:38] (current) |
||
---|---|---|---|
Line 11: | Line 11: | ||
Most networking devices such as routers (even home consumer routers) and managed switches offer SNMP support. The most common usage of SNMP is in querying for system status information as described above, but it is also possible to write values to a system using SNMP and using certain types of system events as what are called SNMP traps, which are sent to a monitoring system which will generate alerts for the system administrators. Neither SNMP writes or SNMP traps are discussed here. Perhaps they will be in an update at some point. | Most networking devices such as routers (even home consumer routers) and managed switches offer SNMP support. The most common usage of SNMP is in querying for system status information as described above, but it is also possible to write values to a system using SNMP and using certain types of system events as what are called SNMP traps, which are sent to a monitoring system which will generate alerts for the system administrators. Neither SNMP writes or SNMP traps are discussed here. Perhaps they will be in an update at some point. | ||
- | I once heard SNMP be described as, "The S in SNMP is for simple, but that does not mean it is trivial." | + | Information is stored in a tree like structure as far as SNMP is concerned. MIBs (Management Information Bases) are essentially like branches on the tree, they are groups of related SNMP data, such as system data, interface data etc. OIDs (object identifiers) are leaves on the tree, that is, they are individual items of queryable data, as defined in the MIBs. Phew. Technical. OIDs are normally numeric values, but thankfully most have human memorable names. MIBs are stored as text files under / |
+ | |||
+ | Many network hardware vendors provide MIBs which map their specific hardware information (temperatures, | ||
+ | |||
+ | I once heard SNMP described as, "The S in SNMP is for simple, but that does not mean it is trivial." | ||
==== Install Software ==== | ==== Install Software ==== | ||
- | On all machines install the SNMP daemon or service. Most SNMP implementation | + | On all machines install the SNMP daemon or service. Most SNMP implementations |
=== For Fedora/Red Hat/CentOS === | === For Fedora/Red Hat/CentOS === | ||
Line 70: | Line 75: | ||
Syslocation is an arbitrary string which says where the machine is physically located and the syscontact is the email address of the system administrator. | Syslocation is an arbitrary string which says where the machine is physically located and the syscontact is the email address of the system administrator. | ||
- | Much of the above config is taken from [[http:// | + | Much of the above config is taken from [[http:// |
So, restart your SNMP daemon to come up with the new config. | So, restart your SNMP daemon to come up with the new config. | ||
Line 86: | Line 91: | ||
==== Set Up Your SNMP Query Host ==== | ==== Set Up Your SNMP Query Host ==== | ||
- | You need a machine to make requests from and this should be the machine which you have in your SNMP configuration on the other machines. For Windows, I don't know what you're going to do, I don't use Windows for anything network related, so you're on your own. You'll probably have to pay someone money for some software, but you could try starting with the snmp command or look at PRTG for graphing, | + | You need a machine to make requests from and this should be the machine which you have in your SNMP configuration on the other machines. For Windows, I don't know what you're going to do, I don't use Windows for anything network related, so you're on your own. You'll probably have to pay someone money for some software, but you could try starting with the snmp command or look at PRTG for graphing, |
On Fedora: | On Fedora: | ||
Line 95: | Line 100: | ||
apt-get install snmp | apt-get install snmp | ||
+ | |||
==== Running SNMP Queries ==== | ==== Running SNMP Queries ==== | ||
Line 102: | Line 108: | ||
snmpwalk -c < | snmpwalk -c < | ||
- | ...where < | + | ...where < |
You can do the same but specify a subset of OIDs to query: | You can do the same but specify a subset of OIDs to query: | ||
Line 112: | Line 118: | ||
snmpwalk -c < | snmpwalk -c < | ||
- | Good huh? | + | for system related OIDs. Good huh? |
==== Graphing Your Output ==== | ==== Graphing Your Output ==== | ||
Line 118: | Line 125: | ||
So, you want to do something useful with your SNMP output, because it's just a great big list of crap? On Linux, use [[http:// | So, you want to do something useful with your SNMP output, because it's just a great big list of crap? On Linux, use [[http:// | ||
- | The following example details how to get bandwidth usage graphs. You can take it further by reading [[http:// | + | The following example details how to get bandwidth usage graphs. You can take it further by reading [[http:// |
=== Install MRTG === | === Install MRTG === | ||
Line 130: | Line 137: | ||
yum install mrtg | yum install mrtg | ||
- | Your distro will probably create you a directory under /var/www for mrtg so try http:// | + | Your distro will probably create you a directory under /var/www for mrtg so try http:// |
Next you need to create some MRTG config files for the hosts you will query: | Next you need to create some MRTG config files for the hosts you will query: | ||
Line 156: | Line 163: | ||
Add the following line to the crontab of a user which is able to write to your web server' | Add the following line to the crontab of a user which is able to write to your web server' | ||
- | | + | '' |
+ | |||
+ | This will make MRTG collect stats via SNMP every 5 minutes. Do the same for any other hosts you wish to graph. Note that I have redirected all standard output and errors to /dev/null, so I don't have to hear about it if it doesn' | ||
+ | |||
+ | And that, my friend, is it. | ||
+ | |||
+ | ==== Going Further ==== | ||
+ | |||
+ | You should try graphing other data such as CPU, disk and memory usage, system load, component temperatures and so on. MRTG is able to graph anything which you pass it information for and SNMP can make most of that information available over a network. Cacti is an alternative to MRTG for graphing other variables and is probably far easier. Investigate SNMP v3 for a more secure implementation. For lower CPU load, try replacing the default graphing tool in MRTG with RRDTool which was written by the same guy as MRTG. | ||
+ | |||
+ | TODO: | ||
- | This will make MRTG collect stats via SNMP | + | Links |