Looking at the different processes that are needed.
Server A is a database server that you want to monitor in detail. You can obtain relevant stats on this machine that you want to display using MRTG but you do not want to run MRTG on this server.
Server B is a server running (possibly multiple instances of) MRTG and Apache. MRTG will collect stats from a variety of servers and network devices using SNMP and other protocols, update its databases and the display pages for each statistic monitored. This server would usually also display pages relating to the structure and configuration of the network (some static, some dynamic content).
There are multiple HTTP clients wanting to see the MRTG web pages on server B. If there was only one client then Apache is not needed on server B as a suitably privileged client could display the MRTG HTML files without the need for a web server (e.g. using sshfs
)
So, if you have multiple clients and do not want to run the Apache (or other web server) process on Server A you have to make the statistics data available at appropriate time intervals to the MRTG process(es) on Server B. SNMP is a common way of doing this when using MRTG, not least because MRTG's origins, as the name suggests, are in monitoring network devices where SNMP is the de facto management mechanism. Servers do not always have SNMP processes running and many statistics of interest are not exposed via SNMP MIBs. Hence,
A) If the statistics you need are exposed via an SNMP MIB variable on server A and the server is running an SNMP daemon then MRTG on server B can be configured to use SNMP to obtain the variable's values. You will need to make the usual checks that the data is reliable, whether it needs any conversion (e.g. string to integer via a ConversionCode) and if it is gauge or absolute (or perhaps derive, if using RRDTool), for example.
B) Else use an external monitoring script (see MRTG documentation). The classic example is using ping
on the MRTG server and graphing the results from that. However, it is equally possible to run a process on server A to collect the data, transfer it to server B (e.g. using sftp
or ssh
) and then reading the data via the external MRTG script (possibly after some pre-processing: e.g. a file of information can be read across from server A to server B and then split into multiple files to be read by multiple external MRTG scripts). There are scripts available that others have written and which may be suitable for a given purpose or at least give a start on writing or customising one for your particular requirement.