[Nagios-devel] [PATCH] Add simple grep support (using strstr - no

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [PATCH] Add simple grep support (using strstr - no

Post by Guest »

This is a multi-part message in MIME format.
--------------090801090400070908040509
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=UTF-8; format=flowed

Adds options grep= and vgrep=

Matthew

Sorry about the blurb below.


This message (including any attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorised use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. Close Premium Finance shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt or damage to your system. Close Premium Finance does not guarantee that the integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference.

Close Premium Finance, Registered in England and Wales, Registered Office: 10 Crown Place, London, EC2A 4FT. Authorised and regulated by the Financial Services Authority
Close Brothers Limited and Close Premium Finance (Ireland) Ltd trading as Close Premium Finance Ireland are authorised and regulated by the Financial Services Authority in the UK, Registered Office: 10 Crown Place, London, EC2A 4FT.
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service.
--------------090801090400070908040509
Content-Transfer-Encoding: 7bit
Content-Type: text/x-patch;
name="showlog-grep.diff"
Content-Disposition: inline;
filename="showlog-grep.diff"

--- showlog.c 2008-01-09 17:51:23.000000000 +0000
+++ showlog-grep.c 2009-01-21 10:06:44.000000000 +0000
@@ -58,6 +58,8 @@
int display_header=TRUE;
int display_frills=TRUE;
int display_timebreaks=TRUE;
+char *grep=NULL;
+int vgrep=FALSE;


int main(void){
@@ -257,6 +259,20 @@
log_archive=0;
}

+ /* we found the archive argument */
+ else if(!strcmp(variables[x],"grep")
+ || !strcmp(variables[x],"vgrep")){
+ if (*variables[x] == 'v')
+ vgrep=TRUE;
+ x++;
+ if(variables[x]==NULL){
+ error=TRUE;
+ break;
+ }
+
+ grep=strdup(variables[x]);
+ }
+
/* we found the order argument */
else if(!strcmp(variables[x],"oldestfirst")){
use_lifo=FALSE;
@@ -360,178 +376,181 @@

strip(input);

- if(strstr(input," starting...")){
- strcpy(image,START_ICON);
- strcpy(image_alt,START_ICON_ALT);
- }
- else if(strstr(input," shutting down...")){
- strcpy(image,STOP_ICON);
- strcpy(image_alt,STOP_ICON_ALT);
- }
- else if(strstr(input,"Bailing out")){
- strcpy(image,STOP_ICON);
- strcpy(image_alt,STOP_ICON_ALT);
- }
- else if(strstr(input," restarting...")){
- strcpy(image,RESTART_ICON);
- strcpy(image_alt,RESTART_ICON_ALT);
- }
- else if(strstr(input,"HOST ALERT:") && strstr(input,";DOWN;")){
- strcpy(image,HOST_DOWN_ICON);
- strcpy(image_alt,HOST_DOWN_ICON_ALT);
- }
- else if(strstr(input,"HOST ALERT:") && strstr(input,";UNREACHABLE;")){
- strcpy(image,HOST_UNREACHABLE_ICON);
- strcpy(image_alt,HOST_UNREACHABLE_ICON_ALT);
- }
- else if(strstr(input,"HOST ALERT:") && (strstr(input,";RECOVERY;") || strstr(input,";UP;"))){
- strcpy(image,HOST_UP_ICON);
- strcpy(image_alt,HOST_UP_ICON_ALT);
- }
- else if(strstr(input,"HOST NOTIFICATION:")){
- strcpy(image,HOST_NOTIFICATION_ICON);
- strcpy(image_alt,HOST_NOTIFICATION_ICON_ALT);
- }
- else if(strstr(input,"SERVICE ALERT:") && strstr(input,";CRITICAL;")){
- strcpy(image,CRITICAL_ICON);
- strcpy(image_alt,CRITICAL_ICON_ALT);
- }
- else if(strstr(input,"SERVICE ALERT:") && strstr(input,";WARNING;")){
- strcpy(image,WARNING_ICON);
- strcpy(image_alt,WARNING_ICON_ALT);
- }
- else if(strstr(input,"SERVICE ALERT:") && strstr(input,";UNKNOWN;")){
- strcpy(image,UNKNOWN_ICON);
- strcpy(image_alt,UNKN

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked