How to monitor remote Linux machines and retrieve installed software in Perl?
I have a couple of Perl scripts that allow me to monitor remote Windows machinses through WMI. Right now I can check CPU usage, Memory usage, Disk usage and Installed Software. But what if I want to do the same job on a remote Linux machine? Ofcourse there's no WMI so I guess I shall use something similar. I have read on another old StackOverflow question that Linux exposes informations through /proc and /sys but can I query them from a remote computer? And how can I do that exactly in Perl? Is there a dedicated module?
EDIT: Just to clarify, the script MUST be agent-free.
Check these :
This will give you memory / disk usage :
snmptable -v1 -c public localhost hrStorageTable snmptable -v1 -c public localhost .22.214.171.124.126.96.36.199.3
This will give you processor utilisation :
snmptable -v1 -c public localhost hrProcessorTable snmptable -v1 -c public localhost .188.8.131.52.184.108.40.206.3
Interface Status :
snmptable -v1 -c public localhost ifTable snmptable -v1 -c public localhost .220.127.116.11.18.104.22.168
If you use rpm-based linux, this will give you installed software :
snmptable -v1 -c public localhost hrSWInstalledTable snmptable -v1 -c public localhost .22.214.171.124.126.96.36.199.3
You can make this work for .deb flavours of linux :
Sample output of `snmptable -v1 -c public localhost hrProcessorTable` hrProcessorFrwID hrProcessorLoad SNMPv2-SMI::zeroDotZero 54 SNMPv2-SMI::zeroDotZero 22
On the box you are querying, does public have read access to .188.8.131.52.2.1.25 ?
You may need to add something like this to your /etc/snmp/snmpd.conf
com2sec monitor default monitor group monitorGroup v1 monitor group monitorGroup v2c monitor view hardware included .184.108.40.206.2.1.25 view hardware included .220.127.116.11.2.1.2 access monitorGroup "" any noauth exact hardware none none
The restart snmpd
Then specify -c monitor in the commands above instead of -c public