Ad Widget

Collapse

Windows UserParameter wildcards extension

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jlh
    Junior Member
    • Nov 2006
    • 8

    #1

    Windows UserParameter wildcards extension

    As I was not able to use a UserParameter tag with[*] in Zabbix Win32 agent, I made some changes in the source code in order to support it. So with this version, you can define a line like
    UserParameter=Disk.FragLevel[*],c:\windows\system32\defrag.exe -a $1
    in you Win32 agent, and define an item with Disk.FragLevel[c:] in your zabbix server.

    Source file and compiled files are attached
    Attached Files
  • navtek007
    Senior Member
    • May 2005
    • 100

    #2
    great, any chance on getting this compiled for 1.1.5?

    thanks.

    Comment

    • den_crane
      Senior Member
      • Feb 2006
      • 272

      #3
      It's work!!!
      Thanks so much for posting this.

      Comment

      • djinn_fr22
        Member
        • Jan 2007
        • 54

        #4
        I tried with agent 1.1.6, it doesn't work so it means that the patch has not been added yet.

        I tried the binary from jlh patch.
        It works when I test in local mode, but it doesn't work when I tried to get data from the zabbix server. I am running the agent in standalone mode and not as a service.

        I am going to try to compile it myself to see if there is a difference.

        Comment

        • jlh
          Junior Member
          • Nov 2006
          • 8

          #5
          I have made one new modification this weekend: compile with 1.1.7 source and add an optional "nowait" tag at the end of the line with the command, this to allow long scripts.
          You can now have something like
          UserParameter=Test[*],TimeConsumingScript $1 $2 $3,nowait
          UserParameter=TestResult[*],QuickResultScript $1 $2 $3
          => The nowait tag will fork the script without waiting for the result. So if the script writes the result in a file, you just need to write another script that will quickly read that file.
          Last edited by jlh; 13-04-2007, 07:57.

          Comment

          • jlh
            Junior Member
            • Nov 2006
            • 8

            #6
            Sorry: previous post has an awful bug. Here is the fixed version. I named this agent version 1.1.7.2. I also removed the incorrect attachment from the previous post.
            Attached Files

            Comment

            • den_crane
              Senior Member
              • Feb 2006
              • 272

              #7
              Strange problem with:
              Zabbix Win32 Agent Version 1.1.4 Build of Dec 29 2006

              In temp dir (c:\winnt\temp) agent leave thousands small files.
              One host had 65k files, and agent stops.

              >dir /w

              Volume in drive C has no label.

              Volume Serial Number is 3865-5B42



              Directory of C:\WINDOWS\Temp



              [.] [..] 111 zbx1.tmp zbx1002.tmp

              zbx100A.tmp zbx1020.tmp zbx109E.tmp zbx10AF.tmp zbx10C9.tmp

              zbx10EB.tmp zbx10F6.tmp zbx115.tmp zbx117C.tmp zbx118B.tmp

              zbx118F.tmp zbx11B6.tmp zbx11E2.tmp zbx11E3.tmp zbx11E6.tmp

              zbx11E8.tmp zbx121.tmp zbx121C.tmp zbx124.tmp zbx1244.tmp

              zbx1251.tmp zbx1254.tmp zbx1263.tmp zbx127.tmp zbx1271.tmp

              zbx1276.tmp zbx128B.tmp zbx1293.tmp zbx1295.tmp zbx12A6.tmp

              zbx12B1.tmp zbx12BE.tmp zbx1304.tmp zbx131.tmp zbx131C.tmp

              zbx131D.tmp zbx131E.tmp zbx131F.tmp zbx1320.tmp zbx1321.tmp

              zbx1322.tmp zbx133A.tmp zbx1342.tmp zbx139A.tmp zbx13C5.tmp

              zbx1400.tmp zbx140A.tmp zbx1440.tmp zbx1441.tmp zbx1445.tmp

              zbx1461.tmp zbx147C.tmp zbx1481.tmp zbx149.tmp zbx14AA.tmp

              zbx14AE.tmp zbx14AF.tmp zbx14B0.tmp zbx14B1.tmp zbx14B2.tmp

              zbx14B3.tmp zbx14B4.tmp zbx14B5.tmp zbx14B6.tmp zbx14B7.tmp

              zbx14BA.tmp zbx14BB.tmp zbx14CE.tmp zbx14DC.tmp zbx14F.tmp

              zbx150F.tmp zbx153A.tmp zbx159C.tmp zbx15A0.tmp zbx15AB.tmp

              zbx15BB.tmp zbx15CB.tmp zbx15DE.tmp zbx15EF.tmp zbx167A.tmp

              zbx16D4.tmp zbx16E1.tmp zbx16E3.tmp zbx16F.tmp zbx170E.tmp

              zbx1727.tmp zbx1732.tmp zbx1741.tmp zbx1785.tmp zbx1795.tmp

              .....
              2623 File(s) 17Ъ497 bytes

              2 Dir(s) 17Ъ196Ъ273Ъ664 bytes free

              >type zbx10AF.tmp
              0.0061

              >type zbx109E.tmp
              1998146


              >type zbx127.tmp
              161


              >type zbx1020.tmp
              1
              Last edited by den_crane; 18-04-2007, 10:44.

              Comment

              • Alexei
                Founder, CEO
                Zabbix Certified Trainer
                Zabbix Certified SpecialistZabbix Certified Professional
                • Sep 2004
                • 5654

                #8
                Upgrade your agent to 1.1.7.
                Alexei Vladishev
                Creator of Zabbix, Product manager
                New York | Tokyo | Riga
                My Twitter

                Comment

                • den_crane
                  Senior Member
                  • Feb 2006
                  • 272

                  #9
                  Originally posted by Alexei
                  Upgrade your agent to 1.1.7.
                  It support wildcards?

                  C:\blat>ZabbixW32.exe version

                  Zabbix Win32 Agent Version 1.1.7 Build of Mar 30 2007

                  C:\blat>ZabbixW32.exe --config C:\blat\zabbix_agentd.conf test oracle[version]

                  Using configuration file "C:\blat\zabbix_agentd.conf"

                  Configuration file OK

                  [18-Apr-2007 13:59:12] *************** Log file opened ****************

                  [18-Apr-2007 13:59:12] Collector thread initialized successfully

                  oracle[version] [ZBX_NOTSUPPORTED]


                  but
                  C:\blat>ZabbixW32.old.exe version

                  Zabbix Win32 Agent Version 1.1.4 Build of Dec 29 2006

                  C:\blat>ZabbixW32.old.exe --config C:\blat\zabbix_agentd.conf test oracle[version]

                  Using configuration file "C:\blat\zabbix_agentd.conf"

                  Error in configuration file, line 28: unknown option "ListenIP"

                  [18-Apr-2007 14:00:17] *************** Log file opened ****************

                  [18-Apr-2007 14:00:17] Collector thread initialized successfully

                  [18-Apr-2007 14:00:17] Information: 1676 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 1900 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 1168 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 2052 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 2136 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 1280 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 704 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 1728 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 1308 : Listen thread is Started.

                  [18-Apr-2007 14:00:17] Information: 2160 : Listen thread is Started.

                  oracle[version] [Oracle Database 10g Enterprise Edition Release 10.2.0

                  .1.0 - Prod]

                  Comment

                  • den_crane
                    Senior Member
                    • Feb 2006
                    • 272

                    #10
                    Originally posted by jlh
                    Sorry: previous post has an awful bug. Here is the fixed version. I named this agent version 1.1.7.2. I also removed the incorrect attachment from the previous post.
                    I could not unzip attachment:

                    unzip zabbixw32.zip
                    Archive: zabbixw32.zip
                    skipping: main.cpp unsupported compression method 98
                    skipping: config.cpp unsupported compression method 98
                    skipping: zabbixw32.h unsupported compression method 98
                    skipping: sysinfo.cpp unsupported compression method 98
                    skipping: execute.cpp unsupported compression method 98
                    skipping: ZabbixW32.exe unsupported compression method 98
                    skipping: active.cpp unsupported compression method 98
                    skipping: eventlog.cpp unsupported compression method 98


                    I'll try winrar, winzip, 7zip -- same problem.

                    I redownload attach by wget it's not help.

                    md5sum zabbixw32.zip
                    95d100442d1888ac5769f4d73d35b693 zabbixw32.zip

                    unzip -h
                    UnZip 5.52 of 28 February 2005, by Info-ZIP.

                    Comment

                    • den_crane
                      Senior Member
                      • Feb 2006
                      • 272

                      #11
                      Originally posted by den_crane
                      I could not unzip attachment:
                      winzip 11, extract it.
                      wildcards work. fine. thanks.

                      Comment

                      • den_crane
                        Senior Member
                        • Feb 2006
                        • 272

                        #12
                        hmm

                        C:\blat>ZabbixW32.exe version
                        Zabbix Win32 Agent Version 1.1.7.2 Build of Apr 11 2007

                        Directory of C:\WINNT\Temp

                        04/18/2007 02:53p <DIR> .
                        04/18/2007 02:53p <DIR> ..
                        04/18/2007 02:25p 9 zbx3444.tmp
                        04/18/2007 02:25p 9 zbx3445.tmp
                        04/18/2007 02:25p 9 zbx3446.tmp
                        04/18/2007 02:25p 3 zbx3447.tmp
                        04/18/2007 02:25p 3 zbx3448.tmp
                        04/18/2007 02:25p 3 zbx3449.tmp
                        04/18/2007 02:25p 7 zbx344A.tmp
                        04/18/2007 02:25p 11 zbx344B.tmp
                        04/18/2007 02:25p 8 zbx344C.tmp
                        04/18/2007 02:25p 7 zbx344D.tmp
                        04/18/2007 02:25p 7 zbx344E.tmp
                        04/18/2007 02:25p 4 zbx344F.tmp
                        04/18/2007 02:25p 8 zbx3450.tmp
                        04/18/2007 02:25p 5 zbx3451.tmp
                        04/18/2007 02:28p 3 zbx3453.tmp
                        04/18/2007 02:28p 7 zbx3454.tmp
                        04/18/2007 02:28p 3 zbx3455.tmp
                        04/18/2007 02:28p 8 zbx3456.tmp
                        04/18/2007 02:28p 9 zbx3457.tmp
                        04/18/2007 02:28p 7 zbx3458.tmp
                        04/18/2007 02:28p 9 zbx3459.tmp
                        04/18/2007 02:28p 11 zbx345C.tmp
                        04/18/2007 02:32p 8 zbx3461.tmp
                        04/18/2007 02:38p 3 zbx3465.tmp
                        04/18/2007 02:38p 7 zbx3466.tmp
                        04/18/2007 02:38p 3 zbx3467.tmp
                        04/18/2007 02:38p 8 zbx3468.tmp
                        04/18/2007 02:38p 9 zbx3469.tmp
                        04/18/2007 02:38p 7 zbx346A.tmp
                        04/18/2007 02:38p 9 zbx346B.tmp
                        04/18/2007 02:38p 8 zbx346C.tmp

                        Comment

                        • den_crane
                          Senior Member
                          • Feb 2006
                          • 272

                          #13
                          in zabbix 117 execute.cpp

                          Code:
                          LONG H_Execute(char *cmd,char *arg,char **value)
                          {
                            .....
                             // Create new process
                             if (!CreateProcess(NULL,ptr1,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
                             {    ...   }
                             else
                             { ....   }
                             // Remove temporary file
                             CloseHandle(hOutput);
                             DeleteFile(szTempFile);
                          .....
                          in zabbix 1172 wildcards extension execute.cpp


                          Code:
                          LONG H_Execute(char *cmd,char *arg,char **value)
                          {
                            .....
                             // Create new process
                             if (!CreateProcess(NULL,ptr1,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
                             {    ...   }
                             else
                             { ....
                                CloseHandle(hOutput);
                                DeleteFile(szTempFile);
                             }
                          .....

                          Comment

                          • jlh
                            Junior Member
                            • Nov 2006
                            • 8

                            #14
                            I think you are not right: the handle must be closed only if it was open. So correct code is this:

                            .....

                            // Create new process
                            if (!CreateProcess(NULL,truecmd,NULL,NULL,TRUE,0,NULL ,NULL,&si,&pi)) {
                            WriteLog(MSG_CREATE_PROCESS_FAILED,EVENTLOG_ERROR_ TYPE,"se",truecmd,GetLastError());
                            ret = SYSINFO_RC_NOTSUPPORTED;
                            *value = strdup("1");
                            }
                            else {
                            // Wait for process termination and close all handles
                            if (bWait) {
                            LOG_DEBUG_INFO("s","Waiting");
                            WaitForSingleObject(pi.hProcess,INFINITE);
                            LOG_DEBUG_INFO("s","End of waiting");
                            CloseHandle(pi.hThread);
                            CloseHandle(pi.hProcess);

                            // Rewind temporary file for reading
                            SetFilePointer(hOutput,0,NULL,FILE_BEGIN);
                            *value=(char *)malloc(MAX_STRING_LEN); // Called and freed in function "ProcessCommand", pointer "strResult"

                            // Read process output
                            ReadFile(hOutput,*value,MAX_STRING_LEN-1,&dwBytes,NULL);
                            (*value)[dwBytes]=0;
                            ptr1=strchr(*value,'\r');
                            if (ptr1!=NULL) *ptr1=0;
                            ptr1=strchr(*value,'\n');
                            if (ptr1!=NULL) *ptr1=0;
                            }
                            else
                            *value = strdup("0");
                            ret = SYSINFO_RC_SUCCESS;
                            }
                            if (bWait) {
                            // Remove temporary file
                            CloseHandle(hOutput);
                            DeleteFile(szTempFile);
                            }
                            return ret;
                            Last edited by jlh; 26-04-2007, 16:55.

                            Comment

                            • den_crane
                              Senior Member
                              • Feb 2006
                              • 272

                              #15
                              Originally posted by jlh
                              I think you are not right: the handle must be closed only if it was open. So correct code is this:
                              ..
                              I show differences between your code and zabbix code. I don't now how is right. I don't have vs to compile and check. But I steel have problem with thousands small files.

                              Comment

                              Working...