To monitor a windows host I use 2 methods, SNMP and NSClient (PerfMon counter). My Nagios agent runs on TCP port 20000.
I use SNMP to monitor NIC stats, this enables me to use the data query of Cacti.
The rest is monitored using the Nagios Client PerfMon Counter functionality.
An example script: All my scripts use the ones you posted as base structure. Thanks for this.
Monitor Exchange Information Store Users
Code: Select all
#!/usr/bin/perl
$response = `/usr/lib/nagios/plugins/check_nt -H $ARGV[0] -p 20000 -v COUNTER -l "\\MSExchangeIS\\User Count"`;
chomp $response;
print "$response\n";
Code: Select all
#!/usr/bin/perl
$proc0_time= `/usr/lib/nagios/plugins/check_nt -H $ARGV[0] -p 20000 -v COUNTER -l "\\Processor(0)\\% Processor Time"`;
chomp $proc0_time;
print "$proc0_time\n";
An example where NSClient Counter interrogation fails:
Code: Select all
#!/usr/bin/perl
$real_scan = `/usr/lib/nagios/plugins/check_antigen -H $ARGV[0] -p 20000 -v COUNTER -l "\\Antigen Scan(Realtime Scan Job,,Logical)\\Total Attachments Scanned"`;
chomp $real_scan;
$real_detect = `/usr/lib/nagios/plugins/check_antigen -H $ARGV[0] -p 20000 -v COUNTER -l "\\Antigen Scan(Realtime Scan Job,,Logical)\\Total Attachments Detected"`;
chomp $real_detect;
$real_clean = `/usr/lib/nagios/plugins/check_antigen -H $ARGV[0] -p 20000 -v COUNTER -l "\\Antigen Scan(Realtime Scan Job,,Logical)\\Total Attachments Cleaned"`;
chomp $real_clean;
$real_remove = `/usr/lib/nagios/plugins/check_antigen -H $ARGV[0] -p 20000 -v COUNTER -l "\\Antigen Scan(Realtime Scan Job,,Logical)\\Total Attachments Removed"`;
chomp $real_remove;
$real_purge = `/usr/lib/nagios/plugins/check_antigen -H $ARGV[0] -p 20000 -v COUNTER -l "\\Antigen Scan(Realtime Scan Job,,Logical)\\Total Messages Purged"`;
chomp $real_purge;
print "real_scan:$real_scan real_detect:$real_detect real_clean:$real_clean real_remove:$real_remove real_purge:$real_purge\n";
Code: Select all
void preparelist(char *string) {
/* Replace all , with & which is the delimiter for the request */
/* If a ,, is detected replace the second , with a space. */
/* It is a counter that has a , in its name */
int i;
for (i = 0; i < strlen(string); i++){
if ((string[i] == ',') && (string[i+1] != ',')){
string[i]='&';
}
if ((string[i] == ',') && (string[i+1] ==',')) {
string[i+1]=' ';
}
}
}