Search
j0ke.net Open Build Service
>
Projects
>
home:netmax
>
nagios-plugins
> check_mysql.c.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File check_mysql.c.patch of Package nagios-plugins (Revision 16)
Currently displaying revision
16
,
show latest
68,87d67 < int strIndexOf(char *string1, char *string2); < char *strSubstring(char *string1, char *string2, int StartingPos, int EndPos); < char *GetThreadsPerfdata(char *stringtoparse); < char *GetQuestionsPerfdata(char *stringtoparse); < char *GetSQPerfdata(char *stringtoparse); < char *GetOpensPerfdata(char *stringtoparse); < char *GetFTPerfdata(char *stringtoparse); < char *GetOTPerfdata(char *stringtoparse); < char *GetQPSAPerfdata(char *stringtoparse); < < struct mysql_statistics < { < char *ThreadsPerfdata; < char *QuestionsPerfdata; < char *SQPerfdata; < char *OpensPerfdata; < char *FTPerfdata; < char *OTPerfdata; < char *QPSAPerfdata; < }; 102,105d81 < < /* variables needed to parse */ < char *StringToParse; < struct mysql_statistics Stats; 138,154d113 < /* parse the server stats */ < strcpy(StringToParse, result); < < Stats.ThreadsPerfdata = GetThreadsPerfdata(StringToParse); < strcpy(StringToParse, result); < Stats.QuestionsPerfdata = GetQuestionsPerfdata(StringToParse); < strcpy(StringToParse, result); < Stats.SQPerfdata = GetSQPerfdata(StringToParse); < strcpy(StringToParse, result); < Stats.OpensPerfdata = GetOpensPerfdata(StringToParse); < strcpy(StringToParse, result); < Stats.FTPerfdata = GetFTPerfdata(StringToParse); < strcpy(StringToParse, result); < Stats.OTPerfdata = GetOTPerfdata(StringToParse); < strcpy(StringToParse, result); < Stats.QPSAPerfdata = GetQPSAPerfdata(StringToParse); < 270c229 < printf ("%s %s | %s %s %s %s %s %s %s\n", result, slaveresult, Stats.ThreadsPerfdata, Stats.SQPerfdata, Stats.OpensPerfdata, Stats.FTPerfdata, Stats.OTPerfdata, Stats.QPSAPerfdata); --- > printf ("%s %s\n", result, slaveresult); 272c231 < printf ("%s | %s %s %s %s %s %s %s\n", result, Stats.ThreadsPerfdata, Stats.QuestionsPerfdata, Stats.SQPerfdata, Stats.OpensPerfdata, Stats.FTPerfdata, Stats.OTPerfdata, Stats.QPSAPerfdata); --- > printf ("%s\n", result); 278,512d236 < char < *GetQPSAPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *qpsa; < char *output; < Start = strIndexOf("Queries per second avg\0", stringtoparse); < End = strlen(stringtoparse); < < qpsa = strSubstring(qpsa, stringtoparse, Start, End); < qpsa = strSubstring(qpsa, qpsa, strIndexOf(" \0", qpsa) + 1, strlen(qpsa)); < qpsa = strSubstring(qpsa, qpsa, strIndexOf(" \0", qpsa) + 1, strlen(qpsa)); < qpsa = strSubstring(qpsa, qpsa, strIndexOf(" \0", qpsa) + 1, strlen(qpsa)); < qpsa = strSubstring(qpsa, qpsa, strIndexOf(" \0", qpsa) + 1, strlen(qpsa)); < printf("%s", qpsa); < asprintf(&output, "%s", fperfdata("queries_per_second_avg", atof(qpsa), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < char < *GetOTPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *ot; < char *output; < Start = strIndexOf("Open tables\0", stringtoparse); < End = strIndexOf("Queries per second avg\0", stringtoparse); < < ot = strSubstring(ot, stringtoparse, Start, End - 2); < ot = strSubstring(ot, ot, strIndexOf(" \0", ot) + 1, strlen(ot)); < ot = strSubstring(ot, ot, strIndexOf(" \0", ot) + 1, strlen(ot)); < asprintf(&output, "%s", perfdata("open_tables", atoi(ot), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < char < *GetFTPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *ft; < char *output; < Start = strIndexOf("Flush tables\0", stringtoparse); < End = strIndexOf("Open tables\0", stringtoparse); < < ft = strSubstring(ft, stringtoparse, Start, End - 2); < ft = strSubstring(ft, ft, strIndexOf(" \0", ft) + 1, strlen(ft)); < ft = strSubstring(ft, ft, strIndexOf(" \0", ft) + 1, strlen(ft)); < asprintf(&output, "%s", perfdata("flush_tables", atoi(ft), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < char < *GetOpensPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *opens; < char *output; < Start = strIndexOf("Opens\0", stringtoparse); < End = strIndexOf("Flush tables\0", stringtoparse); < < opens = strSubstring(opens, stringtoparse, Start, End - 2); < opens = strSubstring(opens, opens, strIndexOf(" \0", opens) + 1, strlen(opens)); < asprintf(&output, "%s", perfdata("opens", atoi(opens), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < char < *GetSQPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *slowqueries; < char *output; < Start = strIndexOf("Slow queries\0", stringtoparse); < End = strIndexOf("Opens\0", stringtoparse); < < slowqueries = strSubstring(slowqueries, stringtoparse, Start, End - 2); < slowqueries = strSubstring(slowqueries, slowqueries, strIndexOf(" \0", slowqueries) + 1, strlen(slowqueries)); < slowqueries = strSubstring(slowqueries, slowqueries, strIndexOf(" \0", slowqueries) + 1, strlen(slowqueries)); < asprintf(&output, "%s", perfdata("slow_queries", atoi(slowqueries), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < char < *GetQuestionsPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *questions; < char *output; < Start = strIndexOf("Questions\0", stringtoparse); < End = strIndexOf("Slow queries\0", stringtoparse); < < questions = strSubstring(questions, stringtoparse, Start, End - 2); < questions = strSubstring(questions, questions, strIndexOf(" \0", questions) + 1, strlen(questions)); < asprintf(&output, "%s", perfdata("questions", atoi(questions), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < char < *GetThreadsPerfdata(char *stringtoparse) < { < int Start = 0; < int End = 0; < char *threads; < char *output; < < Start = strIndexOf("Threads\0", stringtoparse); < End = strIndexOf("Questions\0", stringtoparse); < < threads = strSubstring(threads, stringtoparse, Start, End - 2); < threads = strSubstring(threads, threads, strIndexOf(" \0", threads) + 1, strlen(threads)); < asprintf(&output, "%s", perfdata("threads", atoi(threads), "", < FALSE, 0, < FALSE, 0, < TRUE, 0, < FALSE, 0)); < < return output; < } < < /* takes the substring from string1 between startingpos and the startingpos plus the length, < all is returned */ < char < *strSubstring(char *string1, char *string2, int StartingPos, int EndPos) < { < /* current position in string2 */ < int CurPos = 0; < /* current position in string1 */ < int String1Pos = 0; < char *NULLChar = "\0"; < < for (CurPos = StartingPos; CurPos < EndPos; CurPos++) < { < string1[String1Pos] = string2[CurPos]; < String1Pos++; < } < < string1[String1Pos] = *NULLChar; < < return string1; < } < < /* gets the starting position of string1 in string2, < if string1 is not contained in string2 then the function returns -1 */ < int < strIndexOf (char *string1, char *string2) < { < /* current position in string2 */ < int CurPos = 0; < /* the amount of matches found after the startingposition was found */ < int CharsFound = 0; < /* the starting position of string1 in string2 */ < int StartingPos = -1; < /* length of string1 */ < int Length1 = strlen(string1); < /* Length of string2 */ < int Length2 = strlen(string2); < /* the maximum length of the search */ < int MaxLength = 0; < < /* check if string2 is longer the string1, if not tell the program that something went wrong */ < if (Length2 < Length1) < { < return -2; < } < < /* calculate the max length of the search */ < MaxLength = Length2; < < for (CurPos = 0; CurPos != MaxLength; CurPos++) < { < if (CharsFound == Length1) < { < return StartingPos; < } < < if (StartingPos == -1) < { < if (string2[CurPos] == string1[CharsFound]) < { < StartingPos = CurPos; < CharsFound++; < } < } < else < { < if (string2[CurPos] == string1[CharsFound]) < { < CharsFound++; < } < else < { < CharsFound = 0; < StartingPos = -1; < } < } < } < < return -1; < }