Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipdiscover: no automatic election. Works only if manually forced #356

Closed
iuri-iurcenco opened this issue Oct 27, 2021 · 7 comments
Closed

Comments

@iuri-iurcenco
Copy link

iuri-iurcenco commented Oct 27, 2021

General informations

Operating system : Ubuntu 20.04.3 LTS

Server informations

Perl version : v5.30.0
Mysql / Mariadb / Percona version : Ubuntu 20.04 version 10.3.31-MariaDB-0ubuntu0.20.04.1

OCS Inventory informations

Ocs server version : 2.9.1

Problem's description

ipdiscover: no automatic election. Works only if manually forced

Srver runs on Ubuntu 20.04.3 LTS
Ocs server Linux/Unix Server 2.9.1
Windows Agent 2.9.0.0 (64 bits)

Already tried everething possible.

my settings:
IPDISCOVER
Max number of computers per gateway retrieving IP on the network

ON
2
computers

IPDISCOVER_BETTER_THRESHOLD
Specify the minimal difference to replace an ipdiscover agent

1
day(s)

(Must be greater than or equal to 1)

IPDISCOVER_LATENCY
Ipdiscover latency

100
milisecond(s)

(Must be greater than or equal to 10)

IPDISCOVER_MAX_ALIVE
Maximum number of day before an ipdiscover computer is replaced

1
day(s)

(Must be greater than or equal to 1)

IPDISCOVER_NO_POSTPONE
Disable the time before a first election (not recommended)

ON

IPDISCOVER_USE_GROUPS
Enable groups for ipdiscover (for example, you might want to prevent some groups to be ipdiscover agents)

OFF
IPDISCOVER_LINK_TAG_NETWORK
Link Ipdiscover network to computer TAG
Logout / Login after updating this configuration

OFF
IPDISCOVER_PURGE_OLD
Purge old IPDiscover data

OFF
IPDISCOVER_PURGE_VALIDITY_TIME
Validity time (in days) of an IPDiscover data

30
day(s)

(Must be greater than or equal to 1)

It used to work with my old cenots server with ocs 2.2Rc..and 2.4 win 32 client if I am not mistaken.


I don't know if it's related or not. I have also an apache warning: apachectl[203268]: ocsinventory-server: Bad setting. IPDISCOVER_LINK_TAG_NETWORK is not set. Default: 0

Ideas? Thanks!

@iuri-iurcenco
Copy link
Author

Ideas, anyone?

@pepex7
Copy link

pepex7 commented Jun 24, 2022

Same thing happens to me with default settings.

@iuri-iurcenco
Copy link
Author

Same thing happens to me with default settings.

Did you managet to make it work? Cause I tried all possible settings in the admin interface with no luck.

@pepex7
Copy link

pepex7 commented Jun 25, 2022

No, I still can't get it to work.
No, I still can't get it to work. I am deploying it in proxmox.

@orencio
Copy link

orencio commented Aug 16, 2022

A silly solution (for me) is altering /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util.pl for -auto option parameter.

So I've copied this file:

# cp /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util.pl /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util-cron.pl

At line 199 of /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util-cron.pl file I make changes for this:

  print "\n\n##################\n";
  print "PROCESSING SUBNETS \n";
  print "##################\n\n";
  for(@subnet){
    print "Processing $_->[1] (".$_->[0]."/".$_->[3]."). ".(keys(%subnet)-$i)." networks left.\n";
    open OUT, ">$path/ipd/".$_->[0].".ipd" or die $!;
    unless(flock(OUT, LOCK_EX|LOCK_NB)){
      if($xml){
        print "<ERROR><MESSAGE>345</MESSAGE></ERROR>";
        exit(0);
      }else{
        die "An other analyse is in progress\n";
      }
    }
    print("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'\n");
    system("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'");

    $i++;
  }

Result of changes with diff:

