The first comment I must make is this: Your Grid meter will most likely not show how much energy you are exporting. I have not read the meter manual, but most meters only pulse the LED when importing.
Therefore, you will know the energy you import from the grid, you will know the energy you generate from solar, but you will not know what you export.
See this Directly connecting to Optical Pulse Counter with RPi? for connecting the optical pulse sensors to your Raspberry Pi.
A minor correction to what @pb66 has written there: “The pulse counters are just a logic level switch, it just translates the light pulses to a distinct on or off signal.” That is not quite accurate, it is actually an analogue signal that you can see changing slowly at very low light levels. But that should not affect normal use and you will get a clean pulse.
But you cannot connect to the RPi’s RJ45 socket - that is strictly Ethernet only. You must do as Paul has written and connect to the GPIO pins.
(On the EmonPi, there are two RJ45 connectors - one is Ethernet and the second is for the pulse and temperature sensors. Those sensors are not Ethernet although we use the same connector.)
If your gas meter has a pulse output (via a magnetic reed switch perhaps), you could count pulses from that too.