UserParameter=<>,<>
Where: UserParameter=system.test,who|wc -l
sudo apt-get install smartmontools
sudo smartctl -i /dev/sda | grep SMART SMART support is: Available - device has SMART capability. SMART support is: Enabled
sudo smartctl -s on -S on -o on /dev/sda smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF ENABLE/DISABLE COMMANDS SECTION === SMART Enabled. SMART Attribute Autosave Enabled. SMART Automatic Offline Testing Enabled every four hours.
sudo smartctl -H /dev/sda |grep "test"| cut -f2 -d: |tr -d " "
UserParameter=uHDD.health,sudo smartctl -H /dev/sda |grep "test"| cut -f2 -d: |tr -d " "
UserParameter=uHDD.health.[*],sudo smartctl -H /dev/$1 |grep "test"| cut -f2 -d: |tr -d " "
#!/usr/bin/perl #must be run as root $first = 1; print "{\n"; print "\t\"data\":[\n\n"; for (`ls -l /dev/disk/by-id/ | cut -d"/" -f3 | sort -n | uniq -w 3`) { #DISK LOOP $smart_avail=0; $smart_enabled=0; $smart_enable_tried=0; #next when total 0 at output if ($_ eq "total 0\n") { next; } print "\t,\n" if not $first; $first = 0; $disk =$_; chomp($disk); #SMART STATUS LOOP foreach(`smartctl -i /dev/$disk | grep SMART`) { $line=$_; # if SMART available -> continue if ($line = /Available/){ $smart_avail=1; next; } #if SMART is disabled then try to enable it (also offline tests etc) if ($line = /Disabled/ & $smart_enable_tried == 0){ foreach(`smartctl -i /dev/$disk -s on -o on -S on | grep SMART`) { if (/SMART Enabled/){ $smart_enabled=1; next; } } $smart_enable_tried=1; } if ($line = /Enabled/){ $smart_enabled=1; } } print "\t{\n"; print "\t\t\"{#DISKNAME}\":\"$disk\",\n"; print "\t\t\"{#SMART_ENABLED}\":\"$smart_enabled\"\n"; print "\t}\n"; } print "\n\t]\n"; print "}\n";
$ /usr/local/bin/smartctl-disks-discovery.pl
{ "data":[ { "{#DISKNAME}":"md0", "{#SMART_ENABLED}":"0" }, { "{#DISKNAME}":"md1", "{#SMART_ENABLED}":"0" }, { "{#DISKNAME}":"sda", "{#SMART_ENABLED}":"1" }, { "{#DISKNAME}":"sdb", "{#SMART_ENABLED}":"1" }] }
UserParameter=uHDD.discovery,sudo /usr/local/bin/smartctl-disks-discovery.pl
zabbix ALL= (ALL) NOPASSWD: /usr/sbin/smartctl,/usr/local/bin/smartctl-disks-discovery.pl
'KNOWN ISSUE: If Application name conatins '-' symbol then e-mail alert containing software list will be sent all on one line instead of each packet on a single line variable=InstalledApplications(".") 'WScript.Echo strConvert(variable,"Windows-1251","cp866") Const ForReading = 1 zabbix_dir="C:\zabbix\" Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create old file if does not exist If objFSO.FileExists(zabbix_dir&"uDiffPrograms_old.txt")=0 Then Set objFile4 = objFSO.CreateTextFile(zabbix_dir&"uDiffPrograms_old.txt") objFile4.WriteLine variable objFile4.Close Call ConvertCharsetFile("0x0") WScript.Quit End if 'Create 'new' file Set objFile3 = objFSO.CreateTextFile(zabbix_dir&"uDiffPrograms_new.txt") objFile3.WriteLine variable objFile3.Close 'Compare old and new files Set objArgs = Wscript.Arguments Set objFile5= objFSO.GetFile(zabbix_dir&"uDiffPrograms_new.txt") Set objFile6 = objFSO.GetFile(zabbix_dir&"uDiffPrograms_old.txt") If objFile5.Size <> objFile6.Size Then ' Wscript.Echo "The file is different." Else 'Wscript.Echo "They are the same." objFSO.DeleteFile zabbix_dir&"uDiffPrograms_new.txt" Call ConvertCharsetFile("0x0") WScript.Quit End If 'Search for removed applications Set objFile2 = objFSO.OpenTextFile(zabbix_dir&"uDiffPrograms_old.txt", ForReading) Do Until objFile2.AtEndOfStream strAddress2 = objFile2.ReadLine If InStr(variable, strAddress2&vbCrLf) = 0 Then strNotCurrent2 = strNotCurrent2 & strAddress2 & vbCrLf End If Loop objFile2.Close 'Search for installed applications Set objFile1 = objFSO.OpenTextFile(zabbix_dir&"uDiffPrograms_old.txt", ForReading) oldvar = objFile1.ReadAll objFile1.Close objFSO.DeleteFile zabbix_dir&"uDiffPrograms_old.txt" Set objFile2 = objFSO.OpenTextFile(zabbix_dir&"uDiffPrograms_new.txt", ForReading) Do Until objFile2.AtEndOfStream strAddress = objFile2.ReadLine If InStr(oldvar, strAddress&vbCrLf) = 0 Then strNotCurrent = strNotCurrent & strAddress & vbCrLf End If Loop objFile2.Close 'Rename C:\zabbix\uDiffPrograms_new.txt to C:\zabbix\uDiffPrograms_old.txt objFSO.MoveFile zabbix_dir&"uDiffPrograms_new.txt" , zabbix_dir&"uDiffPrograms_old.txt" 'Output if strNotCurrent <> "" and strNotCurrent2 <> "" then Call ConvertCharsetFile(" :" & vbCrLf & strNotCurrent & vbCrLf & " :" & vbCrLf & strNotCurrent2) Wscript.Quit End if if strNotCurrent <> "" then Call ConvertCharsetFile(" :" & vbCrLf & strNotCurrent) End if if strNotCurrent2 <> "" then Call ConvertCharsetFile(" :" & vbCrLf & strNotCurrent2) End If Function InstalledApplications(node) '''with Versions Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE Set oRegistry = GetObject("winmgmts://" _ & node & "/root/default:StdRegProv") sBaseKey = _ "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys) For Each sKey In arSubKeys iRC = oRegistry.GetStringValue( _ HKLM, sBaseKey & sKey, "DisplayName", sValue) If iRC <> 0 Then oRegistry.GetStringValue _ HKLM, sBaseKey & sKey, "QuietDisplayName", sValue End If If sValue <> "" and instr(sValue, "KB")=0 Then 'instr(sValue, "KB")=0 - to exlude KB-indexed Microsoft Patches If instr(InstalledApplications, sValue&vbCrLf)=0 then 'and instr(InstalledApplications, sValue&vbCrLf)=0 - to exlude possible dublicates InstalledApplications = _ InstalledApplications & sValue & vbCrLf End If End If Next End Function Function ConvertCharsetFile(input) Const adTypeBinary = 1 Const adTypeText = 2 Const bOverwrite = True Const bAsASCII = False 'Write to temp file Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists( zabbix_dir&"uDiffPrograms_temp.txt" ) Then objFSO.DeleteFile zabbix_dir&"uDiffPrograms_temp.txt" Set objFile3 = objFSO.CreateTextFile(zabbix_dir&"uDiffPrograms_temp.txt") objFile3.WriteLine input objFile3.Close Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim sFFSpec : sFFSpec = oFS.GetAbsolutePathName( zabbix_dir&"uDiffPrograms_temp.txt" ) Dim oFrom : Set oFrom = CreateObject( "ADODB.Stream" ) Dim sFrom : sFrom = "windows-1251" Dim oTo : Set oTo = CreateObject( "ADODB.Stream" ) Dim sTo : sTo = "utf-8" oFrom.Type = adTypeText oFrom.Charset = sFrom oFrom.Open oFrom.LoadFromFile sFFSpec oTo.Type = adTypeText oTo.Charset = sTo oTo.Open oTo.WriteText oFrom.ReadText oFrom.Close If oFS.FileExists( sFFSpec ) Then oFS.DeleteFile sFFSpec oTo.SaveToFile sFFSpec oTo.Close End Function '=============================================================================
UserParameter=uDiffPrograms, cscript.exe /nologo "C:\zabbix\uDiffPrograms.vbs" & type C:\zabbix\uDiffPrograms_temp.txt
Source: https://habr.com/ru/post/196218/
All Articles