Perl zabbix with smartmontools

Hello! Who can help to redo the script from Centos 7 "smartctl-disks-discovery.pl " for FreeBSD.
I have this error in FreeBSD.
Code:
{
"data":
uniq: invalid option -- w
usage: uniq [-c | -d | -D | -u] [-i] [-f fields] [-s chars] [input [output]]
ls: /dev/disk/by-id/: No such file or directory


Please HELP me!!!🙏

The script itself is below. For Centos 7
------------------------------------------------
Code:
#!/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`)
#for (`lsblk -r | awk $6 == «disk» {print $1}`)
{
#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";

-----------------------------------------------------
 
This directory /dev/disk/by-id/ doesn't exist on FreeBSD, /usr/bin/perl doesn't exist either.
 
Try this: `ls /dev/da* /dev/ada* 2>/dev/null | sed -E 's/[sp][0-9][abdefg]?//g' | sort | uniq`

You could also look at the output of sysctl -n kern.disks
 
Try this: `ls /dev/da* /dev/ada* 2>/dev/null | sed -E 's/[sp][0-9][abdefg]?//g' | sort | uniq`

You could also look at the output of sysctl -n kern.disks
Dude, you're A GENIUS!!!!!!!!!!!!!!!!!! Let me kiss you!!!!😙😁
Code:
root@s1:/usr/local/etc # sysctl -n kern.disks
da0 ada0
root@s1:/usr/local/etc #
 
Try this: `ls /dev/da* /dev/ada* 2>/dev/null | sed -E 's/[sp][0-9][abdefg]?//g' | sort | uniq`

You could also look at the output of sysctl -n kern.disks
Code:
root@s1:/usr/local/etc # perl smartctl-disks-discovery.pl
{
        "data":[

        {
                "{#DISKNAME}":"/dev/ada0",
                "{#SMART_ENABLED}":"0"
        }
        ,
        {
                "{#DISKNAME}":"/dev/da0",
                "{#SMART_ENABLED}":"0"
        }

        ]
}

EVERYTHING is working!!!!😜😍 Big greetings from Russia!!!
 
One more moment Bro! This command is for Centos

#zabbix_agentd -t uHDD[ada0,Temperature_Celsius]

It should be like it outputs something like that

uHDD[ada0,Temperature_Celsius] [t|35]

But it outputs

zabbix_agentd: No match.

How can I redo it for FreeBSD? Tell me please.
I tried in {} instead of []. Gives it away
Code:
root@s1:/usr/local/etc # zabbix_agentd -t uHDD{ada0,Temperature_Celsius}
zabbix_agentd [28292]: invalid parameter "uHDDTemperature_Celsius"
 
This command is for Centos
It's not.

But it outputs

zabbix_agentd: No match.
It refers to a Zabbix item. Apparently it doesn't exist. Have you actually applied the template to the host?


I tried in {} instead of []. Gives it away
No, that just causes the command to fail. They're supposed to be square brackets. That's how the agent refers to items. Has nothing to do with the OS. When entering this on the command line you need to be careful of the shell interpreting those characters.

 
Back
Top