# diff ipdiscover-util.pl ipdiscover-util-cron.pl
199,201c199,201
<   for(keys(%subnet)){
<     print "Processing $_ (".$subnet{$_}."). ".(keys(%subnet)-$i)." networks left.\n";
<     open OUT, ">$path/ipd/".$subnet{$_}.".ipd" or die $!;
---
>   for(@subnet){
>     print "Processing $_->[1] (".$_->[0]."/".$_->[3]."). ".(keys(%subnet)-$i)." networks left.\n";
>     open OUT, ">$path/ipd/".$_->[0].".ipd" or die $!;
205c205
< 	exit(0);
---
>     	exit(0);
210c210,211
<     system("./ipdiscover-util.pl -net=".$subnet{$_}.($xml?' -xml':'')." -a > $path/ipd/'".$subnet{$_}.".ipd'");
---
>     print("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'\n");
>     system("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'");

After I've add this line to my /etc/crontab:

00 2    * * 5   www-data cd /usr/share/ocsinventory-reports/ocsreports && perl ipdiscover-util-cron.pl -auto -path=/var/log/ocsinventory-reports

(Friday at 2:00)

This changes run IP Discovery and persists changes to database.

@silvaguilherme
Copy link

A silly solution (for me) is altering /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util.pl for -auto option parameter.

So I've copied this file:

# cp /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util.pl /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util-cron.pl

At line 199 of /usr/share/ocsinventory-reports/ocsreports/ipdiscover-util-cron.pl file I make changes for this:

  print "\n\n##################\n";
  print "PROCESSING SUBNETS \n";
  print "##################\n\n";
  for(@subnet){
    print "Processing $_->[1] (".$_->[0]."/".$_->[3]."). ".(keys(%subnet)-$i)." networks left.\n";
    open OUT, ">$path/ipd/".$_->[0].".ipd" or die $!;
    unless(flock(OUT, LOCK_EX|LOCK_NB)){
      if($xml){
        print "<ERROR><MESSAGE>345</MESSAGE></ERROR>";
        exit(0);
      }else{
        die "An other analyse is in progress\n";
      }
    }
    print("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'\n");
    system("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'");

    $i++;
  }

Result of changes with diff:

# diff ipdiscover-util.pl ipdiscover-util-cron.pl
199,201c199,201
<   for(keys(%subnet)){
<     print "Processing $_ (".$subnet{$_}."). ".(keys(%subnet)-$i)." networks left.\n";
<     open OUT, ">$path/ipd/".$subnet{$_}.".ipd" or die $!;
---
>   for(@subnet){
>     print "Processing $_->[1] (".$_->[0]."/".$_->[3]."). ".(keys(%subnet)-$i)." networks left.\n";
>     open OUT, ">$path/ipd/".$_->[0].".ipd" or die $!;
205c205
< 	exit(0);
---
>     	exit(0);
210c210,211
<     system("./ipdiscover-util.pl -net=".$subnet{$_}.($xml?' -xml':'')." -a > $path/ipd/'".$subnet{$_}.".ipd'");
---
>     print("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'\n");
>     system("./ipdiscover-util.pl -net=".$_->[0]." -network=".$_->[0]."/".((()=$_->[3] =~ /255/g)*8)." -a -scantype=nmap > $path/ipd/'".$_->[0].".ipd'");

After I've add this line to my /etc/crontab:

00 2    * * 5   www-data cd /usr/share/ocsinventory-reports/ocsreports && perl ipdiscover-util-cron.pl -auto -path=/var/log/ocsinventory-reports

(Friday at 2:00)

This changes run IP Discovery and persists changes to database.

I changed the lines you mentioned, but the error below appears

Can't use string ("172.18.10.0") as an ARRAY ref while "strict refs" in use at ipdiscover-util-cron.pl line 202.

@charleneauger
Copy link
Member

Hi @iuri-iurcenco ,

This bug has been fixed with PR #415.

Best regards,
Charlene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants